https://rejetto.com/wiki/api.php?action=feedcontributions&user=Rejetto&feedformat=atom
rejetto wiki - User contributions [en-gb]
2024-03-28T11:25:58Z
User contributions
MediaWiki 1.38.4
https://rejetto.com/wiki/index.php?title=Test&diff=5691
Test
2020-09-05T16:58:54Z
<p>Rejetto: Created page with "a"</p>
<hr />
<div>a</div>
Rejetto
https://rejetto.com/wiki/index.php?title=HFS:_scripting_commands&diff=5689
HFS: scripting commands
2020-06-27T09:10:40Z
<p>Rejetto: /* Others */ dialog returns</p>
<hr />
<div>Also known as template macros, these are commands with some useful effects that users can input in HFS to improve a template or to create functionality not otherwise available. <br />
<br />
Some commands simply expand to text, to display information, and some perform server-side actions, like deleting a file.<br />
<br />
Every command is expressed as a name, and sometimes parameters, separated by pipes "<tt>|</tt>".<br />
<br />
Following, with letters we are denoting parameters, and their meaning is explained immediately after.<br />
<br />
You should read this [http://www.rejetto.com/wiki/index.php?title=HFS:_Template_macros] before reading this page.<br />
<br />
== Logic and flow ==<br />
; if | A | B | C<br />
: if A is true, then it expands to B, else it expands to C. When it expands to B, C is just discarded, and the vice versa. C is optional.<br />
: How you tell A is true? A is true if it is not empty and not just a zero. So if A is "hi there!", then it is true.<br />
: Remember to use quoting if you use macros in B or C (the body).<br />
<br />
; if not | A | B | C <br />
: same as ''if'', but the logic is inverted. When A is true it expands to C and vice versa.<br />
<br />
; not | A : true if A is not true. It negates the value of A.<br />
<br />
; and | A | B : true if both A and B are true. In details: in the ''true'' case it returns the last parameter. You can specify as many parameters as necessary. Both Javascript and Python work this way.<br />
<br />
; or | A | B : true if any of A or B are true. In details: it returns the first ''true'' parameter (yes, it supports any number of parameters). If none of the parameters is true, then iit returns false. Both Javascript and Python work this way. Often times you can work without {.or.}, for example {.if| A B | C .} returns true if either A or B are true.<br />
<br />
; xor | A | B : true if A is true while B is false, or the opposite<br />
<br />
; = | A | B : true if A is the same as B. It's case insensitive. You can use the opposite macro, true if they are different, and it's name is '''!=''' or '''<>''' (use the one you like most, there's no difference). You can specify as many parameters as you like.<br />
<br />
; > | A | B : true if A is greater than B. Of course you can also use the related macro '''<'''. You can specify as many parameters as you like.<br />
<br />
; >= | A | B : true if A is equal or greater than B. Of course you can also use the related macro '''<='''. You can specify as many parameters as you like.<br />
<br />
; between | A | B | C : true if B is between A and C (included).<br />
<br />
; between! | A | B | C : true if B is between A and C (excluded).<br />
<br />
; switch | A | B | C | D | E | F ...<br />
: this is rather complex for non-programmers. You can learn how a switch statement is supposed to work [http://en.wikipedia.org/wiki/Switch_statement#Examples from Wikipedia]. When you know how a ''switch'' works, then you will understand this schema that will make you understand how the parameters of this macro work<br />
<pre><nowiki><br />
switch(A) {<br />
case C: return D;<br />
case E: return F;<br />
...<br />
}<br />
</nowiki></pre><br />
: The B is a separator string for C. Let's be clearer: if you want to specify several cases in C, all of them returning D, then you can specify them separating with B.<br />
: As you can see C and D are paired, as E and F, eventually G and H, and so on. If at the end of this list of pairs, a single unpaired parameter is found, then it is used as the else/default case, when all other pairs have failed.<br />
: Let me translated the first example of Wikipedia using the macro<br />
<pre><nowiki><br />
{.switch|%n%|,|<br />
0|you typed zero|<br />
3,5,7|%n% is a prime number|<br />
4,6,8|%n% is an even number|<br />
2|%n% is a prime and even number|<br />
1,9|%n% is a perfect square|<br />
Only single-digit numbers are allowed<br />
.}<br />
</nowiki></pre><br />
<br />
Switch is esentially a quick way of using many {.if.} and {.=.} commands together. For example, if A equals C then D, if A equals E then F, etc.<br />
<br />
; for | A | B | C | D | E<br />
: repeats D by replacing variable <tt>{.^A.}</tt> with every value between B and C (they are meant to be numbers).<br />
: Optionally you can specify a ''step'' for the numbers: that is, instead of going 1-by-1, they can go 2-by-2. The optional ''step'' is specified at position D; in such case the ''body'' is moved from position D to position E.<br />
: Remember to use quoting for the body.<br />
<br />
; for each | A | B | C ... | Z<br />
: a (sometimes) handier version of ''for'', that will repeat Z but replacing variable <tt>{.^A.}</tt> with value B the first time, value C the second time, D etc etc. Remember to quote the body. <br />
: example: <tt>{.for each|i|10|100|1000|{:now it's {.^i.} :}.}</tt><br />
<br />
; while | A | B<br />
: repeats B for as long as A is true. Both B is automatically dequoted. If A is quoted, then it's expanded, otherwise is considered the a variable name.<br />
: Optional parameter ''else'' will be expanded if B is never done.<br />
: Optional parameter ''timeout'' let you specify (in seconds) the maximum time the loop can live before it is stopped. It's 1 second by default.<br />
: Optional parameter ''var'' saves the output in a variable instead of just expanding to it.<br />
: Example: <tt>{.while|#x|{: {.dec|#x.} welcome! :}.}</tt> will welcome 10 times if <tt>#x</tt> is 10.<br />
<br />
; after the list | A<br />
: quoted text A is dequoted and executed, but only if the file listing is completed.<br />
<br />
; dequote | A<br />
: if A is {:quoted:} then quoting markers are removed (unleashing macro execution of the previously quoted text).<br />
<br />
; 123 if 2 | A | B | C<br />
: if B is true, it expands to ABC, otherwise nothing.<br />
: It is basically a shortcut for {.if | B |{: A B C :}.}<br />
<br />
; break : stops execution of this script.<br />
: Optional parameter ''if'' will avoid breaking in case the condition is not met (that is, when it's ''false'').<br />
: Optional parameter ''result'' will output a text only if the break occurs (makes sense only with parameter ''if'').<br />
: Using <tt>{.break|if=data.}</tt> is basically a simplified way to write <tt>{.if|data|{:{.break.}:}.}</tt><br />
<br />
== Data getting ==<br />
; section | A<br />
: A is the name of the [section] you want to include. Note: till build #160 it was case sensitive.<br />
: Optional parameter ''file'' to load the section from an external file.<br />
: Optional parameter ''back=1'' will work in diff templates to access the section in the original template. So you can access it even if you overwrote it.<br />
: Example: <tt>{.section|names|file=tables.txt.}</tt><br />
; get | A<br />
: where A is the name of a value you are interested in, like to know if an option is enabled or not.<br />
: This is a list of supported values for A:<br />
:; can upload : true if in the current folder the user is allowed to upload files. An additional parameter ''path'' will tell you about a different folder instead of the current one.<br />
:; can delete : true if the user is allowed to delete the current item. An additional parameter ''path'' will tell you about a different folder instead of the current one.<br />
:; can access : true if the current item in list is accessible by the user. An additional parameter ''path'' will tell you about a different folder instead of the current one.<br />
:; can recur : true if the option ''Recursive listing'' is enabled<br />
:; can archive : true if the current item in list is archivable. outside the list it refers to the current folder.<br />
:; is new : true if the current item in list is flagged as "new"<br />
:; accounts : semicolon-separated list of username of all accounts. By specifying an additional parameter '''groups''' you'll get only groups. Respectively, a parameter '''users''' will give you only non-group accounts.<br />
:; stop spiders : true if ''stop spider'' option is enabled.<br />
:; protocolon : expands to <tt>http&#58;//</tt> unless you enabled option ''URLs starting with https'' in which case it expands to <tt>https&#58;//</tt> (please notice the final S).<br />
:; speed limit : gives the current global speed limit, as a number (in KB/s).<br />
:; agent : Tells the user's browser. E.g., Firefox expands to Mozilla and IE8 will expand to MSIE 8.0.<br />
<br />
; urlvar | A : url variable. Let's say in the url you see <tt>?sort=s</tt> and you want to know that '''s''', just use the macro ''urlvar|sort''.<br />
: Optional parameter ''var'' will put the resulting text in the specified variable.<br />
; postvar | A : just as ''urlvar'' but reads the value from the POST part of the request instead of the URL.<br />
: Optional parameter ''var'' will put the resulting text in the specified variable.<br />
; header | A : get any value from the HTTP request header. A is the name of the header field. This is something mostly for techies. Don't fret if you don't even know what the header is.<br />
; time | A : returns current time information. The format is specified by optional parameter A. Refer to [[HFS: Time format#Text formatting|this page]] for format syntax. If A is not supplied, value "c" will be used.<br />
: Optional parameter ''when'' to [[HFS: Time format#Numerical format|specify a time]] other than current.<br />
: Optional parameter ''offset'' to specify the number of days differing from the current time.<br />
<br />
; cookie | A : expands to the value A passed by the browser.<br />
: With an optional parameter ''value'' you will set a new value.<br />
: Every known standard parameter for cookies is accepted, as ''expires'' and ''path''. Expires can be expressed in many ways: if it starts with '''+''' or '''-''' will be the number of days in the future or in the past. If it's a number will be considered as unix time format or [[HFS: Time format#Numerical format|HFS format]]. You can even specify it as a date: <tt>2/4/2013</tt>.<br />
: Example: <tt>{.cookie|step.}</tt> will give you the current value<br />
: Example: <tt>{.cookie|step|value=3|expires=+30.}</tt> will set ''step'' to ''3'' and the cookie will expire in 30 days.<br />
: Setting a cookie can also be accomplished by using {.add header.} with Set-Cookie.<br />
<br />
== Data manipulation ==<br />
; substring | A | B | C : cut C from A to B, with B not included. <br />
: Example: <tt>substring|(|belong|you (are) belong to us.}</tt> will be <tt>(are)</tt>.<br />
: If A is not specified, C is taken from the start. If B is not specified, C is taken to the end.<br />
: Optional parameter ''case=1'' to turn on case sensitivity.<br />
: Optional parameter ''include'' to say if A and/or B must be included. Values: 0 (none), 1 (only A), 2 (only B), 1+2 (both).<br />
<br />
; cut | A | B | C : cut C from position A, for B characters. The difference with macro ''substring'' is that here you specify where to cut by numeric positions.<br />
: Example: <tt>cut|2|3|abcdef</tt> will expand to <tt>bcd</tt><br />
: If you don't specify A, it defaults to 1. If you don't specify B, it defaults to the length of C.<br />
: If A is negative, then you are counting backward from the end of C. If B is negative, then you are considering the length of C minus the amount of B.<br />
: Optional parameter ''to'' will let you specify the number of character to cut. B is ignored in this case.<br />
: Optional parameter ''var'' specifies the variable name to work on. You can use it instead of C, but in such case the output will be stored in the variable.<br />
: Optional parameter ''remainder'' works only with parameter ''var'', and let you specify a variable name where all that is cut out is stored.<br />
: You can use named parameter ''from'' instead of A, ''size'' instead of B, and ''what'' instead of C.<br />
: Example: <tt>cut|from=3|size=2|abcdef</tt> will expand to <tt>cd</tt><br />
<br />
; repeat | A | B : repeat B for A times. Example: for A=5 and B=+ the result is +++++<br />
<br />
; upper | A : returns A with all letters uppercased. Example: for A=Hello the result is HELLO<br />
<br />
; lower | A : returns A with all letters lowercased. Example: for A=Hello the result is hello<br />
<br />
; trim | A : returns A with any leading and trailing space removed<br />
<br />
; replace | A | B | C : returns C with every A replaced with B. This command can apply multiple replacements by having multiple pairs of parameters A-B. But you always need to have a final parameter C, that's the text that will be manipulated.<br />
: Optional parameter ''var'' in place of parameter C will make use of the specified variable as both input and output.<br />
<br />
; calc | A : return the result of the mathematical expression A. Example: for 1+(5/2) the result is 3.5<br />
: supported operators are <tt>+ - * / %</tt> (as modulus)<br />
; round | A | B : returns rounded value of A, where A is a non-integer number, and B is the number of digits after the decimal point. B is zero by default if not specified.<br />
<br />
; add | A | B : returns A+B where A and B are numbers<br />
<br />
; sub | A | B : returns A-B where A and B are numbers<br />
<br />
; mul | A | B : returns A*B where A and B are numbers<br />
<br />
; div | A | B : returns A/B where A and B are numbers<br />
<br />
; mod | A | B : returns A modulus B where A and B are numbers<br />
<br />
; min | A | B ... : returns the minimum over all parameters. You can have more than 2 parameters.<br />
<br />
; max | A | B ... : returns the maximum over all parameters. You can have more than 2 parameters.<br />
<br />
; count substring | A | B : tells the number of times A is present in B (case sensitive)<br />
<br />
; encodeuri | A : all characters are encoded in the %XX form used for URLs, except alphanumerics and <tt>#/,&?:$@=+</tt><br />
;: You can add more characters to the set that will be encoded by using the optional parameter ''add'', as well as you can decide to exclude some characters by using the optional parameter ''not''.<br />
;: You can also decide to specify the whole set, one by one, with optional parameter ''only''.<br />
;: In all these optional parameters you can specify many characters just by having them as a string, one after another.<br />
<br />
; decodeuri | A : all encoded characters in the form %XX are decoded.<br />
<br />
; convert | A | B | C<br />
: converts C from charset A to charset B. At the moment only supported charsets are ''ansi'' and ''utf-8''. <br />
<br />
; force ansi | A : if template is using UTF-8 charset, then A is converted to ANSI. Otherwise A is left unchanged.<br />
<br />
; maybe utf8 | A : if template is using UTF-8 charset, then A is converted to UTF-8. Otherwise A is left unchanged.<br />
<br />
; 123 if 2 | A | B | C : returns nothing if B is false/empty, otherwise a concatenation of ABC.<br />
<br />
; chr | A | B ... : returns characters with ANSI code A, B, etc. Numbers are decimal. To use hex numbers, precede them with an "x".<br />
: Example: {.chr|13|10|x0D|x0A.}<br />
<br />
; js encode | A | B<br />
: Encodes characters specified by B using javascript encoding for strings, in text A. If you mean to encode characters ''a'' and ''b'', parameter B should simply be ''ab''.<br />
: If B is not specified, characters encoded are only single-quote and double-quotes. This is supposed to be the frequently used case, when you are passing some data into a javascript string that's enclosed in any form of quotes.<br />
<br />
== Variables and functions ==<br />
; set | A | B<br />
: what you actually do is to bind B (the content) to the name A (the variable). It is called variable because you can always change the content of it. You can later recall B by passing A to the macro "call".<br />
: You can have as many variables as you want. All of them will be bound to the single page/request. When the page is finished and provided (or anyway the execution flow is over) the variables are cleared (and lost) unless you prepend a '''#''' to the name (e.g. #myVariable). In this latter case you are using '''global variables'''. These will survive until you clear them explicitly.<br />
: If you are used to programming, you may already know what variables and functions are. Here '''functions''' are a special case of variable, when the content is made of other commands. When you specify commands for the function, you need to [[HFS: Template_macros#Quoting|quote them]], otherwise they will be executed immediately while instead you want them to be executed at call-time. You can also have parameters: the first one is '''$1''', and so on, that you can specify inside the body ''B''.<br />
: Remember to use quoting if you use macros in the body (B).<br />
: Example: <tt>{.set|x|1.}</tt> or <tt>{.set|double|{:{.mul|$1|2.}:}.}</tt><br />
: Optional parameter ''var'' will let you copy variables.<br />
: Example: <tt>{.set|y|var=x.}</tt><br />
: Optional parameter ''mode'' can be <tt>append</tt> or <tt>prepend</tt>, to concatenate existing content of the variable to the new content, as AB or BA.<br />
: Example: <tt>{.set|x| is a good boy|mode=append.}</tt><br />
<br />
; call | A | B | C | ... : this macro (shortcut by '''^''') expands to the value bound to A. Such value can be a number or a text, doesn't matter. If the value contains symbols '''$1''' and $2, then they are replaced with the parameters B and C (and so on).<br />
: Example referring to above: <tt>{.call|double|15.}</tt> will expand to <tt>30</tt><br />
: You can find some examples for "set" and "call" [http://www.rejetto.com/forum/index.php?topic=5353.msg1031074#msg1031074 on the forum].<br />
<br />
; inc | A | B : if A is a variable with numeric value, then its value is incremented by the number B. If B is omitted, it defaults to 1.<br />
<br />
; dec | A | B : just as the ''inc'' above, but the value is decremented<br />
<br />
; count | A<br />
: each call returns and increments A, so the sequence will be 0 1 2 3...<br />
: variable A is not actually a variable, you can't access it throught {.^A.} and its value can be retrieved only through another call to ''count''. <br />
<br />
; from table | A | B<br />
: A is the table and B is the key. The table is a variable or a section with this form<br />
<pre>key1=value1<br />
key2=value2<br />
key3=value3</pre><br />
: Let's say such text is the content of variable ''foo'', then to get <tt>value2</tt> you should do <tt>{.from table|foo|key2.}</tt>. (yes, poetry)<br />
: If it was the content of table [bar] instead, then you should do <tt>{.from table|$bar|key2.}</tt>.<br />
<br />
; set table | A | B<br />
: it's the counterpart of ''from table''. A is the name of the table, while B is in the form ''key=value''.<br />
: If the key already exists, it's replaced, added otherwise.<br />
: Example: <tt>set table|foo|key2=new value</tt><br />
: Loading entire database-like TXT files can be achieved by replacing A with the database path:<br />
:: <tt>{.for each|value|{.replace|;|{.no pipe||.}|{.load| A .}.}|{:{.if|{.^value.}|{:{.set table|table|{.^value.}.}:}.}:}.}</tt><br />
:: The database file must use the syntax of <tt>key1=value1;key2=value2;key3=value3;</tt><br />
<br />
; cache | A | B | C<br />
: expands to retrieved value B from cache-table A. If not found, the new value C will be set. You can quote C if you need it.<br />
: This is a very useful tool when C takes too much time and you want to be sure you will do it only once.<br />
: Example: <tt><nowiki>{.cache|#countries|%ip%|{:{.load|http://server/giveMeTheCoutry?ip=%ip% .}:}.}</nowiki></tt><br />
<br />
; var domain | A<br />
: returns a list of all variable names starting with prefix A, separated by |.<br />
: Optional parameter ''separator'' to specify a different separator.<br />
: Optional parameter ''get=values'' will return variable values instead of names.<br />
<br />
== Localization ==<br />
Here goes a macro useful for template localization.<br />
<br />
Inside the template you can use identifiers (IDs) instead of real text. So you can gather all the text in one place, and ease the work of whom wants to translate to another language.<br />
<br />
Lets say that you have a link '''<a href ='..'>Go up one level</a>'''. You can replace with '''<a href ='..'>{.!up.}</a>''', moving the text to section '''[special:strings]'''.<br />
[special:strings]<br />
up=Go up one level<br />
<br />
You can optionally provide a parameter (like ''<nowiki><br />
{.!up|Go to parent folder.}</nowiki>'') that will be the default text in case '''up''' is not found in '''[special:strings]'''.<br />
<br />
<br />
If no parameter is provided, then the ID itself will be used as default text.<br />
<br />
== File manipulation ==<br />
Consider most of these macros work only with operating system oriented paths, not the ones of the virtual file system.<br />
<br />
; load | A : you'll love this one. You can specify A as a file name, or as a URL. It will load and expand to it. The file or URL you specify must be accessible from the server machine. A can be <tt>C:\windows\win.ini</tt> or also <tt><nowiki>http://another_hfs_in_lan/the_file_i_want.txt</nowiki></tt>.<br />
: With an optional parameter ''var'' you can specify the name of a variable where the whole content of the file will be stored. In such case, the macro will not expand to the content of the file, it's just in the var.<br />
: Optional parameter ''from'' to specify an offset from where to start reading.<br />
: Optional parameter ''size'' to specify how much to read.<br />
: Optional parameter ''to'' to specify the last byte to read, as an offset from the beginning.<br />
: All parameters ''from, size'' and ''to'' are expressed as number of bytes.<br />
: Example: {.load|document.txt|var=mytext.} or <tt><nowiki>{.load|http://www.domain.tld/test.txt.}</nowiki></tt><br />
<br />
; filesize | A : tells you the size in bytes of the file A. At the moment URL are not supported, only local filenames.<br />
<br />
; save | A | B : stores B to file path A. The path can be absolute, URI based or relative to HFS folder.<br />
: You can supply an optional parameter ''var'' instead of B, and the content of the specified variable will be saved.<br />
<br />
; append | A | B : add B at the end of file A. This may is also useful to keep special logs.<br />
<br />
; delete | A : moves the file A to the recycle bin.<br />
: Optional parameter ''forced=1'' will force deletion in case the bin is not available.<br />
: Optional parameter ''bin=0'' will delete the file permanently instead of moving to the recycled bin.<br />
<br />
; rename | A | B : renames the file A to B. Files can be specified with their disk path or in the URI form.<br />
<br />
; md5 file | A : computes and expands to the MD5 hash for file A.<br />
<br />
; copy | A | B : copies file A to B, where B can be a folder or a full path+filename. A can eventually be specified in the URI form.<br />
; move | A | B : as ''copy'', but A is moved instead of duplicated.<br />
<br />
; chdir | A : changes the current [http://en.wikipedia.org/wiki/Working_directory working directory] of the HFS process.<br />
; mkdir | A : creates the specified folder. URI is supported in A, but it must refer a real folder.<br />
<br />
; exists | A : checks A for existence, may it be a file or folder.<br />
; is file | A : checks A for existence as a file.<br />
<br />
; filename | A : returns only the filename part of A, removing eventual path information.<br />
; filepath | A : returns only the path of A, removing the file name.<br />
; filetime | A : returns timestamp for file A, express in [[HFS:_Time_format#Numerical_format|the usual format]].<br />
<br />
; disk free | A : returns available disk space for specified path in bytes. For example, to display available disk space for drive C:\ in Gigabytes use : {.round|{.div| {.disk free|C:\.} | 1073741824.}|2.}<br />
<br />
; dir | A : lists all the files found at path A, separated by |.<br />
: Optional parameter ''separator'' to specify a different separator.<br />
<br />
; file changed | A : returns true if file A has changed since last time checked (with this same command).<br />
: Optional second parameter will specify a variable name where to load the content of file A if the check returns true.<br />
<br />
== Virtual File System manipulation ==<br />
; add folder | A | B | C<br />
: adds a folder to the virtual file system. A specifies ''real'' or ''virtual'', while B is the name of the folder.<br />
: For real folders B should be the path on disk, but if published name is different than the real one, you can specify the path in parameter B, and the name in C.<br />
: Where in place of a simple name, you specify a virtual path, it will be used to place the folder (otherwise it will be place on the root).<br />
: Any existent folder with same name will be overwritten, unless you specify a parameter <tt>overwrite=0</tt>.<br />
: Example: <tt>{.add folder|virtual|/personal/my pictures.}</tt><br />
:: a virtual folder "my pictures" will be added under existing folder "personal".<br />
: Example: <tt>{.add folder|real|C:\music|my music|overwrite=0.}</tt><br />
:: folder on hard disk C:\music is published with public "my music". If a folder with same name is in the VFS, it's left untouched and no new folder is created.<br />
<br />
; set item | A<br />
: modifies the item A in the virtual file system by using any of these optional parameters<br />
:; hide : set to 1/0 to decide item visibility<br />
:; hide tree : set to 1/0 to decide item visibility and sub-items<br />
:; no log : set to 1/0 to decide item logging<br />
:; not as download : set 1/0, it's the same as ''don't consider as a download''. For folders, set it to ''*'' for all files, or any other file mask you want.<br />
:; comment : set the comment<br />
:; resource : Set the resource. It's the physical path for files and real folders, or the URL for links.<br />
:; archivable : Set whether the folder is archivable or not.<br />
:; browsable : Set whether or not the folder is browsable.<br />
:; download forbidden : Set whether or not to forbid downloading from this folder<br />
:; files filter : Show only certain files in the folder.<br />
:; folders filter : Show only certain folders in the folder.<br />
:; diff template : Change the diff template of a vfs item.<br />
: Example: <tt>{.set item|private files|hide=0|comment=you should never see this!.}</tt><br />
:; access / delete / upload<br />
:;: you can set permissions on the item, by specifying a list of usernames.<br />
:;: Example: <tt>set item|videos|upload=robert</tt> will give account ''robert'' the ability to upload files in ''/videos''.<br />
:;: Moreover, you can prefix permission by '''add''' or '''remove'''. In the previous example you set the ''upload'' permission. If ''mike'' already had upload permission, it is now lost. To '''add''' ''robert'' instead of just overwriting, you should <tt>{.set item|videos|add upload=robert.}</tt>. Now ''mike'' is happy too. As well, if you change your mind, and want to revoke your grant, just <tt>set item|videos|remove upload=robert</tt>.<br />
:;: You can specify more than one username this way: '''robert;mike;rupert'''.<br />
:;: Special usernames are '''@anonymous @any account @anyone'''.<br />
<br />
; get item | A | B<br />
: retrieves information B about VFS item specified by A.<br />
: Supported values for B are: ''exists, comment, resource, hide, hide tree, no log, not as download, access, upload, delete''.<br />
: Example: <tt>{.get item|/putYourFilesHere|upload.}</tt> will tell you who is allowed to upload files in that folder.<br />
<br />
; vfs select | A<br />
: A specifies what VFS item to select, but it's optional. If no parameter is provided, the currently selected item is returned.<br />
: If A is ''next'', the item coming after the current selection becomes the new selection.<br />
: If A is a named parameter ''path'', then you are specifying what item to select in the URI form.<br />
: Example: <tt>{.vfs select| path=/ .}</tt> will reset selection to the home/root, and looping through <tt>{.vfs select| next .}</tt> will select every VFS item, until <tt>{.vfs select.}</tt> is false (an empty string).<br />
<br />
; vfs to disk | A : a web path (URI) is converted to its related drive path. Relative paths like <tt>..</tt> are calculated based on the VFS folder where the script is running.<br />
<br />
== Connections control ==<br />
; disconnect | A | B : with no parameters, it disconnects current connection. If A is supplied, it is considered an [[HFS: IP masks|IP mask]], and every connection matching it (instead of the current one) will be disconnected. If also B is supplied, it will select only connections with port number same as B.<br />
<br />
; set speed limit for connection | A : set a speed limit A in KB/s for the current connection<br />
<br />
; set speed limit for address | A | B : set a speed limit B in KB/s for all connections coming from address A (no masks allowed).<br />
: When A is omitted, then it actually sets the value for the option ''Speed limit for single address'' in the GUI.<br />
<br />
; disconnection reason | A<br />
: this ''reason'' determines if a download must be aborted. Any value will abort the download, but if the value is empty the download goes on.<br />
: This macro will always return the value of the ''reason'' just before its call. So with a single call you are reading and setting the value. If no parameter is specified, then you are only reading.<br />
: Optional named parameter ''if=CONDITION'' is a shortcut for <tt>{.if|CONDITION|{:{.disconnection reason.}:}.}</tt><br />
: Example: <tt>{.disconnection reason|Try firefox|if={.{.get|agent.} != Mozilla.}.}</tt><br />
<br />
; add header | A : adds line A to the [http://en.wikipedia.org/wiki/HTTP_header HTTP header].<br />
<br />
; redirect | A : tells the browser to change to a different address (the specified one).<br />
<br />
; current downloads<br />
: expands to the number of current downloads. <br />
: Optional named parameter ''user'' will count only downloads made by specified user.<br />
: Optional named parameter ''ip'' will count only downloads made by the specified address.<br />
: Optional parameter ''file=this'' will count only downloads of this current file.<br />
: Example: <tt>{.current downloads|user=%user%|file=this.}</tt> will tell you how many connections this user is using to download this same file.<br />
<br />
; current downloads of file<br />
: number of current downloads of current file. <br />
: If an unnamed optional parameter is specified, it is used as [[HFS: IP masks|IP mask]], and only matching connections will be counted.<br />
: If the parameter is given name ''user'', only connections by such user will be counted.<br />
<br />
== Account manipulation ==<br />
; set account | A | ...<br />
: with this command you can change all attributes of the account whose username is specified in first parameter. If the username is left empty, current username is used, given this makes sense in current context.<br />
: Other parameters are the attributes you want to change, in the form <tt>set account|username|thing=value|thing2=value2</tt>.<br />
: Here is a list of such attributes<br />
:;password : set a new password<br />
:;newname : set a new username<br />
:;redirect : set the homonymous field<br />
:;no limits : set the homonymous field (true/false)<br />
:;enabled : set the homonymous field (true/false)<br />
:;is group : set the homonymous field (true/false)<br />
:;member of : set the ''member of'' field (specify more than one group separating by semicolons ";" )<br />
:;add member of : add more groups to the above<br />
:;remove member of : remove some groups to the above<br />
:;notes : set the homonymous field<br />
:;notes key <br />
:;: set the notes as it was a table with <tt>{.set table.}</tt><br />
:;: Example: <tt>{.set account|mike|notes key=last time=%timestamp%.}</tt><br />
<br />
; new account | A | ...<br />
: creates a new account with username A. After the username, you can also specify all the values available in the ''set account'' macro.<br />
<br />
;'' '' delete account | A<br />
: delete specified account (by username).<br />
<br />
; get account | A | B<br />
: expands to the value of property B of account A. <br />
: Supported value for B are ''redirect, no limits, enabled, is group, member of, notes, notes key''. Group names for ''member of'' are semicolon-separated. Special case for ''notes key'' where you should specify the key to retrieve, while the notes are treated as a table, just as for <tt>{.from table.}</tt>.<br />
: If A is omitted, current username is used, given this makes sense in current context.<br />
<br />
; member of | A<br />
: true if the current user is member of group A (specify more than one group separating by semicolons ";").<br />
: Optional parameter ''user'' to check a different user.<br />
: Example <tt>member of|administrators|user=rejetto</tt><br />
: If A is omitted, you will get the full membership for current (or specified) user. This is different from <tt>{.get account||member of.}</tt> because this latter form will consider only direct first-level membership, while <tt>{.member of.}</tt> will actually consider membership at any level.<br />
<br />
== Others ==<br />
; comment | A : this is just discarded. It's for your convenience, to put a comment in the template. HTML comments are readable by visitors if they use ''show html source'' in their browser. Using this macro you will have comments that will never leave your server.<br />
<br />
; length | A : if A is 5 characters length, like <tt>abcde</tt>, it expands to 5.<br />
: Optional parameter ''var'' in place of A, will work on the specified variable instead of considering A as text.<br />
<br />
; match | A | B : it is true if the content B is matched by [[HFS: File masks|the mask]] A.<br />
<br />
; match address | A | B : just like the macro ''match'', but the mask supports ip ranges like 10.0.0.1-10.0.0.25<br />
<br />
; random | A | B | C | ... : it expands to any of the parameters, randomly<br />
<br />
; random number | A | B : if only A is specified then a number between 0 and A is generated. If also B is specified then the number will be between A and B (included).<br />
<br />
; pos | A | B : expands to the position of A in B. Zero if not found. <br />
: Optional parameter ''from'' will start searching from specified position.<br />
: Optional parameter ''case'' will decide case sensitivity. Default is: insensitive.<br />
: Example <tt>pos|the|i'm the alpha and the omega|from=14|case=1</tt> expands to <tt>19</tt><br />
<br />
; regexp | A | B<br />
: Try to [http://en.wikipedia.org/wiki/Regular_expressions match pattern] A on text B.<br />
: When the pattern doesn't match, it just expands to nothing (then, false).<br />
: When it does, the matched sub-pattern is returned.<br />
: You can provide optional parameter ''var'' instead of B, and the text will be the content of the specified variable.<br />
: Optional parameter ''case'' will determine case sensitivity. (off by default)<br />
: Optional parameter ''sub'' will specify the name of a variable that will be set as a table, where you can retrieve every sub-pattern by numerical index.<br />
: If optional parameter ''replace=YYY'' is used, the command returns no more the matched pattern, but the whole text B with every matched pattern replaced by YYY. If you use ''replace'' and ''var'' together, the resulting text will not be returned, but stored in the specified input variable (that means, it's used both for input and output).<br />
: Example: <tt>regexp|\d+|var=weWantNumbers</tt><br />
<br />
; breadcrumbs | A<br />
: builds a [http://en.wikipedia.org/wiki/Breadcrumb_(navigation) breadcrumbs] based on the current folder path. The A is a little html template that is repeated for every piece of the path, for which 3 symbols are provided: ''%bread-url%'' , ''%bread-name%'' and ''%bread-idx%''. <br />
: Remember to use quoting, especially if you use macros in the parameter.<br />
: Optional parameter ''from'' will let you specify how many steps of the path to skip.<br />
: Example: <tt>{.breadcrumbs|{:<a href ="%bread-url%">%bread-name%/</a>:}.}</tt><br />
<br />
; dialog | A | B | C<br />
: display a server-side message in a dialog box. A is the message itself, and only required parameter. B are options separated by spaces, and C a title for the dialog.<br />
: Possible options are<br />
:;okcancel : offers buttons OK and CANCEL. It will return 1/true if OK is pressed, false otherwise.<br />
:;yesno : offers buttons YES and NO. It will return 1/true if YES is pressed, false otherwise.<br />
:;yesnocancel : offers buttons YES, NO and CANCEL. It will return 1/true if YES is pressed, 'cancel' if CANCEL is pressed, false otherwise.<br />
:;error : this is an error reporting dialog<br />
:;question : this is a questioning dialog<br />
:;warning : this is a warning dialog<br />
:;information : this is an informational dialog<br />
:Example: <tt>{.if|{.dialog|stop server?|yesno question.}|{:{.stop server.}:}.}</tt><br />
<br />
; mime | A : set the mime-type sent to the browser. It describes the nature of the content. For techies, it's the value of the header field "Content-type".<br />
<br />
; any macro marker | A : it is true if any macro marker is present in A. Macro markers are {.delimiters.} , {:quotings:} and the parameters separator (the pipe, "|").<br />
<br />
; play system event | A : specify the name of the event bound to a sound that you want to play. ''SystemStart'' and ''MailBeep'' are just examples, for a full list you can open your registry at ''HKEY_CURRENT_USER\AppEvents\EventLabels'' .<br />
<br />
; exec | A : ask system to run file A, eventually with parameters. If you need to use the pipe, then use macro quoting.<br />
: Optional parameter ''out'' will let you capture the console output of the program in the variable specified by name.<br />
: Optional parameter ''timeout'' will specify the max number of seconds the app should be left running.<br />
: Example: <tt>{.exec|notepad.}</tt><br />
<br />
; add to log | A : add A to the log panel. <br />
: Optional parameter ''color'' to [[HFS: color format|specify the color]].<br />
<br />
; get ini | A<br />
: where A is a text in the same format you can find in ''hfs.ini'' (save options -> to file).<br />
: example: <tt>{.get ini|speed limit.}</tt> will return the global speed limit, if any.<br />
<br />
; set ini | A<br />
: where A is a text in the same format you can find in ''hfs.ini'' (save options -> to file).<br />
: example: <tt>{.set ini|speed limit=100.}</tt> will turn the global speed limit to 100KB/s.<br />
<br />
; focus<br />
: will bring HFS window on front of the user.<br />
<br />
; load tpl | A : for this connection only, template A will be used.<br />
: Example: <tt>{.if| it's a mobile | {:{.load tpl|mobile.tpl.}:} /if.}</tt><br />
<br />
; notify | A<br />
: The message A will come out as a balloon over the HFS tray icon.<br />
: Optional parameter ''title'' will let you specify the title of the balloon.<br />
: Optional parameter ''timeout'' specifies the amount of time to show the message.<br />
: Optional parameter ''type'' will show an icon according to its value. Allowed values are ''info, error'' and ''warning''.<br />
<br />
== Shortcuts ==<br />
;$A : is a shortcut for '''section | A'''<br />
;?A : is a shortcut for '''urlvar | A'''<br />
;^A : is a shortcut for '''call | A'''<br />
;A = B : is a shortcut for '''=|A|B'''<br />
;?name = X : is a shortcut for <tt>{.?name.} = X</tt> .<br />
: It works also for '''<> != < <= > >=''' .</div>
Rejetto
https://rejetto.com/wiki/index.php?title=HFS:_Virtual_File_System_menu&diff=5688
HFS: Virtual File System menu
2020-05-10T09:37:19Z
<p>Rejetto: diff template</p>
<hr />
<div>== Virtual File System Menu ==<br />
<br />
; Copy URL : Copies the URL to the clipboard.<br />
; Get passworded URL : Copies the URL to the clipboard. The resultant URL integrates the username and password necessary to access the file.<br />
: Specifying the username/password through the URL is a less secure system, but it is easier to use and more secure than no password at all.<br />
; Set URL : Set the link.<br />
; Browse it : Opens your default web browser on the item's URL.<br />
; Open it : Opens the selected item on the server computer.<br />
; Comment : Specify a comment for the item. It is displayed in the client when browsing.<br />
; Icon : Select a different icon for the item.<br />
; Diff template : This works as the HTML template, but just applies to the selected folder (and below). Using this feature you can have a different template in every folder. The "diff" stands for ''difference'', indeed you can specify only the sections of the template you want to change, not necessarily the whole template. The sections you specify will be added/overwritten to the main template. If you prefer you can keep the text in a file, and enter in this box just the path of the file. If your folder is a ''real folder'', it will also try to load a file named ''hfs.diff.tpl'' in it.<br />
; Switch to virtual-folder : Changes a real folder into a virtual folder.<br />
; New folder : Adds a virtual folder.<br />
; New link : Adds a "link" item. A link has a URL, so you can link to anything on the Internet.<br />
; Rename : Renames the item in the VFS.<br />
; Remove : Removes the item from the VFS.<br />
;Edit resource: Allows you to change the folder or file which the VFS points to.<br />
; Paste : If you copy a file from Explorer, you can then paste it into the VFS.<br />
; Add files : Opens a dialog where you can select files to be added.<br />
; Add folder : Opens a dialog where you can select a folder to be added.<br />
; Files/Folders filter<br />
: If you set a filter for files/folders, then some items are hidden. This works like the "Hide" command, so refer below for more details. The only files displayed are those that match the filter mask. For more information, check [[HFS:_File_masks|here]].<br />
; Default file mask. : When a folder is browsed, the default file mask is used to find a file to serve in place of the folder page. If no file is found, the folder page is served.<br />
; Don't count as download<nowiki> :mask </nowiki><br />
: Files matching this filemask are not added to the global downloads counter. They also never use the tray icon.<br />
; Don't Log<br />
: Prevents hfs from adding any request for the file/folder to the log.<br />
; Set user/pass : You can protect an item by password. This is an on-the-fly protection, if you need something more permanent, use the account system (users).<br />
; Reset user/pass : Removes username/password protection. This just affects the item referenced by the Set option, it does not alter the account protection. <br />
; Restrict access : Protects an item by restricting access to specified users. Before using this option you must configure some accounts. (Putting a tick next to a user grants them access to that item.)<br />
; Visible only to anonymous users : Displays an item to anonymous users, but not to users who have logged in.<br />
; Customized realm : Specify a [[HFS:_Realms|realm]] for the item's login dialog box.<br />
; Upload : Allow specified users to upload to this folder.<br />
; Let browse : Allow or disallow browsing for the selected folder.<br />
; Let download : Allow or disallow users to download a file. Since for real-folders you can't set the option clicking on the files, you can set the option on the folder, and it will be inherited by the files.<br />
; Hide : If you don't want people to know about a file that is in your VFS, you can just hide it. This does not actually prevent retrieval; in fact you can give the full URL of the file to your friends and they will still be able to download it. It simply does not display the file when people are browsing through the VFS. This is not the most secure way to protect your files from unwanted access, although it is quite reasonable since people do not normally know the name of the file you are hiding.<br> This is also useful when you add eg. a folder full of images to your site, but don't want users to see it, or be distracted by it.<br />
; Hide tree : Identical to the option above, but it also includes subitems.<br />
; Auto-hide empty folders : Prevents empty folders from being displayed.</div>
Rejetto
https://rejetto.com/wiki/index.php?title=HFS:_Hidden_things&diff=5687
HFS: Hidden things
2020-05-10T09:31:21Z
<p>Rejetto: </p>
<hr />
<div>These features are not available from the GUI.<br />
You just have to know that they exist.<br />
* Hold SHIFT at startup to skip configuration loading<br />
* Hold CTRL at startup to skip the ''"only 1 instance"'' feature<br />
* If you have a real folder containing a file named ''hfs.diff.tpl'', that will be used as diff template.<br />
* '''~files.lst''' can be customized. Simply create a text file named '''hfs.filelist.tpl''' and add it to the folder that contains '''hfs.exe'''. Then, insert this content:<br />
<br />
<pre><br />
%files%<br />
<br />
[files]<br />
%list%<br />
<br />
[file]<br />
%item-full-url%<br />
<br />
[folder]<br />
%item-full-url%<br />
</pre><br />
: Edit this template to fit your needs.<br />
<br />
* [Since ver 2.3] Sorting by comment is supported (although not used by the default template) by using parameter '''sort=c'''<br />
* [Since ver 2.3] Per-folder default sorting is supported [http://www.rejetto.com/forum/index.php?topic=5656.msg1033337#msg1033337 More info]<br />
* [Since ver 2.3] Adding a folder "upload" from the disk, will quickly give you upload permissions</div>
Rejetto
https://rejetto.com/wiki/index.php?title=HFS:_scripting_commands&diff=5667
HFS: scripting commands
2018-11-04T17:07:53Z
<p>Rejetto: /* Data manipulation */</p>
<hr />
<div>Also known as template macros, these are commands with some useful effects that users can input in HFS to improve a template or to create functionality not otherwise available. <br />
<br />
Some commands simply expand to text, to display information, and some perform server-side actions, like deleting a file.<br />
<br />
Every command is expressed as a name, and sometimes parameters, separated by pipes "<tt>|</tt>".<br />
<br />
Following, with letters we are denoting parameters, and their meaning is explained immediately after.<br />
<br />
You should read this [http://www.rejetto.com/wiki/index.php?title=HFS:_Template_macros] before reading this page.<br />
<br />
== Logic and flow ==<br />
; if | A | B | C<br />
: if A is true, then it expands to B, else it expands to C. When it expands to B, C is just discarded, and the vice versa. C is optional.<br />
: How you tell A is true? A is true if it is not empty and not just a zero. So if A is "hi there!", then it is true.<br />
: Remember to use quoting if you use macros in B or C (the body).<br />
<br />
; if not | A | B | C <br />
: same as ''if'', but the logic is inverted. When A is true it expands to C and vice versa.<br />
<br />
; not | A : true if A is not true. It negates the value of A.<br />
<br />
; and | A | B : true if both A and B are true. In details: in the ''true'' case it returns the last parameter. You can specify as many parameters as necessary. Both Javascript and Python work this way.<br />
<br />
; or | A | B : true if any of A or B are true. In details: it returns the first ''true'' parameter (yes, it supports any number of parameters). If none of the parameters is true, then iit returns false. Both Javascript and Python work this way. Often times you can work without {.or.}, for example {.if| A B | C .} returns true if either A or B are true.<br />
<br />
; xor | A | B : true if A is true while B is false, or the opposite<br />
<br />
; = | A | B : true if A is the same as B. It's case insensitive. You can use the opposite macro, true if they are different, and it's name is '''!=''' or '''<>''' (use the one you like most, there's no difference). You can specify as many parameters as you like.<br />
<br />
; > | A | B : true if A is greater than B. Of course you can also use the related macro '''<'''. You can specify as many parameters as you like.<br />
<br />
; >= | A | B : true if A is equal or greater than B. Of course you can also use the related macro '''<='''. You can specify as many parameters as you like.<br />
<br />
; between | A | B | C : true if B is between A and C (included).<br />
<br />
; between! | A | B | C : true if B is between A and C (excluded).<br />
<br />
; switch | A | B | C | D | E | F ...<br />
: this is rather complex for non-programmers. You can learn how a switch statement is supposed to work [http://en.wikipedia.org/wiki/Switch_statement#Examples from Wikipedia]. When you know how a ''switch'' works, then you will understand this schema that will make you understand how the parameters of this macro work<br />
<pre><nowiki><br />
switch(A) {<br />
case C: return D;<br />
case E: return F;<br />
...<br />
}<br />
</nowiki></pre><br />
: The B is a separator string for C. Let's be clearer: if you want to specify several cases in C, all of them returning D, then you can specify them separating with B.<br />
: As you can see C and D are paired, as E and F, eventually G and H, and so on. If at the end of this list of pairs, a single unpaired parameter is found, then it is used as the else/default case, when all other pairs have failed.<br />
: Let me translated the first example of Wikipedia using the macro<br />
<pre><nowiki><br />
{.switch|%n%|,|<br />
0|you typed zero|<br />
3,5,7|%n% is a prime number|<br />
4,6,8|%n% is an even number|<br />
2|%n% is a prime and even number|<br />
1,9|%n% is a perfect square|<br />
Only single-digit numbers are allowed<br />
.}<br />
</nowiki></pre><br />
<br />
Switch is esentially a quick way of using many {.if.} and {.=.} commands together. For example, if A equals C then D, if A equals E then F, etc.<br />
<br />
; for | A | B | C | D | E<br />
: repeats D by replacing variable <tt>{.^A.}</tt> with every value between B and C (they are meant to be numbers).<br />
: Optionally you can specify a ''step'' for the numbers: that is, instead of going 1-by-1, they can go 2-by-2. The optional ''step'' is specified at position D; in such case the ''body'' is moved from position D to position E.<br />
: Remember to use quoting for the body.<br />
<br />
; for each | A | B | C ... | Z<br />
: a (sometimes) handier version of ''for'', that will repeat Z but replacing variable <tt>{.^A.}</tt> with value B the first time, value C the second time, D etc etc. Remember to quote the body. <br />
: example: <tt>{.for each|i|10|100|1000|{:now it's {.^i.} :}.}</tt><br />
<br />
; while | A | B<br />
: repeats B for as long as A is true. Both B is automatically dequoted. If A is quoted, then it's expanded, otherwise is considered the a variable name.<br />
: Optional parameter ''else'' will be expanded if B is never done.<br />
: Optional parameter ''timeout'' let you specify (in seconds) the maximum time the loop can live before it is stopped. It's 1 second by default.<br />
: Optional parameter ''var'' saves the output in a variable instead of just expanding to it.<br />
: Example: <tt>{.while|#x|{: {.dec|#x.} welcome! :}.}</tt> will welcome 10 times if <tt>#x</tt> is 10.<br />
<br />
; after the list | A<br />
: quoted text A is dequoted and executed, but only if the file listing is completed.<br />
<br />
; dequote | A<br />
: if A is {:quoted:} then quoting markers are removed (unleashing macro execution of the previously quoted text).<br />
<br />
; 123 if 2 | A | B | C<br />
: if B is true, it expands to ABC, otherwise nothing.<br />
: It is basically a shortcut for {.if | B |{: A B C :}.}<br />
<br />
; break : stops execution of this script.<br />
: Optional parameter ''if'' will avoid breaking in case the condition is not met (that is, when it's ''false'').<br />
: Optional parameter ''result'' will output a text only if the break occurs (makes sense only with parameter ''if'').<br />
: Using <tt>{.break|if=data.}</tt> is basically a simplified way to write <tt>{.if|data|{:{.break.}:}.}</tt><br />
<br />
== Data getting ==<br />
; section | A<br />
: A is the name of the [section] you want to include. Note: till build #160 it was case sensitive.<br />
: Optional parameter ''file'' to load the section from an external file.<br />
: Optional parameter ''back=1'' will work in diff templates to access the section in the original template. So you can access it even if you overwrote it.<br />
: Example: <tt>{.section|names|file=tables.txt.}</tt><br />
; get | A<br />
: where A is the name of a value you are interested in, like to know if an option is enabled or not.<br />
: This is a list of supported values for A:<br />
:; can upload : true if in the current folder the user is allowed to upload files. An additional parameter ''path'' will tell you about a different folder instead of the current one.<br />
:; can delete : true if the user is allowed to delete the current item. An additional parameter ''path'' will tell you about a different folder instead of the current one.<br />
:; can access : true if the current item in list is accessible by the user. An additional parameter ''path'' will tell you about a different folder instead of the current one.<br />
:; can recur : true if the option ''Recursive listing'' is enabled<br />
:; can archive : true if the current item in list is archivable. outside the list it refers to the current folder.<br />
:; is new : true if the current item in list is flagged as "new"<br />
:; accounts : semicolon-separated list of username of all accounts. By specifying an additional parameter '''groups''' you'll get only groups. Respectively, a parameter '''users''' will give you only non-group accounts.<br />
:; stop spiders : true if ''stop spider'' option is enabled.<br />
:; protocolon : expands to <tt>http&#58;//</tt> unless you enabled option ''URLs starting with https'' in which case it expands to <tt>https&#58;//</tt> (please notice the final S).<br />
:; speed limit : gives the current global speed limit, as a number (in KB/s).<br />
:; agent : Tells the user's browser. E.g., Firefox expands to Mozilla and IE8 will expand to MSIE 8.0.<br />
<br />
; urlvar | A : url variable. Let's say in the url you see <tt>?sort=s</tt> and you want to know that '''s''', just use the macro ''urlvar|sort''.<br />
: Optional parameter ''var'' will put the resulting text in the specified variable.<br />
; postvar | A : just as ''urlvar'' but reads the value from the POST part of the request instead of the URL.<br />
: Optional parameter ''var'' will put the resulting text in the specified variable.<br />
; header | A : get any value from the HTTP request header. A is the name of the header field. This is something mostly for techies. Don't fret if you don't even know what the header is.<br />
; time | A : returns current time information. The format is specified by optional parameter A. Refer to [[HFS: Time format#Text formatting|this page]] for format syntax. If A is not supplied, value "c" will be used.<br />
: Optional parameter ''when'' to [[HFS: Time format#Numerical format|specify a time]] other than current.<br />
: Optional parameter ''offset'' to specify the number of days differing from the current time.<br />
<br />
; cookie | A : expands to the value A passed by the browser.<br />
: With an optional parameter ''value'' you will set a new value.<br />
: Every known standard parameter for cookies is accepted, as ''expires'' and ''path''. Expires can be expressed in many ways: if it starts with '''+''' or '''-''' will be the number of days in the future or in the past. If it's a number will be considered as unix time format or [[HFS: Time format#Numerical format|HFS format]]. You can even specify it as a date: <tt>2/4/2013</tt>.<br />
: Example: <tt>{.cookie|step.}</tt> will give you the current value<br />
: Example: <tt>{.cookie|step|value=3|expires=+30.}</tt> will set ''step'' to ''3'' and the cookie will expire in 30 days.<br />
: Setting a cookie can also be accomplished by using {.add header.} with Set-Cookie.<br />
<br />
== Data manipulation ==<br />
; substring | A | B | C : cut C from A to B, with B not included. <br />
: Example: <tt>substring|(|belong|you (are) belong to us.}</tt> will be <tt>(are)</tt>.<br />
: If A is not specified, C is taken from the start. If B is not specified, C is taken to the end.<br />
: Optional parameter ''case=1'' to turn on case sensitivity.<br />
: Optional parameter ''include'' to say if A and/or B must be included. Values: 0 (none), 1 (only A), 2 (only B), 1+2 (both).<br />
<br />
; cut | A | B | C : cut C from position A, for B characters. The difference with macro ''substring'' is that here you specify where to cut by numeric positions.<br />
: Example: <tt>cut|2|3|abcdef</tt> will expand to <tt>bcd</tt><br />
: If you don't specify A, it defaults to 1. If you don't specify B, it defaults to the length of C.<br />
: If A is negative, then you are counting backward from the end of C. If B is negative, then you are considering the length of C minus the amount of B.<br />
: Optional parameter ''to'' will let you specify the number of character to cut. B is ignored in this case.<br />
: Optional parameter ''var'' specifies the variable name to work on. You can use it instead of C, but in such case the output will be stored in the variable.<br />
: Optional parameter ''remainder'' works only with parameter ''var'', and let you specify a variable name where all that is cut out is stored.<br />
: You can use named parameter ''from'' instead of A, ''size'' instead of B, and ''what'' instead of C.<br />
: Example: <tt>cut|from=3|size=2|abcdef</tt> will expand to <tt>cd</tt><br />
<br />
; repeat | A | B : repeat B for A times. Example: for A=5 and B=+ the result is +++++<br />
<br />
; upper | A : returns A with all letters uppercased. Example: for A=Hello the result is HELLO<br />
<br />
; lower | A : returns A with all letters lowercased. Example: for A=Hello the result is hello<br />
<br />
; trim | A : returns A with any leading and trailing space removed<br />
<br />
; replace | A | B | C : returns C with every A replaced with B. This command can apply multiple replacements by having multiple pairs of parameters A-B. But you always need to have a final parameter C, that's the text that will be manipulated.<br />
: Optional parameter ''var'' in place of parameter C will make use of the specified variable as both input and output.<br />
<br />
; calc | A : return the result of the mathematical expression A. Example: for 1+(5/2) the result is 3.5<br />
: supported operators are <tt>+ - * / %</tt> (as modulus)<br />
; round | A | B : returns rounded value of A, where A is a non-integer number, and B is the number of digits after the decimal point. B is zero by default if not specified.<br />
<br />
; add | A | B : returns A+B where A and B are numbers<br />
<br />
; sub | A | B : returns A-B where A and B are numbers<br />
<br />
; mul | A | B : returns A*B where A and B are numbers<br />
<br />
; div | A | B : returns A/B where A and B are numbers<br />
<br />
; mod | A | B : returns A modulus B where A and B are numbers<br />
<br />
; min | A | B ... : returns the minimum over all parameters. You can have more than 2 parameters.<br />
<br />
; max | A | B ... : returns the maximum over all parameters. You can have more than 2 parameters.<br />
<br />
; count substring | A | B : tells the number of times A is present in B (case sensitive)<br />
<br />
; encodeuri | A : all characters are encoded in the %XX form used for URLs, except alphanumerics and <tt>#/,&?:$@=+</tt><br />
;: You can add more characters to the set that will be encoded by using the optional parameter ''add'', as well as you can decide to exclude some characters by using the optional parameter ''not''.<br />
;: You can also decide to specify the whole set, one by one, with optional parameter ''only''.<br />
;: In all these optional parameters you can specify many characters just by having them as a string, one after another.<br />
<br />
; decodeuri | A : all encoded characters in the form %XX are decoded.<br />
<br />
; convert | A | B | C<br />
: converts C from charset A to charset B. At the moment only supported charsets are ''ansi'' and ''utf-8''. <br />
<br />
; force ansi | A : if template is using UTF-8 charset, then A is converted to ANSI. Otherwise A is left unchanged.<br />
<br />
; maybe utf8 | A : if template is using UTF-8 charset, then A is converted to UTF-8. Otherwise A is left unchanged.<br />
<br />
; 123 if 2 | A | B | C : returns nothing if B is false/empty, otherwise a concatenation of ABC.<br />
<br />
; chr | A | B ... : returns characters with ANSI code A, B, etc. Numbers are decimal. To use hex numbers, precede them with an "x".<br />
: Example: {.chr|13|10|x0D|x0A.}<br />
<br />
; js encode | A | B<br />
: Encodes characters specified by B using javascript encoding for strings, in text A. If you mean to encode characters ''a'' and ''b'', parameter B should simply be ''ab''.<br />
: If B is not specified, characters encoded are only single-quote and double-quotes. This is supposed to be the frequently used case, when you are passing some data into a javascript string that's enclosed in any form of quotes.<br />
<br />
== Variables and functions ==<br />
; set | A | B<br />
: what you actually do is to bind B (the content) to the name A (the variable). It is called variable because you can always change the content of it. You can later recall B by passing A to the macro "call".<br />
: You can have as many variables as you want. All of them will be bound to the single page/request. When the page is finished and provided (or anyway the execution flow is over) the variables are cleared (and lost) unless you prepend a '''#''' to the name (e.g. #myVariable). In this latter case you are using '''global variables'''. These will survive until you clear them explicitly.<br />
: If you are used to programming, you may already know what variables and functions are. Here '''functions''' are a special case of variable, when the content is made of other commands. When you specify commands for the function, you need to [[HFS: Template_macros#Quoting|quote them]], otherwise they will be executed immediately while instead you want them to be executed at call-time. You can also have parameters: the first one is '''$1''', and so on, that you can specify inside the body ''B''.<br />
: Remember to use quoting if you use macros in the body (B).<br />
: Example: <tt>{.set|x|1.}</tt> or <tt>{.set|double|{:{.mul|$1|2.}:}.}</tt><br />
: Optional parameter ''var'' will let you copy variables.<br />
: Example: <tt>{.set|y|var=x.}</tt><br />
: Optional parameter ''mode'' can be <tt>append</tt> or <tt>prepend</tt>, to concatenate existing content of the variable to the new content, as AB or BA.<br />
: Example: <tt>{.set|x| is a good boy|mode=append.}</tt><br />
<br />
; call | A | B | C | ... : this macro (shortcut by '''^''') expands to the value bound to A. Such value can be a number or a text, doesn't matter. If the value contains symbols '''$1''' and $2, then they are replaced with the parameters B and C (and so on).<br />
: Example referring to above: <tt>{.call|double|15.}</tt> will expand to <tt>30</tt><br />
: You can find some examples for "set" and "call" [http://www.rejetto.com/forum/index.php?topic=5353.msg1031074#msg1031074 on the forum].<br />
<br />
; inc | A | B : if A is a variable with numeric value, then its value is incremented by the number B. If B is omitted, it defaults to 1.<br />
<br />
; dec | A | B : just as the ''inc'' above, but the value is decremented<br />
<br />
; count | A<br />
: each call returns and increments A, so the sequence will be 0 1 2 3...<br />
: variable A is not actually a variable, you can't access it throught {.^A.} and its value can be retrieved only through another call to ''count''. <br />
<br />
; from table | A | B<br />
: A is the table and B is the key. The table is a variable or a section with this form<br />
<pre>key1=value1<br />
key2=value2<br />
key3=value3</pre><br />
: Let's say such text is the content of variable ''foo'', then to get <tt>value2</tt> you should do <tt>{.from table|foo|key2.}</tt>. (yes, poetry)<br />
: If it was the content of table [bar] instead, then you should do <tt>{.from table|$bar|key2.}</tt>.<br />
<br />
; set table | A | B<br />
: it's the counterpart of ''from table''. A is the name of the table, while B is in the form ''key=value''.<br />
: If the key already exists, it's replaced, added otherwise.<br />
: Example: <tt>set table|foo|key2=new value</tt><br />
: Loading entire database-like TXT files can be achieved by replacing A with the database path:<br />
:: <tt>{.for each|value|{.replace|;|{.no pipe||.}|{.load| A .}.}|{:{.if|{.^value.}|{:{.set table|table|{.^value.}.}:}.}:}.}</tt><br />
:: The database file must use the syntax of <tt>key1=value1;key2=value2;key3=value3;</tt><br />
<br />
; cache | A | B | C<br />
: expands to retrieved value B from cache-table A. If not found, the new value C will be set. You can quote C if you need it.<br />
: This is a very useful tool when C takes too much time and you want to be sure you will do it only once.<br />
: Example: <tt><nowiki>{.cache|#countries|%ip%|{:{.load|http://server/giveMeTheCoutry?ip=%ip% .}:}.}</nowiki></tt><br />
<br />
; var domain | A<br />
: returns a list of all variable names starting with prefix A, separated by |.<br />
: Optional parameter ''separator'' to specify a different separator.<br />
: Optional parameter ''get=values'' will return variable values instead of names.<br />
<br />
== Localization ==<br />
Here goes a macro useful for template localization.<br />
<br />
Inside the template you can use identifiers (IDs) instead of real text. So you can gather all the text in one place, and ease the work of whom wants to translate to another language.<br />
<br />
Lets say that you have a link '''<a href ='..'>Go up one level</a>'''. You can replace with '''<a href ='..'>{.!up.}</a>''', moving the text to section '''[special:strings]'''.<br />
[special:strings]<br />
up=Go up one level<br />
<br />
You can optionally provide a parameter (like ''<nowiki><br />
{.!up|Go to parent folder.}</nowiki>'') that will be the default text in case '''up''' is not found in '''[special:strings]'''.<br />
<br />
<br />
If no parameter is provided, then the ID itself will be used as default text.<br />
<br />
== File manipulation ==<br />
Consider most of these macros work only with operating system oriented paths, not the ones of the virtual file system.<br />
<br />
; load | A : you'll love this one. You can specify A as a file name, or as a URL. It will load and expand to it. The file or URL you specify must be accessible from the server machine. A can be <tt>C:\windows\win.ini</tt> or also <tt><nowiki>http://another_hfs_in_lan/the_file_i_want.txt</nowiki></tt>.<br />
: With an optional parameter ''var'' you can specify the name of a variable where the whole content of the file will be stored. In such case, the macro will not expand to the content of the file, it's just in the var.<br />
: Optional parameter ''from'' to specify an offset from where to start reading.<br />
: Optional parameter ''size'' to specify how much to read.<br />
: Optional parameter ''to'' to specify the last byte to read, as an offset from the beginning.<br />
: All parameters ''from, size'' and ''to'' are expressed as number of bytes.<br />
: Example: {.load|document.txt|var=mytext.} or <tt><nowiki>{.load|http://www.domain.tld/test.txt.}</nowiki></tt><br />
<br />
; filesize | A : tells you the size in bytes of the file A. At the moment URL are not supported, only local filenames.<br />
<br />
; save | A | B : stores B to file path A. The path can be absolute, URI based or relative to HFS folder.<br />
: You can supply an optional parameter ''var'' instead of B, and the content of the specified variable will be saved.<br />
<br />
; append | A | B : add B at the end of file A. This may is also useful to keep special logs.<br />
<br />
; delete | A : moves the file A to the recycle bin.<br />
: Optional parameter ''forced=1'' will force deletion in case the bin is not available.<br />
: Optional parameter ''bin=0'' will delete the file permanently instead of moving to the recycled bin.<br />
<br />
; rename | A | B : renames the file A to B. Files can be specified with their disk path or in the URI form.<br />
<br />
; md5 file | A : computes and expands to the MD5 hash for file A.<br />
<br />
; copy | A | B : copies file A to B, where B can be a folder or a full path+filename. A can eventually be specified in the URI form.<br />
; move | A | B : as ''copy'', but A is moved instead of duplicated.<br />
<br />
; chdir | A : changes the current [http://en.wikipedia.org/wiki/Working_directory working directory] of the HFS process.<br />
; mkdir | A : creates the specified folder. URI is supported in A, but it must refer a real folder.<br />
<br />
; exists | A : checks A for existence, may it be a file or folder.<br />
; is file | A : checks A for existence as a file.<br />
<br />
; filename | A : returns only the filename part of A, removing eventual path information.<br />
; filepath | A : returns only the path of A, removing the file name.<br />
; filetime | A : returns timestamp for file A, express in [[HFS:_Time_format#Numerical_format|the usual format]].<br />
<br />
; disk free | A : returns available disk space for specified path in bytes. For example, to display available disk space for drive C:\ in Gigabytes use : {.round|{.div| {.disk free|C:\.} | 1073741824.}|2.}<br />
<br />
; dir | A : lists all the files found at path A, separated by |.<br />
: Optional parameter ''separator'' to specify a different separator.<br />
<br />
; file changed | A : returns true if file A has changed since last time checked (with this same command).<br />
: Optional second parameter will specify a variable name where to load the content of file A if the check returns true.<br />
<br />
== Virtual File System manipulation ==<br />
; add folder | A | B | C<br />
: adds a folder to the virtual file system. A specifies ''real'' or ''virtual'', while B is the name of the folder.<br />
: For real folders B should be the path on disk, but if published name is different than the real one, you can specify the path in parameter B, and the name in C.<br />
: Where in place of a simple name, you specify a virtual path, it will be used to place the folder (otherwise it will be place on the root).<br />
: Any existent folder with same name will be overwritten, unless you specify a parameter <tt>overwrite=0</tt>.<br />
: Example: <tt>{.add folder|virtual|/personal/my pictures.}</tt><br />
:: a virtual folder "my pictures" will be added under existing folder "personal".<br />
: Example: <tt>{.add folder|real|C:\music|my music|overwrite=0.}</tt><br />
:: folder on hard disk C:\music is published with public "my music". If a folder with same name is in the VFS, it's left untouched and no new folder is created.<br />
<br />
; set item | A<br />
: modifies the item A in the virtual file system by using any of these optional parameters<br />
:; hide : set to 1/0 to decide item visibility<br />
:; hide tree : set to 1/0 to decide item visibility and sub-items<br />
:; no log : set to 1/0 to decide item logging<br />
:; not as download : set 1/0, it's the same as ''don't consider as a download''. For folders, set it to ''*'' for all files, or any other file mask you want.<br />
:; comment : set the comment<br />
:; resource : Set the resource. It's the physical path for files and real folders, or the URL for links.<br />
:; archivable : Set whether the folder is archivable or not.<br />
:; browsable : Set whether or not the folder is browsable.<br />
:; download forbidden : Set whether or not to forbid downloading from this folder<br />
:; files filter : Show only certain files in the folder.<br />
:; folders filter : Show only certain folders in the folder.<br />
:; diff template : Change the diff template of a vfs item.<br />
: Example: <tt>{.set item|private files|hide=0|comment=you should never see this!.}</tt><br />
:; access / delete / upload<br />
:;: you can set permissions on the item, by specifying a list of usernames.<br />
:;: Example: <tt>set item|videos|upload=robert</tt> will give account ''robert'' the ability to upload files in ''/videos''.<br />
:;: Moreover, you can prefix permission by '''add''' or '''remove'''. In the previous example you set the ''upload'' permission. If ''mike'' already had upload permission, it is now lost. To '''add''' ''robert'' instead of just overwriting, you should <tt>{.set item|videos|add upload=robert.}</tt>. Now ''mike'' is happy too. As well, if you change your mind, and want to revoke your grant, just <tt>set item|videos|remove upload=robert</tt>.<br />
:;: You can specify more than one username this way: '''robert;mike;rupert'''.<br />
:;: Special usernames are '''@anonymous @any account @anyone'''.<br />
<br />
; get item | A | B<br />
: retrieves information B about VFS item specified by A.<br />
: Supported values for B are: ''exists, comment, resource, hide, hide tree, no log, not as download, access, upload, delete''.<br />
: Example: <tt>{.get item|/putYourFilesHere|upload.}</tt> will tell you who is allowed to upload files in that folder.<br />
<br />
; vfs select | A<br />
: A specifies what VFS item to select, but it's optional. If no parameter is provided, the currently selected item is returned.<br />
: If A is ''next'', the item coming after the current selection becomes the new selection.<br />
: If A is a named parameter ''path'', then you are specifying what item to select in the URI form.<br />
: Example: <tt>{.vfs select| path=/ .}</tt> will reset selection to the home/root, and looping through <tt>{.vfs select| next .}</tt> will select every VFS item, until <tt>{.vfs select.}</tt> is false (an empty string).<br />
<br />
; vfs to disk | A : a web path (URI) is converted to its related drive path. Relative paths like <tt>..</tt> are calculated based on the VFS folder where the script is running.<br />
<br />
== Connections control ==<br />
; disconnect | A | B : with no parameters, it disconnects current connection. If A is supplied, it is considered an [[HFS: IP masks|IP mask]], and every connection matching it (instead of the current one) will be disconnected. If also B is supplied, it will select only connections with port number same as B.<br />
<br />
; set speed limit for connection | A : set a speed limit A in KB/s for the current connection<br />
<br />
; set speed limit for address | A | B : set a speed limit B in KB/s for all connections coming from address A (no masks allowed).<br />
: When A is omitted, then it actually sets the value for the option ''Speed limit for single address'' in the GUI.<br />
<br />
; disconnection reason | A<br />
: this ''reason'' determines if a download must be aborted. Any value will abort the download, but if the value is empty the download goes on.<br />
: This macro will always return the value of the ''reason'' just before its call. So with a single call you are reading and setting the value. If no parameter is specified, then you are only reading.<br />
: Optional named parameter ''if=CONDITION'' is a shortcut for <tt>{.if|CONDITION|{:{.disconnection reason.}:}.}</tt><br />
: Example: <tt>{.disconnection reason|Try firefox|if={.{.get|agent.} != Mozilla.}.}</tt><br />
<br />
; add header | A : adds line A to the [http://en.wikipedia.org/wiki/HTTP_header HTTP header].<br />
<br />
; redirect | A : tells the browser to change to a different address (the specified one).<br />
<br />
; current downloads<br />
: expands to the number of current downloads. <br />
: Optional named parameter ''user'' will count only downloads made by specified user.<br />
: Optional named parameter ''ip'' will count only downloads made by the specified address.<br />
: Optional parameter ''file=this'' will count only downloads of this current file.<br />
: Example: <tt>{.current downloads|user=%user%|file=this.}</tt> will tell you how many connections this user is using to download this same file.<br />
<br />
; current downloads of file<br />
: number of current downloads of current file. <br />
: If an unnamed optional parameter is specified, it is used as [[HFS: IP masks|IP mask]], and only matching connections will be counted.<br />
: If the parameter is given name ''user'', only connections by such user will be counted.<br />
<br />
== Account manipulation ==<br />
; set account | A | ...<br />
: with this command you can change all attributes of the account whose username is specified in first parameter. If the username is left empty, current username is used, given this makes sense in current context.<br />
: Other parameters are the attributes you want to change, in the form <tt>set account|username|thing=value|thing2=value2</tt>.<br />
: Here is a list of such attributes<br />
:;password : set a new password<br />
:;newname : set a new username<br />
:;redirect : set the homonymous field<br />
:;no limits : set the homonymous field (true/false)<br />
:;enabled : set the homonymous field (true/false)<br />
:;is group : set the homonymous field (true/false)<br />
:;member of : set the ''member of'' field (specify more than one group separating by semicolons ";" )<br />
:;add member of : add more groups to the above<br />
:;remove member of : remove some groups to the above<br />
:;notes : set the homonymous field<br />
:;notes key <br />
:;: set the notes as it was a table with <tt>{.set table.}</tt><br />
:;: Example: <tt>{.set account|mike|notes key=last time=%timestamp%.}</tt><br />
<br />
; new account | A | ...<br />
: creates a new account with username A. After the username, you can also specify all the values available in the ''set account'' macro.<br />
<br />
;'' '' delete account | A<br />
: delete specified account (by username).<br />
<br />
; get account | A | B<br />
: expands to the value of property B of account A. <br />
: Supported value for B are ''redirect, no limits, enabled, is group, member of, notes, notes key''. Group names for ''member of'' are semicolon-separated. Special case for ''notes key'' where you should specify the key to retrieve, while the notes are treated as a table, just as for <tt>{.from table.}</tt>.<br />
: If A is omitted, current username is used, given this makes sense in current context.<br />
<br />
; member of | A<br />
: true if the current user is member of group A (specify more than one group separating by semicolons ";").<br />
: Optional parameter ''user'' to check a different user.<br />
: Example <tt>member of|administrators|user=rejetto</tt><br />
: If A is omitted, you will get the full membership for current (or specified) user. This is different from <tt>{.get account||member of.}</tt> because this latter form will consider only direct first-level membership, while <tt>{.member of.}</tt> will actually consider membership at any level.<br />
<br />
== Others ==<br />
; comment | A : this is just discarded. It's for your convenience, to put a comment in the template. HTML comments are readable by visitors if they use ''show html source'' in their browser. Using this macro you will have comments that will never leave your server.<br />
<br />
; length | A : if A is 5 characters length, like <tt>abcde</tt>, it expands to 5.<br />
: Optional parameter ''var'' in place of A, will work on the specified variable instead of considering A as text.<br />
<br />
; match | A | B : it is true if the content B is matched by [[HFS: File masks|the mask]] A.<br />
<br />
; match address | A | B : just like the macro ''match'', but the mask supports ip ranges like 10.0.0.1-10.0.0.25<br />
<br />
; random | A | B | C | ... : it expands to any of the parameters, randomly<br />
<br />
; random number | A | B : if only A is specified then a number between 0 and A is generated. If also B is specified then the number will be between A and B (included).<br />
<br />
; pos | A | B : expands to the position of A in B. Zero if not found. <br />
: Optional parameter ''from'' will start searching from specified position.<br />
: Optional parameter ''case'' will decide case sensitivity. Default is: insensitive.<br />
: Example <tt>pos|the|i'm the alpha and the omega|from=14|case=1</tt> expands to <tt>19</tt><br />
<br />
; regexp | A | B<br />
: Try to [http://en.wikipedia.org/wiki/Regular_expressions match pattern] A on text B.<br />
: When the pattern doesn't match, it just expands to nothing (then, false).<br />
: When it does, the matched sub-pattern is returned.<br />
: You can provide optional parameter ''var'' instead of B, and the text will be the content of the specified variable.<br />
: Optional parameter ''case'' will determine case sensitivity. (off by default)<br />
: Optional parameter ''sub'' will specify the name of a variable that will be set as a table, where you can retrieve every sub-pattern by numerical index.<br />
: If optional parameter ''replace=YYY'' is used, the command returns no more the matched pattern, but the whole text B with every matched pattern replaced by YYY. If you use ''replace'' and ''var'' together, the resulting text will not be returned, but stored in the specified input variable (that means, it's used both for input and output).<br />
: Example: <tt>regexp|\d+|var=weWantNumbers</tt><br />
<br />
; breadcrumbs | A<br />
: builds a [http://en.wikipedia.org/wiki/Breadcrumb_(navigation) breadcrumbs] based on the current folder path. The A is a little html template that is repeated for every piece of the path, for which 3 symbols are provided: ''%bread-url%'' , ''%bread-name%'' and ''%bread-idx%''. <br />
: Remember to use quoting, especially if you use macros in the parameter.<br />
: Optional parameter ''from'' will let you specify how many steps of the path to skip.<br />
: Example: <tt>{.breadcrumbs|{:<a href ="%bread-url%">%bread-name%/</a>:}.}</tt><br />
<br />
; dialog | A | B | C<br />
: display a server-side message in a dialog box. A is the message itself, and only required parameter. B are options separated by spaces, and C a title for the dialog.<br />
: Possible options are<br />
:;okcancel : offers buttons OK and CANCEL<br />
:;yesno : offers buttons YES and NO<br />
:;yesnocancel : offers buttons YES, NO and CANCEL<br />
:;error : this is an error reporting dialog<br />
:;question : this is a questioning dialog<br />
:;warning : this is a warning dialog<br />
:;information : this is an informational dialog<br />
<br />
; mime | A : set the mime-type sent to the browser. It describes the nature of the content. For techies, it's the value of the header field "Content-type".<br />
<br />
; any macro marker | A : it is true if any macro marker is present in A. Macro markers are {.delimiters.} , {:quotings:} and the parameters separator (the pipe, "|").<br />
<br />
; play system event | A : specify the name of the event bound to a sound that you want to play. ''SystemStart'' and ''MailBeep'' are just examples, for a full list you can open your registry at ''HKEY_CURRENT_USER\AppEvents\EventLabels'' .<br />
<br />
; exec | A : ask system to run file A, eventually with parameters. If you need to use the pipe, then use macro quoting.<br />
: Optional parameter ''out'' will let you capture the console output of the program in the variable specified by name.<br />
: Optional parameter ''timeout'' will specify the max number of seconds the app should be left running.<br />
: Example: <tt>{.exec|notepad.}</tt><br />
<br />
; add to log | A : add A to the log panel. <br />
: Optional parameter ''color'' to [[HFS: color format|specify the color]].<br />
<br />
; get ini | A<br />
: where A is a text in the same format you can find in ''hfs.ini'' (save options -> to file).<br />
: example: <tt>{.get ini|speed limit.}</tt> will return the global speed limit, if any.<br />
<br />
; set ini | A<br />
: where A is a text in the same format you can find in ''hfs.ini'' (save options -> to file).<br />
: example: <tt>{.set ini|speed limit=100.}</tt> will turn the global speed limit to 100KB/s.<br />
<br />
; focus<br />
: will bring HFS window on front of the user.<br />
<br />
; load tpl | A : for this connection only, template A will be used.<br />
: Example: <tt>{.if| it's a mobile | {:{.load tpl|mobile.tpl.}:} /if.}</tt><br />
<br />
; notify | A<br />
: The message A will come out as a balloon over the HFS tray icon.<br />
: Optional parameter ''title'' will let you specify the title of the balloon.<br />
: Optional parameter ''timeout'' specifies the amount of time to show the message.<br />
: Optional parameter ''type'' will show an icon according to its value. Allowed values are ''info, error'' and ''warning''.<br />
<br />
== Shortcuts ==<br />
;$A : is a shortcut for '''section | A'''<br />
;?A : is a shortcut for '''urlvar | A'''<br />
;^A : is a shortcut for '''call | A'''<br />
;A = B : is a shortcut for '''=|A|B'''<br />
;?name = X : is a shortcut for <tt>{.?name.} = X</tt> .<br />
: It works also for '''<> != < <= > >=''' .</div>
Rejetto
https://rejetto.com/wiki/index.php?title=HFS:_scripting_commands&diff=5666
HFS: scripting commands
2018-11-04T16:54:18Z
<p>Rejetto: /* Data manipulation */</p>
<hr />
<div>Also known as template macros, these are commands with some useful effects that users can input in HFS to improve a template or to create functionality not otherwise available. <br />
<br />
Some commands simply expand to text, to display information, and some perform server-side actions, like deleting a file.<br />
<br />
Every command is expressed as a name, and sometimes parameters, separated by pipes "<tt>|</tt>".<br />
<br />
Following, with letters we are denoting parameters, and their meaning is explained immediately after.<br />
<br />
You should read this [http://www.rejetto.com/wiki/index.php?title=HFS:_Template_macros] before reading this page.<br />
<br />
== Logic and flow ==<br />
; if | A | B | C<br />
: if A is true, then it expands to B, else it expands to C. When it expands to B, C is just discarded, and the vice versa. C is optional.<br />
: How you tell A is true? A is true if it is not empty and not just a zero. So if A is "hi there!", then it is true.<br />
: Remember to use quoting if you use macros in B or C (the body).<br />
<br />
; if not | A | B | C <br />
: same as ''if'', but the logic is inverted. When A is true it expands to C and vice versa.<br />
<br />
; not | A : true if A is not true. It negates the value of A.<br />
<br />
; and | A | B : true if both A and B are true. In details: in the ''true'' case it returns the last parameter. You can specify as many parameters as necessary. Both Javascript and Python work this way.<br />
<br />
; or | A | B : true if any of A or B are true. In details: it returns the first ''true'' parameter (yes, it supports any number of parameters). If none of the parameters is true, then iit returns false. Both Javascript and Python work this way. Often times you can work without {.or.}, for example {.if| A B | C .} returns true if either A or B are true.<br />
<br />
; xor | A | B : true if A is true while B is false, or the opposite<br />
<br />
; = | A | B : true if A is the same as B. It's case insensitive. You can use the opposite macro, true if they are different, and it's name is '''!=''' or '''<>''' (use the one you like most, there's no difference). You can specify as many parameters as you like.<br />
<br />
; > | A | B : true if A is greater than B. Of course you can also use the related macro '''<'''. You can specify as many parameters as you like.<br />
<br />
; >= | A | B : true if A is equal or greater than B. Of course you can also use the related macro '''<='''. You can specify as many parameters as you like.<br />
<br />
; between | A | B | C : true if B is between A and C (included).<br />
<br />
; between! | A | B | C : true if B is between A and C (excluded).<br />
<br />
; switch | A | B | C | D | E | F ...<br />
: this is rather complex for non-programmers. You can learn how a switch statement is supposed to work [http://en.wikipedia.org/wiki/Switch_statement#Examples from Wikipedia]. When you know how a ''switch'' works, then you will understand this schema that will make you understand how the parameters of this macro work<br />
<pre><nowiki><br />
switch(A) {<br />
case C: return D;<br />
case E: return F;<br />
...<br />
}<br />
</nowiki></pre><br />
: The B is a separator string for C. Let's be clearer: if you want to specify several cases in C, all of them returning D, then you can specify them separating with B.<br />
: As you can see C and D are paired, as E and F, eventually G and H, and so on. If at the end of this list of pairs, a single unpaired parameter is found, then it is used as the else/default case, when all other pairs have failed.<br />
: Let me translated the first example of Wikipedia using the macro<br />
<pre><nowiki><br />
{.switch|%n%|,|<br />
0|you typed zero|<br />
3,5,7|%n% is a prime number|<br />
4,6,8|%n% is an even number|<br />
2|%n% is a prime and even number|<br />
1,9|%n% is a perfect square|<br />
Only single-digit numbers are allowed<br />
.}<br />
</nowiki></pre><br />
<br />
Switch is esentially a quick way of using many {.if.} and {.=.} commands together. For example, if A equals C then D, if A equals E then F, etc.<br />
<br />
; for | A | B | C | D | E<br />
: repeats D by replacing variable <tt>{.^A.}</tt> with every value between B and C (they are meant to be numbers).<br />
: Optionally you can specify a ''step'' for the numbers: that is, instead of going 1-by-1, they can go 2-by-2. The optional ''step'' is specified at position D; in such case the ''body'' is moved from position D to position E.<br />
: Remember to use quoting for the body.<br />
<br />
; for each | A | B | C ... | Z<br />
: a (sometimes) handier version of ''for'', that will repeat Z but replacing variable <tt>{.^A.}</tt> with value B the first time, value C the second time, D etc etc. Remember to quote the body. <br />
: example: <tt>{.for each|i|10|100|1000|{:now it's {.^i.} :}.}</tt><br />
<br />
; while | A | B<br />
: repeats B for as long as A is true. Both B is automatically dequoted. If A is quoted, then it's expanded, otherwise is considered the a variable name.<br />
: Optional parameter ''else'' will be expanded if B is never done.<br />
: Optional parameter ''timeout'' let you specify (in seconds) the maximum time the loop can live before it is stopped. It's 1 second by default.<br />
: Optional parameter ''var'' saves the output in a variable instead of just expanding to it.<br />
: Example: <tt>{.while|#x|{: {.dec|#x.} welcome! :}.}</tt> will welcome 10 times if <tt>#x</tt> is 10.<br />
<br />
; after the list | A<br />
: quoted text A is dequoted and executed, but only if the file listing is completed.<br />
<br />
; dequote | A<br />
: if A is {:quoted:} then quoting markers are removed (unleashing macro execution of the previously quoted text).<br />
<br />
; 123 if 2 | A | B | C<br />
: if B is true, it expands to ABC, otherwise nothing.<br />
: It is basically a shortcut for {.if | B |{: A B C :}.}<br />
<br />
; break : stops execution of this script.<br />
: Optional parameter ''if'' will avoid breaking in case the condition is not met (that is, when it's ''false'').<br />
: Optional parameter ''result'' will output a text only if the break occurs (makes sense only with parameter ''if'').<br />
: Using <tt>{.break|if=data.}</tt> is basically a simplified way to write <tt>{.if|data|{:{.break.}:}.}</tt><br />
<br />
== Data getting ==<br />
; section | A<br />
: A is the name of the [section] you want to include. Note: till build #160 it was case sensitive.<br />
: Optional parameter ''file'' to load the section from an external file.<br />
: Optional parameter ''back=1'' will work in diff templates to access the section in the original template. So you can access it even if you overwrote it.<br />
: Example: <tt>{.section|names|file=tables.txt.}</tt><br />
; get | A<br />
: where A is the name of a value you are interested in, like to know if an option is enabled or not.<br />
: This is a list of supported values for A:<br />
:; can upload : true if in the current folder the user is allowed to upload files. An additional parameter ''path'' will tell you about a different folder instead of the current one.<br />
:; can delete : true if the user is allowed to delete the current item. An additional parameter ''path'' will tell you about a different folder instead of the current one.<br />
:; can access : true if the current item in list is accessible by the user. An additional parameter ''path'' will tell you about a different folder instead of the current one.<br />
:; can recur : true if the option ''Recursive listing'' is enabled<br />
:; can archive : true if the current item in list is archivable. outside the list it refers to the current folder.<br />
:; is new : true if the current item in list is flagged as "new"<br />
:; accounts : semicolon-separated list of username of all accounts. By specifying an additional parameter '''groups''' you'll get only groups. Respectively, a parameter '''users''' will give you only non-group accounts.<br />
:; stop spiders : true if ''stop spider'' option is enabled.<br />
:; protocolon : expands to <tt>http&#58;//</tt> unless you enabled option ''URLs starting with https'' in which case it expands to <tt>https&#58;//</tt> (please notice the final S).<br />
:; speed limit : gives the current global speed limit, as a number (in KB/s).<br />
:; agent : Tells the user's browser. E.g., Firefox expands to Mozilla and IE8 will expand to MSIE 8.0.<br />
<br />
; urlvar | A : url variable. Let's say in the url you see <tt>?sort=s</tt> and you want to know that '''s''', just use the macro ''urlvar|sort''.<br />
: Optional parameter ''var'' will put the resulting text in the specified variable.<br />
; postvar | A : just as ''urlvar'' but reads the value from the POST part of the request instead of the URL.<br />
: Optional parameter ''var'' will put the resulting text in the specified variable.<br />
; header | A : get any value from the HTTP request header. A is the name of the header field. This is something mostly for techies. Don't fret if you don't even know what the header is.<br />
; time | A : returns current time information. The format is specified by optional parameter A. Refer to [[HFS: Time format#Text formatting|this page]] for format syntax. If A is not supplied, value "c" will be used.<br />
: Optional parameter ''when'' to [[HFS: Time format#Numerical format|specify a time]] other than current.<br />
: Optional parameter ''offset'' to specify the number of days differing from the current time.<br />
<br />
; cookie | A : expands to the value A passed by the browser.<br />
: With an optional parameter ''value'' you will set a new value.<br />
: Every known standard parameter for cookies is accepted, as ''expires'' and ''path''. Expires can be expressed in many ways: if it starts with '''+''' or '''-''' will be the number of days in the future or in the past. If it's a number will be considered as unix time format or [[HFS: Time format#Numerical format|HFS format]]. You can even specify it as a date: <tt>2/4/2013</tt>.<br />
: Example: <tt>{.cookie|step.}</tt> will give you the current value<br />
: Example: <tt>{.cookie|step|value=3|expires=+30.}</tt> will set ''step'' to ''3'' and the cookie will expire in 30 days.<br />
: Setting a cookie can also be accomplished by using {.add header.} with Set-Cookie.<br />
<br />
== Data manipulation ==<br />
; substring | A | B | C : cut C from A to B, with B not included. <br />
: Example: <tt>substring|(|belong|you (are) belong to us.}</tt> will be <tt>(are)</tt>.<br />
: If A is not specified, C is taken from the start. If B is not specified, C is taken to the end.<br />
: Optional parameter ''case=1'' to turn on case sensitivity.<br />
: Optional parameter ''include'' to say if A and/or B must be included. Values: 0 (none), 1 (only A), 2 (only B), 1+2 (both).<br />
<br />
; cut | A | B | C : cut C from position A, for B characters. The difference with macro ''substring'' is that here you specify where to cut by numeric positions.<br />
: Example: <tt>cut|2|3|abcdef</tt> will expand to <tt>bcd</tt><br />
: If you don't specify A, it defaults to 1. If you don't specify B, it defaults to the length of C.<br />
: If A is negative, then you are counting backward from the end of C. If B is negative, then you are considering the length of C minus the amount of B.<br />
: Optional parameter ''to'' will let you specify the number of character to cut. B is ignored in this case.<br />
: Optional parameter ''var'' specifies the variable name to work on. You can use it instead of C, but in such case the output will be stored in the variable.<br />
: You can use named parameter ''from'' instead of A, ''size'' instead of B, and ''what'' instead of C.<br />
: Example: <tt>cut|from=3|size=2|abcdef</tt> will expand to <tt>cd</tt><br />
<br />
; repeat | A | B : repeat B for A times. Example: for A=5 and B=+ the result is +++++<br />
<br />
; upper | A : returns A with all letters uppercased. Example: for A=Hello the result is HELLO<br />
<br />
; lower | A : returns A with all letters lowercased. Example: for A=Hello the result is hello<br />
<br />
; trim | A : returns A with any leading and trailing space removed<br />
<br />
; replace | A | B | C : returns C with every A replaced with B. This command can apply multiple replacements by having multiple pairs of parameters A-B. But you always need to have a final parameter C, that's the text that will be manipulated.<br />
: Optional parameter ''var'' in place of parameter C will make use of the specified variable as both input and output.<br />
<br />
; calc | A : return the result of the mathematical expression A. Example: for 1+(5/2) the result is 3.5<br />
: supported operators are <tt>+ - * / %</tt> (as modulus)<br />
; round | A | B : returns rounded value of A, where A is a non-integer number, and B is the number of digits after the decimal point. B is zero by default if not specified.<br />
<br />
; add | A | B : returns A+B where A and B are numbers<br />
<br />
; sub | A | B : returns A-B where A and B are numbers<br />
<br />
; mul | A | B : returns A*B where A and B are numbers<br />
<br />
; div | A | B : returns A/B where A and B are numbers<br />
<br />
; mod | A | B : returns A modulus B where A and B are numbers<br />
<br />
; min | A | B ... : returns the minimum over all parameters. You can have more than 2 parameters.<br />
<br />
; max | A | B ... : returns the maximum over all parameters. You can have more than 2 parameters.<br />
<br />
; count substring | A | B : tells the number of times A is present in B (case sensitive)<br />
<br />
; encodeuri | A : all characters are encoded in the %XX form used for URLs, except alphanumerics and <tt>#/,&?:$@=+</tt><br />
;: You can add more characters to the set that will be encoded by using the optional parameter ''add'', as well as you can decide to exclude some characters by using the optional parameter ''not''.<br />
;: You can also decide to specify the whole set, one by one, with optional parameter ''only''.<br />
;: In all these optional parameters you can specify many characters just by having them as a string, one after another.<br />
<br />
; decodeuri | A : all encoded characters in the form %XX are decoded.<br />
<br />
; convert | A | B | C<br />
: converts C from charset A to charset B. At the moment only supported charsets are ''ansi'' and ''utf-8''. <br />
<br />
; force ansi | A : if template is using UTF-8 charset, then A is converted to ANSI. Otherwise A is left unchanged.<br />
<br />
; maybe utf8 | A : if template is using UTF-8 charset, then A is converted to UTF-8. Otherwise A is left unchanged.<br />
<br />
; 123 if 2 | A | B | C : returns nothing if B is false/empty, otherwise a concatenation of ABC.<br />
<br />
; chr | A | B ... : returns characters with ANSI code A, B, etc. Numbers are decimal. To use hex numbers, precede them with an "x".<br />
: Example: {.chr|13|10|x0D|x0A.}<br />
<br />
; js encode | A | B<br />
: Encodes characters specified by B using javascript encoding for strings, in text A. If you mean to encode characters ''a'' and ''b'', parameter B should simply be ''ab''.<br />
: If B is not specified, characters encoded are only single-quote and double-quotes. This is supposed to be the frequently used case, when you are passing some data into a javascript string that's enclosed in any form of quotes.<br />
<br />
== Variables and functions ==<br />
; set | A | B<br />
: what you actually do is to bind B (the content) to the name A (the variable). It is called variable because you can always change the content of it. You can later recall B by passing A to the macro "call".<br />
: You can have as many variables as you want. All of them will be bound to the single page/request. When the page is finished and provided (or anyway the execution flow is over) the variables are cleared (and lost) unless you prepend a '''#''' to the name (e.g. #myVariable). In this latter case you are using '''global variables'''. These will survive until you clear them explicitly.<br />
: If you are used to programming, you may already know what variables and functions are. Here '''functions''' are a special case of variable, when the content is made of other commands. When you specify commands for the function, you need to [[HFS: Template_macros#Quoting|quote them]], otherwise they will be executed immediately while instead you want them to be executed at call-time. You can also have parameters: the first one is '''$1''', and so on, that you can specify inside the body ''B''.<br />
: Remember to use quoting if you use macros in the body (B).<br />
: Example: <tt>{.set|x|1.}</tt> or <tt>{.set|double|{:{.mul|$1|2.}:}.}</tt><br />
: Optional parameter ''var'' will let you copy variables.<br />
: Example: <tt>{.set|y|var=x.}</tt><br />
: Optional parameter ''mode'' can be <tt>append</tt> or <tt>prepend</tt>, to concatenate existing content of the variable to the new content, as AB or BA.<br />
: Example: <tt>{.set|x| is a good boy|mode=append.}</tt><br />
<br />
; call | A | B | C | ... : this macro (shortcut by '''^''') expands to the value bound to A. Such value can be a number or a text, doesn't matter. If the value contains symbols '''$1''' and $2, then they are replaced with the parameters B and C (and so on).<br />
: Example referring to above: <tt>{.call|double|15.}</tt> will expand to <tt>30</tt><br />
: You can find some examples for "set" and "call" [http://www.rejetto.com/forum/index.php?topic=5353.msg1031074#msg1031074 on the forum].<br />
<br />
; inc | A | B : if A is a variable with numeric value, then its value is incremented by the number B. If B is omitted, it defaults to 1.<br />
<br />
; dec | A | B : just as the ''inc'' above, but the value is decremented<br />
<br />
; count | A<br />
: each call returns and increments A, so the sequence will be 0 1 2 3...<br />
: variable A is not actually a variable, you can't access it throught {.^A.} and its value can be retrieved only through another call to ''count''. <br />
<br />
; from table | A | B<br />
: A is the table and B is the key. The table is a variable or a section with this form<br />
<pre>key1=value1<br />
key2=value2<br />
key3=value3</pre><br />
: Let's say such text is the content of variable ''foo'', then to get <tt>value2</tt> you should do <tt>{.from table|foo|key2.}</tt>. (yes, poetry)<br />
: If it was the content of table [bar] instead, then you should do <tt>{.from table|$bar|key2.}</tt>.<br />
<br />
; set table | A | B<br />
: it's the counterpart of ''from table''. A is the name of the table, while B is in the form ''key=value''.<br />
: If the key already exists, it's replaced, added otherwise.<br />
: Example: <tt>set table|foo|key2=new value</tt><br />
: Loading entire database-like TXT files can be achieved by replacing A with the database path:<br />
:: <tt>{.for each|value|{.replace|;|{.no pipe||.}|{.load| A .}.}|{:{.if|{.^value.}|{:{.set table|table|{.^value.}.}:}.}:}.}</tt><br />
:: The database file must use the syntax of <tt>key1=value1;key2=value2;key3=value3;</tt><br />
<br />
; cache | A | B | C<br />
: expands to retrieved value B from cache-table A. If not found, the new value C will be set. You can quote C if you need it.<br />
: This is a very useful tool when C takes too much time and you want to be sure you will do it only once.<br />
: Example: <tt><nowiki>{.cache|#countries|%ip%|{:{.load|http://server/giveMeTheCoutry?ip=%ip% .}:}.}</nowiki></tt><br />
<br />
; var domain | A<br />
: returns a list of all variable names starting with prefix A, separated by |.<br />
: Optional parameter ''separator'' to specify a different separator.<br />
: Optional parameter ''get=values'' will return variable values instead of names.<br />
<br />
== Localization ==<br />
Here goes a macro useful for template localization.<br />
<br />
Inside the template you can use identifiers (IDs) instead of real text. So you can gather all the text in one place, and ease the work of whom wants to translate to another language.<br />
<br />
Lets say that you have a link '''<a href ='..'>Go up one level</a>'''. You can replace with '''<a href ='..'>{.!up.}</a>''', moving the text to section '''[special:strings]'''.<br />
[special:strings]<br />
up=Go up one level<br />
<br />
You can optionally provide a parameter (like ''<nowiki><br />
{.!up|Go to parent folder.}</nowiki>'') that will be the default text in case '''up''' is not found in '''[special:strings]'''.<br />
<br />
<br />
If no parameter is provided, then the ID itself will be used as default text.<br />
<br />
== File manipulation ==<br />
Consider most of these macros work only with operating system oriented paths, not the ones of the virtual file system.<br />
<br />
; load | A : you'll love this one. You can specify A as a file name, or as a URL. It will load and expand to it. The file or URL you specify must be accessible from the server machine. A can be <tt>C:\windows\win.ini</tt> or also <tt><nowiki>http://another_hfs_in_lan/the_file_i_want.txt</nowiki></tt>.<br />
: With an optional parameter ''var'' you can specify the name of a variable where the whole content of the file will be stored. In such case, the macro will not expand to the content of the file, it's just in the var.<br />
: Optional parameter ''from'' to specify an offset from where to start reading.<br />
: Optional parameter ''size'' to specify how much to read.<br />
: Optional parameter ''to'' to specify the last byte to read, as an offset from the beginning.<br />
: All parameters ''from, size'' and ''to'' are expressed as number of bytes.<br />
: Example: {.load|document.txt|var=mytext.} or <tt><nowiki>{.load|http://www.domain.tld/test.txt.}</nowiki></tt><br />
<br />
; filesize | A : tells you the size in bytes of the file A. At the moment URL are not supported, only local filenames.<br />
<br />
; save | A | B : stores B to file path A. The path can be absolute, URI based or relative to HFS folder.<br />
: You can supply an optional parameter ''var'' instead of B, and the content of the specified variable will be saved.<br />
<br />
; append | A | B : add B at the end of file A. This may is also useful to keep special logs.<br />
<br />
; delete | A : moves the file A to the recycle bin.<br />
: Optional parameter ''forced=1'' will force deletion in case the bin is not available.<br />
: Optional parameter ''bin=0'' will delete the file permanently instead of moving to the recycled bin.<br />
<br />
; rename | A | B : renames the file A to B. Files can be specified with their disk path or in the URI form.<br />
<br />
; md5 file | A : computes and expands to the MD5 hash for file A.<br />
<br />
; copy | A | B : copies file A to B, where B can be a folder or a full path+filename. A can eventually be specified in the URI form.<br />
; move | A | B : as ''copy'', but A is moved instead of duplicated.<br />
<br />
; chdir | A : changes the current [http://en.wikipedia.org/wiki/Working_directory working directory] of the HFS process.<br />
; mkdir | A : creates the specified folder. URI is supported in A, but it must refer a real folder.<br />
<br />
; exists | A : checks A for existence, may it be a file or folder.<br />
; is file | A : checks A for existence as a file.<br />
<br />
; filename | A : returns only the filename part of A, removing eventual path information.<br />
; filepath | A : returns only the path of A, removing the file name.<br />
; filetime | A : returns timestamp for file A, express in [[HFS:_Time_format#Numerical_format|the usual format]].<br />
<br />
; disk free | A : returns available disk space for specified path in bytes. For example, to display available disk space for drive C:\ in Gigabytes use : {.round|{.div| {.disk free|C:\.} | 1073741824.}|2.}<br />
<br />
; dir | A : lists all the files found at path A, separated by |.<br />
: Optional parameter ''separator'' to specify a different separator.<br />
<br />
; file changed | A : returns true if file A has changed since last time checked (with this same command).<br />
: Optional second parameter will specify a variable name where to load the content of file A if the check returns true.<br />
<br />
== Virtual File System manipulation ==<br />
; add folder | A | B | C<br />
: adds a folder to the virtual file system. A specifies ''real'' or ''virtual'', while B is the name of the folder.<br />
: For real folders B should be the path on disk, but if published name is different than the real one, you can specify the path in parameter B, and the name in C.<br />
: Where in place of a simple name, you specify a virtual path, it will be used to place the folder (otherwise it will be place on the root).<br />
: Any existent folder with same name will be overwritten, unless you specify a parameter <tt>overwrite=0</tt>.<br />
: Example: <tt>{.add folder|virtual|/personal/my pictures.}</tt><br />
:: a virtual folder "my pictures" will be added under existing folder "personal".<br />
: Example: <tt>{.add folder|real|C:\music|my music|overwrite=0.}</tt><br />
:: folder on hard disk C:\music is published with public "my music". If a folder with same name is in the VFS, it's left untouched and no new folder is created.<br />
<br />
; set item | A<br />
: modifies the item A in the virtual file system by using any of these optional parameters<br />
:; hide : set to 1/0 to decide item visibility<br />
:; hide tree : set to 1/0 to decide item visibility and sub-items<br />
:; no log : set to 1/0 to decide item logging<br />
:; not as download : set 1/0, it's the same as ''don't consider as a download''. For folders, set it to ''*'' for all files, or any other file mask you want.<br />
:; comment : set the comment<br />
:; resource : Set the resource. It's the physical path for files and real folders, or the URL for links.<br />
:; archivable : Set whether the folder is archivable or not.<br />
:; browsable : Set whether or not the folder is browsable.<br />
:; download forbidden : Set whether or not to forbid downloading from this folder<br />
:; files filter : Show only certain files in the folder.<br />
:; folders filter : Show only certain folders in the folder.<br />
:; diff template : Change the diff template of a vfs item.<br />
: Example: <tt>{.set item|private files|hide=0|comment=you should never see this!.}</tt><br />
:; access / delete / upload<br />
:;: you can set permissions on the item, by specifying a list of usernames.<br />
:;: Example: <tt>set item|videos|upload=robert</tt> will give account ''robert'' the ability to upload files in ''/videos''.<br />
:;: Moreover, you can prefix permission by '''add''' or '''remove'''. In the previous example you set the ''upload'' permission. If ''mike'' already had upload permission, it is now lost. To '''add''' ''robert'' instead of just overwriting, you should <tt>{.set item|videos|add upload=robert.}</tt>. Now ''mike'' is happy too. As well, if you change your mind, and want to revoke your grant, just <tt>set item|videos|remove upload=robert</tt>.<br />
:;: You can specify more than one username this way: '''robert;mike;rupert'''.<br />
:;: Special usernames are '''@anonymous @any account @anyone'''.<br />
<br />
; get item | A | B<br />
: retrieves information B about VFS item specified by A.<br />
: Supported values for B are: ''exists, comment, resource, hide, hide tree, no log, not as download, access, upload, delete''.<br />
: Example: <tt>{.get item|/putYourFilesHere|upload.}</tt> will tell you who is allowed to upload files in that folder.<br />
<br />
; vfs select | A<br />
: A specifies what VFS item to select, but it's optional. If no parameter is provided, the currently selected item is returned.<br />
: If A is ''next'', the item coming after the current selection becomes the new selection.<br />
: If A is a named parameter ''path'', then you are specifying what item to select in the URI form.<br />
: Example: <tt>{.vfs select| path=/ .}</tt> will reset selection to the home/root, and looping through <tt>{.vfs select| next .}</tt> will select every VFS item, until <tt>{.vfs select.}</tt> is false (an empty string).<br />
<br />
; vfs to disk | A : a web path (URI) is converted to its related drive path. Relative paths like <tt>..</tt> are calculated based on the VFS folder where the script is running.<br />
<br />
== Connections control ==<br />
; disconnect | A | B : with no parameters, it disconnects current connection. If A is supplied, it is considered an [[HFS: IP masks|IP mask]], and every connection matching it (instead of the current one) will be disconnected. If also B is supplied, it will select only connections with port number same as B.<br />
<br />
; set speed limit for connection | A : set a speed limit A in KB/s for the current connection<br />
<br />
; set speed limit for address | A | B : set a speed limit B in KB/s for all connections coming from address A (no masks allowed).<br />
: When A is omitted, then it actually sets the value for the option ''Speed limit for single address'' in the GUI.<br />
<br />
; disconnection reason | A<br />
: this ''reason'' determines if a download must be aborted. Any value will abort the download, but if the value is empty the download goes on.<br />
: This macro will always return the value of the ''reason'' just before its call. So with a single call you are reading and setting the value. If no parameter is specified, then you are only reading.<br />
: Optional named parameter ''if=CONDITION'' is a shortcut for <tt>{.if|CONDITION|{:{.disconnection reason.}:}.}</tt><br />
: Example: <tt>{.disconnection reason|Try firefox|if={.{.get|agent.} != Mozilla.}.}</tt><br />
<br />
; add header | A : adds line A to the [http://en.wikipedia.org/wiki/HTTP_header HTTP header].<br />
<br />
; redirect | A : tells the browser to change to a different address (the specified one).<br />
<br />
; current downloads<br />
: expands to the number of current downloads. <br />
: Optional named parameter ''user'' will count only downloads made by specified user.<br />
: Optional named parameter ''ip'' will count only downloads made by the specified address.<br />
: Optional parameter ''file=this'' will count only downloads of this current file.<br />
: Example: <tt>{.current downloads|user=%user%|file=this.}</tt> will tell you how many connections this user is using to download this same file.<br />
<br />
; current downloads of file<br />
: number of current downloads of current file. <br />
: If an unnamed optional parameter is specified, it is used as [[HFS: IP masks|IP mask]], and only matching connections will be counted.<br />
: If the parameter is given name ''user'', only connections by such user will be counted.<br />
<br />
== Account manipulation ==<br />
; set account | A | ...<br />
: with this command you can change all attributes of the account whose username is specified in first parameter. If the username is left empty, current username is used, given this makes sense in current context.<br />
: Other parameters are the attributes you want to change, in the form <tt>set account|username|thing=value|thing2=value2</tt>.<br />
: Here is a list of such attributes<br />
:;password : set a new password<br />
:;newname : set a new username<br />
:;redirect : set the homonymous field<br />
:;no limits : set the homonymous field (true/false)<br />
:;enabled : set the homonymous field (true/false)<br />
:;is group : set the homonymous field (true/false)<br />
:;member of : set the ''member of'' field (specify more than one group separating by semicolons ";" )<br />
:;add member of : add more groups to the above<br />
:;remove member of : remove some groups to the above<br />
:;notes : set the homonymous field<br />
:;notes key <br />
:;: set the notes as it was a table with <tt>{.set table.}</tt><br />
:;: Example: <tt>{.set account|mike|notes key=last time=%timestamp%.}</tt><br />
<br />
; new account | A | ...<br />
: creates a new account with username A. After the username, you can also specify all the values available in the ''set account'' macro.<br />
<br />
;'' '' delete account | A<br />
: delete specified account (by username).<br />
<br />
; get account | A | B<br />
: expands to the value of property B of account A. <br />
: Supported value for B are ''redirect, no limits, enabled, is group, member of, notes, notes key''. Group names for ''member of'' are semicolon-separated. Special case for ''notes key'' where you should specify the key to retrieve, while the notes are treated as a table, just as for <tt>{.from table.}</tt>.<br />
: If A is omitted, current username is used, given this makes sense in current context.<br />
<br />
; member of | A<br />
: true if the current user is member of group A (specify more than one group separating by semicolons ";").<br />
: Optional parameter ''user'' to check a different user.<br />
: Example <tt>member of|administrators|user=rejetto</tt><br />
: If A is omitted, you will get the full membership for current (or specified) user. This is different from <tt>{.get account||member of.}</tt> because this latter form will consider only direct first-level membership, while <tt>{.member of.}</tt> will actually consider membership at any level.<br />
<br />
== Others ==<br />
; comment | A : this is just discarded. It's for your convenience, to put a comment in the template. HTML comments are readable by visitors if they use ''show html source'' in their browser. Using this macro you will have comments that will never leave your server.<br />
<br />
; length | A : if A is 5 characters length, like <tt>abcde</tt>, it expands to 5.<br />
: Optional parameter ''var'' in place of A, will work on the specified variable instead of considering A as text.<br />
<br />
; match | A | B : it is true if the content B is matched by [[HFS: File masks|the mask]] A.<br />
<br />
; match address | A | B : just like the macro ''match'', but the mask supports ip ranges like 10.0.0.1-10.0.0.25<br />
<br />
; random | A | B | C | ... : it expands to any of the parameters, randomly<br />
<br />
; random number | A | B : if only A is specified then a number between 0 and A is generated. If also B is specified then the number will be between A and B (included).<br />
<br />
; pos | A | B : expands to the position of A in B. Zero if not found. <br />
: Optional parameter ''from'' will start searching from specified position.<br />
: Optional parameter ''case'' will decide case sensitivity. Default is: insensitive.<br />
: Example <tt>pos|the|i'm the alpha and the omega|from=14|case=1</tt> expands to <tt>19</tt><br />
<br />
; regexp | A | B<br />
: Try to [http://en.wikipedia.org/wiki/Regular_expressions match pattern] A on text B.<br />
: When the pattern doesn't match, it just expands to nothing (then, false).<br />
: When it does, the matched sub-pattern is returned.<br />
: You can provide optional parameter ''var'' instead of B, and the text will be the content of the specified variable.<br />
: Optional parameter ''case'' will determine case sensitivity. (off by default)<br />
: Optional parameter ''sub'' will specify the name of a variable that will be set as a table, where you can retrieve every sub-pattern by numerical index.<br />
: If optional parameter ''replace=YYY'' is used, the command returns no more the matched pattern, but the whole text B with every matched pattern replaced by YYY. If you use ''replace'' and ''var'' together, the resulting text will not be returned, but stored in the specified input variable (that means, it's used both for input and output).<br />
: Example: <tt>regexp|\d+|var=weWantNumbers</tt><br />
<br />
; breadcrumbs | A<br />
: builds a [http://en.wikipedia.org/wiki/Breadcrumb_(navigation) breadcrumbs] based on the current folder path. The A is a little html template that is repeated for every piece of the path, for which 3 symbols are provided: ''%bread-url%'' , ''%bread-name%'' and ''%bread-idx%''. <br />
: Remember to use quoting, especially if you use macros in the parameter.<br />
: Optional parameter ''from'' will let you specify how many steps of the path to skip.<br />
: Example: <tt>{.breadcrumbs|{:<a href ="%bread-url%">%bread-name%/</a>:}.}</tt><br />
<br />
; dialog | A | B | C<br />
: display a server-side message in a dialog box. A is the message itself, and only required parameter. B are options separated by spaces, and C a title for the dialog.<br />
: Possible options are<br />
:;okcancel : offers buttons OK and CANCEL<br />
:;yesno : offers buttons YES and NO<br />
:;yesnocancel : offers buttons YES, NO and CANCEL<br />
:;error : this is an error reporting dialog<br />
:;question : this is a questioning dialog<br />
:;warning : this is a warning dialog<br />
:;information : this is an informational dialog<br />
<br />
; mime | A : set the mime-type sent to the browser. It describes the nature of the content. For techies, it's the value of the header field "Content-type".<br />
<br />
; any macro marker | A : it is true if any macro marker is present in A. Macro markers are {.delimiters.} , {:quotings:} and the parameters separator (the pipe, "|").<br />
<br />
; play system event | A : specify the name of the event bound to a sound that you want to play. ''SystemStart'' and ''MailBeep'' are just examples, for a full list you can open your registry at ''HKEY_CURRENT_USER\AppEvents\EventLabels'' .<br />
<br />
; exec | A : ask system to run file A, eventually with parameters. If you need to use the pipe, then use macro quoting.<br />
: Optional parameter ''out'' will let you capture the console output of the program in the variable specified by name.<br />
: Optional parameter ''timeout'' will specify the max number of seconds the app should be left running.<br />
: Example: <tt>{.exec|notepad.}</tt><br />
<br />
; add to log | A : add A to the log panel. <br />
: Optional parameter ''color'' to [[HFS: color format|specify the color]].<br />
<br />
; get ini | A<br />
: where A is a text in the same format you can find in ''hfs.ini'' (save options -> to file).<br />
: example: <tt>{.get ini|speed limit.}</tt> will return the global speed limit, if any.<br />
<br />
; set ini | A<br />
: where A is a text in the same format you can find in ''hfs.ini'' (save options -> to file).<br />
: example: <tt>{.set ini|speed limit=100.}</tt> will turn the global speed limit to 100KB/s.<br />
<br />
; focus<br />
: will bring HFS window on front of the user.<br />
<br />
; load tpl | A : for this connection only, template A will be used.<br />
: Example: <tt>{.if| it's a mobile | {:{.load tpl|mobile.tpl.}:} /if.}</tt><br />
<br />
; notify | A<br />
: The message A will come out as a balloon over the HFS tray icon.<br />
: Optional parameter ''title'' will let you specify the title of the balloon.<br />
: Optional parameter ''timeout'' specifies the amount of time to show the message.<br />
: Optional parameter ''type'' will show an icon according to its value. Allowed values are ''info, error'' and ''warning''.<br />
<br />
== Shortcuts ==<br />
;$A : is a shortcut for '''section | A'''<br />
;?A : is a shortcut for '''urlvar | A'''<br />
;^A : is a shortcut for '''call | A'''<br />
;A = B : is a shortcut for '''=|A|B'''<br />
;?name = X : is a shortcut for <tt>{.?name.} = X</tt> .<br />
: It works also for '''<> != < <= > >=''' .</div>
Rejetto
https://rejetto.com/wiki/index.php?title=User:Rejetto&diff=5641
User:Rejetto
2018-09-23T17:51:04Z
<p>Rejetto: </p>
<hr />
<div>[[Image:Capelli.jpg|It's me, in there.]]<br />
<br />
<br />
== to read ==<br />
; http://www.rejetto.com/wiki/index.php?title=HTML_Template_Editor<br />
: This page is more a draft (sorry!). It all needs checking but i've sprinkled ???s around the biggest problems.<br />
; http://www.rejetto.com/wiki/index.php?title=Wiki_Construction_Notes<br />
: Includes a question for you<br />
; http://www.rejetto.com/wiki/index.php?title=First_time_configuration<br />
; http://www.rejetto.com/wiki/index.php?title=Domain_Name_System<br />
; http://www.rejetto.com/wiki/index.php?title=HFS:_Glossary<br />
; http://www.rejetto.com/wiki/index.php?title=Wiki_Construction_Notes#Big_PHnote</div>
Rejetto
https://rejetto.com/wiki/index.php?title=User_talk:90.42.82.178&diff=5640
User talk:90.42.82.178
2018-09-22T17:51:41Z
<p>Rejetto: Created page with "you translated the english page without making a copy of it. I had to restore the english version. --~~~~"</p>
<hr />
<div>you translated the english page without making a copy of it. I had to restore the english version. --[[User:Rejetto|Rejetto]] ([[User talk:Rejetto|talk]]) 17:51, 22 September 2018 (UTC)</div>
Rejetto
https://rejetto.com/wiki/index.php?title=HFS:_Introduction&diff=5639
HFS: Introduction
2018-09-22T17:50:04Z
<p>Rejetto: Reverted edits by 90.42.82.178 (talk) to last revision by Raybob95</p>
<hr />
<div>== What is it? ==<br />
<br />
HFS (Http File Server) is file sharing software which allows you to send and receive files over HTTP. You can limit this sharing to just a few friends, or be open to the whole world. <br />
<br />
HFS is different from classic file sharing because there is no network. HFS is a web server which uses web technology to be more compatible with today's Internet.<br />
<br />
Since it is actually a web server, your friends can download files as if they were downloading from a website using a web browser, such as Internet Explorer or Firefox. Your users don't have to install any new software.<br />
<br />
HFS is designed to let you easily share files.<br />
Most web servers are used to publish a website. While HFS is fully capable of this, it is not designed to do so. You are free to use HFS in any way you wish, but at your own risk.<br />
<br />
== Installation ==<br />
<br />
HFS needs no installation. Just put the "hfs.exe" file in a folder of your choice (perhaps named HFS), and run it. <br />
<br />
The first time it runs, you are prompted to see if you wish to integrate it into the context menu. If you pick "yes", then in Window's Explorer you can simply right-click on a file to add it to HFS (and make it downloadable).<br />
(This option can also be accessed after installation in ''Menu&rarr;Other options&rarr;Shell context menu''.)<br />
<br />
== Basic instructions==<br />
HFS really is very easy to use.<br />
<br />
* Run "HFS.exe".<br />
* In the window (left-pane), drag&drop all the elements to share.<br />
* Communicate to your friends the address of the items to download. <br />
<br />
After you drag&drop the files, the address (ie. the URL) is automatically copied to your Windows clipboard. If you then use, say, a chat window, just PASTE to send the address. <br />
<br />
Alternatively, if you chose to enable the context menu, just right-click on the file/folder to share, and select "Add to HFS". HFS then automatically runs, shares the item, and copies the URL to your clipboard, ready to be pasted.<br />
<br />
Notice that at first, "You are in Easy mode". It is recommended that you stay in this mode until you have used HFS a few times. Simply click the message to change to Expert mode.<br />
<br />
See [[First time configuration]] for more detailed setup information.<br />
<br />
== Uninstallation ==<br />
<br />
Use the Uninstall command from the HFS Main menu.</div>
Rejetto
https://rejetto.com/wiki/index.php?title=Main_Page&diff=5627
Main Page
2018-08-18T15:15:11Z
<p>Rejetto: </p>
<hr />
<div>Earth globe image appearing in the HFS logo is used with permission of Planetary Visions Limited.<br />
<br />
== Hosted wikiprojects ==<br />
<br />
<big><br />
* [[HFS Documentation (English)]]<br />
* [[HFS Documentation (Português-Brazil)]]<br />
* [[HFS Documentation (Français)]]<br />
* [[HFS Documentazione (Italiano)]]<br />
* [[HFS Documentación (Español)]]<br />
* [[HFS Frequently Asked Questions (English)]]<br />
* [[ICQv7 protocol resources]]<br />
* [[Wiki Construction Notes]]<br />
</big></div>
Rejetto
https://rejetto.com/wiki/index.php?title=HFS:_Event_scripts&diff=5612
HFS: Event scripts
2015-07-30T12:20:25Z
<p>Rejetto: /* Network events */</p>
<hr />
<div>'''Warning:''' this feature requires version 2.3 or above.<br />
<br />
Event scripts are scripts that run when something happens: an event.<br />
<br />
The syntax is very similar to [[HFS: Template macros|the one used in templates]]. The name of the event is on a line, surrounded by [square brakets]. The script commands follows.<br />
<br />
Example:<br />
<pre><br />
[upload completed]<br />
{.move|%item-resource%|C:\another_folder\%item-name%.}<br />
</pre><br />
<br />
Would you need to not overwrite an existing event script, you can prefix the event name with a "+" sign. Example: <tt>[+upload completed]</tt>.<br />
<br />
You can read more [http://www.rejetto.com/forum/?topic=6154 on the forum].<br />
<br />
== Events list == <br />
=== Network events ===<br />
; server start : HFS was switched on, to accept connections.<br />
; server stop : HFS was switched off, connections are accepted no more.<br />
; request : an HTTP request has been made, this includes browsing, icons, archives, and normal downloads.<br />
; request completed : the request was fulfilled.<br />
; pre-filter-request : some actions may need to be taken before requests are filtered by some limiting option. In case, you should use this event.<br />
; unauthorized : this user has no permission to access the requested resource.<br />
; connected : a new connection was established by a client.<br />
; disconnected : a connection is ended.<br />
; download : a download was requested.<br />
; download completed : a download has just finished.<br />
; upload completed : a file has been uploaded. Since version 2.3f any text resulting from this event will be considered as "reason for refusal", it will be displayed to the user and the file will be deleted. E.g <br />
<pre><br />
[upload completed]<br />
{.if|{.%item-size-kb% > 500.}|Sorry, limit of 500KB.}<br />
</pre><br />
<br />
; upload failed : a file has failed to be uploaded.<br />
<br />
=== Naming events ===<br />
You can use these events to change the name that will be given to the file that is about to be uploaded or downloaded: ''upload name, archive name, download name''.<br />
The resulting text of these events will be used as new name for the worked file.<br />
<br />
For event ''archive name'' the symbol %stream-size% is provided so that you can use it for actions depending the size of the generated archive.<br />
<br />
=== Other events ===<br />
; start : HFS was started.<br />
; quit : HFS is quitting.<br />
; file deleted : a file was remotely deleted. Use <tt>%item-deleted%</tt> ll path to it.<br />
; on macro rename : a <tt>{.rename.}</tt> was successful. Use <tt>%old-name%</tt> and <tt>%new-name%</tt> to know the full path of them. <br />
: If you do a <tt>{.rename.}</tt> inside this event, by default, it won't fire the event again. If you want it to do it, you must use named parameter <tt>{.rename|recursive=1.}</tt>.<br />
;pre-filter-request : not yet documented<br />
<br />
=== Timed events ===<br />
You can ask HFS to run a script at a certain time, or interval.<br />
<br />
To run a script at 1PM o'clock, you can make an event [at 13:00].<br />
<br />
To run every 15 minutes instead you should make an event [every 15 minutes].<br />
<br />
You can read more [http://www.rejetto.com/forum/index.php?topic=6588.msg1042304#msg1042304 on the forum].</div>
Rejetto
https://rejetto.com/wiki/index.php?title=HFS:_Event_scripts&diff=5611
HFS: Event scripts
2015-07-30T12:19:51Z
<p>Rejetto: /* Network events */ upload completed</p>
<hr />
<div>'''Warning:''' this feature requires version 2.3 or above.<br />
<br />
Event scripts are scripts that run when something happens: an event.<br />
<br />
The syntax is very similar to [[HFS: Template macros|the one used in templates]]. The name of the event is on a line, surrounded by [square brakets]. The script commands follows.<br />
<br />
Example:<br />
<pre><br />
[upload completed]<br />
{.move|%item-resource%|C:\another_folder\%item-name%.}<br />
</pre><br />
<br />
Would you need to not overwrite an existing event script, you can prefix the event name with a "+" sign. Example: <tt>[+upload completed]</tt>.<br />
<br />
You can read more [http://www.rejetto.com/forum/?topic=6154 on the forum].<br />
<br />
== Events list == <br />
=== Network events ===<br />
; server start : HFS was switched on, to accept connections.<br />
; server stop : HFS was switched off, connections are accepted no more.<br />
; request : an HTTP request has been made, this includes browsing, icons, archives, and normal downloads.<br />
; request completed : the request was fulfilled.<br />
; pre-filter-request : some actions may need to be taken before requests are filtered by some limiting option. In case, you should use this event.<br />
; unauthorized : this user has no permission to access the requested resource.<br />
; connected : a new connection was established by a client.<br />
; disconnected : a connection is ended.<br />
; download : a download was requested.<br />
; download completed : a download has just finished.<br />
; upload completed : a file has been uploaded. Any text resulting from this event will be considered as "reason for refusal", it will be displayed to the user and the file will be deleted. E.g <br />
<pre><br />
[upload completed]<br />
{.if|{.%item-size-kb% > 500.}|Sorry, limit of 500KB.}<br />
</pre><br />
<br />
; upload failed : a file has failed to be uploaded.<br />
<br />
=== Naming events ===<br />
You can use these events to change the name that will be given to the file that is about to be uploaded or downloaded: ''upload name, archive name, download name''.<br />
The resulting text of these events will be used as new name for the worked file.<br />
<br />
For event ''archive name'' the symbol %stream-size% is provided so that you can use it for actions depending the size of the generated archive.<br />
<br />
=== Other events ===<br />
; start : HFS was started.<br />
; quit : HFS is quitting.<br />
; file deleted : a file was remotely deleted. Use <tt>%item-deleted%</tt> ll path to it.<br />
; on macro rename : a <tt>{.rename.}</tt> was successful. Use <tt>%old-name%</tt> and <tt>%new-name%</tt> to know the full path of them. <br />
: If you do a <tt>{.rename.}</tt> inside this event, by default, it won't fire the event again. If you want it to do it, you must use named parameter <tt>{.rename|recursive=1.}</tt>.<br />
;pre-filter-request : not yet documented<br />
<br />
=== Timed events ===<br />
You can ask HFS to run a script at a certain time, or interval.<br />
<br />
To run a script at 1PM o'clock, you can make an event [at 13:00].<br />
<br />
To run every 15 minutes instead you should make an event [every 15 minutes].<br />
<br />
You can read more [http://www.rejetto.com/forum/index.php?topic=6588.msg1042304#msg1042304 on the forum].</div>
Rejetto
https://rejetto.com/wiki/index.php?title=HFS:_scripting_commands&diff=5610
HFS: scripting commands
2015-05-17T13:18:25Z
<p>Rejetto: /* Variables and functions */ global variables</p>
<hr />
<div>Also known as template macros, these are commands with some useful effects that users can input in HFS to improve a template or to create functionality not otherwise available. <br />
<br />
Some macros simply expand to text and some perform server-side commands.<br />
<br />
Every command is expressed as a name, and sometimes parameters, separated by pipes "<tt>|</tt>".<br />
<br />
Following, with letters we are denoting parameters, and their meaning is explained immediately after.<br />
<br />
You should read this [http://www.rejetto.com/wiki/index.php?title=HFS:_Template_macros] before reading this page.<br />
<br />
== Logic and flow ==<br />
; if | A | B | C<br />
: if A is true, then it expands to B, else it expands to C. When it expands to B, C is just discarded, and the vice versa. C is optional.<br />
: How you tell A is true? A is true if it is not empty and not just a zero. So if A is "hi there!", then it is true.<br />
: Remember to use quoting if you use macros in B or C (the body).<br />
<br />
; if not | A | B | C <br />
: same as ''if'', but the logic is inverted. When A is true it expands to C and vice versa.<br />
<br />
; not | A : true if A is not true. It negates the value of A.<br />
<br />
; and | A | B : true if both A and B are true. In details: in the ''true'' case it returns the last parameter. You can specify as many parameters as necessary. Both Javascript and Python work this way.<br />
<br />
; or | A | B : true if any of A or B are true. In details: it returns the first ''true'' parameter (yes, it supports any number of parameters). If none of the parameters is true, then iit returns false. Both Javascript and Python work this way. Often times you can work without {.or.}, for example {.if| A B | C .} returns true if either A or B are true.<br />
<br />
; xor | A | B : true if A is true while B is false, or the opposite<br />
<br />
; = | A | B : true if A is the same as B. It's case insensitive. You can use the opposite macro, true if they are different, and it's name is '''!=''' or '''<>''' (use the one you like most, there's no difference). You can specify as many parameters as you like.<br />
<br />
; > | A | B : true if A is greater than B. Of course you can also use the related macro '''<'''. You can specify as many parameters as you like.<br />
<br />
; >= | A | B : true if A is equal or greater than B. Of course you can also use the related macro '''<='''. You can specify as many parameters as you like.<br />
<br />
; between | A | B | C : true if B is between A and C (included).<br />
<br />
; between! | A | B | C : true if B is between A and C (excluded).<br />
<br />
; switch | A | B | C | D | E | F ...<br />
: this is rather complex for non-programmers. You can learn how a switch statement is supposed to work [http://en.wikipedia.org/wiki/Switch_statement#Examples from Wikipedia]. When you know how a ''switch'' works, then you will understand this schema that will make you understand how the parameters of this macro work<br />
<pre><nowiki><br />
switch(A) {<br />
case C: return D;<br />
case E: return F;<br />
...<br />
}<br />
</nowiki></pre><br />
: The B is a separator string for C. Let's be clearer: if you want to specify several cases in C, all of them returning D, then you can specify them separating with B.<br />
: As you can see C and D are paired, as E and F, eventually G and H, and so on. If at the end of this list of pairs, a single unpaired parameter is found, then it is used as the else/default case, when all other pairs have failed.<br />
: Let me translated the first example of Wikipedia using the macro<br />
<pre><nowiki><br />
{.switch|%n%|,|<br />
0|you typed zero|<br />
3,5,7|%n% is a prime number|<br />
4,6,8|%n% is an even number|<br />
2|%n% is a prime and even number|<br />
1,9|%n% is a perfect square|<br />
Only single-digit numbers are allowed<br />
.}<br />
</nowiki></pre><br />
<br />
Switch is esentially a quick way of using many {.if.} and {.=.} commands together. For example, if A equals C then D, if A equals E then F, etc.<br />
<br />
; for | A | B | C | D | E<br />
: repeats D by replacing variable <tt>{.^A.}</tt> with every value between B and C (they are meant to be numbers).<br />
: Optionally you can specify a ''step'' for the numbers: that is, instead of going 1-by-1, they can go 2-by-2. The optional ''step'' is specified at position D; in such case the ''body'' is moved from position D to position E.<br />
: Remember to use quoting for the body.<br />
<br />
; for each | A | B | C ... | Z<br />
: a (sometimes) handier version of ''for'', that will repeat Z but replacing variable <tt>{.^A.}</tt> with value B the first time, value C the second time, D etc etc. Remember to quote the body. <br />
: example: <tt>{.for each|i|10|100|1000|{:now it's {.^i.} :}.}</tt><br />
<br />
; while | A | B<br />
: repeats B for as long as A is true. Both B is automatically dequoted. If A is quoted, then it's expanded, otherwise is considered the a variable name.<br />
: Optional parameter ''else'' will be expanded if B is never done.<br />
: Optional parameter ''timeout'' let you specify (in seconds) the maximum time the loop can live before it is stopped. It's 1 second by default.<br />
: Optional parameter ''var'' saves the output in a variable instead of just expanding to it.<br />
: Example: <tt>{.while|#x|{: {.dec|#x.} welcome! :}.}</tt> will welcome 10 times if <tt>#x</tt> is 10.<br />
<br />
; after the list | A<br />
: quoted text A is dequoted and executed, but only if the file listing is completed.<br />
<br />
; dequote | A<br />
: if A is {:quoted:} then quoting markers are removed (unleashing macro execution of the previously quoted text).<br />
<br />
; 123 if 2 | A | B | C<br />
: if B is true, it expands to ABC, otherwise nothing.<br />
: It is basically a shortcut for {.if | B |{: A B C :}.}<br />
<br />
; break : stops execution of this script.<br />
: Optional parameter ''if'' will avoid breaking in case the condition is not met (that is, when it's ''false'').<br />
: Optional parameter ''result'' will output a text only if the break occurs (makes sense only with parameter ''if'').<br />
: Using <tt>{.break|if=data.}</tt> is basically a simplified way to write <tt>{.if|data|{:{.break.}:}.}</tt><br />
<br />
== Data getting ==<br />
; section | A<br />
: A is the name of the [section] you want to include. Note: till build #160 it was case sensitive.<br />
: Optional parameter ''file'' to load the section from an external file.<br />
: Optional parameter ''back=1'' will work in diff templates to access the section in the original template. So you can access it even if you overwrote it.<br />
: Example: <tt>{.section|names|file=tables.txt.}</tt><br />
; get | A<br />
: where A is the name of a value you are interested in, like to know if an option is enabled or not.<br />
: This is a list of supported values for A:<br />
:; can upload : true if in the current folder the user is allowed to upload files. An additional parameter ''path'' will tell you about a different folder instead of the current one.<br />
:; can delete : true if the user is allowed to delete the current item. An additional parameter ''path'' will tell you about a different folder instead of the current one.<br />
:; can access : true if the current item in list is accessible by the user. An additional parameter ''path'' will tell you about a different folder instead of the current one.<br />
:; can recur : true if the option ''Recursive listing'' is enabled<br />
:; can archive : true if the current item in list is archivable. outside the list it refers to the current folder.<br />
:; is new : true if the current item in list is flagged as "new"<br />
:; accounts : semicolon-separated list of username of all accounts. By specifying an additional parameter '''groups''' you'll get only groups. Respectively, a parameter '''users''' will give you only non-group accounts.<br />
:; stop spiders : true if ''stop spider'' option is enabled.<br />
:; protocolon : expands to <tt>http&#58;//</tt> unless you enabled option ''URLs starting with https'' in which case it expands to <tt>https&#58;//</tt> (please notice the final S).<br />
:; speed limit : gives the current global speed limit, as a number (in KB/s).<br />
:; agent : Tells the user's browser. E.g., Firefox expands to Mozilla and IE8 will expand to MSIE 8.0.<br />
<br />
; urlvar | A : url variable. Let's say in the url you see <tt>?sort=s</tt> and you want to know that '''s''', just use the macro ''urlvar|sort''.<br />
: Optional parameter ''var'' will put the resulting text in the specified variable.<br />
; postvar | A : just as ''urlvar'' but reads the value from the POST part of the request instead of the URL.<br />
: Optional parameter ''var'' will put the resulting text in the specified variable.<br />
; header | A : get any value from the HTTP request header. A is the name of the header field. This is something mostly for techies. Don't fret if you don't even know what the header is.<br />
; time | A : returns current time information. The format is specified by optional parameter A. Refer to [[HFS: Time format#Text formatting|this page]] for format syntax. If A is not supplied, value "c" will be used.<br />
: Optional parameter ''when'' to [[HFS: Time format#Numerical format|specify a time]] other than current.<br />
: Optional parameter ''offset'' to specify the number of days differing from the current time.<br />
<br />
; cookie | A : expands to the value A passed by the browser.<br />
: With an optional parameter ''value'' you will set a new value.<br />
: Every known standard parameter for cookies is accepted, as ''expires'' and ''path''. Expires can be expressed in many ways: if it starts with '''+''' or '''-''' will be the number of days in the future or in the past. If it's a number will be considered as unix time format or [[HFS: Time format#Numerical format|HFS format]]. You can even specify it as a date: <tt>2/4/2013</tt>.<br />
: Example: <tt>{.cookie|step.}</tt> will give you the current value<br />
: Example: <tt>{.cookie|step|value=3|expires=+30.}</tt> will set ''step'' to ''3'' and the cookie will expire in 30 days.<br />
: Setting a cookie can also be accomplished by using {.add header.} with Set-Cookie.<br />
<br />
== Data manipulation ==<br />
; substring | A | B | C : cut C from A to B, with B not included. <br />
: Example: <tt>substring|(|belong|you (are) belong to us.}</tt> will be <tt>(are)</tt>.<br />
: If A is not specified, C is taken from the start. If B is not specified, C is taken to the end.<br />
: Optional parameter ''case=1'' to turn on case sensitivity.<br />
: Optional parameter ''include'' to say if A and/or B must be included. Values: 0 (none), 1 (only A), 2 (only B), 1+2 (both).<br />
<br />
; cut | A | B | C : cut C from position A, for B characters. The difference with macro ''substring'' is that here you specify where to cut by numeric positions.<br />
: Example: <tt>cut|2|3|abcdef</tt> will expand to <tt>bcd</tt><br />
: If you don't specify A, it defaults to 1. If you don't specify B, it defaults to the length of C.<br />
: If A is negative, then you are counting backward from the end of C. If B is negative, then you are considering the length of C minus the amount of B.<br />
: Optional parameter ''to'' will let you specify the number of character to cut. B is ignored in this case.<br />
: Optional parameter ''var'' specifies the variable name to work on. Use it instead of C.<br />
: You can use named parameter ''from'' instead of A, ''size'' instead of B, and ''what'' instead of C.<br />
: Example: <tt>cut|from=3|size=2|abcdef</tt> will expand to <tt>cd</tt><br />
<br />
; repeat | A | B : repeat B for A times. Example: for A=5 and B=+ the result is +++++<br />
<br />
; upper | A : returns A with all letters uppercased. Example: for A=Hello the result is HELLO<br />
<br />
; lower | A : returns A with all letters lowercased. Example: for A=Hello the result is hello<br />
<br />
; trim | A : returns A with any leading and trailing space removed<br />
<br />
; replace | A | B | C : returns C with every A replaced with B. This command can apply multiple replacements by having multiple pairs of parameters A-B. But you always need to have a final parameter C, that's the text that will be manipulated.<br />
: Optional parameter ''var'' in place of parameter C will make use of the specified variable as both input and output.<br />
<br />
; calc | A : return the result of the mathematical expression A. Example: for 1+(5/2) the result is 3.5<br />
: supported operators are <tt>+ - * / %</tt> (as modulus)<br />
; round | A | B : returns rounded value of A, where A is a non-integer number, and B is the number of digits after the decimal point. B is zero by default if not specified.<br />
<br />
; add | A | B : returns A+B where A and B are numbers<br />
<br />
; sub | A | B : returns A-B where A and B are numbers<br />
<br />
; mul | A | B : returns A*B where A and B are numbers<br />
<br />
; div | A | B : returns A/B where A and B are numbers<br />
<br />
; mod | A | B : returns A modulus B where A and B are numbers<br />
<br />
; min | A | B ... : returns the minimum over all parameters. You can have more than 2 parameters.<br />
<br />
; max | A | B ... : returns the maximum over all parameters. You can have more than 2 parameters.<br />
<br />
; count substring | A | B : tells the number of times A is present in B (case sensitive)<br />
<br />
; encodeuri | A : all characters are encoded in the %XX form used for URLs, except alphanumerics and <tt>#/,&?:$@=+</tt><br />
;: You can add more characters to the set that will be encoded by using the optional parameter ''add'', as well as you can decide to exclude some characters by using the optional parameter ''not''.<br />
;: You can also decide to specify the whole set, one by one, with optional parameter ''only''.<br />
;: In all these optional parameters you can specify many characters just by having them as a string, one after another.<br />
<br />
; decodeuri | A : all encoded characters in the form %XX are decoded.<br />
<br />
; convert | A | B | C<br />
: converts C from charset A to charset B. At the moment only supported charsets are ''ansi'' and ''utf-8''. <br />
<br />
; force ansi | A : if template is using UTF-8 charset, then A is converted to ANSI. Otherwise A is left unchanged.<br />
<br />
; maybe utf8 | A : if template is using UTF-8 charset, then A is converted to UTF-8. Otherwise A is left unchanged.<br />
<br />
; 123 if 2 | A | B | C : returns nothing if B is false/empty, otherwise a concatenation of ABC.<br />
<br />
; chr | A | B ... : returns characters with ANSI code A, B, etc. Numbers are decimal. To use hex numbers, precede them with an "x".<br />
: Example: {.chr|13|10|x0D|x0A.}<br />
<br />
; js encode | A | B<br />
: Encodes characters specified by B using javascript encoding for strings, in text A. If you mean to encode characters ''a'' and ''b'', parameter B should simply be ''ab''.<br />
: If B is not specified, characters encoded are only single-quote and double-quotes. This is supposed to be the frequently used case, when you are passing some data into a javascript string that's enclosed in any form of quotes.<br />
<br />
== Variables and functions ==<br />
; set | A | B<br />
: what you actually do is to bind B (the content) to the name A (the variable). It is called variable because you can always change the content of it. You can later recall B by passing A to the macro "call".<br />
: You can have as many variables as you want. All of them will be bound to the single page/request. When the page is finished and provided (or anyway the execution flow is over) the variables are cleared (and lost) unless you prepend a '''#''' to the name (e.g. #myVariable). In this latter case you are using '''global variables'''. These will survive until you clear them explicitly.<br />
: If you are used to programming, you may already know what variables and functions are. Here '''functions''' are a special case of variable, when the content is made of other commands. When you specify commands for the function, you need to [[HFS: Template_macros#Quoting|quote them]], otherwise they will be executed immediately while instead you want them to be executed at call-time. You can also have parameters: the first one is '''$1''', and so on, that you can specify inside the body ''B''.<br />
: Remember to use quoting if you use macros in the body (B).<br />
: Example: <tt>{.set|x|1.}</tt> or <tt>{.set|double|{:{.mul|$1|2.}:}.}</tt><br />
: Optional parameter ''var'' will let you copy variables.<br />
: Example: <tt>{.set|y|var=x.}</tt><br />
: Optional parameter ''mode'' can be <tt>append</tt> or <tt>prepend</tt>, to concatenate existing content of the variable to the new content, as AB or BA.<br />
: Example: <tt>{.set|x| is a good boy|mode=append.}</tt><br />
<br />
; call | A | B | C | ... : this macro (shortcut by '''^''') expands to the value bound to A. Such value can be a number or a text, doesn't matter. If the value contains symbols '''$1''' and $2, then they are replaced with the parameters B and C (and so on).<br />
: Example referring to above: <tt>{.call|double|15.}</tt> will expand to <tt>30</tt><br />
: You can find some examples for "set" and "call" [http://www.rejetto.com/forum/index.php?topic=5353.msg1031074#msg1031074 on the forum].<br />
<br />
; inc | A | B : if A is a variable with numeric value, then its value is incremented by the number B. If B is omitted, it defaults to 1.<br />
<br />
; dec | A | B : just as the ''inc'' above, but the value is decremented<br />
<br />
; count | A<br />
: each call returns and increments A, so the sequence will be 0 1 2 3...<br />
: variable A is not actually a variable, you can't access it throught {.^A.} and its value can be retrieved only through another call to ''count''. <br />
<br />
; from table | A | B<br />
: A is the table and B is the key. The table is a variable or a section with this form<br />
<pre>key1=value1<br />
key2=value2<br />
key3=value3</pre><br />
: Let's say such text is the content of variable ''foo'', then to get <tt>value2</tt> you should do <tt>{.from table|foo|key2.}</tt>. (yes, poetry)<br />
: If it was the content of table [bar] instead, then you should do <tt>{.from table|$bar|key2.}</tt>.<br />
<br />
; set table | A | B<br />
: it's the counterpart of ''from table''. A is the name of the table, while B is in the form ''key=value''.<br />
: If the key already exists, it's replaced, added otherwise.<br />
: Example: <tt>set table|foo|key2=new value</tt><br />
: Loading entire database-like TXT files can be achieved by replacing A with the database path:<br />
:: <tt>{.for each|value|{.replace|;|{.no pipe||.}|{.load| A .}.}|{:{.if|{.^value.}|{:{.set table|table|{.^value.}.}:}.}:}.}</tt><br />
:: The database file must use the syntax of <tt>key1=value1;key2=value2;key3=value3;</tt><br />
<br />
; cache | A | B | C<br />
: expands to retrieved value B from cache-table A. If not found, the new value C will be set. You can quote C if you need it.<br />
: This is a very useful tool when C takes too much time and you want to be sure you will do it only once.<br />
: Example: <tt><nowiki>{.cache|#countries|%ip%|{:{.load|http://server/giveMeTheCoutry?ip=%ip% .}:}.}</nowiki></tt><br />
<br />
; var domain | A<br />
: returns a list of all variable names starting with prefix A, separated by |.<br />
: Optional parameter ''separator'' to specify a different separator.<br />
: Optional parameter ''get=values'' will return variable values instead of names.<br />
<br />
== Localization ==<br />
Here goes a macro useful for template localization.<br />
<br />
Inside the template you can use identifiers (IDs) instead of real text. So you can gather all the text in one place, and ease the work of whom wants to translate to another language.<br />
<br />
Lets say that you have a link '''<a href ='..'>Go up one level</a>'''. You can replace with '''<a href ='..'>{.!up.}</a>''', moving the text to section '''[special:strings]'''.<br />
[special:strings]<br />
up=Go up one level<br />
<br />
You can optionally provide a parameter (like ''<nowiki><br />
{.!up|Go to parent folder.}</nowiki>'') that will be the default text in case '''up''' is not found in '''[special:strings]'''.<br />
<br />
<br />
If no parameter is provided, then the ID itself will be used as default text.<br />
<br />
== File manipulation ==<br />
Consider most of these macros work only with operating system oriented paths, not the ones of the virtual file system.<br />
<br />
; load | A : you'll love this one. You can specify A as a file name, or as a URL. It will load and expand to it. The file or URL you specify must be accessible from the server machine. A can be <tt>C:\windows\win.ini</tt> or also <tt><nowiki>http://another_hfs_in_lan/the_file_i_want.txt</nowiki></tt>.<br />
: With an optional parameter ''var'' you can specify the name of a variable where the whole content of the file will be stored. In such case, the macro will not expand to the content of the file, it's just in the var.<br />
: Optional parameter ''from'' to specify an offset from where to start reading.<br />
: Optional parameter ''size'' to specify how much to read.<br />
: Optional parameter ''to'' to specify the last byte to read, as an offset from the beginning.<br />
: All parameters ''from, size'' and ''to'' are expressed as number of bytes.<br />
: Example: {.load|document.txt|var=mytext.} or <tt><nowiki>{.load|http://www.domain.tld/test.txt.}</nowiki></tt><br />
<br />
; filesize | A : tells you the size in bytes of the file A. At the moment URL are not supported, only local filenames.<br />
<br />
; save | A | B : stores B to file path A. The path can be absolute, URI based or relative to HFS folder.<br />
: You can supply an optional parameter ''var'' instead of B, and the content of the specified variable will be saved.<br />
<br />
; append | A | B : add B at the end of file A. This may is also useful to keep special logs.<br />
<br />
; delete | A : moves the file A to the recycle bin.<br />
: Optional parameter ''forced=1'' will force deletion in case the bin is not available.<br />
: Optional parameter ''bin=0'' will delete the file permanently instead of moving to the recycled bin.<br />
<br />
; rename | A | B : renames the file A to B. Files can be specified with their disk path or in the URI form.<br />
<br />
; md5 file | A : computes and expands to the MD5 hash for file A.<br />
<br />
; copy | A | B : copies file A to B, where B can be a folder or a full path+filename. A can eventually be specified in the URI form.<br />
; move | A | B : as ''copy'', but A is moved instead of duplicated.<br />
<br />
; chdir | A : changes the current [http://en.wikipedia.org/wiki/Working_directory working directory] of the HFS process.<br />
; mkdir | A : creates the specified folder. URI is supported in A, but it must refer a real folder.<br />
<br />
; exists | A : checks A for existence, may it be a file or folder.<br />
; is file | A : checks A for existence as a file.<br />
<br />
; filename | A : returns only the filename part of A, removing eventual path information.<br />
; filepath | A : returns only the path of A, removing the file name.<br />
; filetime | A : returns timestamp for file A, express in [[HFS:_Time_format#Numerical_format|the usual format]].<br />
<br />
; disk free | A : returns available disk space for specified path in bytes. For example, to display available disk space for drive C:\ in Gigabytes use : {.round|{.div| {.disk free|C:\.} | 1073741824.}|2.}<br />
<br />
; dir | A : lists all the files found at path A, separated by |.<br />
: Optional parameter ''separator'' to specify a different separator.<br />
<br />
; file changed | A : returns true if file A has changed since last time checked (with this same command).<br />
: Optional second parameter will specify a variable name where to load the content of file A if the check returns true.<br />
<br />
== Virtual File System manipulation ==<br />
; add folder | A | B | C<br />
: adds a folder to the virtual file system. A specifies ''real'' or ''virtual'', while B is the name of the folder.<br />
: For real folders B should be the path on disk, but if published name is different than the real one, you can specify the path in parameter B, and the name in C.<br />
: Where in place of a simple name, you specify a virtual path, it will be used to place the folder (otherwise it will be place on the root).<br />
: Any existent folder with same name will be overwritten, unless you specify a parameter <tt>overwrite=0</tt>.<br />
: Example: <tt>{.add folder|virtual|/personal/my pictures.}</tt><br />
:: a virtual folder "my pictures" will be added under existing folder "personal".<br />
: Example: <tt>{.add folder|real|C:\music|my music|overwrite=0.}</tt><br />
:: folder on hard disk C:\music is published with public "my music". If a folder with same name is in the VFS, it's left untouched and no new folder is created.<br />
<br />
; set item | A<br />
: modifies the item A in the virtual file system by using any of these optional parameters<br />
:; hide : set to 1/0 to decide item visibility<br />
:; hide tree : set to 1/0 to decide item visibility and sub-items<br />
:; no log : set to 1/0 to decide item logging<br />
:; not as download : set 1/0, it's the same as ''don't consider as a download''. For folders, set it to ''*'' for all files, or any other file mask you want.<br />
:; comment : set the comment<br />
:; resource : Set the resource. It's the physical path for files and real folders, or the URL for links.<br />
:; archivable : Set whether the folder is archivable or not.<br />
:; browsable : Set whether or not the folder is browsable.<br />
:; download forbidden : Set whether or not to forbid downloading from this folder<br />
:; files filter : Show only certain files in the folder.<br />
:; folders filter : Show only certain folders in the folder.<br />
:; diff template : Change the diff template of a vfs item.<br />
: Example: <tt>{.set item|private files|hide=0|comment=you should never see this!.}</tt><br />
:; access / delete / upload<br />
:;: you can set permissions on the item, by specifying a list of usernames.<br />
:;: Example: <tt>set item|videos|upload=robert</tt> will give account ''robert'' the ability to upload files in ''/videos''.<br />
:;: Moreover, you can prefix permission by '''add''' or '''remove'''. In the previous example you set the ''upload'' permission. If ''mike'' already had upload permission, it is now lost. To '''add''' ''robert'' instead of just overwriting, you should <tt>{.set item|videos|add upload=robert.}</tt>. Now ''mike'' is happy too. As well, if you change your mind, and want to revoke your grant, just <tt>set item|videos|remove upload=robert</tt>.<br />
:;: You can specify more than one username this way: '''robert;mike;rupert'''.<br />
:;: Special usernames are '''@anonymous @any account @anyone'''.<br />
<br />
; get item | A | B<br />
: retrieves information B about VFS item specified by A.<br />
: Supported values for B are: ''exists, comment, resource, hide, hide tree, no log, not as download, access, upload, delete''.<br />
: Example: <tt>{.get item|/putYourFilesHere|upload.}</tt> will tell you who is allowed to upload files in that folder.<br />
<br />
; vfs select | A<br />
: A specifies what VFS item to select, but it's optional. If no parameter is provided, the currently selected item is returned.<br />
: If A is ''next'', the item coming after the current selection becomes the new selection.<br />
: If A is a named parameter ''path'', then you are specifying what item to select in the URI form.<br />
: Example: <tt>{.vfs select| path=/ .}</tt> will reset selection to the home/root, and looping through <tt>{.vfs select| next .}</tt> will select every VFS item, until <tt>{.vfs select.}</tt> is false (an empty string).<br />
<br />
; vfs to disk | A : a web path (URI) is converted to its related drive path. Relative paths like <tt>..</tt> are calculated based on the VFS folder where the script is running.<br />
<br />
== Connections control ==<br />
; disconnect | A | B : with no parameters, it disconnects current connection. If A is supplied, it is considered an [[HFS: IP masks|IP mask]], and every connection matching it (instead of the current one) will be disconnected. If also B is supplied, it will select only connections with port number same as B.<br />
<br />
; set speed limit for connection | A : set a speed limit A in KB/s for the current connection<br />
<br />
; set speed limit for address | A | B : set a speed limit B in KB/s for all connections coming from address A (no masks allowed).<br />
: When A is omitted, then it actually sets the value for the option ''Speed limit for single address'' in the GUI.<br />
<br />
; disconnection reason | A<br />
: this ''reason'' determines if a download must be aborted. Any value will abort the download, but if the value is empty the download goes on.<br />
: This macro will always return the value of the ''reason'' just before its call. So with a single call you are reading and setting the value. If no parameter is specified, then you are only reading.<br />
: Optional named parameter ''if=CONDITION'' is a shortcut for <tt>{.if|CONDITION|{:{.disconnection reason.}:}.}</tt><br />
: Example: <tt>{.disconnection reason|Try firefox|if={.{.get|agent.} != Mozilla.}.}</tt><br />
<br />
; add header | A : adds line A to the [http://en.wikipedia.org/wiki/HTTP_header HTTP header].<br />
<br />
; redirect | A : tells the browser to change to a different address (the specified one).<br />
<br />
; current downloads<br />
: expands to the number of current downloads. <br />
: Optional named parameter ''user'' will count only downloads made by specified user.<br />
: Optional named parameter ''ip'' will count only downloads made by the specified address.<br />
: Optional parameter ''file=this'' will count only downloads of this current file.<br />
: Example: <tt>{.current downloads|user=%user%|file=this.}</tt> will tell you how many connections this user is using to download this same file.<br />
<br />
; current downloads of file<br />
: number of current downloads of current file. <br />
: If an unnamed optional parameter is specified, it is used as [[HFS: IP masks|IP mask]], and only matching connections will be counted.<br />
: If the parameter is given name ''user'', only connections by such user will be counted.<br />
<br />
== Account manipulation ==<br />
; set account | A | ...<br />
: with this command you can change all attributes of the account whose username is specified in first parameter. If the username is left empty, current username is used, given this makes sense in current context.<br />
: Other parameters are the attributes you want to change, in the form <tt>set account|username|thing=value|thing2=value2</tt>.<br />
: Here is a list of such attributes<br />
:;password : set a new password<br />
:;newname : set a new username<br />
:;redirect : set the homonymous field<br />
:;no limits : set the homonymous field (true/false)<br />
:;enabled : set the homonymous field (true/false)<br />
:;is group : set the homonymous field (true/false)<br />
:;member of : set the ''member of'' field (specify more than one group separating by semicolons ";" )<br />
:;add member of : add more groups to the above<br />
:;remove member of : remove some groups to the above<br />
:;notes : set the homonymous field<br />
:;notes key <br />
:;: set the notes as it was a table with <tt>{.set table.}</tt><br />
:;: Example: <tt>{.set account|mike|notes key=last time=%timestamp%.}</tt><br />
<br />
; new account | A | ...<br />
: creates a new account with username A. After the username, you can also specify all the values available in the ''set account'' macro.<br />
<br />
;'' '' delete account | A<br />
: delete specified account (by username).<br />
<br />
; get account | A | B<br />
: expands to the value of property B of account A. <br />
: Supported value for B are ''redirect, no limits, enabled, is group, member of, notes, notes key''. Group names for ''member of'' are semicolon-separated. Special case for ''notes key'' where you should specify the key to retrieve, while the notes are treated as a table, just as for <tt>{.from table.}</tt>.<br />
: If A is omitted, current username is used, given this makes sense in current context.<br />
<br />
; member of | A<br />
: true if the current user is member of group A (specify more than one group separating by semicolons ";").<br />
: Optional parameter ''user'' to check a different user.<br />
: Example <tt>member of|administrators|user=rejetto</tt><br />
: If A is omitted, you will get the full membership for current (or specified) user. This is different from <tt>{.get account||member of.}</tt> because this latter form will consider only direct first-level membership, while <tt>{.member of.}</tt> will actually consider membership at any level.<br />
<br />
== Others ==<br />
; comment | A : this is just discarded. It's for your convenience, to put a comment in the template. HTML comments are readable by visitors if they use ''show html source'' in their browser. Using this macro you will have comments that will never leave your server.<br />
<br />
; length | A : if A is 5 characters length, like <tt>abcde</tt>, it expands to 5.<br />
: Optional parameter ''var'' in place of A, will work on the specified variable instead of considering A as text.<br />
<br />
; match | A | B : it is true if the content B is matched by [[HFS: File masks|the mask]] A.<br />
<br />
; match address | A | B : just like the macro ''match'', but the mask supports ip ranges like 10.0.0.1-10.0.0.25<br />
<br />
; random | A | B | C | ... : it expands to any of the parameters, randomly<br />
<br />
; random number | A | B : if only A is specified then a number between 0 and A is generated. If also B is specified then the number will be between A and B (included).<br />
<br />
; pos | A | B : expands to the position of A in B. Zero if not found. <br />
: Optional parameter ''from'' will start searching from specified position.<br />
: Optional parameter ''case'' will decide case sensitivity. Default is: insensitive.<br />
: Example <tt>pos|the|i'm the alpha and the omega|from=14|case=1</tt> expands to <tt>19</tt><br />
<br />
; regexp | A | B<br />
: Try to [http://en.wikipedia.org/wiki/Regular_expressions match pattern] A on text B.<br />
: When the pattern doesn't match, it just expands to nothing (then, false).<br />
: When it does, the matched sub-pattern is returned.<br />
: You can provide optional parameter ''var'' instead of B, and the text will be the content of the specified variable.<br />
: Optional parameter ''case'' will determine case sensitivity. (off by default)<br />
: Optional parameter ''sub'' will specify the name of a variable that will be set as a table, where you can retrieve every sub-pattern by numerical index.<br />
: If optional parameter ''replace=YYY'' is used, the command returns no more the matched pattern, but the whole text B with every matched pattern replaced by YYY. If you use ''replace'' and ''var'' together, the resulting text will not be returned, but stored in the specified input variable (that means, it's used both for input and output).<br />
: Example: <tt>regexp|\d+|var=weWantNumbers</tt><br />
<br />
; breadcrumbs | A<br />
: builds a [http://en.wikipedia.org/wiki/Breadcrumb_(navigation) breadcrumbs] based on the current folder path. The A is a little html template that is repeated for every piece of the path, for which 3 symbols are provided: ''%bread-url%'' , ''%bread-name%'' and ''%bread-idx%''. <br />
: Remember to use quoting, especially if you use macros in the parameter.<br />
: Optional parameter ''from'' will let you specify how many steps of the path to skip.<br />
: Example: <tt>{.breadcrumbs|{:<a href ="%bread-url%">%bread-name%/</a>:}.}</tt><br />
<br />
; dialog | A | B | C<br />
: display a server-side message in a dialog box. A is the message itself, and only required parameter. B are options separated by spaces, and C a title for the dialog.<br />
: Possible options are<br />
:;okcancel : offers buttons OK and CANCEL<br />
:;yesno : offers buttons YES and NO<br />
:;yesnocancel : offers buttons YES, NO and CANCEL<br />
:;error : this is an error reporting dialog<br />
:;question : this is a questioning dialog<br />
:;warning : this is a warning dialog<br />
:;information : this is an informational dialog<br />
<br />
; mime | A : set the mime-type sent to the browser. It describes the nature of the content. For techies, it's the value of the header field "Content-type".<br />
<br />
; any macro marker | A : it is true if any macro marker is present in A. Macro markers are {.delimiters.} , {:quotings:} and the parameters separator (the pipe, "|").<br />
<br />
; play system event | A : specify the name of the event bound to a sound that you want to play. ''SystemStart'' and ''MailBeep'' are just examples, for a full list you can open your registry at ''HKEY_CURRENT_USER\AppEvents\EventLabels'' .<br />
<br />
; exec | A : ask system to run file A, eventually with parameters. If you need to use the pipe, then use macro quoting.<br />
: Optional parameter ''out'' will let you capture the console output of the program in the variable specified by name.<br />
: Optional parameter ''timeout'' will specify the max number of seconds the app should be left running.<br />
: Example: <tt>{.exec|notepad.}</tt><br />
<br />
; add to log | A : add A to the log panel. <br />
: Optional parameter ''color'' to [[HFS: color format|specify the color]].<br />
<br />
; get ini | A<br />
: where A is a text in the same format you can find in ''hfs.ini'' (save options -> to file).<br />
: example: <tt>{.get ini|speed limit.}</tt> will return the global speed limit, if any.<br />
<br />
; set ini | A<br />
: where A is a text in the same format you can find in ''hfs.ini'' (save options -> to file).<br />
: example: <tt>{.set ini|speed limit=100.}</tt> will turn the global speed limit to 100KB/s.<br />
<br />
; focus<br />
: will bring HFS window on front of the user.<br />
<br />
; load tpl | A : for this connection only, template A will be used.<br />
: Example: <tt>{.if| it's a mobile | {:{.load tpl|mobile.tpl.}:} /if.}</tt><br />
<br />
; notify | A<br />
: The message A will come out as a balloon over the HFS tray icon.<br />
: Optional parameter ''title'' will let you specify the title of the balloon.<br />
: Optional parameter ''timeout'' specifies the amount of time to show the message.<br />
: Optional parameter ''type'' will show an icon according to its value. Allowed values are ''info, error'' and ''warning''.<br />
<br />
== Shortcuts ==<br />
;$A : is a shortcut for '''section | A'''<br />
;?A : is a shortcut for '''urlvar | A'''<br />
;^A : is a shortcut for '''call | A'''<br />
;A = B : is a shortcut for '''=|A|B'''<br />
;?name = X : is a shortcut for <tt>{.?name.} = X</tt> .<br />
: It works also for '''<> != < <= > >=''' .</div>
Rejetto
https://rejetto.com/wiki/index.php?title=HFS:_Template_symbols&diff=5607
HFS: Template symbols
2015-03-07T21:00:15Z
<p>Rejetto: /* Symbols available in sections [file] and [folder] */</p>
<hr />
<div>== Symbols list - by section ==<br />
<br />
=== Symbols available in all sections ===<br />
; %style% : inserts the HTML from section [style]<br />
; %login-link% : inserts HTML from section [login-link] if no user is logged in, void otherwise<br />
; %loggedin% : inserts HTML from section [loggedin] if a user is logged in, void otherwise<br />
; %user% : returns the name of the authenticated user, void if no user is logged in<br />
; %ip% : inserts the client IP address on the page<br />
; %version% : returns the HFS version number<br />
; %timestamp% : returns the value for the date and time of the server (format is defined by OS settings)<br />
; %uptime% : returns the value for how long HFS has been running without quitting<br />
; %connections% : returns the value for the current number of connections to HFS<br />
; %speed-out% : returns the value for the current outbound speed<br />
; %speed-in% : returns the value for the current inbound speed<br />
; %total-out% : returns the value for the total amount of bytes sent<br />
; %total-in% : returns the value for total amount the of bytes received<br />
; %total-downloads% : returns the value for the number of downloads <br />
; %total-uploads% : returns the value for the number of uploads <br />
; %number-addresses% : returns the value for the current number of connected clients (IP addresses)<br />
; %number-addresses-downloading% : returns the value for the current number of downloading clients (IP addresses)<br />
; %build% : returns the HFS build number<br />
; %sequential% : returns an increasing number. if it appears 3 times in a page, it will be 1, 2 and 3...<br />
; %number-addresses-ever% : returns the number of unique IP addresses ever connected.<br />
; %port%: port number used by HFS to listen for connections<br />
<br />
=== Symbols available in the main section ===<br />
; %up% : inserts HTML from section [up] if the current folder is not the root, void otherwise<br />
; %upload-link% : inserts HTML from section [upload-link] if upload is available in the current folder, void otherwise<br />
; %host% : returns the Host http header field, as sent by the browser eg. Server-URL(:port) or Server-IP(:port)<br />
; %number% : returns the value for the number of items in the current folder<br />
; %number-folders% : returns the value for the number of folders in the current folder<br />
; %number-files% : returns the value for the number of files in the current folder<br />
; %total-size% : returns the smart value for the amount of space occupied by items in the current folder<br />
; %total-kbytes% : same as '''%total-size%''', but expressed in kilobytes<br />
; %total-bytes% : same as '''%total-size%''', but expressed in bytes<br />
; %build-time% : returns the value for how long it took to generate the page<br />
; %files% : inserts HTML from section [files] if at least one item is present in the current folder, inserts HTML from section [nofiles] otherwise<br />
<br />
=== Symbols available in section [files] === <br />
; %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.<br />
; %item-archive% : Expands to the [item-archive] section if the folder is archivable.<br />
; %item-ext% : returns the extension of the current item.<br />
<br />
=== Symbols available in sections [file], [folder] and [link] === <br />
; %item-type% : returns ''file'' if current item is a file, ''folder'' if it's a folder, ''link'' if it's a link<br />
; %new% : inserts HTML from section [new] if the file is marked as new, void otherwise<br />
; %item-comment% : returns the comment of the item<br />
; %item-url% : returns the value for the path to get the item<br />
; %item-name% : returns the value for the label of the item<br />
; %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.<br />
; %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).<br />
: If you need to pass the value to {.time.} use %item-added-dt% instead.<br />
<br />
=== Symbols available in sections [file] and [folder] ===<br />
; %item-dl-count% : returns the value for the download counter (virtual folders totalize inner counters)<br />
; %item-modified% : returns the value for the modification time as reported by file or folder (date and time format is defined by OS settings).<br />
: If you need to pass the value to {.time.} use %item-modified-dt% instead.<br />
<br />
=== Symbols available in section [file] ===<br />
; %item-size% : returns the value for the amount of space occupied by the item<br />
; %item-size-b% : same as '''%item-size%''', but expressed in bytes<br />
; %item-size-kb% : same as '''%item-size%''', but expressed in kilobytes<br />
<br />
=== Symbols available in sections [upload], [upload+progress], [upload-results] and main section ===<br />
; %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)<br />
; %folder% : returns the value for the path to the current folder<br />
; %encoded-folder% : returns the value for the encoded path to the current folder<br />
; %parent-folder% : returns the value for the encoded path to the parent folder<br />
; %folder-comment% : inserts the HTML from section [folder-comment] if a comment is available for the current folder, void otherwise<br />
<br />
=== Symbols available in section [error-page] ===<br />
; %content% : inserts the HTML from sections [ban], [deny], [not found], [unauthorized] or [overload], depending on the error code<br />
<br />
=== Symbols available in section [ban] ===<br />
; %reason% : returns value for the ban description from the hfs.ini<br />
<br />
=== Symbols available in section [progress] ===<br />
; %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<br />
<br />
=== Symbols available in sections [progress-download-file] and [progress-upload-file] ===<br />
These sections are related to file transferring.<br />
; %perc% : returns the value for the percentage done<br />
; %filename% : returns the value for the name of the file<br />
; %done-bytes% : returns the value for the transferred bytes<br />
; %done% : same as '''%done-bytes%''', but using dynamic measure units<br />
; %total-bytes% : returns the value for the number of bytes of the completed transfer<br />
; %total% : same as '''%total-bytes%''', but using dynamic measure units<br />
; %speed-kb% : returns the value for the throughput speed<br />
; %time-left% : esteemed time of arrival<br />
<br />
=== Symbols available in section [upload] ===<br />
; %uploaded-files% : input boxes for files to be uploaded got by pasting [upload-file] for each file<br />
; %host% : returns the Host http header field, as sent by the browser eg. Server-URL(:port) or Server-IP(:port) (since v2.1beta)<br />
; %up% : inserts HTML from section [up] if the current folder is not the root, void otherwise (since v2.1beta)<br />
<br />
=== Symbols available in section [upload-file] ===<br />
; %idx% : ordinal index of the input box<br />
<br />
=== Symbols available in section [upload-results] ===<br />
; %uploaded-files% : list of uploaded files got by pasting section[upload-success] and/or section [upload-failed] for each file<br />
; %host% : returns the Host http header field, as sent by the browser eg. Server-URL(:port) or Server-IP(:port) (since v2.1beta)<br />
; %up% : inserts HTML from section [up] if the current folder is not the root, void otherwise (since v2.1beta)<br />
<br />
=== Symbols available in sections [upload-success] and [upload-failed] ===<br />
; %item-name% : name of the file<br />
; %item-url% : address of the file<br />
<br />
=== Symbols available in section [upload-success] ===<br />
; %item-size% : returns the value for the size of the uploaded file<br />
; %speed% : returns the value for the average upload speed<br />
<br />
=== Symbols available in section [upload-failed] ===<br />
; %reason% : returns the value for the error occurred while uploading</div>
Rejetto
https://rejetto.com/wiki/index.php?title=HFS:_Template_symbols&diff=5606
HFS: Template symbols
2015-03-07T20:59:57Z
<p>Rejetto: /* Symbols available in sections [file], [folder] and [link] */</p>
<hr />
<div>== Symbols list - by section ==<br />
<br />
=== Symbols available in all sections ===<br />
; %style% : inserts the HTML from section [style]<br />
; %login-link% : inserts HTML from section [login-link] if no user is logged in, void otherwise<br />
; %loggedin% : inserts HTML from section [loggedin] if a user is logged in, void otherwise<br />
; %user% : returns the name of the authenticated user, void if no user is logged in<br />
; %ip% : inserts the client IP address on the page<br />
; %version% : returns the HFS version number<br />
; %timestamp% : returns the value for the date and time of the server (format is defined by OS settings)<br />
; %uptime% : returns the value for how long HFS has been running without quitting<br />
; %connections% : returns the value for the current number of connections to HFS<br />
; %speed-out% : returns the value for the current outbound speed<br />
; %speed-in% : returns the value for the current inbound speed<br />
; %total-out% : returns the value for the total amount of bytes sent<br />
; %total-in% : returns the value for total amount the of bytes received<br />
; %total-downloads% : returns the value for the number of downloads <br />
; %total-uploads% : returns the value for the number of uploads <br />
; %number-addresses% : returns the value for the current number of connected clients (IP addresses)<br />
; %number-addresses-downloading% : returns the value for the current number of downloading clients (IP addresses)<br />
; %build% : returns the HFS build number<br />
; %sequential% : returns an increasing number. if it appears 3 times in a page, it will be 1, 2 and 3...<br />
; %number-addresses-ever% : returns the number of unique IP addresses ever connected.<br />
; %port%: port number used by HFS to listen for connections<br />
<br />
=== Symbols available in the main section ===<br />
; %up% : inserts HTML from section [up] if the current folder is not the root, void otherwise<br />
; %upload-link% : inserts HTML from section [upload-link] if upload is available in the current folder, void otherwise<br />
; %host% : returns the Host http header field, as sent by the browser eg. Server-URL(:port) or Server-IP(:port)<br />
; %number% : returns the value for the number of items in the current folder<br />
; %number-folders% : returns the value for the number of folders in the current folder<br />
; %number-files% : returns the value for the number of files in the current folder<br />
; %total-size% : returns the smart value for the amount of space occupied by items in the current folder<br />
; %total-kbytes% : same as '''%total-size%''', but expressed in kilobytes<br />
; %total-bytes% : same as '''%total-size%''', but expressed in bytes<br />
; %build-time% : returns the value for how long it took to generate the page<br />
; %files% : inserts HTML from section [files] if at least one item is present in the current folder, inserts HTML from section [nofiles] otherwise<br />
<br />
=== Symbols available in section [files] === <br />
; %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.<br />
; %item-archive% : Expands to the [item-archive] section if the folder is archivable.<br />
; %item-ext% : returns the extension of the current item.<br />
<br />
=== Symbols available in sections [file], [folder] and [link] === <br />
; %item-type% : returns ''file'' if current item is a file, ''folder'' if it's a folder, ''link'' if it's a link<br />
; %new% : inserts HTML from section [new] if the file is marked as new, void otherwise<br />
; %item-comment% : returns the comment of the item<br />
; %item-url% : returns the value for the path to get the item<br />
; %item-name% : returns the value for the label of the item<br />
; %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.<br />
; %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).<br />
: If you need to pass the value to {.time.} use %item-added-dt% instead.<br />
<br />
=== Symbols available in sections [file] and [folder] ===<br />
; %item-dl-count% : returns the value for the download counter (virtual folders totalize inner counters)<br />
; %item-modified% : returns the value for the modification time as reported by file or folder (date and time format is defined by OS settings)<br />
<br />
<br />
=== Symbols available in section [file] ===<br />
; %item-size% : returns the value for the amount of space occupied by the item<br />
; %item-size-b% : same as '''%item-size%''', but expressed in bytes<br />
; %item-size-kb% : same as '''%item-size%''', but expressed in kilobytes<br />
<br />
=== Symbols available in sections [upload], [upload+progress], [upload-results] and main section ===<br />
; %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)<br />
; %folder% : returns the value for the path to the current folder<br />
; %encoded-folder% : returns the value for the encoded path to the current folder<br />
; %parent-folder% : returns the value for the encoded path to the parent folder<br />
; %folder-comment% : inserts the HTML from section [folder-comment] if a comment is available for the current folder, void otherwise<br />
<br />
=== Symbols available in section [error-page] ===<br />
; %content% : inserts the HTML from sections [ban], [deny], [not found], [unauthorized] or [overload], depending on the error code<br />
<br />
=== Symbols available in section [ban] ===<br />
; %reason% : returns value for the ban description from the hfs.ini<br />
<br />
=== Symbols available in section [progress] ===<br />
; %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<br />
<br />
=== Symbols available in sections [progress-download-file] and [progress-upload-file] ===<br />
These sections are related to file transferring.<br />
; %perc% : returns the value for the percentage done<br />
; %filename% : returns the value for the name of the file<br />
; %done-bytes% : returns the value for the transferred bytes<br />
; %done% : same as '''%done-bytes%''', but using dynamic measure units<br />
; %total-bytes% : returns the value for the number of bytes of the completed transfer<br />
; %total% : same as '''%total-bytes%''', but using dynamic measure units<br />
; %speed-kb% : returns the value for the throughput speed<br />
; %time-left% : esteemed time of arrival<br />
<br />
=== Symbols available in section [upload] ===<br />
; %uploaded-files% : input boxes for files to be uploaded got by pasting [upload-file] for each file<br />
; %host% : returns the Host http header field, as sent by the browser eg. Server-URL(:port) or Server-IP(:port) (since v2.1beta)<br />
; %up% : inserts HTML from section [up] if the current folder is not the root, void otherwise (since v2.1beta)<br />
<br />
=== Symbols available in section [upload-file] ===<br />
; %idx% : ordinal index of the input box<br />
<br />
=== Symbols available in section [upload-results] ===<br />
; %uploaded-files% : list of uploaded files got by pasting section[upload-success] and/or section [upload-failed] for each file<br />
; %host% : returns the Host http header field, as sent by the browser eg. Server-URL(:port) or Server-IP(:port) (since v2.1beta)<br />
; %up% : inserts HTML from section [up] if the current folder is not the root, void otherwise (since v2.1beta)<br />
<br />
=== Symbols available in sections [upload-success] and [upload-failed] ===<br />
; %item-name% : name of the file<br />
; %item-url% : address of the file<br />
<br />
=== Symbols available in section [upload-success] ===<br />
; %item-size% : returns the value for the size of the uploaded file<br />
; %speed% : returns the value for the average upload speed<br />
<br />
=== Symbols available in section [upload-failed] ===<br />
; %reason% : returns the value for the error occurred while uploading</div>
Rejetto
https://rejetto.com/wiki/index.php?title=HFS:_Template_symbols&diff=5605
HFS: Template symbols
2015-02-23T00:03:28Z
<p>Rejetto: /* Symbols available in sections [file], [folder] and [link] */</p>
<hr />
<div>== Symbols list - by section ==<br />
<br />
=== Symbols available in all sections ===<br />
; %style% : inserts the HTML from section [style]<br />
; %login-link% : inserts HTML from section [login-link] if no user is logged in, void otherwise<br />
; %loggedin% : inserts HTML from section [loggedin] if a user is logged in, void otherwise<br />
; %user% : returns the name of the authenticated user, void if no user is logged in<br />
; %ip% : inserts the client IP address on the page<br />
; %version% : returns the HFS version number<br />
; %timestamp% : returns the value for the date and time of the server (format is defined by OS settings)<br />
; %uptime% : returns the value for how long HFS has been running without quitting<br />
; %connections% : returns the value for the current number of connections to HFS<br />
; %speed-out% : returns the value for the current outbound speed<br />
; %speed-in% : returns the value for the current inbound speed<br />
; %total-out% : returns the value for the total amount of bytes sent<br />
; %total-in% : returns the value for total amount the of bytes received<br />
; %total-downloads% : returns the value for the number of downloads <br />
; %total-uploads% : returns the value for the number of uploads <br />
; %number-addresses% : returns the value for the current number of connected clients (IP addresses)<br />
; %number-addresses-downloading% : returns the value for the current number of downloading clients (IP addresses)<br />
; %build% : returns the HFS build number<br />
; %sequential% : returns an increasing number. if it appears 3 times in a page, it will be 1, 2 and 3...<br />
; %number-addresses-ever% : returns the number of unique IP addresses ever connected.<br />
; %port%: port number used by HFS to listen for connections<br />
<br />
=== Symbols available in the main section ===<br />
; %up% : inserts HTML from section [up] if the current folder is not the root, void otherwise<br />
; %upload-link% : inserts HTML from section [upload-link] if upload is available in the current folder, void otherwise<br />
; %host% : returns the Host http header field, as sent by the browser eg. Server-URL(:port) or Server-IP(:port)<br />
; %number% : returns the value for the number of items in the current folder<br />
; %number-folders% : returns the value for the number of folders in the current folder<br />
; %number-files% : returns the value for the number of files in the current folder<br />
; %total-size% : returns the smart value for the amount of space occupied by items in the current folder<br />
; %total-kbytes% : same as '''%total-size%''', but expressed in kilobytes<br />
; %total-bytes% : same as '''%total-size%''', but expressed in bytes<br />
; %build-time% : returns the value for how long it took to generate the page<br />
; %files% : inserts HTML from section [files] if at least one item is present in the current folder, inserts HTML from section [nofiles] otherwise<br />
<br />
=== Symbols available in section [files] === <br />
; %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.<br />
; %item-archive% : Expands to the [item-archive] section if the folder is archivable.<br />
; %item-ext% : returns the extension of the current item.<br />
<br />
=== Symbols available in sections [file], [folder] and [link] === <br />
; %item-type% : returns ''file'' if current item is a file, ''folder'' if it's a folder, ''link'' if it's a link<br />
; %new% : inserts HTML from section [new] if the file is marked as new, void otherwise<br />
; %item-comment% : returns the comment of the item<br />
; %item-url% : returns the value for the path to get the item<br />
; %item-name% : returns the value for the label of the item<br />
; %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.<br />
; %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)<br />
<br />
=== Symbols available in sections [file] and [folder] ===<br />
; %item-dl-count% : returns the value for the download counter (virtual folders totalize inner counters)<br />
; %item-modified% : returns the value for the modification time as reported by file or folder (date and time format is defined by OS settings)<br />
<br />
<br />
=== Symbols available in section [file] ===<br />
; %item-size% : returns the value for the amount of space occupied by the item<br />
; %item-size-b% : same as '''%item-size%''', but expressed in bytes<br />
; %item-size-kb% : same as '''%item-size%''', but expressed in kilobytes<br />
<br />
=== Symbols available in sections [upload], [upload+progress], [upload-results] and main section ===<br />
; %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)<br />
; %folder% : returns the value for the path to the current folder<br />
; %encoded-folder% : returns the value for the encoded path to the current folder<br />
; %parent-folder% : returns the value for the encoded path to the parent folder<br />
; %folder-comment% : inserts the HTML from section [folder-comment] if a comment is available for the current folder, void otherwise<br />
<br />
=== Symbols available in section [error-page] ===<br />
; %content% : inserts the HTML from sections [ban], [deny], [not found], [unauthorized] or [overload], depending on the error code<br />
<br />
=== Symbols available in section [ban] ===<br />
; %reason% : returns value for the ban description from the hfs.ini<br />
<br />
=== Symbols available in section [progress] ===<br />
; %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<br />
<br />
=== Symbols available in sections [progress-download-file] and [progress-upload-file] ===<br />
These sections are related to file transferring.<br />
; %perc% : returns the value for the percentage done<br />
; %filename% : returns the value for the name of the file<br />
; %done-bytes% : returns the value for the transferred bytes<br />
; %done% : same as '''%done-bytes%''', but using dynamic measure units<br />
; %total-bytes% : returns the value for the number of bytes of the completed transfer<br />
; %total% : same as '''%total-bytes%''', but using dynamic measure units<br />
; %speed-kb% : returns the value for the throughput speed<br />
; %time-left% : esteemed time of arrival<br />
<br />
=== Symbols available in section [upload] ===<br />
; %uploaded-files% : input boxes for files to be uploaded got by pasting [upload-file] for each file<br />
; %host% : returns the Host http header field, as sent by the browser eg. Server-URL(:port) or Server-IP(:port) (since v2.1beta)<br />
; %up% : inserts HTML from section [up] if the current folder is not the root, void otherwise (since v2.1beta)<br />
<br />
=== Symbols available in section [upload-file] ===<br />
; %idx% : ordinal index of the input box<br />
<br />
=== Symbols available in section [upload-results] ===<br />
; %uploaded-files% : list of uploaded files got by pasting section[upload-success] and/or section [upload-failed] for each file<br />
; %host% : returns the Host http header field, as sent by the browser eg. Server-URL(:port) or Server-IP(:port) (since v2.1beta)<br />
; %up% : inserts HTML from section [up] if the current folder is not the root, void otherwise (since v2.1beta)<br />
<br />
=== Symbols available in sections [upload-success] and [upload-failed] ===<br />
; %item-name% : name of the file<br />
; %item-url% : address of the file<br />
<br />
=== Symbols available in section [upload-success] ===<br />
; %item-size% : returns the value for the size of the uploaded file<br />
; %speed% : returns the value for the average upload speed<br />
<br />
=== Symbols available in section [upload-failed] ===<br />
; %reason% : returns the value for the error occurred while uploading</div>
Rejetto
https://rejetto.com/wiki/index.php?title=HFS:_Hidden_things&diff=5598
HFS: Hidden things
2014-12-25T22:29:51Z
<p>Rejetto: </p>
<hr />
<div>These features are not available from the GUI.<br />
You just have to know that they exist.<br />
* Hold SHIFT at startup to skip configuration loading<br />
* Hold CTRL at startup to skip the ''"only 1 instance"'' feature<br />
* You can have diff templates on file, as an alternative to input them in the GUI. It works only for real-folders. Put in your folder a file named '''hfs.diff.tpl'''. This file has to be a simple text file, and should contain the diff template.<br />
* '''~files.lst''' can be customized. Simply create a text file named '''hfs.filelist.tpl''' and add it to the folder that contains '''hfs.exe'''. Then, insert this content:<br />
<br />
<pre><br />
%files%<br />
<br />
[files]<br />
%list%<br />
<br />
[file]<br />
%item-full-url%<br />
<br />
[folder]<br />
%item-full-url%<br />
</pre><br />
: Edit this template to fit your needs.<br />
<br />
* [Since ver 2.3] Sorting by comment is supported (although not used by the default template) by using parameter '''sort=c'''<br />
* [Since ver 2.3] Per-folder default sorting is supported [http://www.rejetto.com/forum/index.php?topic=5656.msg1033337#msg1033337 More info]<br />
* [Since ver 2.3] Adding a folder "upload" from the disk, will quickly give you upload permissions</div>
Rejetto
https://rejetto.com/wiki/index.php?title=HFS:_scripting_commands&diff=5593
HFS: scripting commands
2014-11-12T22:42:38Z
<p>Rejetto: /* Account manipulation */</p>
<hr />
<div>Also known as template macros, these are commands with some useful effects that users can input in HFS to improve a template or to create functionality not otherwise available. <br />
<br />
Some macros simply expand to text and some perform server-side commands.<br />
<br />
Every command is expressed as a name, and sometimes parameters, separated by pipes "<tt>|</tt>".<br />
<br />
Following, with letters we are denoting parameters, and their meaning is explained immediately after.<br />
<br />
You should read this [http://www.rejetto.com/wiki/index.php?title=HFS:_Template_macros] before reading this page.<br />
<br />
== Logic and flow ==<br />
; if | A | B | C<br />
: if A is true, then it expands to B, else it expands to C. When it expands to B, C is just discarded, and the vice versa. C is optional.<br />
: How you tell A is true? A is true if it is not empty and not just a zero. So if A is "hi there!", then it is true.<br />
: Remember to use quoting if you use macros in B or C (the body).<br />
<br />
; if not | A | B | C <br />
: same as ''if'', but the logic is inverted. When A is true it expands to C and vice versa.<br />
<br />
; not | A : true if A is not true. It negates the value of A.<br />
<br />
; and | A | B : true if both A and B are true. In details: in the ''true'' case it returns the last parameter. You can specify as many parameters as necessary. Both Javascript and Python work this way.<br />
<br />
; or | A | B : true if any of A or B are true. In details: it returns the first ''true'' parameter (yes, it supports any number of parameters). If none of the parameters is true, then iit returns false. Both Javascript and Python work this way. Often times you can work without {.or.}, for example {.if| A B | C .} returns true if either A or B are true.<br />
<br />
; xor | A | B : true if A is true while B is false, or the opposite<br />
<br />
; = | A | B : true if A is the same as B. It's case insensitive. You can use the opposite macro, true if they are different, and it's name is '''!=''' or '''<>''' (use the one you like most, there's no difference). You can specify as many parameters as you like.<br />
<br />
; > | A | B : true if A is greater than B. Of course you can also use the related macro '''<'''. You can specify as many parameters as you like.<br />
<br />
; >= | A | B : true if A is equal or greater than B. Of course you can also use the related macro '''<='''. You can specify as many parameters as you like.<br />
<br />
; between | A | B | C : true if B is between A and C (included).<br />
<br />
; between! | A | B | C : true if B is between A and C (excluded).<br />
<br />
; switch | A | B | C | D | E | F ...<br />
: this is rather complex for non-programmers. You can learn how a switch statement is supposed to work [http://en.wikipedia.org/wiki/Switch_statement#Examples from Wikipedia]. When you know how a ''switch'' works, then you will understand this schema that will make you understand how the parameters of this macro work<br />
<pre><nowiki><br />
switch(A) {<br />
case C: return D;<br />
case E: return F;<br />
...<br />
}<br />
</nowiki></pre><br />
: The B is a separator string for C. Let's be clearer: if you want to specify several cases in C, all of them returning D, then you can specify them separating with B.<br />
: As you can see C and D are paired, as E and F, eventually G and H, and so on. If at the end of this list of pairs, a single unpaired parameter is found, then it is used as the else/default case, when all other pairs have failed.<br />
: Let me translated the first example of Wikipedia using the macro<br />
<pre><nowiki><br />
{.switch|%n%|,|<br />
0|you typed zero|<br />
3,5,7|%n% is a prime number|<br />
4,6,8|%n% is an even number|<br />
2|%n% is a prime and even number|<br />
1,9|%n% is a perfect square|<br />
Only single-digit numbers are allowed<br />
.}<br />
</nowiki></pre><br />
<br />
Switch is esentially a quick way of using many {.if.} and {.=.} commands together. For example, if A equals C then D, if A equals E then F, etc.<br />
<br />
; for | A | B | C | D | E<br />
: repeats D by replacing variable <tt>{.^A.}</tt> with every value between B and C (they are meant to be numbers).<br />
: Optionally you can specify a ''step'' for the numbers: that is, instead of going 1-by-1, they can go 2-by-2. The optional ''step'' is specified at position D; in such case the ''body'' is moved from position D to position E.<br />
: Remember to use quoting for the body.<br />
<br />
; for each | A | B | C ... | Z<br />
: a (sometimes) handier version of ''for'', that will repeat Z but replacing variable <tt>{.^A.}</tt> with value B the first time, value C the second time, D etc etc. Remember to quote the body. <br />
: example: <tt>{.for each|i|10|100|1000|{:now it's {.^i.} :}.}</tt><br />
<br />
; while | A | B<br />
: repeats B for as long as A is true. Both B is automatically dequoted. If A is quoted, then it's expanded, otherwise is considered the a variable name.<br />
: Optional parameter ''else'' will be expanded if B is never done.<br />
: Optional parameter ''timeout'' let you specify (in seconds) the maximum time the loop can live before it is stopped. It's 1 second by default.<br />
: Optional parameter ''var'' saves the output in a variable instead of just expanding to it.<br />
: Example: <tt>{.while|#x|{: {.dec|#x.} welcome! :}.}</tt> will welcome 10 times if <tt>#x</tt> is 10.<br />
<br />
; after the list | A<br />
: quoted text A is dequoted and executed, but only if the file listing is completed.<br />
<br />
; dequote | A<br />
: if A is {:quoted:} then quoting markers are removed (unleashing macro execution of the previously quoted text).<br />
<br />
; 123 if 2 | A | B | C<br />
: if B is true, it expands to ABC, otherwise nothing.<br />
: It is basically a shortcut for {.if | B |{: A B C :}.}<br />
<br />
; break : stops execution of this script.<br />
: Optional parameter ''if'' will avoid breaking in case the condition is not met (that is, when it's ''false'').<br />
: Optional parameter ''result'' will output a text only if the break occurs (makes sense only with parameter ''if'').<br />
: Using <tt>{.break|if=data.}</tt> is basically a simplified way to write <tt>{.if|data|{:{.break.}:}.}</tt><br />
<br />
== Data getting ==<br />
; section | A<br />
: A is the name of the [section] you want to include. Note: till build #160 it was case sensitive.<br />
: Optional parameter ''file'' to load the section from an external file.<br />
: Optional parameter ''back=1'' will work in diff templates to access the section in the original template. So you can access it even if you overwrote it.<br />
: Example: <tt>{.section|names|file=tables.txt.}</tt><br />
; get | A<br />
: where A is the name of a value you are interested in, like to know if an option is enabled or not.<br />
: This is a list of supported values for A:<br />
:; can upload : true if in the current folder the user is allowed to upload files. An additional parameter ''path'' will tell you about a different folder instead of the current one.<br />
:; can delete : true if the user is allowed to delete the current item. An additional parameter ''path'' will tell you about a different folder instead of the current one.<br />
:; can access : true if the current item in list is accessible by the user. An additional parameter ''path'' will tell you about a different folder instead of the current one.<br />
:; can recur : true if the option ''Recursive listing'' is enabled<br />
:; can archive : true if the current item in list is archivable. outside the list it refers to the current folder.<br />
:; is new : true if the current item in list is flagged as "new"<br />
:; accounts : semicolon-separated list of username of all accounts. By specifying an additional parameter '''groups''' you'll get only groups. Respectively, a parameter '''users''' will give you only non-group accounts.<br />
:; stop spiders : true if ''stop spider'' option is enabled.<br />
:; protocolon : expands to <tt>http&#58;//</tt> unless you enabled option ''URLs starting with https'' in which case it expands to <tt>https&#58;//</tt> (please notice the final S).<br />
:; speed limit : gives the current global speed limit, as a number (in KB/s).<br />
:; agent : Tells the user's browser. E.g., Firefox expands to Mozilla and IE8 will expand to MSIE 8.0.<br />
<br />
; urlvar | A : url variable. Let's say in the url you see <tt>?sort=s</tt> and you want to know that '''s''', just use the macro ''urlvar|sort''.<br />
: Optional parameter ''var'' will put the resulting text in the specified variable.<br />
; postvar | A : just as ''urlvar'' but reads the value from the POST part of the request instead of the URL.<br />
: Optional parameter ''var'' will put the resulting text in the specified variable.<br />
; header | A : get any value from the HTTP request header. A is the name of the header field. This is something mostly for techies. Don't fret if you don't even know what the header is.<br />
; time | A : returns current time information. The format is specified by optional parameter A. Refer to [[HFS: Time format#Text formatting|this page]] for format syntax. If A is not supplied, value "c" will be used.<br />
: Optional parameter ''when'' to [[HFS: Time format#Numerical format|specify a time]] other than current.<br />
: Optional parameter ''offset'' to specify the number of days differing from the current time.<br />
<br />
; cookie | A : expands to the value A passed by the browser.<br />
: With an optional parameter ''value'' you will set a new value.<br />
: Every known standard parameter for cookies is accepted, as ''expires'' and ''path''. Expires can be expressed in many ways: if it starts with '''+''' or '''-''' will be the number of days in the future or in the past. If it's a number will be considered as unix time format or [[HFS: Time format#Numerical format|HFS format]]. You can even specify it as a date: <tt>2/4/2013</tt>.<br />
: Example: <tt>{.cookie|step.}</tt> will give you the current value<br />
: Example: <tt>{.cookie|step|value=3|expires=+30.}</tt> will set ''step'' to ''3'' and the cookie will expire in 30 days.<br />
: Setting a cookie can also be accomplished by using {.add header.} with Set-Cookie.<br />
<br />
== Data manipulation ==<br />
; substring | A | B | C : cut C from A to B, with B not included. <br />
: Example: <tt>substring|(|belong|you (are) belong to us.}</tt> will be <tt>(are)</tt>.<br />
: If A is not specified, C is taken from the start. If B is not specified, C is taken to the end.<br />
: Optional parameter ''case=1'' to turn on case sensitivity.<br />
: Optional parameter ''include'' to say if A and/or B must be included. Values: 0 (none), 1 (only A), 2 (only B), 1+2 (both).<br />
<br />
; cut | A | B | C : cut C from position A, for B characters. The difference with macro ''substring'' is that here you specify where to cut by numeric positions.<br />
: Example: <tt>cut|2|3|abcdef</tt> will expand to <tt>bcd</tt><br />
: If you don't specify A, it defaults to 1. If you don't specify B, it defaults to the length of C.<br />
: If A is negative, then you are counting backward from the end of C. If B is negative, then you are considering the length of C minus the amount of B.<br />
: Optional parameter ''to'' will let you specify the number of character to cut. B is ignored in this case.<br />
: Optional parameter ''var'' specifies the variable name to work on. Use it instead of C.<br />
: You can use named parameter ''from'' instead of A, ''size'' instead of B, and ''what'' instead of C.<br />
: Example: <tt>cut|from=3|size=2|abcdef</tt> will expand to <tt>cd</tt><br />
<br />
; repeat | A | B : repeat B for A times. Example: for A=5 and B=+ the result is +++++<br />
<br />
; upper | A : returns A with all letters uppercased. Example: for A=Hello the result is HELLO<br />
<br />
; lower | A : returns A with all letters lowercased. Example: for A=Hello the result is hello<br />
<br />
; trim | A : returns A with any leading and trailing space removed<br />
<br />
; replace | A | B | C : returns C with every A replaced with B. This command can apply multiple replacements by having multiple pairs of parameters A-B. But you always need to have a final parameter C, that's the text that will be manipulated.<br />
: Optional parameter ''var'' in place of parameter C will make use of the specified variable as both input and output.<br />
<br />
; calc | A : return the result of the mathematical expression A. Example: for 1+(5/2) the result is 3.5<br />
: supported operators are <tt>+ - * / %</tt> (as modulus)<br />
; round | A | B : returns rounded value of A, where A is a non-integer number, and B is the number of digits after the decimal point. B is zero by default if not specified.<br />
<br />
; add | A | B : returns A+B where A and B are numbers<br />
<br />
; sub | A | B : returns A-B where A and B are numbers<br />
<br />
; mul | A | B : returns A*B where A and B are numbers<br />
<br />
; div | A | B : returns A/B where A and B are numbers<br />
<br />
; mod | A | B : returns A modulus B where A and B are numbers<br />
<br />
; min | A | B ... : returns the minimum over all parameters. You can have more than 2 parameters.<br />
<br />
; max | A | B ... : returns the maximum over all parameters. You can have more than 2 parameters.<br />
<br />
; count substring | A | B : tells the number of times A is present in B (case sensitive)<br />
<br />
; encodeuri | A : all characters are encoded in the %XX form used for URLs, except alphanumerics and <tt>#/,&?:$@=+</tt><br />
;: You can add more characters to the set that will be encoded by using the optional parameter ''add'', as well as you can decide to exclude some characters by using the optional parameter ''not''.<br />
;: You can also decide to specify the whole set, one by one, with optional parameter ''only''.<br />
;: In all these optional parameters you can specify many characters just by having them as a string, one after another.<br />
<br />
; decodeuri | A : all encoded characters in the form %XX are decoded.<br />
<br />
; convert | A | B | C<br />
: converts C from charset A to charset B. At the moment only supported charsets are ''ansi'' and ''utf-8''. <br />
<br />
; force ansi | A : if template is using UTF-8 charset, then A is converted to ANSI. Otherwise A is left unchanged.<br />
<br />
; maybe utf8 | A : if template is using UTF-8 charset, then A is converted to UTF-8. Otherwise A is left unchanged.<br />
<br />
; 123 if 2 | A | B | C : returns nothing if B is false/empty, otherwise a concatenation of ABC.<br />
<br />
; chr | A | B ... : returns characters with ANSI code A, B, etc. Numbers are decimal. To use hex numbers, precede them with an "x".<br />
: Example: {.chr|13|10|x0D|x0A.}<br />
<br />
; js encode | A | B<br />
: Encodes characters specified by B using javascript encoding for strings, in text A. If you mean to encode characters ''a'' and ''b'', parameter B should simply be ''ab''.<br />
: If B is not specified, characters encoded are only single-quote and double-quotes. This is supposed to be the frequently used case, when you are passing some data into a javascript string that's enclosed in any form of quotes.<br />
<br />
== Variables and functions ==<br />
; set | A | B<br />
: what you actually do is to bind B to the name A. You can later recall B by passing A to the macro call.<br />
: If you are used to programming, you may know what variables and functions are. In such case, consider that '''set|x|1''' is similar to a variable '''x''' with value '''1'''. By binding to ''x'' something more complex, with parameters, you are creating a function. The first parameter is '''$1''', the second '''$2''', and so on, that you can specify inside the body ''B''.<br />
: Remember to use quoting if you use macros in the body (B).<br />
: Example: <tt>{.set|x|1.}</tt> or <tt>{.set|double|{:{.mul|$1|2.}:}.}</tt><br />
: Optional parameter ''var'' will let you copy variables.<br />
: Example: <tt>{.set|y|var=x.}</tt><br />
: Optional parameter ''mode'' can be <tt>append</tt> or <tt>prepend</tt>, to concatenate existing content of the variable to the new content, as AB or BA.<br />
: Example: <tt>{.set|x| is a good boy|mode=append.}</tt><br />
<br />
; call | A | B | C | ... : this macro (shortcut by '''^''') expands to the value bound to A. Such value can be a number or a text, doesn't matter. If the value contains symbols '''$1''' and '''$2''', then they are replaced with the parameters B and C (and so on).<br />
: Example referring to above: <tt>{.call|double|15.}</tt> will expand to <tt>30</tt><br />
: You can find some examples for ''set'' and ''call'' [http://www.rejetto.com/forum/index.php?topic=5353.msg1031074#msg1031074 on the forum].<br />
<br />
; inc | A | B : if A is a variable with numeric value, then its value is incremented by the number B. If B is omitted, it defaults to 1.<br />
<br />
; dec | A | B : just as the ''inc'' above, but the value is decremented<br />
<br />
; count | A<br />
: each call returns and increments A, so the sequence will be 0 1 2 3...<br />
: variable A is not actually a variable, you can't access it throught {.^A.} and its value can be retrieved only through another call to ''count''. <br />
<br />
; from table | A | B<br />
: A is the table and B is the key. The table is a variable or a section with this form<br />
<pre>key1=value1<br />
key2=value2<br />
key3=value3</pre><br />
: Let's say such text is the content of variable ''foo'', then to get <tt>value2</tt> you should do <tt>{.from table|foo|key2.}</tt>. (yes, poetry)<br />
: If it was the content of table [bar] instead, then you should do <tt>{.from table|$bar|key2.}</tt>.<br />
<br />
; set table | A | B<br />
: it's the counterpart of ''from table''. A is the name of the table, while B is in the form ''key=value''.<br />
: If the key already exists, it's replaced, added otherwise.<br />
: Example: <tt>set table|foo|key2=new value</tt><br />
: Loading entire database-like TXT files can be achieved by replacing A with the database path:<br />
:: <tt>{.for each|value|{.replace|;|{.no pipe||.}|{.load| A .}.}|{:{.if|{.^value.}|{:{.set table|table|{.^value.}.}:}.}:}.}</tt><br />
:: The database file must use the syntax of <tt>key1=value1;key2=value2;key3=value3;</tt><br />
<br />
; cache | A | B | C<br />
: expands to retrieved value B from cache-table A. If not found, the new value C will be set. You can quote C if you need it.<br />
: This is a very useful tool when C takes too much time and you want to be sure you will do it only once.<br />
: Example: <tt><nowiki>{.cache|#countries|%ip%|{:{.load|http://server/giveMeTheCoutry?ip=%ip% .}:}.}</nowiki></tt><br />
<br />
; var domain | A<br />
: returns a list of all variable names starting with prefix A, separated by |.<br />
: Optional parameter ''separator'' to specify a different separator.<br />
: Optional parameter ''get=values'' will return variable values instead of names.<br />
<br />
== Localization ==<br />
Here goes a macro useful for template localization.<br />
<br />
Inside the template you can use identifiers (IDs) instead of real text. So you can gather all the text in one place, and ease the work of whom wants to translate to another language.<br />
<br />
Lets say that you have a link '''<a href ='..'>Go up one level</a>'''. You can replace with '''<a href ='..'>{.!up.}</a>''', moving the text to section '''[special:strings]'''.<br />
[special:strings]<br />
up=Go up one level<br />
<br />
You can optionally provide a parameter (like ''<nowiki><br />
{.!up|Go to parent folder.}</nowiki>'') that will be the default text in case '''up''' is not found in '''[special:strings]'''.<br />
<br />
<br />
If no parameter is provided, then the ID itself will be used as default text.<br />
<br />
== File manipulation ==<br />
Consider most of these macros work only with operating system oriented paths, not the ones of the virtual file system.<br />
<br />
; load | A : you'll love this one. You can specify A as a file name, or as a URL. It will load and expand to it. The file or URL you specify must be accessible from the server machine. A can be <tt>C:\windows\win.ini</tt> or also <tt><nowiki>http://another_hfs_in_lan/the_file_i_want.txt</nowiki></tt>.<br />
: With an optional parameter ''var'' you can specify the name of a variable where the whole content of the file will be stored. In such case, the macro will not expand to the content of the file, it's just in the var.<br />
: Optional parameter ''from'' to specify an offset from where to start reading.<br />
: Optional parameter ''size'' to specify how much to read.<br />
: Optional parameter ''to'' to specify the last byte to read, as an offset from the beginning.<br />
: All parameters ''from, size'' and ''to'' are expressed as number of bytes.<br />
: Example: {.load|document.txt|var=mytext.} or <tt><nowiki>{.load|http://www.domain.tld/test.txt.}</nowiki></tt><br />
<br />
; filesize | A : tells you the size in bytes of the file A. At the moment URL are not supported, only local filenames.<br />
<br />
; save | A | B : stores B to file path A. The path can be absolute, URI based or relative to HFS folder.<br />
: You can supply an optional parameter ''var'' instead of B, and the content of the specified variable will be saved.<br />
<br />
; append | A | B : add B at the end of file A. This may is also useful to keep special logs.<br />
<br />
; delete | A : moves the file A to the recycle bin.<br />
: Optional parameter ''forced=1'' will force deletion in case the bin is not available.<br />
: Optional parameter ''bin=0'' will delete the file permanently instead of moving to the recycled bin.<br />
<br />
; rename | A | B : renames the file A to B. Files can be specified with their disk path or in the URI form.<br />
<br />
; md5 file | A : computes and expands to the MD5 hash for file A.<br />
<br />
; copy | A | B : copies file A to B, where B can be a folder or a full path+filename. A can eventually be specified in the URI form.<br />
; move | A | B : as ''copy'', but A is moved instead of duplicated.<br />
<br />
; chdir | A : changes the current [http://en.wikipedia.org/wiki/Working_directory working directory] of the HFS process.<br />
; mkdir | A : creates the specified folder. URI is supported in A, but it must refer a real folder.<br />
<br />
; exists | A : checks A for existence, may it be a file or folder.<br />
; is file | A : checks A for existence as a file.<br />
<br />
; filename | A : returns only the filename part of A, removing eventual path information.<br />
; filepath | A : returns only the path of A, removing the file name.<br />
; filetime | A : returns timestamp for file A, express in [[HFS:_Time_format#Numerical_format|the usual format]].<br />
<br />
; disk free | A : returns available disk space for specified path in bytes. For example, to display available disk space for drive C:\ in Gigabytes use : {.round|{.div| {.disk free|C:\.} | 1073741824.}|2.}<br />
<br />
; dir | A : lists all the files found at path A, separated by |.<br />
: Optional parameter ''separator'' to specify a different separator.<br />
<br />
; file changed | A : returns true if file A has changed since last time checked (with this same command).<br />
: Optional second parameter will specify a variable name where to load the content of file A if the check returns true.<br />
<br />
== Virtual File System manipulation ==<br />
; add folder | A | B | C<br />
: adds a folder to the virtual file system. A specifies ''real'' or ''virtual'', while B is the name of the folder.<br />
: For real folders B should be the path on disk, but if published name is different than the real one, you can specify the path in parameter B, and the name in C.<br />
: Where in place of a simple name, you specify a virtual path, it will be used to place the folder (otherwise it will be place on the root).<br />
: Any existent folder with same name will be overwritten, unless you specify a parameter <tt>overwrite=0</tt>.<br />
: Example: <tt>{.add folder|virtual|/personal/my pictures.}</tt><br />
:: a virtual folder "my pictures" will be added under existing folder "personal".<br />
: Example: <tt>{.add folder|real|C:\music|my music|overwrite=0.}</tt><br />
:: folder on hard disk C:\music is published with public "my music". If a folder with same name is in the VFS, it's left untouched and no new folder is created.<br />
<br />
; set item | A<br />
: modifies the item A in the virtual file system by using any of these optional parameters<br />
:; hide : set to 1/0 to decide item visibility<br />
:; hide tree : set to 1/0 to decide item visibility and sub-items<br />
:; no log : set to 1/0 to decide item logging<br />
:; not as download : set 1/0, it's the same as ''don't consider as a download''. For folders, set it to ''*'' for all files, or any other file mask you want.<br />
:; comment : set the comment<br />
:; resource : Set the resource. It's the physical path for files and real folders, or the URL for links.<br />
:; archivable : Set whether the folder is archivable or not.<br />
:; browsable : Set whether or not the folder is browsable.<br />
:; download forbidden : Set whether or not to forbid downloading from this folder<br />
:; files filter : Show only certain files in the folder.<br />
:; folders filter : Show only certain folders in the folder.<br />
:; diff template : Change the diff template of a vfs item.<br />
: Example: <tt>{.set item|private files|hide=0|comment=you should never see this!.}</tt><br />
:; access / delete / upload<br />
:;: you can set permissions on the item, by specifying a list of usernames.<br />
:;: Example: <tt>set item|videos|upload=robert</tt> will give account ''robert'' the ability to upload files in ''/videos''.<br />
:;: Moreover, you can prefix permission by '''add''' or '''remove'''. In the previous example you set the ''upload'' permission. If ''mike'' already had upload permission, it is now lost. To '''add''' ''robert'' instead of just overwriting, you should <tt>{.set item|videos|add upload=robert.}</tt>. Now ''mike'' is happy too. As well, if you change your mind, and want to revoke your grant, just <tt>set item|videos|remove upload=robert</tt>.<br />
:;: You can specify more than one username this way: '''robert;mike;rupert'''.<br />
:;: Special usernames are '''@anonymous @any account @anyone'''.<br />
<br />
; get item | A | B<br />
: retrieves information B about VFS item specified by A.<br />
: Supported values for B are: ''exists, comment, resource, hide, hide tree, no log, not as download, access, upload, delete''.<br />
: Example: <tt>{.get item|/putYourFilesHere|upload.}</tt> will tell you who is allowed to upload files in that folder.<br />
<br />
; vfs select | A<br />
: A specifies what VFS item to select, but it's optional. If no parameter is provided, the currently selected item is returned.<br />
: If A is ''next'', the item coming after the current selection becomes the new selection.<br />
: If A is a named parameter ''path'', then you are specifying what item to select in the URI form.<br />
: Example: <tt>{.vfs select| path=/ .}</tt> will reset selection to the home/root, and looping through <tt>{.vfs select| next .}</tt> will select every VFS item, until <tt>{.vfs select.}</tt> is false (an empty string).<br />
<br />
; vfs to disk | A : a web path (URI) is converted to its related drive path. Relative paths like <tt>..</tt> are calculated based on the VFS folder where the script is running.<br />
<br />
== Connections control ==<br />
; disconnect | A | B : with no parameters, it disconnects current connection. If A is supplied, it is considered an [[HFS: IP masks|IP mask]], and every connection matching it (instead of the current one) will be disconnected. If also B is supplied, it will select only connections with port number same as B.<br />
<br />
; set speed limit for connection | A : set a speed limit A in KB/s for the current connection<br />
<br />
; set speed limit for address | A | B : set a speed limit B in KB/s for all connections coming from address A (no masks allowed).<br />
: When A is omitted, then it actually sets the value for the option ''Speed limit for single address'' in the GUI.<br />
<br />
; disconnection reason | A<br />
: this ''reason'' determines if a download must be aborted. Any value will abort the download, but if the value is empty the download goes on.<br />
: This macro will always return the value of the ''reason'' just before its call. So with a single call you are reading and setting the value. If no parameter is specified, then you are only reading.<br />
: Optional named parameter ''if=CONDITION'' is a shortcut for <tt>{.if|CONDITION|{:{.disconnection reason.}:}.}</tt><br />
: Example: <tt>{.disconnection reason|Try firefox|if={.{.get|agent.} != Mozilla.}.}</tt><br />
<br />
; add header | A : adds line A to the [http://en.wikipedia.org/wiki/HTTP_header HTTP header].<br />
<br />
; redirect | A : tells the browser to change to a different address (the specified one).<br />
<br />
; current downloads<br />
: expands to the number of current downloads. <br />
: Optional named parameter ''user'' will count only downloads made by specified user.<br />
: Optional named parameter ''ip'' will count only downloads made by the specified address.<br />
: Optional parameter ''file=this'' will count only downloads of this current file.<br />
: Example: <tt>{.current downloads|user=%user%|file=this.}</tt> will tell you how many connections this user is using to download this same file.<br />
<br />
; current downloads of file<br />
: number of current downloads of current file. <br />
: If an unnamed optional parameter is specified, it is used as [[HFS: IP masks|IP mask]], and only matching connections will be counted.<br />
: If the parameter is given name ''user'', only connections by such user will be counted.<br />
<br />
== Account manipulation ==<br />
; set account | A | ...<br />
: with this command you can change all attributes of the account whose username is specified in first parameter. If the username is left empty, current username is used, given this makes sense in current context.<br />
: Other parameters are the attributes you want to change, in the form <tt>set account|username|thing=value|thing2=value2</tt>.<br />
: Here is a list of such attributes<br />
:;password : set a new password<br />
:;newname : set a new username<br />
:;redirect : set the homonymous field<br />
:;no limits : set the homonymous field (true/false)<br />
:;enabled : set the homonymous field (true/false)<br />
:;is group : set the homonymous field (true/false)<br />
:;member of : set the ''member of'' field (specify more than one group separating by semicolons ";" )<br />
:;add member of : add more groups to the above<br />
:;remove member of : remove some groups to the above<br />
:;notes : set the homonymous field<br />
:;notes key <br />
:;: set the notes as it was a table with <tt>{.set table.}</tt><br />
:;: Example: <tt>{.set account|mike|notes key=last time=%timestamp%.}</tt><br />
<br />
; new account | A | ...<br />
: creates a new account with username A. After the username, you can also specify all the values available in the ''set account'' macro.<br />
<br />
;'' '' delete account | A<br />
: delete specified account (by username).<br />
<br />
; get account | A | B<br />
: expands to the value of property B of account A. <br />
: Supported value for B are ''redirect, no limits, enabled, is group, member of, notes, notes key''. Group names for ''member of'' are semicolon-separated. Special case for ''notes key'' where you should specify the key to retrieve, while the notes are treated as a table, just as for <tt>{.from table.}</tt>.<br />
: If A is omitted, current username is used, given this makes sense in current context.<br />
<br />
; member of | A<br />
: true if the current user is member of group A (specify more than one group separating by semicolons ";").<br />
: Optional parameter ''user'' to check a different user.<br />
: Example <tt>member of|administrators|user=rejetto</tt><br />
: If A is omitted, you will get the full membership for current (or specified) user. This is different from <tt>{.get account||member of.}</tt> because this latter form will consider only direct first-level membership, while <tt>{.member of.}</tt> will actually consider membership at any level.<br />
<br />
== Others ==<br />
; comment | A : this is just discarded. It's for your convenience, to put a comment in the template. HTML comments are readable by visitors if they use ''show html source'' in their browser. Using this macro you will have comments that will never leave your server.<br />
<br />
; length | A : if A is 5 characters length, like <tt>abcde</tt>, it expands to 5.<br />
: Optional parameter ''var'' in place of A, will work on the specified variable instead of considering A as text.<br />
<br />
; match | A | B : it is true if the content B is matched by [[HFS: File masks|the mask]] A.<br />
<br />
; match address | A | B : just like the macro ''match'', but the mask supports ip ranges like 10.0.0.1-10.0.0.25<br />
<br />
; random | A | B | C | ... : it expands to any of the parameters, randomly<br />
<br />
; random number | A | B : if only A is specified then a number between 0 and A is generated. If also B is specified then the number will be between A and B (included).<br />
<br />
; pos | A | B : expands to the position of A in B. Zero if not found. <br />
: Optional parameter ''from'' will start searching from specified position.<br />
: Optional parameter ''case'' will decide case sensitivity. Default is: insensitive.<br />
: Example <tt>pos|the|i'm the alpha and the omega|from=14|case=1</tt> expands to <tt>19</tt><br />
<br />
; regexp | A | B<br />
: Try to [http://en.wikipedia.org/wiki/Regular_expressions match pattern] A on text B.<br />
: When the pattern doesn't match, it just expands to nothing (then, false).<br />
: When it does, the matched sub-pattern is returned.<br />
: You can provide optional parameter ''var'' instead of B, and the text will be the content of the specified variable.<br />
: Optional parameter ''case'' will determine case sensitivity. (off by default)<br />
: Optional parameter ''sub'' will specify the name of a variable that will be set as a table, where you can retrieve every sub-pattern by numerical index.<br />
: If optional parameter ''replace=YYY'' is used, the command returns no more the matched pattern, but the whole text B with every matched pattern replaced by YYY. If you use ''replace'' and ''var'' together, the resulting text will not be returned, but stored in the specified input variable (that means, it's used both for input and output).<br />
: Example: <tt>regexp|\d+|var=weWantNumbers</tt><br />
<br />
; breadcrumbs | A<br />
: builds a [http://en.wikipedia.org/wiki/Breadcrumb_(navigation) breadcrumbs] based on the current folder path. The A is a little html template that is repeated for every piece of the path, for which 3 symbols are provided: ''%bread-url%'' , ''%bread-name%'' and ''%bread-idx%''. <br />
: Remember to use quoting, especially if you use macros in the parameter.<br />
: Optional parameter ''from'' will let you specify how many steps of the path to skip.<br />
: Example: <tt>{.breadcrumbs|{:<a href ="%bread-url%">%bread-name%/</a>:}.}</tt><br />
<br />
; dialog | A | B | C<br />
: display a server-side message in a dialog box. A is the message itself, and only required parameter. B are options separated by spaces, and C a title for the dialog.<br />
: Possible options are<br />
:;okcancel : offers buttons OK and CANCEL<br />
:;yesno : offers buttons YES and NO<br />
:;yesnocancel : offers buttons YES, NO and CANCEL<br />
:;error : this is an error reporting dialog<br />
:;question : this is a questioning dialog<br />
:;warning : this is a warning dialog<br />
:;information : this is an informational dialog<br />
<br />
; mime | A : set the mime-type sent to the browser. It describes the nature of the content. For techies, it's the value of the header field "Content-type".<br />
<br />
; any macro marker | A : it is true if any macro marker is present in A. Macro markers are {.delimiters.} , {:quotings:} and the parameters separator (the pipe, "|").<br />
<br />
; play system event | A : specify the name of the event bound to a sound that you want to play. ''SystemStart'' and ''MailBeep'' are just examples, for a full list you can open your registry at ''HKEY_CURRENT_USER\AppEvents\EventLabels'' .<br />
<br />
; exec | A : ask system to run file A, eventually with parameters. If you need to use the pipe, then use macro quoting.<br />
: Optional parameter ''out'' will let you capture the console output of the program in the variable specified by name.<br />
: Optional parameter ''timeout'' will specify the max number of seconds the app should be left running.<br />
: Example: <tt>{.exec|notepad.}</tt><br />
<br />
; add to log | A : add A to the log panel. <br />
: Optional parameter ''color'' to [[HFS: color format|specify the color]].<br />
<br />
; get ini | A<br />
: where A is a text in the same format you can find in ''hfs.ini'' (save options -> to file).<br />
: example: <tt>{.get ini|speed limit.}</tt> will return the global speed limit, if any.<br />
<br />
; set ini | A<br />
: where A is a text in the same format you can find in ''hfs.ini'' (save options -> to file).<br />
: example: <tt>{.set ini|speed limit=100.}</tt> will turn the global speed limit to 100KB/s.<br />
<br />
; focus<br />
: will bring HFS window on front of the user.<br />
<br />
; load tpl | A : for this connection only, template A will be used.<br />
: Example: <tt>{.if| it's a mobile | {:{.load tpl|mobile.tpl.}:} /if.}</tt><br />
<br />
; notify | A<br />
: The message A will come out as a balloon over the HFS tray icon.<br />
: Optional parameter ''title'' will let you specify the title of the balloon.<br />
: Optional parameter ''timeout'' specifies the amount of time to show the message.<br />
: Optional parameter ''type'' will show an icon according to its value. Allowed values are ''info, error'' and ''warning''.<br />
<br />
== Shortcuts ==<br />
;$A : is a shortcut for '''section | A'''<br />
;?A : is a shortcut for '''urlvar | A'''<br />
;^A : is a shortcut for '''call | A'''<br />
;A = B : is a shortcut for '''=|A|B'''<br />
;?name = X : is a shortcut for <tt>{.?name.} = X</tt> .<br />
: It works also for '''<> != < <= > >=''' .</div>
Rejetto
https://rejetto.com/wiki/index.php?title=User_talk:Evanshead&diff=5580
User talk:Evanshead
2014-07-19T18:47:04Z
<p>Rejetto: Welcome!</p>
<hr />
<div>'''Welcome to ''rejetto wiki''!'''<br />
We hope you will contribute much and well.<br />
You will probably want to read the [[Help:Contents|help pages]].<br />
Again, welcome and have fun! [[User:Rejetto|rejetto]] ([[User talk:Rejetto|talk]]) 13:47, 19 July 2014 (CDT)</div>
Rejetto
https://rejetto.com/wiki/index.php?title=User:Evanshead&diff=5579
User:Evanshead
2014-07-19T18:47:04Z
<p>Rejetto: Creating user page for new user.</p>
<hr />
<div></div>
Rejetto
https://rejetto.com/wiki/index.php?title=User_talk:Killajae&diff=5578
User talk:Killajae
2014-07-19T18:47:00Z
<p>Rejetto: Welcome!</p>
<hr />
<div>'''Welcome to ''rejetto wiki''!'''<br />
We hope you will contribute much and well.<br />
You will probably want to read the [[Help:Contents|help pages]].<br />
Again, welcome and have fun! [[User:Rejetto|rejetto]] ([[User talk:Rejetto|talk]]) 13:47, 19 July 2014 (CDT)</div>
Rejetto
https://rejetto.com/wiki/index.php?title=User:Killajae&diff=5577
User:Killajae
2014-07-19T18:47:00Z
<p>Rejetto: Creating user page for new user.</p>
<hr />
<div></div>
Rejetto
https://rejetto.com/wiki/index.php?title=User_talk:Manusol&diff=5576
User talk:Manusol
2014-07-19T18:46:25Z
<p>Rejetto: Welcome!</p>
<hr />
<div>'''Welcome to ''rejetto wiki''!'''<br />
We hope you will contribute much and well.<br />
You will probably want to read the [[Help:Contents|help pages]].<br />
Again, welcome and have fun! [[User:Rejetto|rejetto]] ([[User talk:Rejetto|talk]]) 13:46, 19 July 2014 (CDT)</div>
Rejetto
https://rejetto.com/wiki/index.php?title=User:Manusol&diff=5575
User:Manusol
2014-07-19T18:46:25Z
<p>Rejetto: Creating user page for new user.</p>
<hr />
<div>Vet for life (an inherited passion).<br />
Technician in disassemble and resemblé. Antique Hi-fi appliances, to return them to life and past splendor. Vinils and tapes.<br />
New tech, a minute in an hour, for an hour in a day. For one month in a year.</div>
Rejetto
https://rejetto.com/wiki/index.php?title=User_talk:Skytrooper&diff=5574
User talk:Skytrooper
2014-05-04T11:09:05Z
<p>Rejetto: Welcome!</p>
<hr />
<div>'''Welcome to ''rejetto wiki''!'''<br />
We hope you will contribute much and well.<br />
You will probably want to read the [[Help:Contents|help pages]].<br />
Again, welcome and have fun! [[User:Rejetto|rejetto]] ([[User talk:Rejetto|talk]]) 06:09, 4 May 2014 (CDT)</div>
Rejetto
https://rejetto.com/wiki/index.php?title=User:Skytrooper&diff=5573
User:Skytrooper
2014-05-04T11:09:05Z
<p>Rejetto: Creating user page for new user.</p>
<hr />
<div></div>
Rejetto
https://rejetto.com/wiki/index.php?title=User_talk:Mohamed&diff=5572
User talk:Mohamed
2014-04-26T16:00:28Z
<p>Rejetto: Welcome!</p>
<hr />
<div>'''Welcome to ''rejetto wiki''!'''<br />
We hope you will contribute much and well.<br />
You will probably want to read the [[Help:Contents|help pages]].<br />
Again, welcome and have fun! [[User:Rejetto|rejetto]] ([[User talk:Rejetto|talk]]) 11:00, 26 April 2014 (CDT)</div>
Rejetto
https://rejetto.com/wiki/index.php?title=User:Mohamed&diff=5571
User:Mohamed
2014-04-26T16:00:27Z
<p>Rejetto: Creating user page for new user.</p>
<hr />
<div></div>
Rejetto
https://rejetto.com/wiki/index.php?title=User_talk:Marsan&diff=5570
User talk:Marsan
2014-03-26T00:01:30Z
<p>Rejetto: Welcome!</p>
<hr />
<div>'''Welcome to ''rejetto wiki''!'''<br />
We hope you will contribute much and well.<br />
You will probably want to read the [[Help:Contents|help pages]].<br />
Again, welcome and have fun! [[User:Rejetto|rejetto]] ([[User talk:Rejetto|talk]]) 19:01, 25 March 2014 (CDT)</div>
Rejetto
https://rejetto.com/wiki/index.php?title=User:Marsan&diff=5569
User:Marsan
2014-03-26T00:01:29Z
<p>Rejetto: Creating user page for new user.</p>
<hr />
<div>eu si atit</div>
Rejetto
https://rejetto.com/wiki/index.php?title=User_talk:Rohail&diff=5568
User talk:Rohail
2014-03-23T23:09:04Z
<p>Rejetto: Welcome!</p>
<hr />
<div>'''Welcome to ''rejetto wiki''!'''<br />
We hope you will contribute much and well.<br />
You will probably want to read the [[Help:Contents|help pages]].<br />
Again, welcome and have fun! [[User:Rejetto|rejetto]] ([[User talk:Rejetto|talk]]) 18:09, 23 March 2014 (CDT)</div>
Rejetto
https://rejetto.com/wiki/index.php?title=User:Rohail&diff=5567
User:Rohail
2014-03-23T23:09:04Z
<p>Rejetto: Creating user page for new user.</p>
<hr />
<div></div>
Rejetto
https://rejetto.com/wiki/index.php?title=User_talk:Vagrantlikee&diff=5566
User talk:Vagrantlikee
2014-03-05T21:27:00Z
<p>Rejetto: Welcome!</p>
<hr />
<div>'''Welcome to ''rejetto wiki''!'''<br />
We hope you will contribute much and well.<br />
You will probably want to read the [[Help:Contents|help pages]].<br />
Again, welcome and have fun! [[User:Rejetto|rejetto]] ([[User talk:Rejetto|talk]]) 15:27, 5 March 2014 (CST)</div>
Rejetto
https://rejetto.com/wiki/index.php?title=User:Vagrantlikee&diff=5565
User:Vagrantlikee
2014-03-05T21:27:00Z
<p>Rejetto: Creating user page for new user.</p>
<hr />
<div></div>
Rejetto
https://rejetto.com/wiki/index.php?title=User_talk:Vagrantlike&diff=5564
User talk:Vagrantlike
2014-03-03T21:11:56Z
<p>Rejetto: Welcome!</p>
<hr />
<div>'''Welcome to ''rejetto wiki''!'''<br />
We hope you will contribute much and well.<br />
You will probably want to read the [[Help:Contents|help pages]].<br />
Again, welcome and have fun! [[User:Rejetto|rejetto]] ([[User talk:Rejetto|talk]]) 15:11, 3 March 2014 (CST)</div>
Rejetto
https://rejetto.com/wiki/index.php?title=User:Vagrantlike&diff=5563
User:Vagrantlike
2014-03-03T21:11:56Z
<p>Rejetto: Creating user page for new user.</p>
<hr />
<div></div>
Rejetto
https://rejetto.com/wiki/index.php?title=User_talk:Cato33&diff=5562
User talk:Cato33
2014-03-02T12:01:02Z
<p>Rejetto: Welcome!</p>
<hr />
<div>'''Welcome to ''rejetto wiki''!'''<br />
We hope you will contribute much and well.<br />
You will probably want to read the [[Help:Contents|help pages]].<br />
Again, welcome and have fun! [[User:Rejetto|rejetto]] ([[User talk:Rejetto|talk]]) 06:01, 2 March 2014 (CST)</div>
Rejetto
https://rejetto.com/wiki/index.php?title=User:Cato33&diff=5561
User:Cato33
2014-03-02T12:01:02Z
<p>Rejetto: Creating user page for new user.</p>
<hr />
<div></div>
Rejetto
https://rejetto.com/wiki/index.php?title=User_talk:Romrod&diff=5560
User talk:Romrod
2014-02-07T23:09:33Z
<p>Rejetto: Welcome!</p>
<hr />
<div>'''Welcome to ''rejetto wiki''!'''<br />
We hope you will contribute much and well.<br />
You will probably want to read the [[Help:Contents|help pages]].<br />
Again, welcome and have fun! [[User:Rejetto|rejetto]] ([[User talk:Rejetto|talk]]) 17:09, 7 February 2014 (CST)</div>
Rejetto
https://rejetto.com/wiki/index.php?title=User:Romrod&diff=5559
User:Romrod
2014-02-07T23:09:33Z
<p>Rejetto: Creating user page for new user.</p>
<hr />
<div>blah blah blah</div>
Rejetto
https://rejetto.com/wiki/index.php?title=User_talk:Kristof&diff=5558
User talk:Kristof
2014-01-30T12:27:54Z
<p>Rejetto: Welcome!</p>
<hr />
<div>'''Welcome to ''rejetto wiki''!'''<br />
We hope you will contribute much and well.<br />
You will probably want to read the [[Help:Contents|help pages]].<br />
Again, welcome and have fun! [[User:Rejetto|rejetto]] ([[User talk:Rejetto|talk]]) 06:27, 30 January 2014 (CST)</div>
Rejetto
https://rejetto.com/wiki/index.php?title=User:Kristof&diff=5557
User:Kristof
2014-01-30T12:27:54Z
<p>Rejetto: Creating user page for new user.</p>
<hr />
<div></div>
Rejetto
https://rejetto.com/wiki/index.php?title=User_talk:Mayk_xyz&diff=5556
User talk:Mayk xyz
2014-01-30T12:27:47Z
<p>Rejetto: Welcome!</p>
<hr />
<div>'''Welcome to ''rejetto wiki''!'''<br />
We hope you will contribute much and well.<br />
You will probably want to read the [[Help:Contents|help pages]].<br />
Again, welcome and have fun! [[User:Rejetto|rejetto]] ([[User talk:Rejetto|talk]]) 06:27, 30 January 2014 (CST)</div>
Rejetto
https://rejetto.com/wiki/index.php?title=User:Mayk_xyz&diff=5555
User:Mayk xyz
2014-01-30T12:27:46Z
<p>Rejetto: Creating user page for new user.</p>
<hr />
<div></div>
Rejetto
https://rejetto.com/wiki/index.php?title=User_talk:Archi&diff=5554
User talk:Archi
2014-01-30T12:27:14Z
<p>Rejetto: Welcome!</p>
<hr />
<div>'''Welcome to ''rejetto wiki''!'''<br />
We hope you will contribute much and well.<br />
You will probably want to read the [[Help:Contents|help pages]].<br />
Again, welcome and have fun! [[User:Rejetto|rejetto]] ([[User talk:Rejetto|talk]]) 06:27, 30 January 2014 (CST)</div>
Rejetto
https://rejetto.com/wiki/index.php?title=User:Archi&diff=5553
User:Archi
2014-01-30T12:27:14Z
<p>Rejetto: Creating user page for new user.</p>
<hr />
<div></div>
Rejetto
https://rejetto.com/wiki/index.php?title=User:Inco&diff=5551
User:Inco
2013-12-08T14:57:50Z
<p>Rejetto: Creating user page for new user.</p>
<hr />
<div></div>
Rejetto
https://rejetto.com/wiki/index.php?title=User:Axlenick&diff=5549
User:Axlenick
2013-12-05T16:32:20Z
<p>Rejetto: Creating user page for new user.</p>
<hr />
<div>good with computers</div>
Rejetto
https://rejetto.com/wiki/index.php?title=HFS:_scripting_commands&diff=5548
HFS: scripting commands
2013-08-24T11:25:44Z
<p>Rejetto: /* Others */ clearer</p>
<hr />
<div>Also known as template macros, these are commands with some useful effects that users can input in HFS to improve a template or to create functionality not otherwise available. <br />
<br />
Some macros simply expand to text and some perform server-side commands.<br />
<br />
Every command is expressed as a name, and sometimes parameters, separated by pipes "<tt>|</tt>".<br />
<br />
Following, with letters we are denoting parameters, and their meaning is explained immediately after.<br />
<br />
You should read this [http://www.rejetto.com/wiki/index.php?title=HFS:_Template_macros] before reading this page.<br />
<br />
== Logic and flow ==<br />
; if | A | B | C<br />
: if A is true, then it expands to B, else it expands to C. When it expands to B, C is just discarded, and the vice versa. C is optional.<br />
: How you tell A is true? A is true if it is not empty and not just a zero. So if A is "hi there!", then it is true.<br />
: Remember to use quoting if you use macros in B or C (the body).<br />
<br />
; if not | A | B | C <br />
: same as ''if'', but the logic is inverted. When A is true it expands to C and vice versa.<br />
<br />
; not | A : true if A is not true. It negates the value of A.<br />
<br />
; and | A | B : true if both A and B are true. In details: in the ''true'' case it returns the last parameter. You can specify as many parameters as necessary. Both Javascript and Python work this way.<br />
<br />
; or | A | B : true if any of A or B are true. In details: it returns the first ''true'' parameter (yes, it supports any number of parameters). If none of the parameters is true, then iit returns false. Both Javascript and Python work this way. Often times you can work without {.or.}, for example {.if| A B | C .} returns true if either A or B are true.<br />
<br />
; xor | A | B : true if A is true while B is false, or the opposite<br />
<br />
; = | A | B : true if A is the same as B. It's case insensitive. You can use the opposite macro, true if they are different, and it's name is '''!=''' or '''<>''' (use the one you like most, there's no difference). You can specify as many parameters as you like.<br />
<br />
; > | A | B : true if A is greater than B. Of course you can also use the related macro '''<'''. You can specify as many parameters as you like.<br />
<br />
; >= | A | B : true if A is equal or greater than B. Of course you can also use the related macro '''<='''. You can specify as many parameters as you like.<br />
<br />
; between | A | B | C : true if B is between A and C (included).<br />
<br />
; between! | A | B | C : true if B is between A and C (excluded).<br />
<br />
; switch | A | B | C | D | E | F ...<br />
: this is rather complex for non-programmers. You can learn how a switch statement is supposed to work [http://en.wikipedia.org/wiki/Switch_statement#Examples from Wikipedia]. When you know how a ''switch'' works, then you will understand this schema that will make you understand how the parameters of this macro work<br />
<pre><nowiki><br />
switch(A) {<br />
case C: return D;<br />
case E: return F;<br />
...<br />
}<br />
</nowiki></pre><br />
: The B is a separator string for C. Let's be clearer: if you want to specify several cases in C, all of them returning D, then you can specify them separating with B.<br />
: As you can see C and D are paired, as E and F, eventually G and H, and so on. If at the end of this list of pairs, a single unpaired parameter is found, then it is used as the else/default case, when all other pairs have failed.<br />
: Let me translated the first example of Wikipedia using the macro<br />
<pre><nowiki><br />
{.switch|%n%|,|<br />
0|you typed zero|<br />
3,5,7|%n% is a prime number|<br />
4,6,8|%n% is an even number|<br />
2|%n% is a prime and even number|<br />
1,9|%n% is a perfect square|<br />
Only single-digit numbers are allowed<br />
.}<br />
</nowiki></pre><br />
<br />
Switch is esentially a quick way of using many {.if.} and {.=.} commands together. For example, if A equals C then D, if A equals E then F, etc.<br />
<br />
; for | A | B | C | D | E<br />
: repeats D by replacing variable <tt>{.^A.}</tt> with every value between B and C (they are meant to be numbers).<br />
: Optionally you can specify a ''step'' for the numbers: that is, instead of going 1-by-1, they can go 2-by-2. The optional ''step'' is specified at position D; in such case the ''body'' is moved from position D to position E.<br />
: Remember to use quoting for the body.<br />
<br />
; for each | A | B | C ... | Z<br />
: a (sometimes) handier version of ''for'', that will repeat Z but replacing variable <tt>{.^A.}</tt> with value B the first time, value C the second time, D etc etc. Remember to quote the body. <br />
: example: <tt>{.for each|i|10|100|1000|{:now it's {.^i.} :}.}</tt><br />
<br />
; while | A | B<br />
: repeats B for as long as A is true. Both B is automatically dequoted. If A is quoted, then it's expanded, otherwise is considered the a variable name.<br />
: Optional parameter ''else'' will be expanded if B is never done.<br />
: Optional parameter ''timeout'' let you specify (in seconds) the maximum time the loop can live before it is stopped. It's 1 second by default.<br />
: Optional parameter ''var'' saves the output in a variable instead of just expanding to it.<br />
: Example: <tt>{.while|#x|{: {.dec|#x.} welcome! :}.}</tt> will welcome 10 times if <tt>#x</tt> is 10.<br />
<br />
; after the list | A<br />
: quoted text A is dequoted and executed, but only if the file listing is completed.<br />
<br />
; dequote | A<br />
: if A is {:quoted:} then quoting markers are removed (unleashing macro execution of the previously quoted text).<br />
<br />
; 123 if 2 | A | B | C<br />
: if B is true, it expands to ABC, otherwise nothing.<br />
: It is basically a shortcut for {.if | B |{: A B C :}.}<br />
<br />
; break : stops execution of this script.<br />
: Optional parameter ''if'' will avoid breaking in case the condition is not met (that is, when it's ''false'').<br />
: Optional parameter ''result'' will output a text only if the break occurs (makes sense only with parameter ''if'').<br />
: Using <tt>{.break|if=data.}</tt> is basically a simplified way to write <tt>{.if|data|{:{.break.}:}.}</tt><br />
<br />
== Data getting ==<br />
; section | A<br />
: A is the name of the [section] you want to include. Note: till build #160 it was case sensitive.<br />
: Optional parameter ''file'' to load the section from an external file.<br />
: Optional parameter ''back=1'' will work in diff templates to access the section in the original template. So you can access it even if you overwrote it.<br />
: Example: <tt>{.section|names|file=tables.txt.}</tt><br />
; get | A<br />
: where A is the name of a value you are interested in, like to know if an option is enabled or not.<br />
: This is a list of supported values for A:<br />
:; can upload : true if in the current folder the user is allowed to upload files. An additional parameter ''path'' will tell you about a different folder instead of the current one.<br />
:; can delete : true if the user is allowed to delete the current item. An additional parameter ''path'' will tell you about a different folder instead of the current one.<br />
:; can access : true if the current item in list is accessible by the user. An additional parameter ''path'' will tell you about a different folder instead of the current one.<br />
:; can recur : true if the option ''Recursive listing'' is enabled<br />
:; can archive : true if the current item in list is archivable. outside the list it refers to the current folder.<br />
:; is new : true if the current item in list is flagged as "new"<br />
:; accounts : semicolon-separated list of username of all accounts. By specifying an additional parameter '''groups''' you'll get only groups. Respectively, a parameter '''users''' will give you only non-group accounts.<br />
:; stop spiders : true if ''stop spider'' option is enabled.<br />
:; protocolon : expands to <tt>http&#58;//</tt> unless you enabled option ''URLs starting with https'' in which case it expands to <tt>https&#58;//</tt> (please notice the final S).<br />
:; speed limit : gives the current global speed limit, as a number (in KB/s).<br />
:; agent : Tells the user's browser. E.g., Firefox expands to Mozilla and IE8 will expand to MSIE 8.0.<br />
<br />
; urlvar | A : url variable. Let's say in the url you see <tt>?sort=s</tt> and you want to know that '''s''', just use the macro ''urlvar|sort''.<br />
: Optional parameter ''var'' will put the resulting text in the specified variable.<br />
; postvar | A : just as ''urlvar'' but reads the value from the POST part of the request instead of the URL.<br />
: Optional parameter ''var'' will put the resulting text in the specified variable.<br />
; header | A : get any value from the HTTP request header. A is the name of the header field. This is something mostly for techies. Don't fret if you don't even know what the header is.<br />
; time | A : returns current time information. The format is specified by optional parameter A. Refer to [[HFS: Time format#Text formatting|this page]] for format syntax. If A is not supplied, value "c" will be used.<br />
: Optional parameter ''when'' to [[HFS: Time format#Numerical format|specify a time]] other than current.<br />
: Optional parameter ''offset'' to specify the number of days differing from the current time.<br />
<br />
; cookie | A : expands to the value A passed by the browser.<br />
: With an optional parameter ''value'' you will set a new value.<br />
: Every known standard parameter for cookies is accepted, as ''expires'' and ''path''. Expires can be expressed in many ways: if it starts with '''+''' or '''-''' will be the number of days in the future or in the past. If it's a number will be considered as unix time format or [[HFS: Time format#Numerical format|HFS format]]. You can even specify it as a date: <tt>2/4/2013</tt>.<br />
: Example: <tt>{.cookie|step.}</tt> will give you the current value<br />
: Example: <tt>{.cookie|step|value=3|expires=+30.}</tt> will set ''step'' to ''3'' and the cookie will expire in 30 days.<br />
: Setting a cookie can also be accomplished by using {.add header.} with Set-Cookie.<br />
<br />
== Data manipulation ==<br />
; substring | A | B | C : cut C from A to B, with B not included. <br />
: Example: <tt>substring|(|belong|you (are) belong to us.}</tt> will be <tt>(are)</tt>.<br />
: If A is not specified, C is taken from the start. If B is not specified, C is taken to the end.<br />
: Optional parameter ''case=1'' to turn on case sensitivity.<br />
: Optional parameter ''include'' to say if A and/or B must be included. Values: 0 (none), 1 (only A), 2 (only B), 1+2 (both).<br />
<br />
; cut | A | B | C : cut C from position A, for B characters. The difference with macro ''substring'' is that here you specify where to cut by numeric positions.<br />
: Example: <tt>cut|2|3|abcdef</tt> will expand to <tt>bcd</tt><br />
: If you don't specify A, it defaults to 1. If you don't specify B, it defaults to the length of C.<br />
: If A is negative, then you are counting backward from the end of C. If B is negative, then you are considering the length of C minus the amount of B.<br />
: Optional parameter ''to'' will let you specify the number of character to cut. B is ignored in this case.<br />
: Optional parameter ''var'' specifies the variable name to work on. Use it instead of C.<br />
: You can use named parameter ''from'' instead of A, ''size'' instead of B, and ''what'' instead of C.<br />
: Example: <tt>cut|from=3|size=2|abcdef</tt> will expand to <tt>cd</tt><br />
<br />
; repeat | A | B : repeat B for A times. Example: for A=5 and B=+ the result is +++++<br />
<br />
; upper | A : returns A with all letters uppercased. Example: for A=Hello the result is HELLO<br />
<br />
; lower | A : returns A with all letters lowercased. Example: for A=Hello the result is hello<br />
<br />
; trim | A : returns A with any leading and trailing space removed<br />
<br />
; replace | A | B | C : returns C with every A replaced with B. This command can apply multiple replacements by having multiple pairs of parameters A-B. But you always need to have a final parameter C, that's the text that will be manipulated.<br />
: Optional parameter ''var'' in place of parameter C will make use of the specified variable as both input and output.<br />
<br />
; calc | A : return the result of the mathematical expression A. Example: for 1+(5/2) the result is 3.5<br />
: supported operators are <tt>+ - * / %</tt> (as modulus)<br />
; round | A | B : returns rounded value of A, where A is a non-integer number, and B is the number of digits after the decimal point. B is zero by default if not specified.<br />
<br />
; add | A | B : returns A+B where A and B are numbers<br />
<br />
; sub | A | B : returns A-B where A and B are numbers<br />
<br />
; mul | A | B : returns A*B where A and B are numbers<br />
<br />
; div | A | B : returns A/B where A and B are numbers<br />
<br />
; mod | A | B : returns A modulus B where A and B are numbers<br />
<br />
; min | A | B ... : returns the minimum over all parameters. You can have more than 2 parameters.<br />
<br />
; max | A | B ... : returns the maximum over all parameters. You can have more than 2 parameters.<br />
<br />
; count substring | A | B : tells the number of times A is present in B (case sensitive)<br />
<br />
; encodeuri | A : all characters are encoded in the %XX form used for URLs, except alphanumerics and <tt>#/,&?:$@=+</tt><br />
;: You can add more characters to the set that will be encoded by using the optional parameter ''add'', as well as you can decide to exclude some characters by using the optional parameter ''not''.<br />
;: You can also decide to specify the whole set, one by one, with optional parameter ''only''.<br />
;: In all these optional parameters you can specify many characters just by having them as a string, one after another.<br />
<br />
; decodeuri | A : all encoded characters in the form %XX are decoded.<br />
<br />
; convert | A | B | C<br />
: converts C from charset A to charset B. At the moment only supported charsets are ''ansi'' and ''utf-8''. <br />
<br />
; force ansi | A : if template is using UTF-8 charset, then A is converted to ANSI. Otherwise A is left unchanged.<br />
<br />
; maybe utf8 | A : if template is using UTF-8 charset, then A is converted to UTF-8. Otherwise A is left unchanged.<br />
<br />
; 123 if 2 | A | B | C : returns nothing if B is false/empty, otherwise a concatenation of ABC.<br />
<br />
; chr | A | B ... : returns characters with ANSI code A, B, etc. Numbers are decimal. To use hex numbers, precede them with an "x".<br />
: Example: {.chr|13|10|x0D|x0A.}<br />
<br />
; js encode | A | B<br />
: Encodes characters specified by B using javascript encoding for strings, in text A. If you mean to encode characters ''a'' and ''b'', parameter B should simply be ''ab''.<br />
: If B is not specified, characters encoded are only single-quote and double-quotes. This is supposed to be the frequently used case, when you are passing some data into a javascript string that's enclosed in any form of quotes.<br />
<br />
== Variables and functions ==<br />
; set | A | B<br />
: what you actually do is to bind B to the name A. You can later recall B by passing A to the macro call.<br />
: If you are used to programming, you may know what variables and functions are. In such case, consider that '''set|x|1''' is similar to a variable '''x''' with value '''1'''. By binding to ''x'' something more complex, with parameters, you are creating a function. The first parameter is '''$1''', the second '''$2''', and so on, that you can specify inside the body ''B''.<br />
: Remember to use quoting if you use macros in the body (B).<br />
: Example: <tt>{.set|x|1.}</tt> or <tt>{.set|double|{:{.mul|$1|2.}:}.}</tt><br />
: Optional parameter ''var'' will let you copy variables.<br />
: Example: <tt>{.set|y|var=x.}</tt><br />
: Optional parameter ''mode'' can be <tt>append</tt> or <tt>prepend</tt>, to concatenate existing content of the variable to the new content, as AB or BA.<br />
: Example: <tt>{.set|x| is a good boy|mode=append.}</tt><br />
<br />
; call | A | B | C | ... : this macro (shortcut by '''^''') expands to the value bound to A. Such value can be a number or a text, doesn't matter. If the value contains symbols '''$1''' and '''$2''', then they are replaced with the parameters B and C (and so on).<br />
: Example referring to above: <tt>{.call|double|15.}</tt> will expand to <tt>30</tt><br />
: You can find some examples for ''set'' and ''call'' [http://www.rejetto.com/forum/index.php?topic=5353.msg1031074#msg1031074 on the forum].<br />
<br />
; inc | A | B : if A is a variable with numeric value, then its value is incremented by the number B. If B is omitted, it defaults to 1.<br />
<br />
; dec | A | B : just as the ''inc'' above, but the value is decremented<br />
<br />
; count | A<br />
: each call returns and increments A, so the sequence will be 0 1 2 3...<br />
: variable A is not actually a variable, you can't access it throught {.^A.} and its value can be retrieved only through another call to ''count''. <br />
<br />
; from table | A | B<br />
: A is the table and B is the key. The table is a variable or a section with this form<br />
<pre>key1=value1<br />
key2=value2<br />
key3=value3</pre><br />
: Let's say such text is the content of variable ''foo'', then to get <tt>value2</tt> you should do <tt>{.from table|foo|key2.}</tt>. (yes, poetry)<br />
: If it was the content of table [bar] instead, then you should do <tt>{.from table|$bar|key2.}</tt>.<br />
<br />
; set table | A | B<br />
: it's the counterpart of ''from table''. A is the name of the table, while B is in the form ''key=value''.<br />
: If the key already exists, it's replaced, added otherwise.<br />
: Example: <tt>set table|foo|key2=new value</tt><br />
: Loading entire database-like TXT files can be achieved by replacing A with the database path:<br />
:: <tt>{.for each|value|{.replace|;|{.no pipe||.}|{.load| A .}.}|{:{.if|{.^value.}|{:{.set table|table|{.^value.}.}:}.}:}.}</tt><br />
:: The database file must use the syntax of <tt>key1=value1;key2=value2;key3=value3;</tt><br />
<br />
; cache | A | B | C<br />
: expands to retrieved value B from cache-table A. If not found, the new value C will be set. You can quote C if you need it.<br />
: This is a very useful tool when C takes too much time and you want to be sure you will do it only once.<br />
: Example: <tt><nowiki>{.cache|#countries|%ip%|{:{.load|http://server/giveMeTheCoutry?ip=%ip% .}:}.}</nowiki></tt><br />
<br />
; var domain | A<br />
: returns a list of all variable names starting with prefix A, separated by |.<br />
: Optional parameter ''separator'' to specify a different separator.<br />
: Optional parameter ''get=values'' will return variable values instead of names.<br />
<br />
== Localization ==<br />
Here goes a macro useful for template localization.<br />
<br />
Inside the template you can use identifiers (IDs) instead of real text. So you can gather all the text in one place, and ease the work of whom wants to translate to another language.<br />
<br />
Lets say that you have a link '''<a href ='..'>Go up one level</a>'''. You can replace with '''<a href ='..'>{.!up.}</a>''', moving the text to section '''[special:strings]'''.<br />
[special:strings]<br />
up=Go up one level<br />
<br />
You can optionally provide a parameter (like ''<nowiki><br />
{.!up|Go to parent folder.}</nowiki>'') that will be the default text in case '''up''' is not found in '''[special:strings]'''.<br />
<br />
<br />
If no parameter is provided, then the ID itself will be used as default text.<br />
<br />
== File manipulation ==<br />
Consider most of these macros work only with operating system oriented paths, not the ones of the virtual file system.<br />
<br />
; load | A : you'll love this one. You can specify A as a file name, or as a URL. It will load and expand to it. The file or URL you specify must be accessible from the server machine. A can be <tt>C:\windows\win.ini</tt> or also <tt><nowiki>http://another_hfs_in_lan/the_file_i_want.txt</nowiki></tt>.<br />
: With an optional parameter ''var'' you can specify the name of a variable where the whole content of the file will be stored. In such case, the macro will not expand to the content of the file, it's just in the var.<br />
: Optional parameter ''from'' to specify an offset from where to start reading.<br />
: Optional parameter ''size'' to specify how much to read.<br />
: Optional parameter ''to'' to specify the last byte to read, as an offset from the beginning.<br />
: All parameters ''from, size'' and ''to'' are expressed as number of bytes.<br />
: Example: {.load|document.txt|var=mytext.} or <tt><nowiki>{.load|http://www.domain.tld/test.txt.}</nowiki></tt><br />
<br />
; filesize | A : tells you the size in bytes of the file A. At the moment URL are not supported, only local filenames.<br />
<br />
; save | A | B : stores B to file path A. The path can be absolute, URI based or relative to HFS folder.<br />
: You can supply an optional parameter ''var'' instead of B, and the content of the specified variable will be saved.<br />
<br />
; append | A | B : add B at the end of file A. This may is also useful to keep special logs.<br />
<br />
; delete | A : moves the file A to the recycle bin.<br />
: Optional parameter ''forced=1'' will force deletion in case the bin is not available.<br />
: Optional parameter ''bin=0'' will delete the file permanently instead of moving to the recycled bin.<br />
<br />
; rename | A | B : renames the file A to B. Files can be specified with their disk path or in the URI form.<br />
<br />
; md5 file | A : computes and expands to the MD5 hash for file A.<br />
<br />
; copy | A | B : copies file A to B, where B can be a folder or a full path+filename. A can eventually be specified in the URI form.<br />
; move | A | B : as ''copy'', but A is moved instead of duplicated.<br />
<br />
; chdir | A : changes the current [http://en.wikipedia.org/wiki/Working_directory working directory] of the HFS process.<br />
; mkdir | A : creates the specified folder. URI is supported in A, but it must refer a real folder.<br />
<br />
; exists | A : checks A for existence, may it be a file or folder.<br />
; is file | A : checks A for existence as a file.<br />
<br />
; filename | A : returns only the filename part of A, removing eventual path information.<br />
; filepath | A : returns only the path of A, removing the file name.<br />
; filetime | A : returns timestamp for file A, express in [[HFS:_Time_format#Numerical_format|the usual format]].<br />
<br />
; disk free | A : returns available disk space for specified path in bytes. For example, to display available disk space for drive C:\ in Gigabytes use : {.round|{.div| {.disk free|C:\.} | 1073741824.}|2.}<br />
<br />
; dir | A : lists all the files found at path A, separated by |.<br />
: Optional parameter ''separator'' to specify a different separator.<br />
<br />
; file changed | A : returns true if file A has changed since last time checked (with this same command).<br />
: Optional second parameter will specify a variable name where to load the content of file A if the check returns true.<br />
<br />
== Virtual File System manipulation ==<br />
; add folder | A | B | C<br />
: adds a folder to the virtual file system. A specifies ''real'' or ''virtual'', while B is the name of the folder.<br />
: For real folders B should be the path on disk, but if published name is different than the real one, you can specify the path in parameter B, and the name in C.<br />
: Where in place of a simple name, you specify a virtual path, it will be used to place the folder (otherwise it will be place on the root).<br />
: Any existent folder with same name will be overwritten, unless you specify a parameter <tt>overwrite=0</tt>.<br />
: Example: <tt>{.add folder|virtual|/personal/my pictures.}</tt><br />
:: a virtual folder "my pictures" will be added under existing folder "personal".<br />
: Example: <tt>{.add folder|real|C:\music|my music|overwrite=0.}</tt><br />
:: folder on hard disk C:\music is published with public "my music". If a folder with same name is in the VFS, it's left untouched and no new folder is created.<br />
<br />
; set item | A<br />
: modifies the item A in the virtual file system by using any of these optional parameters<br />
:; hide : set to 1/0 to decide item visibility<br />
:; hide tree : set to 1/0 to decide item visibility and sub-items<br />
:; no log : set to 1/0 to decide item logging<br />
:; not as download : set 1/0, it's the same as ''don't consider as a download''. For folders, set it to ''*'' for all files, or any other file mask you want.<br />
:; comment : set the comment<br />
:; resource : Set the resource. It's the physical path for files and real folders, or the URL for links.<br />
:; archivable : Set whether the folder is archivable or not.<br />
:; browsable : Set whether or not the folder is browsable.<br />
:; download forbidden : Set whether or not to forbid downloading from this folder<br />
:; files filter : Show only certain files in the folder.<br />
:; folders filter : Show only certain folders in the folder.<br />
:; diff template : Change the diff template of a vfs item.<br />
: Example: <tt>{.set item|private files|hide=0|comment=you should never see this!.}</tt><br />
:; access / delete / upload<br />
:;: you can set permissions on the item, by specifying a list of usernames.<br />
:;: Example: <tt>set item|videos|upload=robert</tt> will give account ''robert'' the ability to upload files in ''/videos''.<br />
:;: Moreover, you can prefix permission by '''add''' or '''remove'''. In the previous example you set the ''upload'' permission. If ''mike'' already had upload permission, it is now lost. To '''add''' ''robert'' instead of just overwriting, you should <tt>{.set item|videos|add upload=robert.}</tt>. Now ''mike'' is happy too. As well, if you change your mind, and want to revoke your grant, just <tt>set item|videos|remove upload=robert</tt>.<br />
:;: You can specify more than one username this way: '''robert;mike;rupert'''.<br />
:;: Special usernames are '''@anonymous @any account @anyone'''.<br />
<br />
; get item | A | B<br />
: retrieves information B about VFS item specified by A.<br />
: Supported values for B are: ''exists, comment, resource, hide, hide tree, no log, not as download, access, upload, delete''.<br />
: Example: <tt>{.get item|/putYourFilesHere|upload.}</tt> will tell you who is allowed to upload files in that folder.<br />
<br />
; vfs select | A<br />
: A specifies what VFS item to select, but it's optional. If no parameter is provided, the currently selected item is returned.<br />
: If A is ''next'', the item coming after the current selection becomes the new selection.<br />
: If A is a named parameter ''path'', then you are specifying what item to select in the URI form.<br />
: Example: <tt>{.vfs select| path=/ .}</tt> will reset selection to the home/root, and looping through <tt>{.vfs select| next .}</tt> will select every VFS item, until <tt>{.vfs select.}</tt> is false (an empty string).<br />
<br />
; vfs to disk | A : a web path (URI) is converted to its related drive path. Relative paths like <tt>..</tt> are calculated based on the VFS folder where the script is running.<br />
<br />
== Connections control ==<br />
; disconnect | A | B : with no parameters, it disconnects current connection. If A is supplied, it is considered an [[HFS: IP masks|IP mask]], and every connection matching it (instead of the current one) will be disconnected. If also B is supplied, it will select only connections with port number same as B.<br />
<br />
; set speed limit for connection | A : set a speed limit A in KB/s for the current connection<br />
<br />
; set speed limit for address | A | B : set a speed limit B in KB/s for all connections coming from address A (no masks allowed).<br />
: When A is omitted, then it actually sets the value for the option ''Speed limit for single address'' in the GUI.<br />
<br />
; disconnection reason | A<br />
: this ''reason'' determines if a download must be aborted. Any value will abort the download, but if the value is empty the download goes on.<br />
: This macro will always return the value of the ''reason'' just before its call. So with a single call you are reading and setting the value. If no parameter is specified, then you are only reading.<br />
: Optional named parameter ''if=CONDITION'' is a shortcut for <tt>{.if|CONDITION|{:{.disconnection reason.}:}.}</tt><br />
: Example: <tt>{.disconnection reason|Try firefox|if={.{.get|agent.} != Mozilla.}.}</tt><br />
<br />
; add header | A : adds line A to the [http://en.wikipedia.org/wiki/HTTP_header HTTP header].<br />
<br />
; redirect | A : tells the browser to change to a different address (the specified one).<br />
<br />
; current downloads<br />
: expands to the number of current downloads. <br />
: Optional named parameter ''user'' will count only downloads made by specified user.<br />
: Optional named parameter ''ip'' will count only downloads made by the specified address.<br />
: Optional parameter ''file=this'' will count only downloads of this current file.<br />
: Example: <tt>{.current downloads|user=%user%|file=this.}</tt> will tell you how many connections this user is using to download this same file.<br />
<br />
; current downloads of file<br />
: number of current downloads of current file. <br />
: If an unnamed optional parameter is specified, it is used as [[HFS: IP masks|IP mask]], and only matching connections will be counted.<br />
: If the parameter is given name ''user'', only connections by such user will be counted.<br />
<br />
== Account manipulation ==<br />
; set account | A | ...<br />
: with this command you can change all attributes of the account whose username is specified in first parameter. If the username is left empty, current username is used, given this makes sense in current context.<br />
: Other parameters are the attributes you want to change, in the form <tt>set account|username|thing=value|thing2=value2</tt>.<br />
: Here is a list of such attributes<br />
:;password : set a new password<br />
:;newname : set a new username<br />
:;redirect : set the homonymous field<br />
:;no limits : set the homonymous field (true/false)<br />
:;enabled : set the homonymous field (true/false)<br />
:;is group : set the homonymous field (true/false)<br />
:;member of : set the ''member of'' field (specify more than one group separating by semicolons ";" )<br />
:;add member of : add more groups to the above<br />
:;remove member of : remove some groups to the above<br />
:;notes : set the homonymous field<br />
:;notes key <br />
:;: set the notes as it was a table with <tt>{.set table.}</tt><br />
:;: Example: <tt>{.set account|mike|notes key=last time=%timestamp%.}</tt><br />
<br />
; new account | A | ...<br />
: creates a new account with username A. After the username, you can also specify all the values available in the ''set account'' macro.<br />
<br />
; get account | A | B<br />
: expands to the value of property B of account A. <br />
: Supported value for B are ''redirect, no limits, enabled, is group, member of, notes, notes key''. Group names for ''member of'' are semicolon-separated. Special case for ''notes key'' where you should specify the key to retrieve, while the notes are treated as a table, just as for <tt>{.from table.}</tt>.<br />
: If A is omitted, current username is used, given this makes sense in current context.<br />
<br />
; member of | A<br />
: true if the current user is member of group A (specify more than one group separating by semicolons ";").<br />
: Optional parameter ''user'' to check a different user.<br />
: Example <tt>member of|administrators|user=rejetto</tt><br />
: If A is omitted, you will get the full membership for current (or specified) user. This is different from <tt>{.get account||member of.}</tt> because this latter form will consider only direct first-level membership, while <tt>{.member of.}</tt> will actually consider membership at any level.<br />
<br />
== Others ==<br />
; comment | A : this is just discarded. It's for your convenience, to put a comment in the template. HTML comments are readable by visitors if they use ''show html source'' in their browser. Using this macro you will have comments that will never leave your server.<br />
<br />
; length | A : if A is 5 characters length, like <tt>abcde</tt>, it expands to 5.<br />
: Optional parameter ''var'' in place of A, will work on the specified variable instead of considering A as text.<br />
<br />
; match | A | B : it is true if the content B is matched by [[HFS: File masks|the mask]] A.<br />
<br />
; match address | A | B : just like the macro ''match'', but the mask supports ip ranges like 10.0.0.1-10.0.0.25<br />
<br />
; random | A | B | C | ... : it expands to any of the parameters, randomly<br />
<br />
; random number | A | B : if only A is specified then a number between 0 and A is generated. If also B is specified then the number will be between A and B (included).<br />
<br />
; pos | A | B : expands to the position of A in B. Zero if not found. <br />
: Optional parameter ''from'' will start searching from specified position.<br />
: Optional parameter ''case'' will decide case sensitivity. Default is: insensitive.<br />
: Example <tt>pos|the|i'm the alpha and the omega|from=14|case=1</tt> expands to <tt>19</tt><br />
<br />
; regexp | A | B<br />
: Try to [http://en.wikipedia.org/wiki/Regular_expressions match pattern] A on text B.<br />
: When the pattern doesn't match, it just expands to nothing (then, false).<br />
: When it does, the matched sub-pattern is returned.<br />
: You can provide optional parameter ''var'' instead of B, and the text will be the content of the specified variable.<br />
: Optional parameter ''case'' will determine case sensitivity. (off by default)<br />
: Optional parameter ''sub'' will specify the name of a variable that will be set as a table, where you can retrieve every sub-pattern by numerical index.<br />
: If optional parameter ''replace=YYY'' is used, the command returns no more the matched pattern, but the whole text B with every matched pattern replaced by YYY. If you use ''replace'' and ''var'' together, the resulting text will not be returned, but stored in the specified input variable (that means, it's used both for input and output).<br />
: Example: <tt>regexp|\d+|var=weWantNumbers</tt><br />
<br />
; breadcrumbs | A<br />
: builds a [http://en.wikipedia.org/wiki/Breadcrumb_(navigation) breadcrumbs] based on the current folder path. The A is a little html template that is repeated for every piece of the path, for which 3 symbols are provided: ''%bread-url%'' , ''%bread-name%'' and ''%bread-idx%''. <br />
: Remember to use quoting, especially if you use macros in the parameter.<br />
: Optional parameter ''from'' will let you specify how many steps of the path to skip.<br />
: Example: <tt>{.breadcrumbs|{:<a href ="%bread-url%">%bread-name%/</a>:}.}</tt><br />
<br />
; dialog | A | B | C<br />
: display a server-side message in a dialog box. A is the message itself, and only required parameter. B are options separated by spaces, and C a title for the dialog.<br />
: Possible options are<br />
:;okcancel : offers buttons OK and CANCEL<br />
:;yesno : offers buttons YES and NO<br />
:;yesnocancel : offers buttons YES, NO and CANCEL<br />
:;error : this is an error reporting dialog<br />
:;question : this is a questioning dialog<br />
:;warning : this is a warning dialog<br />
:;information : this is an informational dialog<br />
<br />
; mime | A : set the mime-type sent to the browser. It describes the nature of the content. For techies, it's the value of the header field "Content-type".<br />
<br />
; any macro marker | A : it is true if any macro marker is present in A. Macro markers are {.delimiters.} , {:quotings:} and the parameters separator (the pipe, "|").<br />
<br />
; play system event | A : specify the name of the event bound to a sound that you want to play. ''SystemStart'' and ''MailBeep'' are just examples, for a full list you can open your registry at ''HKEY_CURRENT_USER\AppEvents\EventLabels'' .<br />
<br />
; exec | A : ask system to run file A, eventually with parameters. If you need to use the pipe, then use macro quoting.<br />
: Optional parameter ''out'' will let you capture the console output of the program in the variable specified by name.<br />
: Optional parameter ''timeout'' will specify the max number of seconds the app should be left running.<br />
: Example: <tt>{.exec|notepad.}</tt><br />
<br />
; add to log | A : add A to the log panel. <br />
: Optional parameter ''color'' to [[HFS: color format|specify the color]].<br />
<br />
; get ini | A<br />
: where A is a text in the same format you can find in ''hfs.ini'' (save options -> to file).<br />
: example: <tt>{.get ini|speed limit.}</tt> will return the global speed limit, if any.<br />
<br />
; set ini | A<br />
: where A is a text in the same format you can find in ''hfs.ini'' (save options -> to file).<br />
: example: <tt>{.set ini|speed limit=100.}</tt> will turn the global speed limit to 100KB/s.<br />
<br />
; focus<br />
: will bring HFS window on front of the user.<br />
<br />
; load tpl | A : for this connection only, template A will be used.<br />
: Example: <tt>{.if| it's a mobile | {:{.load tpl|mobile.tpl.}:} /if.}</tt><br />
<br />
; notify | A<br />
: The message A will come out as a balloon over the HFS tray icon.<br />
: Optional parameter ''title'' will let you specify the title of the balloon.<br />
: Optional parameter ''timeout'' specifies the amount of time to show the message.<br />
: Optional parameter ''type'' will show an icon according to its value. Allowed values are ''info, error'' and ''warning''.<br />
<br />
== Shortcuts ==<br />
;$A : is a shortcut for '''section | A'''<br />
;?A : is a shortcut for '''urlvar | A'''<br />
;^A : is a shortcut for '''call | A'''<br />
;A = B : is a shortcut for '''=|A|B'''<br />
;?name = X : is a shortcut for <tt>{.?name.} = X</tt> .<br />
: It works also for '''<> != < <= > >=''' .</div>
Rejetto
https://rejetto.com/wiki/index.php?title=HFS:_scripting_commands&diff=5547
HFS: scripting commands
2013-08-19T17:56:22Z
<p>Rejetto: /* Others */ get ini</p>
<hr />
<div>Also known as template macros, these are commands with some useful effects that users can input in HFS to improve a template or to create functionality not otherwise available. <br />
<br />
Some macros simply expand to text and some perform server-side commands.<br />
<br />
Every command is expressed as a name, and sometimes parameters, separated by pipes "<tt>|</tt>".<br />
<br />
Following, with letters we are denoting parameters, and their meaning is explained immediately after.<br />
<br />
You should read this [http://www.rejetto.com/wiki/index.php?title=HFS:_Template_macros] before reading this page.<br />
<br />
== Logic and flow ==<br />
; if | A | B | C<br />
: if A is true, then it expands to B, else it expands to C. When it expands to B, C is just discarded, and the vice versa. C is optional.<br />
: How you tell A is true? A is true if it is not empty and not just a zero. So if A is "hi there!", then it is true.<br />
: Remember to use quoting if you use macros in B or C (the body).<br />
<br />
; if not | A | B | C <br />
: same as ''if'', but the logic is inverted. When A is true it expands to C and vice versa.<br />
<br />
; not | A : true if A is not true. It negates the value of A.<br />
<br />
; and | A | B : true if both A and B are true. In details: in the ''true'' case it returns the last parameter. You can specify as many parameters as necessary. Both Javascript and Python work this way.<br />
<br />
; or | A | B : true if any of A or B are true. In details: it returns the first ''true'' parameter (yes, it supports any number of parameters). If none of the parameters is true, then iit returns false. Both Javascript and Python work this way. Often times you can work without {.or.}, for example {.if| A B | C .} returns true if either A or B are true.<br />
<br />
; xor | A | B : true if A is true while B is false, or the opposite<br />
<br />
; = | A | B : true if A is the same as B. It's case insensitive. You can use the opposite macro, true if they are different, and it's name is '''!=''' or '''<>''' (use the one you like most, there's no difference). You can specify as many parameters as you like.<br />
<br />
; > | A | B : true if A is greater than B. Of course you can also use the related macro '''<'''. You can specify as many parameters as you like.<br />
<br />
; >= | A | B : true if A is equal or greater than B. Of course you can also use the related macro '''<='''. You can specify as many parameters as you like.<br />
<br />
; between | A | B | C : true if B is between A and C (included).<br />
<br />
; between! | A | B | C : true if B is between A and C (excluded).<br />
<br />
; switch | A | B | C | D | E | F ...<br />
: this is rather complex for non-programmers. You can learn how a switch statement is supposed to work [http://en.wikipedia.org/wiki/Switch_statement#Examples from Wikipedia]. When you know how a ''switch'' works, then you will understand this schema that will make you understand how the parameters of this macro work<br />
<pre><nowiki><br />
switch(A) {<br />
case C: return D;<br />
case E: return F;<br />
...<br />
}<br />
</nowiki></pre><br />
: The B is a separator string for C. Let's be clearer: if you want to specify several cases in C, all of them returning D, then you can specify them separating with B.<br />
: As you can see C and D are paired, as E and F, eventually G and H, and so on. If at the end of this list of pairs, a single unpaired parameter is found, then it is used as the else/default case, when all other pairs have failed.<br />
: Let me translated the first example of Wikipedia using the macro<br />
<pre><nowiki><br />
{.switch|%n%|,|<br />
0|you typed zero|<br />
3,5,7|%n% is a prime number|<br />
4,6,8|%n% is an even number|<br />
2|%n% is a prime and even number|<br />
1,9|%n% is a perfect square|<br />
Only single-digit numbers are allowed<br />
.}<br />
</nowiki></pre><br />
<br />
Switch is esentially a quick way of using many {.if.} and {.=.} commands together. For example, if A equals C then D, if A equals E then F, etc.<br />
<br />
; for | A | B | C | D | E<br />
: repeats D by replacing variable <tt>{.^A.}</tt> with every value between B and C (they are meant to be numbers).<br />
: Optionally you can specify a ''step'' for the numbers: that is, instead of going 1-by-1, they can go 2-by-2. The optional ''step'' is specified at position D; in such case the ''body'' is moved from position D to position E.<br />
: Remember to use quoting for the body.<br />
<br />
; for each | A | B | C ... | Z<br />
: a (sometimes) handier version of ''for'', that will repeat Z but replacing variable <tt>{.^A.}</tt> with value B the first time, value C the second time, D etc etc. Remember to quote the body. <br />
: example: <tt>{.for each|i|10|100|1000|{:now it's {.^i.} :}.}</tt><br />
<br />
; while | A | B<br />
: repeats B for as long as A is true. Both B is automatically dequoted. If A is quoted, then it's expanded, otherwise is considered the a variable name.<br />
: Optional parameter ''else'' will be expanded if B is never done.<br />
: Optional parameter ''timeout'' let you specify (in seconds) the maximum time the loop can live before it is stopped. It's 1 second by default.<br />
: Optional parameter ''var'' saves the output in a variable instead of just expanding to it.<br />
: Example: <tt>{.while|#x|{: {.dec|#x.} welcome! :}.}</tt> will welcome 10 times if <tt>#x</tt> is 10.<br />
<br />
; after the list | A<br />
: quoted text A is dequoted and executed, but only if the file listing is completed.<br />
<br />
; dequote | A<br />
: if A is {:quoted:} then quoting markers are removed (unleashing macro execution of the previously quoted text).<br />
<br />
; 123 if 2 | A | B | C<br />
: if B is true, it expands to ABC, otherwise nothing.<br />
: It is basically a shortcut for {.if | B |{: A B C :}.}<br />
<br />
; break : stops execution of this script.<br />
: Optional parameter ''if'' will avoid breaking in case the condition is not met (that is, when it's ''false'').<br />
: Optional parameter ''result'' will output a text only if the break occurs (makes sense only with parameter ''if'').<br />
: Using <tt>{.break|if=data.}</tt> is basically a simplified way to write <tt>{.if|data|{:{.break.}:}.}</tt><br />
<br />
== Data getting ==<br />
; section | A<br />
: A is the name of the [section] you want to include. Note: till build #160 it was case sensitive.<br />
: Optional parameter ''file'' to load the section from an external file.<br />
: Optional parameter ''back=1'' will work in diff templates to access the section in the original template. So you can access it even if you overwrote it.<br />
: Example: <tt>{.section|names|file=tables.txt.}</tt><br />
; get | A<br />
: where A is the name of a value you are interested in, like to know if an option is enabled or not.<br />
: This is a list of supported values for A:<br />
:; can upload : true if in the current folder the user is allowed to upload files. An additional parameter ''path'' will tell you about a different folder instead of the current one.<br />
:; can delete : true if the user is allowed to delete the current item. An additional parameter ''path'' will tell you about a different folder instead of the current one.<br />
:; can access : true if the current item in list is accessible by the user. An additional parameter ''path'' will tell you about a different folder instead of the current one.<br />
:; can recur : true if the option ''Recursive listing'' is enabled<br />
:; can archive : true if the current item in list is archivable. outside the list it refers to the current folder.<br />
:; is new : true if the current item in list is flagged as "new"<br />
:; accounts : semicolon-separated list of username of all accounts. By specifying an additional parameter '''groups''' you'll get only groups. Respectively, a parameter '''users''' will give you only non-group accounts.<br />
:; stop spiders : true if ''stop spider'' option is enabled.<br />
:; protocolon : expands to <tt>http&#58;//</tt> unless you enabled option ''URLs starting with https'' in which case it expands to <tt>https&#58;//</tt> (please notice the final S).<br />
:; speed limit : gives the current global speed limit, as a number (in KB/s).<br />
:; agent : Tells the user's browser. E.g., Firefox expands to Mozilla and IE8 will expand to MSIE 8.0.<br />
<br />
; urlvar | A : url variable. Let's say in the url you see <tt>?sort=s</tt> and you want to know that '''s''', just use the macro ''urlvar|sort''.<br />
: Optional parameter ''var'' will put the resulting text in the specified variable.<br />
; postvar | A : just as ''urlvar'' but reads the value from the POST part of the request instead of the URL.<br />
: Optional parameter ''var'' will put the resulting text in the specified variable.<br />
; header | A : get any value from the HTTP request header. A is the name of the header field. This is something mostly for techies. Don't fret if you don't even know what the header is.<br />
; time | A : returns current time information. The format is specified by optional parameter A. Refer to [[HFS: Time format#Text formatting|this page]] for format syntax. If A is not supplied, value "c" will be used.<br />
: Optional parameter ''when'' to [[HFS: Time format#Numerical format|specify a time]] other than current.<br />
: Optional parameter ''offset'' to specify the number of days differing from the current time.<br />
<br />
; cookie | A : expands to the value A passed by the browser.<br />
: With an optional parameter ''value'' you will set a new value.<br />
: Every known standard parameter for cookies is accepted, as ''expires'' and ''path''. Expires can be expressed in many ways: if it starts with '''+''' or '''-''' will be the number of days in the future or in the past. If it's a number will be considered as unix time format or [[HFS: Time format#Numerical format|HFS format]]. You can even specify it as a date: <tt>2/4/2013</tt>.<br />
: Example: <tt>{.cookie|step.}</tt> will give you the current value<br />
: Example: <tt>{.cookie|step|value=3|expires=+30.}</tt> will set ''step'' to ''3'' and the cookie will expire in 30 days.<br />
: Setting a cookie can also be accomplished by using {.add header.} with Set-Cookie.<br />
<br />
== Data manipulation ==<br />
; substring | A | B | C : cut C from A to B, with B not included. <br />
: Example: <tt>substring|(|belong|you (are) belong to us.}</tt> will be <tt>(are)</tt>.<br />
: If A is not specified, C is taken from the start. If B is not specified, C is taken to the end.<br />
: Optional parameter ''case=1'' to turn on case sensitivity.<br />
: Optional parameter ''include'' to say if A and/or B must be included. Values: 0 (none), 1 (only A), 2 (only B), 1+2 (both).<br />
<br />
; cut | A | B | C : cut C from position A, for B characters. The difference with macro ''substring'' is that here you specify where to cut by numeric positions.<br />
: Example: <tt>cut|2|3|abcdef</tt> will expand to <tt>bcd</tt><br />
: If you don't specify A, it defaults to 1. If you don't specify B, it defaults to the length of C.<br />
: If A is negative, then you are counting backward from the end of C. If B is negative, then you are considering the length of C minus the amount of B.<br />
: Optional parameter ''to'' will let you specify the number of character to cut. B is ignored in this case.<br />
: Optional parameter ''var'' specifies the variable name to work on. Use it instead of C.<br />
: You can use named parameter ''from'' instead of A, ''size'' instead of B, and ''what'' instead of C.<br />
: Example: <tt>cut|from=3|size=2|abcdef</tt> will expand to <tt>cd</tt><br />
<br />
; repeat | A | B : repeat B for A times. Example: for A=5 and B=+ the result is +++++<br />
<br />
; upper | A : returns A with all letters uppercased. Example: for A=Hello the result is HELLO<br />
<br />
; lower | A : returns A with all letters lowercased. Example: for A=Hello the result is hello<br />
<br />
; trim | A : returns A with any leading and trailing space removed<br />
<br />
; replace | A | B | C : returns C with every A replaced with B. This command can apply multiple replacements by having multiple pairs of parameters A-B. But you always need to have a final parameter C, that's the text that will be manipulated.<br />
: Optional parameter ''var'' in place of parameter C will make use of the specified variable as both input and output.<br />
<br />
; calc | A : return the result of the mathematical expression A. Example: for 1+(5/2) the result is 3.5<br />
: supported operators are <tt>+ - * / %</tt> (as modulus)<br />
; round | A | B : returns rounded value of A, where A is a non-integer number, and B is the number of digits after the decimal point. B is zero by default if not specified.<br />
<br />
; add | A | B : returns A+B where A and B are numbers<br />
<br />
; sub | A | B : returns A-B where A and B are numbers<br />
<br />
; mul | A | B : returns A*B where A and B are numbers<br />
<br />
; div | A | B : returns A/B where A and B are numbers<br />
<br />
; mod | A | B : returns A modulus B where A and B are numbers<br />
<br />
; min | A | B ... : returns the minimum over all parameters. You can have more than 2 parameters.<br />
<br />
; max | A | B ... : returns the maximum over all parameters. You can have more than 2 parameters.<br />
<br />
; count substring | A | B : tells the number of times A is present in B (case sensitive)<br />
<br />
; encodeuri | A : all characters are encoded in the %XX form used for URLs, except alphanumerics and <tt>#/,&?:$@=+</tt><br />
;: You can add more characters to the set that will be encoded by using the optional parameter ''add'', as well as you can decide to exclude some characters by using the optional parameter ''not''.<br />
;: You can also decide to specify the whole set, one by one, with optional parameter ''only''.<br />
;: In all these optional parameters you can specify many characters just by having them as a string, one after another.<br />
<br />
; decodeuri | A : all encoded characters in the form %XX are decoded.<br />
<br />
; convert | A | B | C<br />
: converts C from charset A to charset B. At the moment only supported charsets are ''ansi'' and ''utf-8''. <br />
<br />
; force ansi | A : if template is using UTF-8 charset, then A is converted to ANSI. Otherwise A is left unchanged.<br />
<br />
; maybe utf8 | A : if template is using UTF-8 charset, then A is converted to UTF-8. Otherwise A is left unchanged.<br />
<br />
; 123 if 2 | A | B | C : returns nothing if B is false/empty, otherwise a concatenation of ABC.<br />
<br />
; chr | A | B ... : returns characters with ANSI code A, B, etc. Numbers are decimal. To use hex numbers, precede them with an "x".<br />
: Example: {.chr|13|10|x0D|x0A.}<br />
<br />
; js encode | A | B<br />
: Encodes characters specified by B using javascript encoding for strings, in text A. If you mean to encode characters ''a'' and ''b'', parameter B should simply be ''ab''.<br />
: If B is not specified, characters encoded are only single-quote and double-quotes. This is supposed to be the frequently used case, when you are passing some data into a javascript string that's enclosed in any form of quotes.<br />
<br />
== Variables and functions ==<br />
; set | A | B<br />
: what you actually do is to bind B to the name A. You can later recall B by passing A to the macro call.<br />
: If you are used to programming, you may know what variables and functions are. In such case, consider that '''set|x|1''' is similar to a variable '''x''' with value '''1'''. By binding to ''x'' something more complex, with parameters, you are creating a function. The first parameter is '''$1''', the second '''$2''', and so on, that you can specify inside the body ''B''.<br />
: Remember to use quoting if you use macros in the body (B).<br />
: Example: <tt>{.set|x|1.}</tt> or <tt>{.set|double|{:{.mul|$1|2.}:}.}</tt><br />
: Optional parameter ''var'' will let you copy variables.<br />
: Example: <tt>{.set|y|var=x.}</tt><br />
: Optional parameter ''mode'' can be <tt>append</tt> or <tt>prepend</tt>, to concatenate existing content of the variable to the new content, as AB or BA.<br />
: Example: <tt>{.set|x| is a good boy|mode=append.}</tt><br />
<br />
; call | A | B | C | ... : this macro (shortcut by '''^''') expands to the value bound to A. Such value can be a number or a text, doesn't matter. If the value contains symbols '''$1''' and '''$2''', then they are replaced with the parameters B and C (and so on).<br />
: Example referring to above: <tt>{.call|double|15.}</tt> will expand to <tt>30</tt><br />
: You can find some examples for ''set'' and ''call'' [http://www.rejetto.com/forum/index.php?topic=5353.msg1031074#msg1031074 on the forum].<br />
<br />
; inc | A | B : if A is a variable with numeric value, then its value is incremented by the number B. If B is omitted, it defaults to 1.<br />
<br />
; dec | A | B : just as the ''inc'' above, but the value is decremented<br />
<br />
; count | A<br />
: each call returns and increments A, so the sequence will be 0 1 2 3...<br />
: variable A is not actually a variable, you can't access it throught {.^A.} and its value can be retrieved only through another call to ''count''. <br />
<br />
; from table | A | B<br />
: A is the table and B is the key. The table is a variable or a section with this form<br />
<pre>key1=value1<br />
key2=value2<br />
key3=value3</pre><br />
: Let's say such text is the content of variable ''foo'', then to get <tt>value2</tt> you should do <tt>{.from table|foo|key2.}</tt>. (yes, poetry)<br />
: If it was the content of table [bar] instead, then you should do <tt>{.from table|$bar|key2.}</tt>.<br />
<br />
; set table | A | B<br />
: it's the counterpart of ''from table''. A is the name of the table, while B is in the form ''key=value''.<br />
: If the key already exists, it's replaced, added otherwise.<br />
: Example: <tt>set table|foo|key2=new value</tt><br />
: Loading entire database-like TXT files can be achieved by replacing A with the database path:<br />
:: <tt>{.for each|value|{.replace|;|{.no pipe||.}|{.load| A .}.}|{:{.if|{.^value.}|{:{.set table|table|{.^value.}.}:}.}:}.}</tt><br />
:: The database file must use the syntax of <tt>key1=value1;key2=value2;key3=value3;</tt><br />
<br />
; cache | A | B | C<br />
: expands to retrieved value B from cache-table A. If not found, the new value C will be set. You can quote C if you need it.<br />
: This is a very useful tool when C takes too much time and you want to be sure you will do it only once.<br />
: Example: <tt><nowiki>{.cache|#countries|%ip%|{:{.load|http://server/giveMeTheCoutry?ip=%ip% .}:}.}</nowiki></tt><br />
<br />
; var domain | A<br />
: returns a list of all variable names starting with prefix A, separated by |.<br />
: Optional parameter ''separator'' to specify a different separator.<br />
: Optional parameter ''get=values'' will return variable values instead of names.<br />
<br />
== Localization ==<br />
Here goes a macro useful for template localization.<br />
<br />
Inside the template you can use identifiers (IDs) instead of real text. So you can gather all the text in one place, and ease the work of whom wants to translate to another language.<br />
<br />
Lets say that you have a link '''<a href ='..'>Go up one level</a>'''. You can replace with '''<a href ='..'>{.!up.}</a>''', moving the text to section '''[special:strings]'''.<br />
[special:strings]<br />
up=Go up one level<br />
<br />
You can optionally provide a parameter (like ''<nowiki><br />
{.!up|Go to parent folder.}</nowiki>'') that will be the default text in case '''up''' is not found in '''[special:strings]'''.<br />
<br />
<br />
If no parameter is provided, then the ID itself will be used as default text.<br />
<br />
== File manipulation ==<br />
Consider most of these macros work only with operating system oriented paths, not the ones of the virtual file system.<br />
<br />
; load | A : you'll love this one. You can specify A as a file name, or as a URL. It will load and expand to it. The file or URL you specify must be accessible from the server machine. A can be <tt>C:\windows\win.ini</tt> or also <tt><nowiki>http://another_hfs_in_lan/the_file_i_want.txt</nowiki></tt>.<br />
: With an optional parameter ''var'' you can specify the name of a variable where the whole content of the file will be stored. In such case, the macro will not expand to the content of the file, it's just in the var.<br />
: Optional parameter ''from'' to specify an offset from where to start reading.<br />
: Optional parameter ''size'' to specify how much to read.<br />
: Optional parameter ''to'' to specify the last byte to read, as an offset from the beginning.<br />
: All parameters ''from, size'' and ''to'' are expressed as number of bytes.<br />
: Example: {.load|document.txt|var=mytext.} or <tt><nowiki>{.load|http://www.domain.tld/test.txt.}</nowiki></tt><br />
<br />
; filesize | A : tells you the size in bytes of the file A. At the moment URL are not supported, only local filenames.<br />
<br />
; save | A | B : stores B to file path A. The path can be absolute, URI based or relative to HFS folder.<br />
: You can supply an optional parameter ''var'' instead of B, and the content of the specified variable will be saved.<br />
<br />
; append | A | B : add B at the end of file A. This may is also useful to keep special logs.<br />
<br />
; delete | A : moves the file A to the recycle bin.<br />
: Optional parameter ''forced=1'' will force deletion in case the bin is not available.<br />
: Optional parameter ''bin=0'' will delete the file permanently instead of moving to the recycled bin.<br />
<br />
; rename | A | B : renames the file A to B. Files can be specified with their disk path or in the URI form.<br />
<br />
; md5 file | A : computes and expands to the MD5 hash for file A.<br />
<br />
; copy | A | B : copies file A to B, where B can be a folder or a full path+filename. A can eventually be specified in the URI form.<br />
; move | A | B : as ''copy'', but A is moved instead of duplicated.<br />
<br />
; chdir | A : changes the current [http://en.wikipedia.org/wiki/Working_directory working directory] of the HFS process.<br />
; mkdir | A : creates the specified folder. URI is supported in A, but it must refer a real folder.<br />
<br />
; exists | A : checks A for existence, may it be a file or folder.<br />
; is file | A : checks A for existence as a file.<br />
<br />
; filename | A : returns only the filename part of A, removing eventual path information.<br />
; filepath | A : returns only the path of A, removing the file name.<br />
; filetime | A : returns timestamp for file A, express in [[HFS:_Time_format#Numerical_format|the usual format]].<br />
<br />
; disk free | A : returns available disk space for specified path in bytes. For example, to display available disk space for drive C:\ in Gigabytes use : {.round|{.div| {.disk free|C:\.} | 1073741824.}|2.}<br />
<br />
; dir | A : lists all the files found at path A, separated by |.<br />
: Optional parameter ''separator'' to specify a different separator.<br />
<br />
; file changed | A : returns true if file A has changed since last time checked (with this same command).<br />
: Optional second parameter will specify a variable name where to load the content of file A if the check returns true.<br />
<br />
== Virtual File System manipulation ==<br />
; add folder | A | B | C<br />
: adds a folder to the virtual file system. A specifies ''real'' or ''virtual'', while B is the name of the folder.<br />
: For real folders B should be the path on disk, but if published name is different than the real one, you can specify the path in parameter B, and the name in C.<br />
: Where in place of a simple name, you specify a virtual path, it will be used to place the folder (otherwise it will be place on the root).<br />
: Any existent folder with same name will be overwritten, unless you specify a parameter <tt>overwrite=0</tt>.<br />
: Example: <tt>{.add folder|virtual|/personal/my pictures.}</tt><br />
:: a virtual folder "my pictures" will be added under existing folder "personal".<br />
: Example: <tt>{.add folder|real|C:\music|my music|overwrite=0.}</tt><br />
:: folder on hard disk C:\music is published with public "my music". If a folder with same name is in the VFS, it's left untouched and no new folder is created.<br />
<br />
; set item | A<br />
: modifies the item A in the virtual file system by using any of these optional parameters<br />
:; hide : set to 1/0 to decide item visibility<br />
:; hide tree : set to 1/0 to decide item visibility and sub-items<br />
:; no log : set to 1/0 to decide item logging<br />
:; not as download : set 1/0, it's the same as ''don't consider as a download''. For folders, set it to ''*'' for all files, or any other file mask you want.<br />
:; comment : set the comment<br />
:; resource : Set the resource. It's the physical path for files and real folders, or the URL for links.<br />
:; archivable : Set whether the folder is archivable or not.<br />
:; browsable : Set whether or not the folder is browsable.<br />
:; download forbidden : Set whether or not to forbid downloading from this folder<br />
:; files filter : Show only certain files in the folder.<br />
:; folders filter : Show only certain folders in the folder.<br />
:; diff template : Change the diff template of a vfs item.<br />
: Example: <tt>{.set item|private files|hide=0|comment=you should never see this!.}</tt><br />
:; access / delete / upload<br />
:;: you can set permissions on the item, by specifying a list of usernames.<br />
:;: Example: <tt>set item|videos|upload=robert</tt> will give account ''robert'' the ability to upload files in ''/videos''.<br />
:;: Moreover, you can prefix permission by '''add''' or '''remove'''. In the previous example you set the ''upload'' permission. If ''mike'' already had upload permission, it is now lost. To '''add''' ''robert'' instead of just overwriting, you should <tt>{.set item|videos|add upload=robert.}</tt>. Now ''mike'' is happy too. As well, if you change your mind, and want to revoke your grant, just <tt>set item|videos|remove upload=robert</tt>.<br />
:;: You can specify more than one username this way: '''robert;mike;rupert'''.<br />
:;: Special usernames are '''@anonymous @any account @anyone'''.<br />
<br />
; get item | A | B<br />
: retrieves information B about VFS item specified by A.<br />
: Supported values for B are: ''exists, comment, resource, hide, hide tree, no log, not as download, access, upload, delete''.<br />
: Example: <tt>{.get item|/putYourFilesHere|upload.}</tt> will tell you who is allowed to upload files in that folder.<br />
<br />
; vfs select | A<br />
: A specifies what VFS item to select, but it's optional. If no parameter is provided, the currently selected item is returned.<br />
: If A is ''next'', the item coming after the current selection becomes the new selection.<br />
: If A is a named parameter ''path'', then you are specifying what item to select in the URI form.<br />
: Example: <tt>{.vfs select| path=/ .}</tt> will reset selection to the home/root, and looping through <tt>{.vfs select| next .}</tt> will select every VFS item, until <tt>{.vfs select.}</tt> is false (an empty string).<br />
<br />
; vfs to disk | A : a web path (URI) is converted to its related drive path. Relative paths like <tt>..</tt> are calculated based on the VFS folder where the script is running.<br />
<br />
== Connections control ==<br />
; disconnect | A | B : with no parameters, it disconnects current connection. If A is supplied, it is considered an [[HFS: IP masks|IP mask]], and every connection matching it (instead of the current one) will be disconnected. If also B is supplied, it will select only connections with port number same as B.<br />
<br />
; set speed limit for connection | A : set a speed limit A in KB/s for the current connection<br />
<br />
; set speed limit for address | A | B : set a speed limit B in KB/s for all connections coming from address A (no masks allowed).<br />
: When A is omitted, then it actually sets the value for the option ''Speed limit for single address'' in the GUI.<br />
<br />
; disconnection reason | A<br />
: this ''reason'' determines if a download must be aborted. Any value will abort the download, but if the value is empty the download goes on.<br />
: This macro will always return the value of the ''reason'' just before its call. So with a single call you are reading and setting the value. If no parameter is specified, then you are only reading.<br />
: Optional named parameter ''if=CONDITION'' is a shortcut for <tt>{.if|CONDITION|{:{.disconnection reason.}:}.}</tt><br />
: Example: <tt>{.disconnection reason|Try firefox|if={.{.get|agent.} != Mozilla.}.}</tt><br />
<br />
; add header | A : adds line A to the [http://en.wikipedia.org/wiki/HTTP_header HTTP header].<br />
<br />
; redirect | A : tells the browser to change to a different address (the specified one).<br />
<br />
; current downloads<br />
: expands to the number of current downloads. <br />
: Optional named parameter ''user'' will count only downloads made by specified user.<br />
: Optional named parameter ''ip'' will count only downloads made by the specified address.<br />
: Optional parameter ''file=this'' will count only downloads of this current file.<br />
: Example: <tt>{.current downloads|user=%user%|file=this.}</tt> will tell you how many connections this user is using to download this same file.<br />
<br />
; current downloads of file<br />
: number of current downloads of current file. <br />
: If an unnamed optional parameter is specified, it is used as [[HFS: IP masks|IP mask]], and only matching connections will be counted.<br />
: If the parameter is given name ''user'', only connections by such user will be counted.<br />
<br />
== Account manipulation ==<br />
; set account | A | ...<br />
: with this command you can change all attributes of the account whose username is specified in first parameter. If the username is left empty, current username is used, given this makes sense in current context.<br />
: Other parameters are the attributes you want to change, in the form <tt>set account|username|thing=value|thing2=value2</tt>.<br />
: Here is a list of such attributes<br />
:;password : set a new password<br />
:;newname : set a new username<br />
:;redirect : set the homonymous field<br />
:;no limits : set the homonymous field (true/false)<br />
:;enabled : set the homonymous field (true/false)<br />
:;is group : set the homonymous field (true/false)<br />
:;member of : set the ''member of'' field (specify more than one group separating by semicolons ";" )<br />
:;add member of : add more groups to the above<br />
:;remove member of : remove some groups to the above<br />
:;notes : set the homonymous field<br />
:;notes key <br />
:;: set the notes as it was a table with <tt>{.set table.}</tt><br />
:;: Example: <tt>{.set account|mike|notes key=last time=%timestamp%.}</tt><br />
<br />
; new account | A | ...<br />
: creates a new account with username A. After the username, you can also specify all the values available in the ''set account'' macro.<br />
<br />
; get account | A | B<br />
: expands to the value of property B of account A. <br />
: Supported value for B are ''redirect, no limits, enabled, is group, member of, notes, notes key''. Group names for ''member of'' are semicolon-separated. Special case for ''notes key'' where you should specify the key to retrieve, while the notes are treated as a table, just as for <tt>{.from table.}</tt>.<br />
: If A is omitted, current username is used, given this makes sense in current context.<br />
<br />
; member of | A<br />
: true if the current user is member of group A (specify more than one group separating by semicolons ";").<br />
: Optional parameter ''user'' to check a different user.<br />
: Example <tt>member of|administrators|user=rejetto</tt><br />
: If A is omitted, you will get the full membership for current (or specified) user. This is different from <tt>{.get account||member of.}</tt> because this latter form will consider only direct first-level membership, while <tt>{.member of.}</tt> will actually consider membership at any level.<br />
<br />
== Others ==<br />
; comment | A : this is just discarded. It's for your convenience, to put a comment in the template. HTML comments are readable by visitors if they use ''show html source'' in their browser. Using this macro you will have comments that will never leave your server.<br />
<br />
; length | A : if A is 5 characters length, like <tt>abcde</tt>, it expands to 5.<br />
: Optional parameter ''var'' in place of A, will work on the specified variable instead of considering A as text.<br />
<br />
; match | A | B : it is true if the content B is matched by [[HFS: File masks|the mask]] A.<br />
<br />
; match address | A | B : just like the macro ''match'', but the mask supports ip ranges like 10.0.0.1-10.0.0.25<br />
<br />
; random | A | B | C | ... : it expands to any of the parameters, randomly<br />
<br />
; random number | A | B : if only A is specified then a number between 0 and A is generated. If also B is specified then the number will be between A and B (included).<br />
<br />
; pos | A | B : expands to the position of A in B. Zero if not found. <br />
: Optional parameter ''from'' will start searching from specified position.<br />
: Optional parameter ''case'' will decide case sensitivity. Default is: insensitive.<br />
: Example <tt>pos|the|i'm the alpha and the omega|from=14|case=1</tt> expands to <tt>19</tt><br />
<br />
; regexp | A | B<br />
: Try to [http://en.wikipedia.org/wiki/Regular_expressions match pattern] A on text B.<br />
: When the pattern doesn't match, it just expands to nothing (then, false).<br />
: When it does, the matched sub-pattern is returned.<br />
: You can provide optional parameter ''var'' instead of B, and the text will be the content of the specified variable.<br />
: Optional parameter ''case'' will determine case sensitivity. (off by default)<br />
: Optional parameter ''sub'' will specify the name of a variable that will be set as a table, where you can retrieve every sub-pattern by numerical index.<br />
: If optional parameter ''replace=YYY'' is used, the command returns no more the matched pattern, but the whole text B with every matched pattern replaced by YYY. If you use ''replace'' and ''var'' together, the resulting text will not be returned, but stored in the specified input variable (that means, it's used both for input and output).<br />
: Example: <tt>regexp|\d+|var=weWantNumbers</tt><br />
<br />
; breadcrumbs | A<br />
: builds a [http://en.wikipedia.org/wiki/Breadcrumb_(navigation) breadcrumbs] based on the current folder path. The A is a little html template that is repeated for every piece of the path, for which 3 symbols are provided: ''%bread-url%'' , ''%bread-name%'' and ''%bread-idx%''. <br />
: Remember to use quoting, especially if you use macros in the parameter.<br />
: Optional parameter ''from'' will let you specify how many steps of the path to skip.<br />
: Example: <tt>{.breadcrumbs|{:<a href ="%bread-url%">%bread-name%/</a>:}.}</tt><br />
<br />
; dialog | A | B | C<br />
: display a server-side message in a dialog box. A is the message itself, and only required parameter. B are options separated by spaces, and C a title for the dialog.<br />
: Possible options are<br />
:;okcancel : offers buttons OK and CANCEL<br />
:;yesno : offers buttons YES and NO<br />
:;yesnocancel : offers buttons YES, NO and CANCEL<br />
:;error : this is an error reporting dialog<br />
:;question : this is a questioning dialog<br />
:;warning : this is a warning dialog<br />
:;information : this is an informational dialog<br />
<br />
; mime | A : set the mime-type sent to the browser. It describes the nature of the content. For techies, it's the value of the header field "Content-type".<br />
<br />
; any macro marker | A : it is true if any macro marker is present in A. Macro markers are {.delimiters.} , {:quotings:} and the parameters separator (the pipe, "|").<br />
<br />
; play system event | A : specify the name of the event bound to a sound that you want to play. ''SystemStart'' and ''MailBeep'' are just examples, for a full list you can open your registry at ''HKEY_CURRENT_USER\AppEvents\EventLabels'' .<br />
<br />
; exec | A : ask system to run file A, eventually with parameters. If you need to use the pipe, then use macro quoting.<br />
: Optional parameter ''out'' will let you capture the console output of the program to the specified parameter.<br />
: Optional parameter ''timeout'' will specify the max number of seconds the app should be left running.<br />
: Example: <tt>{.exec|notepad.}</tt><br />
<br />
; add to log | A : add A to the log panel. <br />
: Optional parameter ''color'' to [[HFS: color format|specify the color]].<br />
<br />
; get ini | A<br />
: where A is a text in the same format you can find in ''hfs.ini'' (save options -> to file).<br />
: example: <tt>{.get ini|speed limit.}</tt> will return the global speed limit, if any.<br />
<br />
; set ini | A<br />
: where A is a text in the same format you can find in ''hfs.ini'' (save options -> to file).<br />
: example: <tt>{.set ini|speed limit=100.}</tt> will turn the global speed limit to 100KB/s.<br />
<br />
; focus<br />
: will bring HFS window on front of the user.<br />
<br />
; load tpl | A : for this connection only, template A will be used.<br />
: Example: <tt>{.if| it's a mobile | {:{.load tpl|mobile.tpl.}:} /if.}</tt><br />
<br />
; notify | A<br />
: The message A will come out as a balloon over the HFS tray icon.<br />
: Optional parameter ''title'' will let you specify the title of the balloon.<br />
: Optional parameter ''timeout'' specifies the amount of time to show the message.<br />
: Optional parameter ''type'' will show an icon according to its value. Allowed values are ''info, error'' and ''warning''.<br />
<br />
== Shortcuts ==<br />
;$A : is a shortcut for '''section | A'''<br />
;?A : is a shortcut for '''urlvar | A'''<br />
;^A : is a shortcut for '''call | A'''<br />
;A = B : is a shortcut for '''=|A|B'''<br />
;?name = X : is a shortcut for <tt>{.?name.} = X</tt> .<br />
: It works also for '''<> != < <= > >=''' .</div>
Rejetto