https://rejetto.com/wiki/api.php?action=feedcontributions&user=NaitLee&feedformat=atom
rejetto wiki - User contributions [en-gb]
2024-03-29T06:38:24Z
User contributions
MediaWiki 1.38.4
https://rejetto.com/wiki/index.php?title=HFS:_%E6%A8%A1%E6%9D%BF%E5%AE%8F&diff=5708
HFS: 模板宏
2020-10-27T06:52:41Z
<p>NaitLee: Correction of logic</p>
<hr />
<div>HFS 支持服务器端语言(指令),也叫做宏。这种语言在模板和事件脚本中的表现几乎相同。<br />
<br />
'''请注意:''' 2.3 之前的版本不支持宏。<br />
<br />
宏很强大,可以用于给 HFS 及其文件页面添加新的功能。<br />
<br />
== 宏是如何工作的 ==<br />
<br />
=== 与占位符的不同 ===<br />
您需要对[[HFS: Template#How_templates_work|模板如何工作]]有大概的了解。宏与占位符相似。输入的宏将在用户浏览页面时被替换为有实际意义的内容(我们称之“扩展”)。<br />
<br />
占位符只代表一个名称,而宏有自己的功能及相应的参数。占位符只会被替换为文本(比如 %user% 替换为当前用户),而宏被用来在 HFS 服务器端进行指令操作(如 {.load.} 用以加载文件内容)。 <br />
<br />
您可以很简单地区分占位符与宏:占位符由 %百分号% 包围,而宏由 <nowiki>{.带点的大括号.}</nowiki> 包围.<br />
<br />
=== 更多 ===<br />
宏如何工作取决于输入的参数。一个宏根据输入的参数可进行不同的操作。<br />
<br />
在一个模板中,宏 ''section'' 会复制位于该模板中所定义的一个 [节] 的内容——而您应该添加一个具体参数,使它知道应该读取哪一个节。<br />
<br />
例如:<tt><nowiki>{.section|style.}</nowiki></tt> 将会读取节 [style] 的内容。该宏的快捷方式是 {.$style.}。<br />
<br />
=== 参数 ===<br />
在宏名称的后面,您可以添加管道字符“|”以添加参数,如:<tt><nowiki>{.宏名称|参数.}</nowiki></tt>.<br />
如果需要更多参数,只需添加更多管道字符:<tt><nowiki>{.宏名称 | 参数1 | 参数2 | 参数3.}</nowiki></tt>.<br />
<br />
=== 可读性 ===<br />
宏是可以嵌套的。不过,这可能使得宏难以阅读。为了增加宏的可读性,您可以:<br />
* 将每个宏排列到独立的行并[http://en.wikipedia.org/wiki/Indentation#Indentation_in_programming 缩进].<br />
* 在一层宏的结尾添加: <tt>/宏名称</tt> 以提示自己关闭了一个宏。例如:<tt><nowiki>{.load|{.section|stuff /section.} /load.}</nowiki></tt>。最后的 <tt>/section</tt> 和 <tt>/load</tt> 会被 HFS 忽略——这只是为了您的便利。<br />
<br />
=== 引用 ===<br />
某些情况下,您可能不希望 HFS 将某段文本当作宏处理。有一种不让 HFS 处理这种文本的方式,叫做“引用”。<br />
<br />
要引用一段文本,只需用带冒号的大括号包围: <tt>{:这是一段普通文本,并且{.这个宏不会被执行.}:}</tt>。<br />
<br />
同时引用还可以让宏 ''set'' 和 ''if'' 不提前执行其参数宏指令——您会在后面有所了解。<br />
<br />
如果您需要在宏参数中使用管道字符而不分割参数,引用就是一种方法。<br />
例如: <tt>{.add to log|输出一个管道字符:{:|:}.}</tt>。如此您可在日志中使用管道字符。您也可以使用宏 ''no pipe'':<tt>{.no pipe||.}</tt><br />
<br />
== 可用的指令 ==<br />
HFS 预置了许多实用指令。请参阅[[HFS: 宏脚本命令大全|完整列表]]。<br />
<br />
== 执行次序 ==<br />
如果宏是嵌套的,那么它们的执行次序为:从里到外,从左到右。宏的嵌套格式就像 XHTML,以保证其不重叠。<br />
<br />
比如:<tt>{.A {.B.} {.C.}.} {.D.}</tt>。在此例中,宏的执行顺序为: B, C, A, D。HFS 在处理 B 与 C 前不能处理 A——因为 HFS 仍不知道 B 与 C 的最终结果,而 B、C 的最终结果才是 A 要处理的。<br />
<br />
=== 问题与解决方案 ===<br />
除了[[#Quoting|被引用的宏]]之外,其他宏都会被扩展。不过,''if'' 宏 <tt>{.if | A | B | C .}</tt> 根据 A 来判断执行(扩展为) B 还是 C,但是如果 B 与 C 本身是宏,那么 B 与 C 总是会被执行。<br />
<br />
因此我们需要''引用'' B 与 C。引用后,B 与 C 不会被提前执行,而是会在 ''if'' 判断符合条件后解除引用,然后被正确执行。<br />
当然,如果 B 与 C 都是常文本,那么它们不必被引用。<br />
<br />
比如:<br />
<tt><nowiki>{.if| %user% | {.append|日志文件.txt|有用户登录了哦!.} .}</nowiki></tt><br />
如前文所描述,无论占位符 %user% 扩展为何,{.append.} 宏总是会被执行——这不是我们想要的。<br />
<br />
然而,当我们将宏引用后:<br />
<tt><nowiki>{.if| %user% | {:{.append|日志文件.txt|有用户登录了哦!.}:} .}</nowiki></tt><br />
仅当 %user% 扩展不为空时(值为真),{.append.} 宏才会被解除引用并执行。<br />
<br />
在其他情况下,您需要使用宏 {.dequote.} 来解除引用。不过如 ''if'' 之类的特殊宏则不必。此类宏有:''if'', ''set'', ''for'', ''for each'', ''switch'' 和 ''breadcrumbs''。这允许您使用变量改变输出。<br />
<br />
=== 预处理 ===<br />
如果您需要在每份文件页面加载之前处理一些宏,那么您可以将宏放置在节 '''[special:begin]''' 下。如:<br />
<br />
<pre><nowiki><br />
[special:begin] <br />
{.if| %user% | {:{.append|日志文件.txt|用户 %user% 登录了哦!.}:} .}<br />
</nowiki></pre></div>
NaitLee
https://rejetto.com/wiki/index.php?title=HFS:_%E5%AE%8F%E8%84%9A%E6%9C%AC%E5%91%BD%E4%BB%A4%E5%A4%A7%E5%85%A8&diff=5707
HFS: 宏脚本命令大全
2020-09-28T12:24:47Z
<p>NaitLee: </p>
<hr />
<div>宏脚本命令也叫模板宏。HFS 已预置许多功能性的指令,而您可以将其用于模板或事件文件中以创建、改进模板,制作出原本没有的功能。<br />
<br />
一些指令会简单地扩展为文本,用以显示一些信息。也有一些指令可以用以进行服务器端操作,例如删除文件。<br />
<br />
每一个指令都以名称的形式表达,有时也需要参数,用管道字符“|”分隔。<br />
<br />
以下将介绍一些宏,以供您使用。<br />
<br />
在阅读之前,您可能需要首先[http://rejetto.com/wiki/index.php?title=HFS:_%E6%A8%A1%E6%9D%BF%E5%AE%8F 了解模板编写]。<br />
<br />
== 逻辑与流程 ==<br />
; if | A | B | C<br />
: ''释义:如果 A 为真,那么 B,否则 C''<br />
: 如果 A 为真,那么 B 将被执行(扩展),否则 C 将被执行(扩展)。当它扩展为 B 时,C 就消失不见了。反之亦然。<br />
: 如何判断 A 为真?假值即空字符串或者数字 <tt>0</tt>。其余情况都为真。<br />
: 当 B 或 C 为宏时,请[http://rejetto.com/wiki/index.php?title=HFS:_%E6%A8%A1%E6%9D%BF%E5%AE%8F#.E9.97.AE.E9.A2.98.E4.B8.8E.E8.A7.A3.E5.86.B3.E6.96.B9.E6.A1.88 引用]它们。<br />
<br />
; if not | A | B | C <br />
: ''释义:如果 A 为假,那么 B,否则 C''<br />
: 与 ''if'' 相似,但是逻辑相反。<br />
<br />
; not | A<br />
: ''释义:非 A''<br />
: 反转逻辑。A 真则为假,A 假则为真。<br />
<br />
; and | A | B | ...<br />
: ''释义:A 且 B ……''<br />
: 当 A 与 B 都为真时则为真。具体说来,当结果为真时,它将返回(扩展为)最后一个参数。与 JavaScript 和 Python 相似,参数的个数没有限制。<br />
<br />
; or | A | B | ...<br />
: ''释义:A 或 B ……''<br />
: 如果 A 与 B 其中有一个为真,则为真。具体说来,它将返回第一个为真的值。如果参数都为假,那么它扩展为假值。这与 JavaScript 和 Python 相似。<br />
: 由于 HFS 宏基于字符串,您可以这样:{.if| A B | C .}。A 与 B 连接为单个字符串,如果有真值则为真。这可以方便地替代 {.or.}。<br />
<br />
; xor | A | B<br />
: ''释义:A 异或 B''<br />
: 当 A、B 中仅有一个为真时扩展为真值。<br />
<br />
; = | A | B | ...<br />
: ''释义:A 等于 B ……''<br />
: 若 A 与 B 相等则为真。它对字母大小写'''不'''敏感。不等于则为: '''!=''' 或者 '''<>'''。两者等价。参数的个数没有限制。<br />
<br />
; > | A | B | ...<br />
: ''释义:A 大于 B ……''<br />
: 若 A 大于 B 则为真。小于则为 '''<'''。参数的个数没有限制。<br />
<br />
; >= | A | B<br />
: ''释义:A 大于或等于 B ……''<br />
: 若 A 大于或等于 B 则为真。小于或等于则为 '''<='''。参数的个数没有限制。<br />
<br />
; between | A | B | C<br />
: ''释义:B 在 A 与 C 之间''<br />
: 若 B 在 A 与 C 之间则为真。包含 A、C(即闭区间)。<br />
<br />
; between! | A | B | C<br />
: ''释义:B 在 A 与 C 之间''<br />
: 若 B 在 A 与 C 之间则为真。不包含 A、C(即开区间)。<br />
<br />
; switch | A | B | C | D | E | F ...<br />
: ''释义:把 C,E…… 用 B 内容分隔后,若 A 包含于 C 中则 D,若 A 包含于 E 中则 F ……''<br />
: 这对非程序员可能难以理解。您可以参阅[http://en.wikipedia.org/wiki/Switch_statement#Examples 维基百科相关内容]并进行探究。<br />
<pre><nowiki><br />
switch(A) {<br />
case C.split(B)[0]: return D;<br />
case C.split(B)[1]: return D;<br />
case C.split(B)[2]: return D;<br />
// ...<br />
case E.split(B)[0]: return F;<br />
case E.split(B)[1]: return F;<br />
// ...<br />
}<br />
</nowiki></pre><br />
: B 是 C 与 E 内容的分隔符。更确切地说:如果 C 中包含几个用特定字符分隔的结果(如:3,5,7),您想让它们都返回 D 值,那么您可以指定一个 B 参数。<br />
: C 与 D、E 与 F 都是配对的。若最后一个参数未配对,那么它将作为默认(default)返回值——即当其他条件都不匹配时被返回。<br />
: 以下为维基百科页面中第一个样例在 HFS 宏中的表示:<br />
<pre><nowiki><br />
{.switch|%n%|,|<br />
0|您输入了零。|<br />
3,5,7|%n% 是一个质数。|<br />
4,6,8|%n% 是一个偶数。|<br />
2|%n% 既是质数又是偶数。|<br />
1,9|%n% 是一个完全平方数。|<br />
仅支持输入个位数。<br />
.}<br />
</nowiki></pre><br />
<br />
若需要使用许多 {.if.} 和 {.=.},{.switch.} 无疑是更好的选择。<br />
<br />
; for | A | B | C | D | E<br />
: ''释义:定义变量 A,使其值从 B 依次增加到 C,分别替换 D 中的 A 变量并扩展''<br />
: 重复扩展为 D,且将其中的 <tt>{.^A.}</tt> 变量替换为 B 与 C 之间的每一个数值(它们需要都为数字,步进为 1)。<br />
: 您也可以在 D 处使用可选变量 ''step'',这样可以更改数值的步进。这样做时此宏将重复扩展为 E。<br />
: 请记得引用在 D 或 E 处的宏文本。<br />
<br />
; for each | A | B | C ... | Z<br />
: ''释义:定义变量 A,使其值分别为 B, C, D, ...,分别替换最后一个参数中的 A 变量并扩展''<br />
: 一个有时更有用的 ''for'' 版本。请记得引用最后一个变量中的宏文本。<br />
: 例: <tt>{.for each|i|10|100|1000|{:now it's {.^i.} :}.}</tt><br />
<br />
; while | A | B<br />
: ''释义:当 A 为真时,重复扩展为 B''<br />
: 当 A 为真时,重复扩展为 B。B 变量将被自动取消引用。若 A 被引用,它将被扩展,否则它会成为替换 B 中相应变量的一个变量。<br />
: 可选参数 ''else'' 的值将会在 B 未被执行过时扩展。<br />
: 可选参数 ''timeout'' 可以让您定义此循环可进行的最大时间(单位为秒)。在未定义时它默认为 1 秒。<br />
: 可选参数 ''var'' 会使宏不扩展,而将本应扩展的值存入定义的变量。<br />
: 如: <tt>{.while|#x|{: {.dec|#x.} 欢迎! :}.}</tt> 会在 <tt>#x</tt> 变量值为 10 时欢迎您 10 次。<br />
<br />
; after the list | A<br />
: ''释义:仅在文件列表工作结束后执行 A''<br />
: 解除引用并执行 A——仅在文件列表工作结束之后才会如此。<br />
<br />
; dequote | A<br />
: ''释义:解除 A 的引用''<br />
: 如果 A 被 {:引用:},那么解除其引用(其中包含的宏文本也会被执行)。<br />
<br />
; 123 if 2 | A | B | C<br />
: ''释义:如果 B 为真,则扩展为 ABC''<br />
: 如果 B 为真,则扩展为 ABC 连接后的结果;否则扩展为空。<br />
: 这是 {.if | B |{: A B C :}.} 的快捷方式。<br />
<br />
; break<br />
: ''释义:中断''<br />
: 中断宏的执行。<br />
: 可选参数 ''if'' 可以添加中断时的限制条件(相当于嵌套一个 {.if.})。<br />
: 可选参数的用法示例:<tt>{.break|if={.=|%user%|root.}.}</tt><br />
: 可选参数 ''result'' 会在宏中断后显示一行文本(仅当与可选参数 if 配合使用时)。<br />
<br />
== 数据的获取 ==<br />
; section | A<br />
: ''释义:获取节 A 的内容''<br />
: A 是您希望加载的一个 [节] 的名称。HFS 构建号 #160 之后它对大小写敏感。<br />
: 可选参数 ''file'' 可以使它从外部文件加载节。<br />
: 可选参数 ''back=1'' 可用于覆盖式模板(diff template)使其可以加载原模板中的节。这样您可以做到在覆盖其中的节后仍可访问原先的节。<br />
: 例如: <tt>{.section|names|file=tables.txt.}</tt><br />
; get | A<br />
: ''释义:获取属性 A 的值''<br />
: A 即您想要了解的属性。<br />
: 支持的属性有:<br />
:; can upload : 如果用户在当前文件夹有权限上传文件则为真。附加可选参数 ''path'' 可让您知道在另一个文件夹路径是否如此。<br />
:; can delete : 如果用户可以删除当前文件(夹)则为真。附加可选参数 ''path'' 可让您知道在另一个文件夹是否如此。<br />
:; can access : 如果用户有权限访问当前文件(夹)则为真。附加可选参数 ''path'' 可让您知道在另一个文件(夹)是否如此。<br />
:; can recur : 若选项 ''Recursive listing (递归列表,“允许在文件列表页面列出包含于文件夹中的文件”)'' 启用则为真。<br />
:; can archive : 如果当前文件(夹)可被打包则为真。<br />
:; is new : 若当前文件(夹)被标记为 "new (“新”)"则为真。<br />
:; accounts : 获取到所有用户的名称,用分号分隔。附加可选参数 '''groups''' 可只获取用户组。同样,附加可选参数 '''users''' 可只获取用户。<br />
:; stop spiders : 若选项 ''stop spider 阻止蜘蛛(网页爬虫)'' 启用则为真。<br />
:; protocolon : 若未启用选项 ''URLs starting with https(URL 以 https 开头)'' 则扩展为 <tt>http&#58;//</tt> 反之扩展为 <tt>https&#58;//</tt> (注意最后的 s).<br />
:; speed limit :扩展为当前的全局速度限制 (单位为 KB/s)。<br />
:; agent : 扩展为用户(可能)使用的浏览器。如,火狐会扩展为 Mozilla,IE8 会扩展为 MSIE 8.0。<br />
<br />
; urlvar | A : 获取 url 变量。即附加在地址后形如 <tt>?sort=s</tt> 的值。若您想知道此 url 变量中的 '''s''',可以使用宏 ''urlvar|sort''.<br />
: 可选参数 ''var'' 可使结果被储存在指定的变量中。<br />
; postvar | A : 与 ''urlvar'' 相似,但从请求的 POST 数据读取变量,而非 url。<br />
: 可选参数 ''var'' 可使结果被储存在指定的变量中。<br />
; header | A : 从 HTTP 请求的头部(Header)读取指定的数据值。<br />
; time | A : 扩展为当前服务器端的时间。可以在可选参数 A 处指定格式。请参考 [[HFS: Time format#Text formatting|此处]] 了解时间格式。若 A 未指定,则使用系统时间格式(格式“c”)。<br />
: 使用可选参数 ''when'' 可以指定 [[HFS: Time format#Numerical format|特定的时刻]]。<br />
: 使用可选参数 ''offset'' 指定偏移量。<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 translation, see [special:strings] part<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>
NaitLee
https://rejetto.com/wiki/index.php?title=Gallery&diff=5706
Gallery
2020-09-25T10:33:27Z
<p>NaitLee: Added new templates for 2.4 for a fine overview for new-comers.</p>
<hr />
<div>This Gallery provides a place where template makers can display their creations.<br><br />
Normally, a link to related forum page, or download link to a .zip or .rar file is also provided, perhaps with a note about how to use the template. (And/or a small text file inside the zip.)<br />
<br />
Most of these examples can be downloaded from the forum. Forum versions <br />
may well be more up-to-date than the versions shown here. The forum post of known [http://www.rejetto.com/forum/index.php?topic=1750.msg1008818#msg1008818 Shared Templates] also acts as an informal source for HFS templates.<br />
<br />
Most of the pictures in this section have been made smaller, for easy visibility. In user's browsers, of course, they display at full size.<br />
<br />
If you are not familiar with using HFS Templates, it is strongly recommended that you read the section "HTML Editor and Templates" in the section [[Refinements]]. This includes instructions about creating folders named C:/HFS and C:/HFS/Templates.<br />
---------<br />
= For ver. 2.4 (Beta) =<br />
== The Mobil-light Template ==<br />
[http://rejetto.com/forum/index.php?topic=11754.0 View on the Forum] <br />
<br />
'''Author: '''dj <br />
<br />
Features:<br />
* The most lightweight one, ever.<br />
* Mobile friendly.<br />
* Full-filled with powerful features.<br />
* Similar to the Default template (2.4), but used ajax, costs much less flow.<br />
* Many addons are supported.<br />
* For modern-enough browsers.<br />
<br />
== The Throwback Template ==<br />
[http://rejetto.com/forum/index.php?topic=12055.0 View on the Forum] <br />
<br />
'''Author: '''danny, dj <br />
<br />
Features:<br />
* Lightweight enough, never slows down the server.<br />
* Mobile friendly.<br />
* Filelist can stream between server and clients, that means the filelist stage will be half faster than ajax templates, having the ability to list millions of files with no worry.<br />
* Built-in thumbnail (lazyload) and music player.<br />
* Various versions are available, both for 2.3 and 2.4.<br />
* Works in almost all browsers.<br />
<br />
== The Takeback Template ==<br />
[http://rejetto.com/forum/index.php?topic=13287.0 View on the Forum] <br />
<br />
'''Author: '''NaitLee, danny, dj <br />
<br />
Features:<br />
* Based on Throwback. You may see it's heavy, but actually it's still lightweight as Throwback.<br />
* Mobile friendly.<br />
* Starry night (highlight) theme, different from other design styles. Picture background is also available.<br />
* Fully customizable in many ways.<br />
* Built-in powerful previewing function, music player, thumbnail and slideshow.<br />
* It's for modern browsers mainly, but also supports IE >= 10.<br />
<br />
== The Fuh Template ==<br />
View on the Forum: [http://rejetto.com/forum/index.php?topic=13368.0 1.0] [http://rejetto.com/forum/index.php?topic=13375.0 2.0] <br />
<br />
'''Author: '''fahad15090, rejetto<br />
<br />
Features:<br />
* Based on the default template, pure and friendly.<br />
* An upgraded design, with rich icon support.<br />
* Some addons are also included.<br />
<br />
= For ver. 2.3m or older =<br />
<br />
==The "Thunderchicken of Glory" Template==<br />
'''Author:''' RAWR-Designs<br />
<br />
[http://www.rawr-designs.com/projects/tog/index.html DOWNLOAD]<br />
<br />
© Christopher [http://www.rejetto.com/forum/index.php?action=profile;u=2138 'That Stevens Guy'] Stevens & Richard [http://www.rejetto.com/forum/index.php?action=profile;u=2365 'Giant Eagle'] Tuininga, [http://creativecommons.org/licenses/by-nc-sa/3.0/ Some Rights Reserved].<br />
---------<br />
<br />
==The "Terayon" Template==<br />
'''Author:''' RAWR-Designs<br />
<br />
[http://www.rawr-designs.com/projects/terayon/index.html DOWNLOAD]<br />
<br />
© Christopher [http://www.rejetto.com/forum/index.php?action=profile;u=2138 'That Stevens Guy'] Stevens & Richard [http://www.rejetto.com/forum/index.php?action=profile;u=2365 'Giant Eagle'] Tuininga, [http://creativecommons.org/licenses/by-nc-sa/3.0/ Some Rights Reserved].<br />
<br />
---------<br />
<br />
==The "RAWR-Template"==<br />
'''Author:''' RAWR-Designs<br />
<br />
[http://www.rawr-designs.com/projects/template/index.html DOWNLOAD]<br />
<br />
© Christopher [http://www.rejetto.com/forum/index.php?action=profile;u=2138 'That Stevens Guy'] Stevens & Richard [http://www.rejetto.com/forum/index.php?action=profile;u=2365 'Giant Eagle'] Tuininga, [http://creativecommons.org/licenses/by-nc-sa/3.0/ Some Rights Reserved].<br />
<br />
---------<br />
<br />
==The "Live" Template==<br />
'''Author:''' RAWR-Designs<br />
<br />
<i>Based on original template, Live, by Chrno</i><br />
<br />
[http://www.rawr-designs.com/projects/live/index.html DOWNLOAD]<br />
<br />
Version 3.0.0 or greater © Christopher [http://www.rejetto.com/forum/index.php?action=profile;u=2138 'That Stevens Guy'] Stevens & Richard [http://www.rejetto.com/forum/index.php?action=profile;u=2365 'Giant Eagle'] Tuininga, [http://creativecommons.org/licenses/by-nc-sa/3.0/ Some Rights Reserved].<br />
<br />
---------<br />
<br />
==The "Black" Template==<br />
'''Author:''' Mr Anon<br />
<br />
[http://www.rejetto.com/hfsfiles/That_Stevens_Guy/Beta%20Black.rar DOWNLOAD]</div>
NaitLee
https://rejetto.com/wiki/index.php?title=HFS:_%E5%AE%8F%E8%84%9A%E6%9C%AC%E5%91%BD%E4%BB%A4%E5%A4%A7%E5%85%A8&diff=5705
HFS: 宏脚本命令大全
2020-09-25T09:51:41Z
<p>NaitLee: </p>
<hr />
<div>宏脚本命令也叫模板宏。HFS 已预置许多功能性的指令,而您可以将其用于模板或事件文件中以创建、改进模板,制作出原本没有的功能。<br />
<br />
一些指令会简单地扩展为文本,用以显示一些信息。也有一些指令可以用以进行服务器端操作,例如删除文件。<br />
<br />
每一个指令都以名称的形式表达,有时也需要参数,用管道字符“|”分隔。<br />
<br />
以下将介绍一些宏,以供您使用。<br />
<br />
在阅读之前,您可能需要首先[http://rejetto.com/wiki/index.php?title=HFS:_%E6%A8%A1%E6%9D%BF%E5%AE%8F 了解模板编写]。<br />
<br />
== 逻辑与流程 ==<br />
; if | A | B | C<br />
: ''释义:如果 A 为真,那么 B,否则 C''<br />
: 如果 A 为真,那么 B 将被执行(扩展),否则 C 将被执行(扩展)。当它扩展为 B 时,C 就消失不见了。反之亦然。<br />
: 如何判断 A 为真?假值即空字符串或者数字 <tt>0</tt>。其余情况都为真。<br />
: 当 B 或 C 为宏时,请[http://rejetto.com/wiki/index.php?title=HFS:_%E6%A8%A1%E6%9D%BF%E5%AE%8F#.E9.97.AE.E9.A2.98.E4.B8.8E.E8.A7.A3.E5.86.B3.E6.96.B9.E6.A1.88 引用]它们。<br />
<br />
; if not | A | B | C <br />
: ''释义:如果 A 为假,那么 B,否则 C''<br />
: 与 ''if'' 相似,但是逻辑相反。<br />
<br />
; not | A<br />
: ''释义:非 A''<br />
: 反转逻辑。A 真则为假,A 假则为真。<br />
<br />
; and | A | B | ...<br />
: ''释义:A 且 B ……''<br />
: 当 A 与 B 都为真时则为真。具体说来,当结果为真时,它将返回(扩展为)最后一个参数。与 JavaScript 和 Python 相似,参数的个数没有限制。<br />
<br />
; or | A | B | ...<br />
: ''释义:A 或 B ……''<br />
: 如果 A 与 B 其中有一个为真,则为真。具体说来,它将返回第一个为真的值。如果参数都为假,那么它扩展为假值。这与 JavaScript 和 Python 相似。<br />
: 由于 HFS 宏基于字符串,您可以这样:{.if| A B | C .}。A 与 B 连接为单个字符串,如果有真值则为真。这可以方便地替代 {.or.}。<br />
<br />
; xor | A | B<br />
: ''释义:A 异或 B''<br />
: 当 A、B 中仅有一个为真时扩展为真值。<br />
<br />
; = | A | B | ...<br />
: ''释义:A 等于 B ……''<br />
: 若 A 与 B 相等则为真。它对字母大小写'''不'''敏感。不等于则为: '''!=''' 或者 '''<>'''。两者等价。参数的个数没有限制。<br />
<br />
; > | A | B | ...<br />
: ''释义:A 大于 B ……''<br />
: 若 A 大于 B 则为真。小于则为 '''<'''。参数的个数没有限制。<br />
<br />
; >= | A | B<br />
: ''释义:A 大于或等于 B ……''<br />
: 若 A 大于或等于 B 则为真。小于或等于则为 '''<='''。参数的个数没有限制。<br />
<br />
; between | A | B | C<br />
: ''释义:B 在 A 与 C 之间''<br />
: 若 B 在 A 与 C 之间则为真。包含 A、C(即闭区间)。<br />
<br />
; between! | A | B | C<br />
: ''释义:B 在 A 与 C 之间''<br />
: 若 B 在 A 与 C 之间则为真。不包含 A、C(即开区间)。<br />
<br />
; switch | A | B | C | D | E | F ...<br />
: ''释义:把 C,E…… 用 B 内容分隔后,若 A 包含于 C 中则 D,若 A 包含于 E 中则 F ……''<br />
: 这对非程序员可能难以理解。您可以参阅[http://en.wikipedia.org/wiki/Switch_statement#Examples 维基百科相关内容]并进行探究。<br />
<pre><nowiki><br />
switch(A) {<br />
case C.split(B)[0]: return D;<br />
case C.split(B)[1]: return D;<br />
case C.split(B)[2]: return D;<br />
// ...<br />
case E.split(B)[0]: return F;<br />
case E.split(B)[1]: return F;<br />
// ...<br />
}<br />
</nowiki></pre><br />
: B 是 C 与 E 内容的分隔符。更确切地说:如果 C 中包含几个用特定字符分隔的结果(如:3,5,7),您想让它们都返回 D 值,那么您可以指定一个 B 参数。<br />
: C 与 D、E 与 F 都是配对的。若最后一个参数未配对,那么它将作为默认(default)返回值——即当其他条件都不匹配时被返回。<br />
: 以下为维基百科页面中第一个样例在 HFS 宏中的表示:<br />
<pre><nowiki><br />
{.switch|%n%|,|<br />
0|您输入了零。|<br />
3,5,7|%n% 是一个质数。|<br />
4,6,8|%n% 是一个偶数。|<br />
2|%n% 既是质数又是偶数。|<br />
1,9|%n% 是一个完全平方数。|<br />
仅支持输入个位数。<br />
.}<br />
</nowiki></pre><br />
<br />
若需要使用许多 {.if.} 和 {.=.},{.switch.} 无疑是更好的选择。<br />
<br />
; for | A | B | C | D | E<br />
: ''释义:定义变量 A,使其值从 B 依次增加到 C,分别替换 D 中的 A 变量并扩展''<br />
: 重复扩展为 D,且将其中的 <tt>{.^A.}</tt> 变量替换为 B 与 C 之间的每一个数值(它们需要都为数字,步进为 1)。<br />
: 您也可以在 D 处使用可选变量 ''step'',这样可以更改数值的步进。这样做时此宏将重复扩展为 E。<br />
: 请记得引用在 D 或 E 处的宏文本。<br />
<br />
; for each | A | B | C ... | Z<br />
: ''释义:定义变量 A,使其值分别为 B, C, D, ...,分别替换最后一个参数中的 A 变量并扩展''<br />
: 一个有时更有用的 ''for'' 版本。请记得引用最后一个变量中的宏文本。<br />
: 例: <tt>{.for each|i|10|100|1000|{:now it's {.^i.} :}.}</tt><br />
<br />
; while | A | B<br />
: ''释义:当 A 为真时,重复扩展为 B''<br />
: 当 A 为真时,重复扩展为 B。B 变量将被自动取消引用。若 A 被引用,它将被扩展,否则它会成为替换 B 中相应变量的一个变量。<br />
: 可选参数 ''else'' 的值将会在 B 未被执行过时扩展。<br />
: 可选参数 ''timeout'' 可以让您定义此循环可进行的最大时间(单位为秒)。在未定义时它默认为 1 秒。<br />
: 可选参数 ''var'' 会使宏不扩展,而将本应扩展的值存入定义的变量。<br />
: 如: <tt>{.while|#x|{: {.dec|#x.} 欢迎! :}.}</tt> 会在 <tt>#x</tt> 变量值为 10 时欢迎您 10 次。<br />
<br />
; after the list | A<br />
: ''释义:仅在文件列表工作结束后执行 A''<br />
: 解除引用并执行 A——仅在文件列表工作结束之后才会如此。<br />
<br />
; dequote | A<br />
: ''释义:解除 A 的引用''<br />
: 如果 A 被 {:引用:},那么解除其引用(其中包含的宏文本也会被执行)。<br />
<br />
; 123 if 2 | A | B | C<br />
: ''释义:如果 B 为真,则扩展为 ABC''<br />
: 如果 B 为真,则扩展为 ABC 连接后的结果;否则扩展为空。<br />
: 这是 {.if | B |{: A B C :}.} 的快捷方式。<br />
<br />
; break<br />
: ''释义:中断''<br />
: 中断宏的执行。<br />
: 可选参数 ''if'' 可以添加中断时的限制条件(相当于嵌套一个 {.if.})。<br />
: 可选参数的用法示例:<tt>{.break|if={.=|%user%|root.}.}</tt><br />
: 可选参数 ''result'' 会在宏中断后显示一行文本(仅当与可选参数 if 配合使用时)。<br />
<br />
== 数据的获取 ==<br />
; section | A<br />
: ''释义:获取节 A 的内容''<br />
: A 是您希望加载的一个 [节] 的名称。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 translation, see [special:strings] part<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>
NaitLee
https://rejetto.com/wiki/index.php?title=HFS:_%E5%AE%8F%E8%84%9A%E6%9C%AC%E5%91%BD%E4%BB%A4%E5%A4%A7%E5%85%A8&diff=5704
HFS: 宏脚本命令大全
2020-09-13T03:29:45Z
<p>NaitLee: </p>
<hr />
<div>宏脚本命令也叫模板宏。HFS 已预置许多功能性的指令,而您可以将其用于模板或事件文件中以创建、改进模板,制作出原本没有的功能。<br />
<br />
一些指令会简单地扩展为文本,用以显示一些信息。也有一些指令可以用以进行服务器端操作,例如删除文件。<br />
<br />
每一个指令都以名称的形式表达,有时也需要参数,用管道字符“|”分隔。<br />
<br />
以下将介绍一些宏,以供您使用。<br />
<br />
在阅读之前,您可能需要首先[http://rejetto.com/wiki/index.php?title=HFS:_%E6%A8%A1%E6%9D%BF%E5%AE%8F 了解模板编写]。<br />
<br />
== 逻辑与流程 ==<br />
; if | A | B | C<br />
: ''释义:如果 A 为真,那么 B,否则 C''<br />
: 如果 A 为真,那么 B 将被执行(扩展),否则 C 将被执行(扩展)。当它扩展为 B 时,C 就消失不见了。反之亦然。<br />
: 如何判断 A 为真?假值即空字符串或者数字 <tt>0</tt>。其余情况都为真。<br />
: 当 B 或 C 为宏时,请[http://rejetto.com/wiki/index.php?title=HFS:_%E6%A8%A1%E6%9D%BF%E5%AE%8F#.E9.97.AE.E9.A2.98.E4.B8.8E.E8.A7.A3.E5.86.B3.E6.96.B9.E6.A1.88 引用]它们。<br />
<br />
; if not | A | B | C <br />
: ''释义:如果 A 为假,那么 B,否则 C''<br />
: 与 ''if'' 相似,但是逻辑相反。<br />
<br />
; not | A<br />
: ''释义:非 A''<br />
: 反转逻辑。A 真则为假,A 假则为真。<br />
<br />
; and | A | B | ...<br />
: ''释义:A 且 B ……''<br />
: 当 A 与 B 都为真时则为真。具体说来,当结果为真时,它将返回(扩展为)最后一个参数。与 JavaScript 和 Python 相似,参数的个数没有限制。<br />
<br />
; or | A | B | ...<br />
: ''释义:A 或 B ……''<br />
: 如果 A 与 B 其中有一个为真,则为真。具体说来,它将返回第一个为真的值。如果参数都为假,那么它扩展为假值。这与 JavaScript 和 Python 相似。<br />
: 由于 HFS 宏基于字符串,您可以这样:{.if| A B | C .}。A 与 B 连接为单个字符串,如果有真值则为真。这可以方便地替代 {.or.}。<br />
<br />
; xor | A | B<br />
: ''释义:A 异或 B''<br />
: 当 A、B 中仅有一个为真时扩展为真值。<br />
<br />
; = | A | B | ...<br />
: ''释义:A 等于 B ……''<br />
: 若 A 与 B 相等则为真。它对字母大小写'''不'''敏感。不等于则为: '''!=''' 或者 '''<>'''。两者等价。参数的个数没有限制。<br />
<br />
; > | A | B | ...<br />
: ''释义:A 大于 B ……''<br />
: 若 A 大于 B 则为真。小于则为 '''<'''。参数的个数没有限制。<br />
<br />
; >= | A | B<br />
: ''释义:A 大于或等于 B ……''<br />
: 若 A 大于或等于 B 则为真。小于或等于则为 '''<='''。参数的个数没有限制。<br />
<br />
; between | A | B | C<br />
: ''释义:B 在 A 与 C 之间''<br />
: 若 B 在 A 与 C 之间则为真。包含 A、C(即闭区间)。<br />
<br />
; between! | A | B | C<br />
: ''释义:B 在 A 与 C 之间''<br />
: 若 B 在 A 与 C 之间则为真。不包含 A、C(即开区间)。<br />
<br />
; switch | A | B | C | D | E | F ...<br />
: ''释义:把 C,E…… 用 B 内容分隔后,若 A 包含于 C 中则 D,若 A 包含于 E 中则 F ……''<br />
: 这对非程序员可能难以理解。您可以参阅[http://en.wikipedia.org/wiki/Switch_statement#Examples 维基百科相关内容]并进行探究。<br />
<pre><nowiki><br />
switch(A) {<br />
case C.split(B)[0]: return D;<br />
case C.split(B)[1]: return D;<br />
case C.split(B)[2]: return D;<br />
case E.split(B)[0]: return F;<br />
case E.split(B)[1]: return F;<br />
...<br />
}<br />
</nowiki></pre><br />
: B 是 C 与 E 内容的分隔符。更确切地说:如果 C 中包含几个用特定字符分隔的结果(如:3,5,7),您想让它们都返回 D 值,那么您可以指定一个 B 参数。<br />
: C 与 D、E 与 F 都是配对的。若最后一个参数未配对,那么它将作为默认(default)返回值——即当其他条件都不匹配时被返回。<br />
: 以下为维基百科页面中第一个样例在 HFS 宏中的表示:<br />
<pre><nowiki><br />
{.switch|%n%|,|<br />
0|您输入了零。|<br />
3,5,7|%n% 是一个质数。|<br />
4,6,8|%n% 是一个偶数。|<br />
2|%n% 既是质数又是偶数。|<br />
1,9|%n% 是一个完全平方数。|<br />
仅支持输入个位数。<br />
.}<br />
</nowiki></pre><br />
<br />
若需要使用许多 {.if.} 和 {.=.},{.switch.} 无疑是更好的选择。<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 />
: ''释义:仅在文件列表工作结束后执行 A''<br />
: 解除引用并执行 A——仅在文件列表工作结束之后才会如此。<br />
<br />
; dequote | A<br />
: ''释义:解除 A 的引用''<br />
: 如果 A 被 {:引用:},那么解除其引用(其中包含的宏文本也会被执行)。<br />
<br />
; 123 if 2 | A | B | C<br />
: ''释义:如果 B 为真,则扩展为 ABC''<br />
: 如果 B 为真,则扩展为 ABC 连接后的结果;否则扩展为空。<br />
: 这是 {.if | B |{: A B C :}.} 的快捷方式。<br />
<br />
; break<br />
: ''释义:中断''<br />
: 中断宏的执行。<br />
: 可选参数 ''if'' 可以添加中断时的限制条件(相当于嵌套一个 {.if.})。<br />
: 可选参数的用法示例:<tt>{.break|if={.=|%user%|root.}.}</tt><br />
: 可选参数 ''result'' 会在宏中断后显示一行文本(仅当与可选参数 if 配合使用时)。<br />
<br />
== 数据的获取 ==<br />
; section | A<br />
: ''释义:获取节 A 的内容''<br />
: A 是您希望加载的一个 [节] 的名称。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 translation, see [special:strings] part<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>
NaitLee
https://rejetto.com/wiki/index.php?title=HFS_%E5%B8%AE%E5%8A%A9%E6%96%87%E6%A1%A3_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=5703
HFS 帮助文档 (简体中文)
2020-09-08T04:08:40Z
<p>NaitLee: </p>
<hr />
<div>本翻译页面可能有些许失误,请以英文文档页面为准。<br />
<br />
此文档的大部分内容适用于 HFS 版本 2.2f——尽管有部分内容已过时。其他一些可能适用于 2.3 及以后版本。<br />
<br />
HFS Logo 标志的地球图像依 Planetary Visions Limited 的许可使用。<br />
<br />
本页面仍在建设中,请保持耐心!<br />
<br />
== 计划与进度 ==<br />
计划优先翻译有关模板宏的内容,以便更多人参与模板编写,让 HFS 更加强大!<br />
* [[HFS: 模板宏|了解模板编写(宏脚本)]] —— 于 2020-9-6 完成<br />
* [[HFS: 宏脚本命令大全|宏脚本命令大全]] —— 于 2020-9-6 开始<br />
* 其余仍指向英文页面(若需编辑,请新建相应的中文页面)<br />
<br />
== 教程 ==<br />
* [[HFS: Introduction|HFS 介绍]]<br />
* [[Use HFS to host a website|使用 HFS 建立一个服务器]]<br />
* [[HFS: Secure your server|使您的服务器更加安全]]<br />
* [[HFS: Working with uploads|探究上传]]<br />
* [[First time configuration|初次配置]]<br />
* [[Refinements|精制功能]]<br />
* [[User groups|用户组]]<br />
<br />
== 菜单 ==<br />
* [[HFS: Main menu|主菜单]]<br />
* [[HFS: Virtual File System menu|虚拟文件系统菜单]]<br />
* [[HFS: Log menu|日志菜单]]<br />
* [[HFS: Connections menu|连接菜单]]<br />
<br />
== 高级术语及用法 ==<br />
* [[HFS: The Virtual File System|虚拟文件系统]]<br />
* [[HFS: MIME Types|MIME 类型]]<br />
* [[HFS: File masks|文件蒙版(掩码)]]<br />
* [[HFS: IP masks|IP 蒙版(掩码)]]<br />
* [[HFS: Realms|领域]]<br />
* [[How does a webserver work|网络服务器如何工作]]<br />
* [[HFS: Template|模板系统如何工作]]<br />
* [[HFS: Comment files|从外部文件加载注释]]<br />
* [[HFS: Folder Archives|打包文件夹]]<br />
* [[HFS: URL parameters|URL 参数(地址操作符)]]<br />
* [[HFS: 模板宏|了解模板编写(宏脚本)]]<br />
* [[HFS: Event scripts|了解事件脚本]]<br />
* [[HFS: 宏脚本命令大全|宏脚本命令大全]]<br />
<br />
== 杂项 ==<br />
* [[HFS: Hidden things|隐藏功能]]<br />
* [[HFS: Command line parameters|命令行参数]]<br />
* [[HFS Frequently Asked Questions (english)|常见问题(F.A.Q.)]]<br />
* [[HFS: Similar software|相似的软件]]<br />
* [[FHFS|FHFS(带有 FTP 功能的 HFS)]]<br />
* [[HFS: Glossary|相关术语]]<br />
* [[Gallery|模板展览]]<br />
* [[HFS: Known limits|已知限制]]<br />
* [[HFS: History|历史]]</div>
NaitLee
https://rejetto.com/wiki/index.php?title=HFS:_%E5%AE%8F%E8%84%9A%E6%9C%AC%E5%91%BD%E4%BB%A4%E5%A4%A7%E5%85%A8&diff=5702
HFS: 宏脚本命令大全
2020-09-06T03:49:30Z
<p>NaitLee: Created page with "宏脚本命令也叫模板宏。HFS 已预置许多功能性的指令,而您可以将其用于模板或事件文件中以创建、改进模板,制作出原本没有的功..."</p>
<hr />
<div>宏脚本命令也叫模板宏。HFS 已预置许多功能性的指令,而您可以将其用于模板或事件文件中以创建、改进模板,制作出原本没有的功能。<br />
<br />
一些指令会简单地扩展为文本,用以显示一些信息。也有一些指令可以用以进行服务器端操作,例如删除文件。<br />
<br />
每一个指令都以名称的形式表达,有时也需要参数,用管道字符“|”分隔。<br />
<br />
以下将介绍一些宏,以供您使用。<br />
<br />
在阅读之前,您可能需要首先[http://rejetto.com/wiki/index.php?title=HFS:_%E6%A8%A1%E6%9D%BF%E5%AE%8F 了解模板编写]。<br />
<br />
== 逻辑与流程 ==<br />
; if | A | B | C<br />
: ''释义:如果 A 为真,那么 B,否则 C''<br />
: 如果 A 为真,那么 B 将被执行(扩展),否则 C 将被执行(扩展)。当它扩展为 B 时,C 就消失不见了。反之亦然。<br />
: 如何判断 A 为真?假值即空字符串或者数字 <tt>0</tt>。其余情况都为真。<br />
: 当 B 或 C 为宏时,请[http://rejetto.com/wiki/index.php?title=HFS:_%E6%A8%A1%E6%9D%BF%E5%AE%8F#.E9.97.AE.E9.A2.98.E4.B8.8E.E8.A7.A3.E5.86.B3.E6.96.B9.E6.A1.88 引用]它们。<br />
<br />
; if not | A | B | C <br />
: ''释义:如果 A 为假,那么 B,否则 C''<br />
: 与 ''if'' 相似,但是逻辑相反。<br />
<br />
; not | A<br />
: ''释义:非 A''<br />
: 反转逻辑。A 真则为假,A 假则为真。<br />
<br />
; and | A | B | ...<br />
: ''释义:A 且 B ……''<br />
: 当 A 与 B 都为真时则为真。具体说来,当结果为真时,它将返回(扩展为)最后一个参数。与 JavaScript 和 Python 相似,参数的个数没有限制。<br />
<br />
; or | A | B | ...<br />
: ''释义:A 或 B ……''<br />
: 如果 A 与 B 其中有一个为真,则为真。具体说来,它将返回第一个为真的值。如果参数都为假,那么它扩展为假值。这与 JavaScript 和 Python 相似。<br />
: 由于 HFS 宏基于字符串,您可以这样:{.if| A B | C .}。A 与 B 连接为单个字符串,如果有真值则为真。这可以方便地替代 {.or.}。<br />
<br />
; xor | A | B<br />
: ''释义:A 异或 B''<br />
: 当 A、B 中仅有一个为真时扩展为真值。<br />
<br />
; = | A | B | ...<br />
: ''释义:A 等于 B ……''<br />
: 若 A 与 B 相等则为真。它对字母大小写'''不'''敏感。不等于则为: '''!=''' 或者 '''<>'''。两者等价。参数的个数没有限制。<br />
<br />
; > | A | B | ...<br />
: ''释义:A 大于 B ……''<br />
: 若 A 大于 B 则为真。小于则为 '''<'''。参数的个数没有限制。<br />
<br />
; >= | A | B<br />
: ''释义:A 大于或等于 B ……''<br />
: 若 A 大于或等于 B 则为真。小于或等于则为 '''<='''。参数的个数没有限制。<br />
<br />
; between | A | B | C<br />
: ''释义:B 在 A 与 C 之间''<br />
: 若 B 在 A 与 C 之间则为真。包含 A、C(即闭区间)。<br />
<br />
; between! | A | B | C<br />
: ''释义:B 在 A 与 C 之间''<br />
: 若 B 在 A 与 C 之间则为真。不包含 A、C(即开区间)。<br />
<br />
; switch | A | B | C | D | E | F ...<br />
: ''释义:把 C,E…… 用 B 内容分隔后,若 A 包含于 C 中则 D,若 A 包含于 E 中则 F ……''<br />
: 这对非程序员可能难以理解。您可以参阅[http://en.wikipedia.org/wiki/Switch_statement#Examples 维基百科相关内容]并进行探究。<br />
<pre><nowiki><br />
switch(A) {<br />
case C.split(B)[0]: return D;<br />
case C.split(B)[1]: return D;<br />
case C.split(B)[2]: return D;<br />
case E.split(B)[0]: return F;<br />
case E.split(B)[1]: return F;<br />
...<br />
}<br />
</nowiki></pre><br />
: B 是 C 与 E 内容的分隔符。更确切地说:如果 C 中包含几个用特定字符分隔的结果(如:3,5,7),您想让它们都返回 D 值,那么您可以指定一个 B 参数。<br />
: C 与 D、E 与 F 都是配对的。若最后一个参数未配对,那么它将作为默认(default)返回值——即当其他条件都不匹配时被返回。<br />
: 以下为维基百科页面中第一个样例在 HFS 宏中的表示:<br />
<pre><nowiki><br />
{.switch|%n%|,|<br />
0|您输入了零。|<br />
3,5,7|%n% 是一个质数。|<br />
4,6,8|%n% 是一个偶数。|<br />
2|%n% 既是质数又是偶数。|<br />
1,9|%n% 是一个完全平方数。|<br />
仅支持输入个位数。<br />
.}<br />
</nowiki></pre><br />
<br />
若需要使用许多 {.if.} 和 {.=.},{.switch.} 无疑是更好的选择。<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 translation, see [special:strings] part<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>
NaitLee
https://rejetto.com/wiki/index.php?title=HFS_%E5%B8%AE%E5%8A%A9%E6%96%87%E6%A1%A3_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=5701
HFS 帮助文档 (简体中文)
2020-09-06T02:56:51Z
<p>NaitLee: </p>
<hr />
<div>本翻译页面可能有些许失误,请以英文文档页面为准。<br />
<br />
此文档的大部分内容适用于 HFS 版本 2.2f——尽管有部分内容已过时。其他一些可能适用于 2.3 及以后版本。<br />
<br />
HFS Logo 标志的地球图像依 Planetary Visions Limited 的许可使用。<br />
<br />
本页面仍在建设中,请保持耐心!<br />
<br />
== 计划与进度 ==<br />
计划优先翻译有关模板宏的内容,以便更多人参与模板编写,让 HFS 更加强大!<br />
* [[HFS: 模板宏|了解模板编写(宏脚本)]] —— 于 2020-9-6 完成<br />
* [[HFS: 宏脚本命令大全|宏脚本命令大全]] —— 于 2020-9-6 开始<br />
* 其余仍为英文<br />
<br />
== 教程 ==<br />
* [[HFS: Introduction|HFS 介绍]]<br />
* [[Use HFS to host a website|使用 HFS 建立一个服务器]]<br />
* [[HFS: Secure your server|使您的服务器更加安全]]<br />
* [[HFS: Working with uploads|探究上传]]<br />
* [[First time configuration|初次配置]]<br />
* [[Refinements|精制功能]]<br />
* [[User groups|用户组]]<br />
<br />
== 菜单 ==<br />
* [[HFS: Main menu|主菜单]]<br />
* [[HFS: Virtual File System menu|虚拟文件系统菜单]]<br />
* [[HFS: Log menu|日志菜单]]<br />
* [[HFS: Connections menu|连接菜单]]<br />
<br />
== 高级术语及用法 ==<br />
* [[HFS: The Virtual File System|虚拟文件系统]]<br />
* [[HFS: MIME Types|MIME 类型]]<br />
* [[HFS: File masks|文件蒙版(掩码)]]<br />
* [[HFS: IP masks|IP 蒙版(掩码)]]<br />
* [[HFS: Realms|领域]]<br />
* [[How does a webserver work|网络服务器如何工作]]<br />
* [[HFS: Template|模板系统如何工作]]<br />
* [[HFS: Comment files|从外部文件加载注释]]<br />
* [[HFS: Folder Archives|打包文件夹]]<br />
* [[HFS: URL parameters|URL 参数(地址操作符)]]<br />
* [[HFS: 模板宏|了解模板编写(宏脚本)]]<br />
* [[HFS: Event scripts|了解事件脚本]]<br />
* [[HFS: 宏脚本命令大全|宏脚本命令大全]]<br />
<br />
== 杂项 ==<br />
* [[HFS: Hidden things|隐藏功能]]<br />
* [[HFS: Command line parameters|命令行参数]]<br />
* [[HFS Frequently Asked Questions (english)|常见问题(F.A.Q.)]]<br />
* [[HFS: Similar software|相似的软件]]<br />
* [[FHFS|FHFS(带有 FTP 功能的 HFS)]]<br />
* [[HFS: Glossary|相关术语]]<br />
* [[Gallery|模板展览]]<br />
* [[HFS: Known limits|已知限制]]<br />
* [[HFS: History|历史]]</div>
NaitLee
https://rejetto.com/wiki/index.php?title=HFS:_%E6%A8%A1%E6%9D%BF%E5%AE%8F&diff=5700
HFS: 模板宏
2020-09-06T02:55:13Z
<p>NaitLee: Fully translated</p>
<hr />
<div>HFS 支持服务器端语言(指令),也叫做宏。这种语言在模板和事件脚本中的表现几乎相同。<br />
<br />
'''请注意:''' 2.3 之前的版本不支持宏。<br />
<br />
宏很强大,可以用于给 HFS 及其文件页面添加新的功能。<br />
<br />
== 宏是如何工作的 ==<br />
<br />
=== 与占位符的不同 ===<br />
您需要对[[HFS: Template#How_templates_work|模板如何工作]]有大概的了解。宏与占位符相似。输入的宏将在用户浏览页面时被替换为有实际意义的内容(我们称之“扩展”)。<br />
<br />
占位符只代表一个名称,而宏有自己的功能及相应的参数。占位符只会被替换为文本(比如 %user% 替换为当前用户),而宏被用来在 HFS 服务器端进行指令操作(如 {.load.} 用以加载文件内容)。 <br />
<br />
您可以很简单地区分占位符与宏:占位符由 %百分号% 包围,而宏由 <nowiki>{.带点的大括号.}</nowiki> 包围.<br />
<br />
=== 更多 ===<br />
宏如何工作取决于输入的参数。一个宏根据输入的参数可进行不同的操作。<br />
<br />
在一个模板中,宏 ''section'' 会复制位于该模板中所定义的一个 [节] 的内容——而您应该添加一个具体参数,使它知道应该读取哪一个节。<br />
<br />
例如:<tt><nowiki>{.section|style.}</nowiki></tt> 将会读取节 [style] 的内容。该宏的快捷方式是 {.$style.}。<br />
<br />
=== 参数 ===<br />
在宏名称的后面,您可以添加管道字符“|”以添加参数,如:<tt><nowiki>{.宏名称|参数.}</nowiki></tt>.<br />
如果需要更多参数,只需添加更多管道字符:<tt><nowiki>{.宏名称 | 参数1 | 参数2 | 参数3.}</nowiki></tt>.<br />
<br />
=== 可读性 ===<br />
宏是可以嵌套的。不过,这可能使得宏难以阅读。为了增加宏的可读性,您可以:<br />
* 将每个宏排列到独立的行并[http://en.wikipedia.org/wiki/Indentation#Indentation_in_programming 缩进].<br />
* 在一层宏的结尾添加: <tt>/宏名称</tt> 以提示自己关闭了一个宏。例如:<tt><nowiki>{.load|{.section|stuff /section.} /load.}</nowiki></tt>。最后的 <tt>/section</tt> 和 <tt>/load</tt> 会被 HFS 忽略——这只是为了您的便利。<br />
<br />
=== 引用 ===<br />
某些情况下,您可能不希望 HFS 将某段文本当作宏处理。有一种不让 HFS 处理这种文本的方式,叫做“引用”。<br />
<br />
要引用一段文本,只需用带冒号的大括号包围: <tt>{:这是一段普通文本,并且{.这个宏不会被执行.}:}</tt>。<br />
<br />
同时引用还可以让宏 ''set'' 和 ''if'' 不提前执行其参数宏指令——您会在后面有所了解。<br />
<br />
如果您需要在宏参数中使用管道字符而不分割参数,引用就是一种方法。<br />
例如: <tt>{.add to log|输出一个管道字符:{:|:}.}</tt>。如此您可在日志中使用管道字符。您也可以使用宏 ''no pipe'':<tt>{.no pipe||.}</tt><br />
<br />
== 可用的指令 ==<br />
HFS 预置了许多实用指令。请参阅[[HFS: 宏脚本命令大全|完整列表]]。<br />
<br />
== 执行次序 ==<br />
如果宏是嵌套的,那么它们的执行次序为:从里到外,从左到右。宏的嵌套格式就像 XHTML,以保证其不重叠。<br />
<br />
比如:<tt>{.A {.B.} {.C.}.} {.D.}</tt>。在此例中,宏的执行顺序为: B, C, A, D。HFS 在处理 B 与 C 前不能处理 A——因为 HFS 仍不知道 B 与 C 的最终结果,而 B、C 的最终结果才是 A 要处理的。<br />
<br />
=== 问题与解决方案 ===<br />
除了[[#Quoting|被引用的宏]]之外,其他宏都会被扩展。不过,''if'' 宏 <tt>{.if | A | B | C .}</tt> 根据 A 来判断执行(扩展为) B 还是 C,但是如果 B 与 C 本身是宏,那么 B 与 C 总是会被执行。<br />
<br />
因此我们需要''引用'' B 与 C。引用后,B 与 C 不会被提前执行,而是会在 ''if'' 判断符合条件后解除引用,然后被正确执行。<br />
当然,如果 B 与 C 都是常文本,那么它们不必被引用。<br />
<br />
比如:<br />
<tt><nowiki>{.if| %user% | {.append|日志文件.txt|有用户登录了哦!.} .}</nowiki></tt><br />
如前文所描述,无论占位符 %user% 扩展为何,{.append.} 宏总是会被执行——这不是我们想要的。<br />
<br />
然而,当我们将宏引用后:<br />
<tt><nowiki>{.if| %user% | {:{.append|日志文件.txt|有用户登录了哦!.}:} .}</nowiki></tt><br />
仅当 %user% 扩展为空时(值为假),{.append.} 宏才会被解除引用并执行。<br />
<br />
在其他情况下,您需要使用宏 {.dequote.} 来解除引用。不过如 ''if'' 之类的特殊宏则不必。此类宏有:''if'', ''set'', ''for'', ''for each'', ''switch'' 和 ''breadcrumbs''。这允许您使用变量改变输出。<br />
<br />
=== 预处理 ===<br />
如果您需要在每份文件页面加载之前处理一些宏,那么您可以将宏放置在节 '''[special:begin]''' 下。如:<br />
<br />
<pre><nowiki><br />
[special:begin] <br />
{.if| %user% | {:{.append|日志文件.txt|用户 %user% 登录了哦!.}:} .}<br />
</nowiki></pre></div>
NaitLee
https://rejetto.com/wiki/index.php?title=HFS_%E5%B8%AE%E5%8A%A9%E6%96%87%E6%A1%A3_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=5699
HFS 帮助文档 (简体中文)
2020-09-06T01:55:57Z
<p>NaitLee: </p>
<hr />
<div>本翻译页面可能有些许失误,请以英文文档页面为准。<br />
<br />
此文档的大部分内容适用于 HFS 版本 2.2f——尽管有部分内容已过时。其他一些可能适用于 2.3 及以后版本。<br />
<br />
HFS Logo 标志的地球图像依 Planetary Visions Limited 的许可使用。<br />
<br />
本页面仍在建设中,请保持耐心!<br />
<br />
== 计划与进度 ==<br />
计划优先翻译有关模板宏的内容,以便更多人参与模板编写,让 HFS 更加强大!<br />
* [[HFS: 模板宏|了解模板编写(宏脚本)]] —— 于 2020-9-6 完成很小一部分<br />
* 其余仍为英文<br />
<br />
== 教程 ==<br />
* [[HFS: Introduction|HFS 介绍]]<br />
* [[Use HFS to host a website|使用 HFS 建立一个服务器]]<br />
* [[HFS: Secure your server|使您的服务器更加安全]]<br />
* [[HFS: Working with uploads|探究上传]]<br />
* [[First time configuration|初次配置]]<br />
* [[Refinements|精制功能]]<br />
* [[User groups|用户组]]<br />
<br />
== 菜单 ==<br />
* [[HFS: Main menu|主菜单]]<br />
* [[HFS: Virtual File System menu|虚拟文件系统菜单]]<br />
* [[HFS: Log menu|日志菜单]]<br />
* [[HFS: Connections menu|连接菜单]]<br />
<br />
== 高级术语及用法 ==<br />
* [[HFS: The Virtual File System|虚拟文件系统]]<br />
* [[HFS: MIME Types|MIME 类型]]<br />
* [[HFS: File masks|文件蒙版(掩码)]]<br />
* [[HFS: IP masks|IP 蒙版(掩码)]]<br />
* [[HFS: Realms|领域]]<br />
* [[How does a webserver work|网络服务器如何工作]]<br />
* [[HFS: Template|模板系统如何工作]]<br />
* [[HFS: Comment files|从外部文件加载注释]]<br />
* [[HFS: Folder Archives|打包文件夹]]<br />
* [[HFS: URL parameters|URL 参数(地址操作符)]]<br />
* [[HFS: 模板宏|了解模板编写(宏脚本)]]<br />
* [[HFS: Event scripts|了解事件脚本]]<br />
* [[HFS: scripting commands|宏脚本命令大全]]<br />
<br />
== 杂项 ==<br />
* [[HFS: Hidden things|隐藏功能]]<br />
* [[HFS: Command line parameters|命令行参数]]<br />
* [[HFS Frequently Asked Questions (english)|常见问题(F.A.Q.)]]<br />
* [[HFS: Similar software|相似的软件]]<br />
* [[FHFS|FHFS(带有 FTP 功能的 HFS)]]<br />
* [[HFS: Glossary|相关术语]]<br />
* [[Gallery|模板展览]]<br />
* [[HFS: Known limits|已知限制]]<br />
* [[HFS: History|历史]]</div>
NaitLee
https://rejetto.com/wiki/index.php?title=HFS_%E5%B8%AE%E5%8A%A9%E6%96%87%E6%A1%A3_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=5698
HFS 帮助文档 (简体中文)
2020-09-05T17:58:55Z
<p>NaitLee: </p>
<hr />
<div>本翻译页面可能有些许失误,请以英文文档页面为准。<br />
<br />
此文档的大部分内容适用于 HFS 版本 2.2f——尽管有部分内容已过时。其他一些可能适用于 2.3 及以后版本。<br />
<br />
HFS Logo 标志的地球图像依 Planetary Visions Limited 的许可使用。<br />
<br />
本页面仍在建设中,请保持耐心!<br />
== 进度 ==<br />
* [[HFS: 模板宏|了解模板编写(宏脚本)]] —— 2020-9-6 完成很小一部分<br />
* 其余仍为英文<br />
<br />
== 教程 ==<br />
* [[HFS: Introduction|HFS 介绍]]<br />
* [[Use HFS to host a website|使用 HFS 建立一个服务器]]<br />
* [[HFS: Secure your server|使您的服务器更加安全]]<br />
* [[HFS: Working with uploads|探究上传]]<br />
* [[First time configuration|初次配置]]<br />
* [[Refinements|精制功能]]<br />
* [[User groups|用户组]]<br />
<br />
== 菜单 ==<br />
* [[HFS: Main menu|主菜单]]<br />
* [[HFS: Virtual File System menu|虚拟文件系统菜单]]<br />
* [[HFS: Log menu|日志菜单]]<br />
* [[HFS: Connections menu|连接菜单]]<br />
<br />
== 高级术语及用法 ==<br />
* [[HFS: The Virtual File System|虚拟文件系统]]<br />
* [[HFS: MIME Types|MIME 类型]]<br />
* [[HFS: File masks|文件蒙版(掩码)]]<br />
* [[HFS: IP masks|IP 蒙版(掩码)]]<br />
* [[HFS: Realms|领域]]<br />
* [[HFS: Template|模板系统如何工作]]<br />
* [[How does a webserver work|一个网络服务器是如何工作的?]]<br />
* [[HFS: Comment files|从外部文件加载注释]]<br />
* [[HFS: Folder Archives|打包文件夹]]<br />
* [[HFS: URL parameters|URL 参数(地址操作符)]]<br />
* [[HFS: 模板宏|了解模板编写(宏脚本)]]<br />
* [[HFS: Event scripts|了解事件脚本]]<br />
* [[HFS: scripting commands|宏脚本命令大全]]<br />
<br />
== 杂项 ==<br />
* [[HFS: Hidden things|隐藏功能]]<br />
* [[HFS: Command line parameters|命令行参数]]<br />
* [[HFS Frequently Asked Questions (english)|常见问题(F.A.Q.)]]<br />
* [[HFS: Similar software|相似的软件]]<br />
* [[FHFS|FHFS(带有 FTP 功能的 HFS)]]<br />
* [[HFS: Glossary|相关术语]]<br />
* [[Gallery|模板展览]]<br />
* [[HFS: Known limits|已知限制]]<br />
* [[HFS: History|历史]]</div>
NaitLee
https://rejetto.com/wiki/index.php?title=HFS:_%E6%A8%A1%E6%9D%BF%E5%AE%8F&diff=5697
HFS: 模板宏
2020-09-05T17:55:44Z
<p>NaitLee: Created page with "HFS 支持服务器端语言(指令),也叫做宏。这种语言在模板和事件脚本中的表现几乎相同。 '''请注意:''' 2.3 之前的版本不支持宏..."</p>
<hr />
<div>HFS 支持服务器端语言(指令),也叫做宏。这种语言在模板和事件脚本中的表现几乎相同。<br />
<br />
'''请注意:''' 2.3 之前的版本不支持宏。<br />
<br />
宏很强大,可以用于给 HFS 及其文件页面添加新的功能。<br />
<br />
== 宏是如何工作的 ==<br />
<br />
=== 与占位符的不同 ===<br />
您需要对[[HFS: Template#How_templates_work|模板如何工作]]有大概的了解。宏与占位符相似。输入的宏将在用户浏览页面时被替换为有实际意义的内容(我们称之“扩展”)。<br />
<br />
占位符只代表一个名称,而宏有自己的功能及相应的参数。占位符只会被替换为文本(比如 %user% 替换为当前用户),而宏被用来在 HFS 服务器端进行指令操作(如 {.load.} 用以加载文件内容)。 <br />
<br />
您可以很简单地区分占位符与宏:占位符由 %百分号% 包围,而宏由 <nowiki>{.带点的大括号.}</nowiki> 包围.<br />
<br />
=== More on them ===<br />
How the macro will work depends on the parameters. The same macro can have a variety of functions based on its parameters.<br />
<br />
The macro ''section'' will copy the content of a [section] of the template. The parameter in the macro specifies which section. So, you have one macro, ''section'', but it will expand to any content as you change the name of the section (as parameter). Let's say <tt><nowiki>{.section|style.}</nowiki></tt> and it will copy the content of section [style]. A shortcut for this is {.$style.}.<br />
<br />
=== Parameters ===<br />
After the macro name you specify parameters with "|" (pipes) and then the parameter: <tt><nowiki>{.name|parameter.}</nowiki></tt>.<br />
If the macro requires more parameters, you just add more pipes: <tt><nowiki>{.name | parameter | another parameter | a third parameter.}</nowiki></tt>.<br />
<br />
=== Readability ===<br />
You can also put macros inside macros, or nest them. However, this can often be a mess to read. To increase readability, you can:<br />
* split the syntax over several lines, and [http://en.wikipedia.org/wiki/Indentation#Indentation_in_programming indent].<br />
* add a final <tt>/macroname</tt> to know that you are closing just that macro, like <tt><nowiki>{.load|{.section|stuff /section.} /load.}</nowiki></tt>. The final <tt>/load</tt> is ignored by hfs, it's just for your convenience.<br />
<br />
=== Quoting ===<br />
Sometimes you don't want HFS to consider plain text as part of the macro syntax. There's a way to tell HFS to not process the text, and it is called ''quoting''.<br />
<br />
To quote text you type <tt>{:</tt> then the text you want. To close the quoting just type <tt>:}</tt> .<br />
<br />
This capability is very useful with macros ''set'' and ''if''. You'll see later.<br />
<br />
Sometimes you may need to use the pipe in plain text. To tell HFS not to interpret it as a parameter, you can quote it.<br />
Example: <tt>{.add to log|print{:|:}pipes.}</tt> to have the pipe character in your log. Additionally, you can use the command {.no pipe||.}<br />
<br />
== Available commands ==<br />
Refer to [[HFS: scripting commands|the full list]] for available commands.<br />
<br />
== Execution order ==<br />
The current execution order of macros is: from inner to outer, from left to right. Macros are like XHTML in that they cannot overlap.<br />
<br />
An example: <tt>{.A {.B.} {.C.}.} {.D.}</tt>. In this scenario, the order is B, C, A, D. HFS cannot process A until B and C are processed because it doesn't yet know what the macro {.A.} contains. <br />
<br />
=== Problem and Solution ===<br />
All macros, except [[#Quoting|quoted ones]], are expanded, not matter what. For example, if you have the command {.if | A | B | C .}, then B and C will both be expanded, no matter what A is.<br />
<br />
Since it is important to be able to select the execution of B or C based on the value of A, there's a workaround.<br />
By quoting B and C, you stop them from being executed. After the ''if'' command chooses between B (''then'') and C (''else'') based on A, it removes the surrounding quoting markers, if any, executing the proper command. However, if B and C contain only text and not macros, they do not need to be quoted.<br />
Here's an example:<br />
<tt><nowiki>{.if| %user% | {.append|file.txt|someone is in!.} .}</nowiki></tt><br />
As we stated before, this is not going to choose whether or not to execute the append command. ''Append'' will always be executed, because every macro is executed. The only way to stop this is to surround with quoting markers:<br />
<tt><nowiki>{.if| %user% | {:{.append|file.txt|someone is in!.}:} .}</nowiki></tt><br />
By having quoted the ''append'', it will only be dequoted and then executed if ''%user%'' is not void. This is because the ''if'' automatically removes the appropriate quoting markers.<br />
<br />
Normally you would have to remove the markers yourself, by using macro ''dequote''. But some macros (like ''if'') have this special behavior, for your convenience. The special macros with such behavior are: ''if'', ''set'', ''for'', ''for each'', ''switch'' and ''breadcrumbs''. These allow you to use variables to change output.<br />
<br />
=== From the beginning ===<br />
Sometimes you need to be sure something gets done before every page is built and sent to the browser. In such case, you can put all your macros in the section '''[special:begin]'''.</div>
NaitLee
https://rejetto.com/wiki/index.php?title=HFS_%E5%B8%AE%E5%8A%A9%E6%96%87%E6%A1%A3_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=5696
HFS 帮助文档 (简体中文)
2020-09-05T17:40:14Z
<p>NaitLee: </p>
<hr />
<div>本翻译页面可能有些许失误,请以英文文档页面为准。<br />
<br />
本页面仍在建设中,请保持耐心!<br />
<br />
此文档的大部分内容适用于 HFS 版本 2.2f——尽管有部分内容已过时。其他一些可能适用于 2.3 及以后版本。<br />
<br />
HFS Logo 标志的地球图像依 Planetary Visions Limited 的许可使用。<br />
<br />
== 教程 ==<br />
* [[HFS: Introduction|HFS 介绍]]<br />
* [[Use HFS to host a website|使用 HFS 建立一个服务器]]<br />
* [[HFS: Secure your server|使您的服务器更加安全]]<br />
* [[HFS: Working with uploads|探究上传]]<br />
* [[First time configuration|初次配置]]<br />
* [[Refinements|精制功能]]<br />
* [[User groups|用户组]]<br />
<br />
== 菜单 ==<br />
* [[HFS: Main menu|主菜单]]<br />
* [[HFS: Virtual File System menu|虚拟文件系统菜单]]<br />
* [[HFS: Log menu|日志菜单]]<br />
* [[HFS: Connections menu|连接菜单]]<br />
<br />
== 高级术语及用法 ==<br />
* [[HFS: The Virtual File System|虚拟文件系统]]<br />
* [[HFS: MIME Types|MIME 类型]]<br />
* [[HFS: File masks|文件蒙版(掩码)]]<br />
* [[HFS: IP masks|IP 蒙版(掩码)]]<br />
* [[HFS: Realms|领域]]<br />
* [[HFS: Template|模板系统如何工作]]<br />
* [[How does a webserver work|一个网络服务器是如何工作的?]]<br />
* [[HFS: Comment files|从外部文件加载注释]]<br />
* [[HFS: Folder Archives|打包文件夹]]<br />
* [[HFS: URL parameters|URL 参数(地址操作符)]]<br />
* [[HFS: Template macros|了解模板编写(宏脚本)]]<br />
* [[HFS: Event scripts|了解事件脚本]]<br />
* [[HFS: scripting commands|宏脚本命令大全]]<br />
<br />
== 杂项 ==<br />
* [[HFS: Hidden things|隐藏功能]]<br />
* [[HFS: Command line parameters|命令行参数]]<br />
* [[HFS Frequently Asked Questions (english)|常见问题(F.A.Q.)]]<br />
* [[HFS: Similar software|相似的软件]]<br />
* [[FHFS|FHFS(带有 FTP 功能的 HFS)]]<br />
* [[HFS: Glossary|相关术语]]<br />
* [[Gallery|模板展览]]<br />
* [[HFS: Known limits|已知限制]]<br />
* [[HFS: History|历史]]</div>
NaitLee
https://rejetto.com/wiki/index.php?title=HFS_%E5%B8%AE%E5%8A%A9%E6%96%87%E6%A1%A3_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=5695
HFS 帮助文档 (简体中文)
2020-09-05T17:37:11Z
<p>NaitLee: </p>
<hr />
<div>本翻译页面可能有些许失误,请以英文文档页面为准。<br />
<br />
本页面仍在建设中,请保持耐心!<br />
<br />
此文档的大部分内容适用于 HFS 版本 2.2f——尽管有部分内容已过时。其他一些可能适用于 2.3 及以后版本。<br />
<br />
HFS Logo 标志的地球图像依 Planetary Visions Limited 的许可使用。<br />
<br />
== 教程 ==<br />
* [[HFS: Introduction|HFS 介绍]]<br />
* [[HFS: Secure your server|使您的服务器更加安全]]<br />
* [[Use HFS to host a website|使用 HFS 建立一个服务器]]<br />
* [[HFS: Working with uploads|探究上传]]<br />
* [[First time configuration|初次配置]]<br />
* [[Refinements|精制功能]]<br />
* [[User groups|用户组]]<br />
<br />
== 菜单 ==<br />
* [[HFS: Main menu|主菜单]]<br />
* [[HFS: Virtual File System menu|虚拟文件系统菜单]]<br />
* [[HFS: Log menu|日志菜单]]<br />
* [[HFS: Connections menu|连接菜单]]<br />
<br />
== 高级术语及用法 ==<br />
* [[HFS: The Virtual File System|虚拟文件系统]]<br />
* [[HFS: MIME Types|MIME 类型]]<br />
* [[HFS: File masks|文件蒙版(掩码)]]<br />
* [[HFS: IP masks|IP 蒙版(掩码)]]<br />
* [[HFS: Realms|领域]]<br />
* [[HFS: Template|模板系统如何工作]]<br />
* [[How does a webserver work|一个网络服务器是如何工作的]]?<br />
* [[HFS: Comment files|从外部文件加载注释]]<br />
* [[HFS: Folder Archives|打包文件夹]]<br />
* [[HFS: URL parameters|URL 参数 (也叫地址操作符)]]<br />
* [[HFS: Template macros|了解模板编写(宏脚本)]]<br />
* [[HFS: Event scripts|了解事件脚本]]<br />
* [[HFS: scripting commands|宏脚本命令大全]]<br />
<br />
== 杂项 ==<br />
* [[HFS: Hidden things|隐藏功能]]<br />
* [[HFS: Command line parameters|命令行参数]]<br />
* [[HFS Frequently Asked Questions (english)|F.A.Q. 常见问题]]<br />
* [[HFS: Similar software|相似的软件]]<br />
* [[FHFS|FHFS (带有 FTP 功能的 HFS)]]<br />
* [[HFS: Glossary|相关术语]]<br />
* [[Gallery|模板展览]]<br />
* [[HFS: Known limits|已知限制]]<br />
* [[HFS: History|历史]]</div>
NaitLee
https://rejetto.com/wiki/index.php?title=Main_Page&diff=5694
Main Page
2020-09-05T17:26:35Z
<p>NaitLee: </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 />
* [http://translate.google.com/translate?hl=es&sl=auto&tl=es&u=http%3A%2F%2Frejetto.com%2Fwiki%2Findex.php%3Ftitle%3DHFS_Documentation_(English) HFS Documentación (Español)]<br />
* [http://translate.google.com/translate?hl=ru&sl=auto&tl=ru&u=http%3A%2F%2Frejetto.com%2Fwiki%2Findex.php%3Ftitle%3DHFS_Documentation_(English) HFS документация (Русская - Russian)]<br />
* [[HFS 帮助文档 (简体中文)]]<br />
* [[HFS Frequently Asked Questions (English)]]<br />
* [[ICQv7 protocol resources]]<br />
* [[Wiki Construction Notes]]<br />
</big></div>
NaitLee
https://rejetto.com/wiki/index.php?title=HFS_%E5%B8%AE%E5%8A%A9%E6%96%87%E6%A1%A3_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=5693
HFS 帮助文档 (简体中文)
2020-09-05T17:26:19Z
<p>NaitLee: Created page with "本翻译页面可能有些许失误,请以英文文档页面为准。 本页面仍在建设中,请保持耐心! 此文档的大部分内容适用于 HFS 版本 2.2f—..."</p>
<hr />
<div>本翻译页面可能有些许失误,请以英文文档页面为准。<br />
本页面仍在建设中,请保持耐心!<br />
<br />
此文档的大部分内容适用于 HFS 版本 2.2f——尽管有部分内容已过时。其他一些可能适用于 2.3 及以后版本。<br />
<br />
HFS Logo 标志的地球图像依 Planetary Visions Limited 的许可使用。<br />
<br />
== 教程 ==<br />
* [[HFS: Introduction|Introduction]]<br />
* [[HFS: Secure your server|Secure your server]]<br />
* [[Use HFS to host a website]]<br />
* [[HFS: Working with uploads|Working with uploads]]<br />
* [[First time configuration]]<br />
* [[Refinements]]<br />
* [[User groups]]<br />
<br />
== 菜单 ==<br />
* [[HFS: Main menu|Main menu]]<br />
* [[HFS: Virtual File System menu|Virtual File System menu]]<br />
* [[HFS: Log menu|Log menu]]<br />
* [[HFS: Connections menu|Connections menu]]<br />
<br />
== 高级术语及用法 ==<br />
* [[HFS: The Virtual File System|Virtual File System]]<br />
* [[HFS: MIME Types|MIME types]]<br />
* [[HFS: File masks|File masks]]<br />
* [[HFS: IP masks|IP masks]]<br />
* [[HFS: Realms|Realms]]<br />
* [[HFS: Template|How the template system works]]<br />
* [[How does a webserver work]]?<br />
* [[HFS: Comment files|Loading comments from external files]]<br />
* [[HFS: Folder Archives|Folder Archives]]<br />
* [[HFS: URL parameters|URL parameters (formerly: address operators)]]<br />
* [[HFS: Template macros|Template scripting (macros)]]<br />
* [[HFS: Event scripts|Event scripts]]<br />
* [[HFS: scripting commands|Scripting Commands]]<br />
<br />
== Miscellaneous ==<br />
* [[HFS: Hidden things|Hidden things]]<br />
* [[HFS: Command line parameters|Command line parameters]]<br />
* [[HFS Frequently Asked Questions (english)|F.A.Q.]]<br />
* [[HFS: Similar software|Similar software]]<br />
* [[FHFS|FHFS (HFS with FTP)]]<br />
* [[HFS: Glossary|Glossary]]<br />
* [[Gallery|Template Gallery]]<br />
* [[HFS: Known limits|Known limits]]<br />
* [[HFS: History|History]]</div>
NaitLee