Using MakeTree
1. What is MakeTree?
MakeTree is a small program that enables you to use the excellent
Folder-Tree script by Marcelino Alves Martins without any knowledge of JavaScript - or programming! You simply start up your editor and define the layout of your tree. Then you call MakeTree and it will generate the proper JavaScript for you. It doesn't get any easier than this! Now download it!
2. Designing your Folder-Tree
The easiest way to design your Folder-Tree is to do it graphically. Just sit down, take a piece of paper and draw it. Which folders do I want and what should they contain. You might end up with something like on the right.
Yes, subfolders with no documents or other subfolders are allowed! In fact there are four types of subfolders:
- Empty subfolders
- Subfolders with subfolders
- Subfolders with documents
- Mixed subfolders, which contain documents as well as other subfolders
If you do create mixed subfolders, note that there are no subfolders allowed after documents. In other words, documents should come last. There is one other rule to observe. You may not "skip" a level and there should be a rootfolder at all times. The rootfolder is the main folder that contains all other folders.
3. Writing the ".mt" file (Version 1.x)
IMPORTANT!
If you are generating for Folder-Tree V2.x, you must skip both this step and the next! Please, continue with step 5.
In fact, designing your Folder-Tree is the hardest part. Now you got to lay it down in an ".mt" file, which is the file MakeTree uses. It is a simple ASCII file, which can be created with any editor. An ".mt" file contains three kinds of records:
- A rootrecord
- Folderrecords
- Documentrecords
- The rootrecord should be defined on the first line. It contains three fields, separated by a semi-colon. The first one defines the kind of tree you want. Two types are supported. You can have the leafs with plain text and use the icon to activate the hyperlink, or you can have the active area extended to the document name itself. The advantages of the last are:
- The appearance/function of links/docs is more intuitive
- The user can see which links/docs have been followed/viewed
- The user has a larger 'target' upon which to click
The selection is made with the value '0' (no hypertext) or '1' (use hypertext).
The second field contains the name of the rootfolder. The third field contains the title of your homepage. Any string is allowed as long as it doesn't contain any semi-colons.
- A folderrecord contains two fields, separated by a semi-colon. The first field is the level. It is an arbitrary string and may contain any series of characters (apart from semi-colons). The length of this string is important. It will actually show you how deep this item is nested. It must at least contain one character. The second field contains the name of the folder. Yeah, you guessed it: no semi-colons allowed!
- A documentrecord contains four fields. The first is the level. Read some more on that in the 'folderrecord' section. The second field is the documenttype: '0' for local documents, '1' for remote docs that open in a new window, '2' for remote docs that open in the right frame. The third field is the name of document (no semi-colons). The fourth is the link which you want to jump to. Do not add "http://"! Folder-Tree does that all by itself.
4. A sample ".mt" file
0;Start folder;My homepage
.;Local docs
..;Profile
...;0;Personal info;ident.html
...;0;Resume;resume.html
..;Likes
...;0;Portugal;portugal.html
...;0;Books & Movies;arts.html
...;0;Photography;salgado.html
...;0;Music;musica.htm
.;Web favorites
..;Friends with sites
..;Reading
...;News
...;Cartoons
...;Science
...;Reference
...;Computers
...;1;Newsgroups;www.dejanews.com
...;1;Motorcycle;www.motorcycle.com
...;1;Agenda Cultural;portugal.hpv.pt/lisboa/agenda/
..;Searches
..;Sights & Sounds
..;Downloads
..;Shopping
Well, that doesn't look too hard does it? It is in essence an exact representation of the tree we've drawn above. We hope this will clarify what MakeTree actually expects.
5. Writing the ".mt2" file (Version 2.x)
IMPORTANT!
If you are generating for Folder-Tree V1.x, you must skip both this step and the next! Please, continue with step 7.
In fact, designing your Folder-Tree is the hardest part. Now you got to lay it down in an ".mt2" file, which is the file MakeTree uses. It is a simple ASCII file, which can be created with any editor. An ".mt2" file contains three kinds of records:
- A rootrecord
- Folderrecords
- Documentrecords
- The rootrecord should be defined on the first line. It contains two fields, separated by a semi-colon. The first field contains the name of the rootfolder. The second field is the link you want to open for the rootfolder (HTML filename). Any string is allowed as long as it doesn't contain any semi-colons.
- A folderrecord contains three fields, separated by a semi-colon. The first field is the level. It is an arbitrary string and may contain any series of characters (apart from semi-colons). The length of this string is important. It will actually show you how deep this item is nested. It must at least contain one character. The second field contains the name of the folder. The third field is the link you want to open for this folder. Yeah, you guessed it: no semi-colons allowed!
- A documentrecord contains four fields. The first is the level. Read some more on that in the 'folderrecord' section. The second field is the documenttype: '0' for local documents, '1' for remote docs that open in a new window, '2' for remote docs that open in the right frame. The third field is the name of document (no semi-colons). The fourth is the link which you want to jump to.
6. A sample ".mt2" file
Start folder;myhome.html
.;Local docs;local.html
..;Profile;profile.html
...;0;Personal info;ident.html
...;0;Resume;resume.html
..;Likes;likes.html
...;0;Portugal;portugal.html
...;0;Books & Movies;arts.html
...;0;Photography;salgado.html
...;0;Music;musica.htm
.;Web favorites;favorite.html
..;Friends with sites;friends.html
..;Reading;reading.html
...;News;news.html
...;Cartoons;cartoons.html
...;Science;science.html
...;Reference;refs.html
...;Computers;comp.html
...;1;Newsgroups;www.dejanews.com
...;1;Motorcycle;www.motorcycle.com
...;1;Agenda Cultural;portugal.hpv.pt/lisboa/agenda/
..;Searches;searches.html
..;Sights & Sounds;sights.html
..;Downloads;download.html
..;Shopping;shopping.html
Well, that doesn't look too hard does it? It is in essence an exact representation of the tree we've drawn above. We hope this will clarify what MakeTree actually expects.
7. Generating Folder-Tree
We assume that you have installed MakeTree according to the instructions. All you have to do now is run it. MakeTree was designed as an commandline utility, so it takes arguments. The first argument is always your ".mt" file. The second is the optional outputfile, e.g.:
maketree foldtree.mt
Will output the generated Folder-Tree V1.x program to the console (stdout). This one will create "index.htm" in the current directory:
maketree foldtree.mt index.htm
This one will create "photosturism.js" file for Folder-Tree V2.x in the current directory:
maketree -2 foldtree.mt2 photosturism.js
There are three options available, which you can add before the ".mt" file:
- -2: You MUST use this option if you want to generate a "photosturism.js" file for Folder-Tree V2.x! Otherwise, the program will assume you want a Folder-Tree V1.x compatible file.
- -b: This option is only available with MS Operating Systems. It will open the output file in binary mode, which will result in a Unix-compatible ASCII file.
- -d%c: This option will force the program to use character "%c" as a delimiter instead of a semi-colon.
8. Error messages
In order to help you find problems within your ".mt" or ".mt2" file, we have included the number of the offending line in the message. We have to stress that succesful generation does not always guarantee a useful Folder-Tree script. There are errors that MakeTree does not trap. If this happens, study the rules we've given carefully, take a look at our FAQ and if all fails, us. These are the messages MakeTree can generate:
- Out of memory: We've created MakeTree to create a tree, not a forest! Note that large trees are confusing, not helpful!
- Invalid documenttype: The documenttype is not '0', '1' or '2'.
- Invalid depth: Only the rootfolder may be located at level zero. There may be only one rootfolder. Use a proper level string.
- Invalid rootfolder: The rootfolder record contained too many or too few fields. May be you used the wrong delimiter (must be a semi-colon).
- Invalid USETEXTLINKS: The rootfolder record contained an invalid value for the treetype. Must be '0' or '1'.
- Invalid entry: This line did not contain a documentrecord or a folderrecord.
- Can't read input file: The inputfile could not be read due to I/O or memory errors.
- No entries to process: The inputfile did not contain any lines.
- Marker not found: There was no [TITLE] or [TREE] marker in "maketree.js". Make sure you're not using a Unix ASCII file with an MS-DOS version of MakeTree or vice versa.
- Can't open outputfile: There was an I/O error while opening the output file.