Difference between revisions of "HFS: Template"

From rejetto wiki
Jump to: navigation, search
(graph image URL options, documented)
m (Customizing graph colors and size)
Line 189: Line 189:
 
'''Available since build #081.'''
 
'''Available since build #081.'''
  
You can customize graph colors inside the template. You will find that graph address is ''~img_graph'', but you can append to the name several options separated by an <tt>x</tt>.
+
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 <tt>x</tt>.
  
E.g. <tt>~img_graph190x40xx333x000</tt>
+
For example,  <tt>~img_graph190x40xx333x000</tt>
  
 
The full list of options, in order is: width, height, refresh rate, background color, grid color, out bandwidth color, in bandwidth color, text color.
 
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 may specify as many options as you want, even none.
+
You can specify as many options as you want, even none.
Current default values for width/height/colors are same as in HFS window.  
+
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.
 
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.
 
''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.

Revision as of 19:20, 25 January 2007

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.

Template help

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 and command line operators 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 list - by section

Symbols available in all sections

 %style% 
inserts the HTML from section [style]
 %login-link% 
inserts HTML from section [login-link] if no user is logged in, void otherwise
 %loggedin% 
inserts HTML from section [loggedin] if a user is logged in, void otherwise
 %user% 
returns the name of the authenticated user, void if no user is logged in
 %ip%  
inserts the client IP address on the page
 %version% 
returns the HFS version number
 %timestamp% 
returns the value for the date and time of the server (format is defined by OS settings)
 %uptime%  
returns the value for how long HFS has been running without quitting
 %connections% 
returns the value for the current number of connections to HFS
 %speed-out% 
returns the value for the current outbound speed
 %speed-in% 
returns the value for the current inbound speed
 %total-out% 
returns the value for the total amount of bytes sent
 %total-in%  
returns the value for total amount the of bytes received
 %number-addresses%  
returns the value for the current number of connected clients (IP addresses)
 %number-addresses-downloading% 
returns the value for the current number of downloading clients (IP addresses)

Symbols available in the main section

 %up%  
inserts HTML from section [up] if the current folder is not the root, void otherwise
 %upload-link% 
inserts HTML from section [upload-link] if upload is available in the current folder, void otherwise
 %host% 
returns the Host http header field, as sent by the browser eg. Server-URL(:port) or Server-IP(:port)
 %number% 
returns the value for the number of items in the current folder
 %number-folders% 
returns the value for the number of folders in the current folder
 %number-files% 
returns the value for the number of files in the current folder
 %total-size% 
returns the smart value for the amount of space occupied by items in the current folder
 %total-kbytes% 
same as %total-size%, but expressed in kilobytes
 %total-bytes%  
same as %total-size%, but expressed in bytes
 %build-time% 
returns the value for how long it took to generate the page
 %files%  
inserts HTML from section [files] if at least one item is present in the current folder, inserts HTML from section [nofiles] otherwise

Symbols available in section [files]

 %list% 
the full list of items in the current folder, got by pasting each item after the pertinent section where [folder], [file] or [link] was inserted.

Symbols available in sections [file], [folder] and [link]

 %new% 
inserts HTML from section [new] if the file is marked as new, void otherwise
 %comment% 
inserts HTML from section [comment] if a comment is available for the item, void otherwise
 %item-url% 
returns the value for the path to get the item
 %item-name% 
returns the value for the label of the item
 %item-folder% 
returns the path to the item, not in URL format. Most times it is the same as %folder%, but it is different for recursive listings.
 %item-added% 
returns the value for date and time when the item was added to the VFS (date and time format is defined by OS settings)

Symbols available in sections [file] and [folder]

 %item-dl-count% 
returns the value for the download counter (virtual folders totalize inner counters)
 %item-modified% 
returns the value for the modification time as reported by file or folder (date and time format is defined by OS settings)


Symbols available in section [file]

 %item-size% 
returns the value for the amount of space occupied by the item
 %item-size-b% 
same as %item-size%, but expressed in bytes
 %item-size-kb% 
same as %item-size%, but expressed in kilobytes

Symbols available in sections [upload], [upload+progress], [upload-results] and main section

 %diskfree% 
returns the value for the total amount of available space minus the reserved space in the drive containing the current folder (makes sense only for real folders)
 %folder% 
returns the value for the path to the current folder
 %encoded-folder% 
returns the value for the encoded path to the current folder
 %parent-folder% 
returns the value for the encoded path to the parent folder
 %folder-comment% 
inserts the HTML from section [folder-comment] if a comment is available for the current folder, void otherwise

Symbols available in section [error-page]

 %content% 
inserts the HTML from sections [ban], [deny], [not found], [unauthorized] or [overload], depending on the error code

Symbols available in section [ban]

 %reason% 
returns value for the ban description from the hfs.ini

Symbols available in section [progress]

 %progress-files% 
inserts the HTML from section [progress-nofiles] if no file is transferred with the current client, otherwise the list of transferring files got by pasting each file after the pertinent section [progress-download-file] and/or [progress-upload-file] is inserted

Symbols available in sections [progress-download-file] and [progress-upload-file]

These sections are related to file transferring.

 %perc% 
returns the value for the percentage done
 %filename% 
returns the value for the name of the file
 %done-bytes% 
returns the value for the transferred bytes
 %done% 
same as %done-bytes%, but using dynamic measure units
 %total-bytes% 
returns the value for the number of bytes of the completed transfer
 %total% 
same as %total-bytes%, but using dynamic measure units
 %speed-kb% 
returns the value for the throughput speed


Symbols available in section [upload]

 %uploaded-files% 
input boxes for files to be uploaded got by pasting [upload-file] for each file
 %host% 
returns the Host http header field, as sent by the browser eg. Server-URL(:port) or Server-IP(:port) (since v2.1beta)
 %up%  
inserts HTML from section [up] if the current folder is not the root, void otherwise (since v2.1beta)

Symbols available in section [upload-file]

 %idx% 
ordinal index of the input box

Symbols available in section [upload-results]

 %uploaded-files% 
list of uploaded files got by pasting section[upload-success] and/or section [upload-failed] for each file
 %host% 
returns the Host http header field, as sent by the browser eg. Server-URL(:port) or Server-IP(:port) (since v2.1beta)
 %up%  
inserts HTML from section [up] if the current folder is not the root, void otherwise (since v2.1beta)

Symbols available in sections [upload-success] and [upload-failed]

 %item-name% 
name of the file
 %item-url% 
address of the file

Symbols available in section [upload-success]

 %item-size% 
returns the value for the size of the uploaded file
 %speed% 
returns the value for the average upload speed

Symbols available in section [upload-failed]

 %reason% 
returns the value for the error occurred while uploading

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

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

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.