HFS: Template

From rejetto wiki
Jump to navigation Jump to search

In HFS 2.1, some of the procedural information in this section is now outdated. Although almost all the detail about sections and symbols etc. is still correct, you should obviously use the new HTML Template Editor.


Applying templates from the forum

You can download templates from the HFS templates forum or from the HFS Template Gallery. To apply a template, follow these steps:

  1. Open the "Menu" in HFS.
  2. Select "Other options" and open "Edit HTML template".
  3. Copy your HTML template and paste it over the HFS "HTML template".

Test your new HTML template by pressing the "apply" button and reloading the HFS web page into your browser.

Building your own HTML template

1. Open the "Menu" in HFS.

2. Select "Other options" and open "Edit HTML template".

3. Press the "Help" button to list the available symbols for your HTML template.

How templates work

HFS builds HTML pages dynamically by loading pieces of HTML code from a template. A template is text divided into sections. Each section describes a part of the final HTML page which will be served to the requesting browser. The template must provide all sections for correct working of the generated HTML, so a section usually contains HTML code. Since the final HTML page is built dynamically, symbols have to be used to get valid output. Symbols are surrounded by %percent% characters and define the corresponding sections. A section is labelled by using [square brackets]. Symbols will be translated into actual values at run-time. Some symbols return a string for the current variable, while others only get activated if a certain condition is met. Besides symbols, some defined address line operators can also call sections to generate HTML for output.

In the main section, which is unlabeled, and in all other sections, symbols can be used to control the HTML output. Some symbols are limited to a specific section. Some symbols will produce the HTML from the corresponding sections, while others just return the corresponding actual string or value.

The best way to build a template is to edit an existing template.

Where is the template stored

The template is stored always "near" the options. If the options are saved in disk (file hfs.ini) then the template is also saved to disk (file named hfs.tpl). You can find these files in the same folder as hfs.exe (the software). More often, both the template and the options are saved in the registry (by default).

The template is loaded at HFS startup. If no template is found, then the default one is used.

Symbols and macros

All symbols and macros have a specific page.

Address line operators list

Address line operators can be used in HTML eg. href="/~login" and in the address'command line of the browser eg. www.yoursite.com/~login.

~nodefault
doesn't serve default file in a folder, but folder with files (since v2.1beta)
~login
calls for the login screen
~files.lst
inserts HTML from filelist.tpl if exists in hfs.exe folder, otherwise produces ASCII file list of the requested folder
~img
shows server graphic
~progress
calls the HTML from section [progress]
~upload
calls HTML from section [upload] for the requested folder
~upload-no-progress
calls HTML from section [upload-no-progress] for requested folder
~upload+progress
calls HTML from section [upload+progress] for the requested folder
~folder.tar
calls for all files in the folder to be downloaded in .tar format
~folder.tar?recursive
calls for all the files and folders in the current folder to be downloaded in .tar format

other address line operators  ? param1&param2&....:

sort=[ n | e | s | t | d ]
Sort by [ Name | Ext | Size | Date | Hits ]
rev
Invert the order of sorting
offset=nn
List files from the offset nn(0 being the first file)
limit=nn
Limit the listing with nn items
page=mm,nn
List files from the page mm with nn items
filter=mask
Show items corresponding to the mask filter
files-filter=mask
Show files corresponding to the mask filter
folders-filter=mask
Show folders corresponding to the mask filter
to be continued ....

To access the icon images...

/~img_folder
shows a default folder image.
/~img_file
will load the according icon for the file type.
/~img_link
shows the image for a link.

It is also possible specify what icons to use…

/~img#
where ‘#’ is the number of the icon in the icon list of HFS.

Sections list

Sections available in the template:

[style]
HTML for the %style% symbol
[login-link]
HTML for the %login-link% symbol when no user is logged in
[loggedin]
HTML for the %loggedin% symbol when the user has logged in
[up]
HTML for the %up% symbol when there's a parent folder (not root)
[link]
HTML for the a link to an URL
[folder]
HTML for the link to a folder
[file]
HTML for the link to a file
[file.<EXT>]
used in place of [file] when the file has the specified extention
[files]
HTML for the %files% symbol when the current folder is not empty
[nofiles]
HTML for the %files% symbol when the current folder is empty
[comment]
HTML for the %comment% symbol for sections [file], [folder] and [link] if available in the VFS
[folder-comment]
HTML for the %folder-comment% symbol if available in the VFS
[newfile]
HTML for the %new% symbol if the item is marked as new
[upload-link]
HTML for the %upload-link% symbol when the user has upload rights
[upload]
HTML for the ~upload command
[upload-file]
HTML for the upload form
[upload-results]
HTML for the upload results page after upload has finished
[upload-success]
HTML for the successfully uploaded files
[upload-failed]
HTML for the unsuccessfully uploaded files
[progress]
HTML for the %progress% symbol
[progress-download-file]
HTML for ongoing download
[progress-upload-file]
HTML for ongoing upload
[progress-nofiles]
HTML when no file transfer is ongoing
[upload-no-progress]
HTML for the ~upload-no-progress command
[upload+progress]
HTML for the ~upload+progress command
[error-page]
HTML in case of an error
[overload]
HTML for the %content% symbol
[unauthorized]
HTML for the %content% symbol
[deny]
HTML for the %content% symbol
[ban]
HTML for the %content% symbol
[max contemp downloads]
HTML for the %content% symbol
[not-found]
HTML for the %content% symbol
[item-archivable]
HTML for the %item-archivable% symbol
[sym-My_Section]
HTML for the %sym-My_Section% symbol ( %sym-test% <>[sym-test] )
[protected]
HTML for the %protected% status, associate with <img src='/~img_lock'>

Section aliasing

You can specify 2 or more sections in brackets, and the same content will be assigned to all of them.

The syntax is [A = B = C = D] where A, B, C, etc, are sections.

This is very useful when you are specifying the content for [file.EXT] sections, like images. [file.jpg = file.jpeg = file.png = file.gif]

Customizing graph colors and size

Available since build #081.

You can customize graph colors inside the template. The graph address is ~img_graph, but you can append to the name several options separated by an x.

For example, ~img_graph190x40xx333x000

The full list of options, in order is: width, height, refresh rate, background color, grid color, out bandwidth color, in bandwidth color, text color.

You can specify as many options as you want, even none. Current default values for width/height/colors are the same as in HFS window.

Colors can be specified in at least two forms: RGB, RRGGBB.

Refresh rate doesn't work inside template itself, but only if you access the graph alone, directly in your browser. If not specified, refresh is disabled.

Embedding pages inside a template

If you put a whole HTML page under [a_name_you_choose] section, then it will be available at

http://YOUR_ADDRESS/~a_name_you_choose