♻️ refactor(playbook): streamline agents and refresh tsl docs
This commit is contained in:
@@ -18,23 +18,19 @@
|
||||
|
||||
##### 介绍
|
||||
|
||||
TSL可用于Web开发,下面是一个简单的示例
|
||||
TSL 可用于 Web 开发,下面是一个简单示例:
|
||||
|
||||
```text
|
||||
<?tslx>
|
||||
|
||||
<HTML>
|
||||
|
||||
<Title>TSL Web Page</Title>
|
||||
|
||||
<Body>
|
||||
|
||||
<html>
|
||||
<title>TSL Web Page</title>
|
||||
<body>
|
||||
<?tsl
|
||||
|
||||
writeln("First Tsl Web page");
|
||||
|
||||
>
|
||||
|
||||
</Body>
|
||||
WriteLn("First TSL Web page");
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
与 PHP类似, TSL代码被嵌入HTML代码中做一些事情,
|
||||
|
||||
@@ -81,41 +77,42 @@ Apache 2.2与其2.0版本做了比较大的修改,所以TSL取消了模块对2
|
||||
|
||||
####### Apache 2.2 Module模式:
|
||||
|
||||
在httpd.conf中加入:
|
||||
在 httpd.conf 中加入:
|
||||
|
||||
LoadModule tsl_module C:/Tinysoft/tsl/MOD_TSL2.dll
|
||||
|
||||
AddType tslscript-handler .tsl
|
||||
|
||||
AddHandler tslscript-handler .tsl
|
||||
```text
|
||||
LoadModule tsl_module C:/Tinysoft/tsl/MOD_TSL2.dll
|
||||
AddType tslscript-handler .tsl
|
||||
AddHandler tslscript-handler .tsl
|
||||
```
|
||||
|
||||
####### Apache 2.X CGI模式:
|
||||
|
||||
在httpd.conf中加入:
|
||||
在 httpd.conf 中加入:
|
||||
|
||||
```text
|
||||
<Directory "C:/Tinysoft/tsl">
|
||||
|
||||
AllowOverride None
|
||||
|
||||
Options None
|
||||
|
||||
Order allow,deny
|
||||
|
||||
Allow from all
|
||||
|
||||
</Directory>
|
||||
|
||||
AddHandler tslscript-handler .tsl
|
||||
AddHandler tslscript-handler .tsl
|
||||
ScriptAlias /tsl/ "c:/Tinysoft/tsl/"
|
||||
Action tslscript-handler "/tsl/TSLCgi.exe"
|
||||
```
|
||||
|
||||
ScriptAlias /tsl/ "c:/Tinysoft/tsl/"
|
||||
或者:
|
||||
|
||||
Action tslscript-handler "/tsl/TSLCgi.exe"
|
||||
```text
|
||||
AddHandler cgi-script .tsl
|
||||
```
|
||||
|
||||
或者在httpd.conf中加入:
|
||||
并在 `.tsl` 第一行加入:
|
||||
|
||||
AddHandler cgi-script .tsl
|
||||
|
||||
并且在.tsl的第一行加入#!C:/Tinysoft/tsl/tslCgi.exe
|
||||
```text
|
||||
#!C:/Tinysoft/tsl/tslCgi.exe
|
||||
```
|
||||
|
||||
###### Apache 1.x
|
||||
|
||||
@@ -127,69 +124,66 @@ Apache 2.2与其2.0版本做了比较大的修改,所以TSL取消了模块对2
|
||||
|
||||
####### Apache 1.x Module模式:
|
||||
|
||||
在httpd.conf中加入:
|
||||
在 httpd.conf 中加入:
|
||||
|
||||
LoadModule tsl_module C:/tsl/mod_tsl1.dll
|
||||
|
||||
AddModule mod_tsl.c
|
||||
|
||||
AddType application/tslscript .tsl
|
||||
|
||||
AddHandler tslscript-handler .tsl
|
||||
```text
|
||||
LoadModule tsl_module C:/tsl/mod_tsl1.dll
|
||||
AddModule mod_tsl.c
|
||||
AddType application/tslscript .tsl
|
||||
AddHandler tslscript-handler .tsl
|
||||
```
|
||||
|
||||
####### Apache 1.x CGI模式:
|
||||
|
||||
在httpd.conf中加入:
|
||||
在 httpd.conf 中加入:
|
||||
|
||||
```text
|
||||
<Directory "C:/Tinysoft/tsl">
|
||||
|
||||
AllowOverride None
|
||||
|
||||
Options None
|
||||
|
||||
Order allow,deny
|
||||
|
||||
Allow from all
|
||||
|
||||
</Directory>
|
||||
|
||||
ScriptAlias /tsl/ "c:/Tinysoft/tsl/"
|
||||
ScriptAlias /tsl/ "c:/Tinysoft/tsl/"
|
||||
AddHandler application/tslcgi .tsl
|
||||
Action application/tslcgi "/tsl/tslcgi.exe"
|
||||
```
|
||||
|
||||
AddHandler application/tslcgi .tsl
|
||||
或者:
|
||||
|
||||
Action application/tslcgi "/tsl/tslcgi.exe"
|
||||
```text
|
||||
AddHandler cgi-script .tsl
|
||||
```
|
||||
|
||||
或者在httpd.conf中加入:
|
||||
并在 `.tsl` 第一行加入:
|
||||
|
||||
AddHandler cgi-script .tsl
|
||||
|
||||
并且在.tsl的第一行加入#!C:/Tinysoft/tsl/tslCgi.exe
|
||||
```text
|
||||
#!C:/Tinysoft/tsl/tslCgi.exe
|
||||
```
|
||||
|
||||
##### 程序结构
|
||||
|
||||
与PHP不同TSL脚本默认是程序,而非HTML文本。
|
||||
与 PHP 不同,TSL 脚本默认是程序而非 HTML 文本。
|
||||
|
||||
下面的脚本会直接执行
|
||||
下面的脚本会直接执行:
|
||||
|
||||
s:="this is a tsl script";
|
||||
```tsl
|
||||
message := "this is a tsl script";
|
||||
WriteLn(message);
|
||||
```
|
||||
|
||||
writeln(s);
|
||||
若要输出完整 HTML 结构,可显式输出:
|
||||
|
||||
如果要输出完整的HTML结构,需要编写下面的代码
|
||||
|
||||
write("
|
||||
|
||||
<HTML>
|
||||
|
||||
<Body>
|
||||
|
||||
<p>TSL Script</p>
|
||||
|
||||
</Body>
|
||||
|
||||
</HTML>
|
||||
|
||||
");
|
||||
```tsl
|
||||
Write(
|
||||
"<html>\n" +
|
||||
"<body>\n" +
|
||||
"<p>TSL Script</p>\n" +
|
||||
"</body>\n" +
|
||||
"</html>\n"
|
||||
);
|
||||
```
|
||||
|
||||
###### 内容
|
||||
- <?tslx> 标记
|
||||
@@ -199,103 +193,84 @@ write("
|
||||
|
||||
###### <?tslx> 标记
|
||||
|
||||
标记下面文字是HTML代码,代码将会原文输出到网页上.直到出现<?tsl ,
|
||||
标记后续文本为 HTML 代码,原文输出到网页上,直到出现 `<?tsl`。
|
||||
|
||||
上面的代码可以使用这种标记方式:
|
||||
|
||||
```text
|
||||
<?tslx>
|
||||
|
||||
<HTML>
|
||||
|
||||
<Body>
|
||||
|
||||
<html>
|
||||
<body>
|
||||
<p>TSL Script</p>
|
||||
|
||||
</Body>
|
||||
|
||||
</HTML>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
###### <?tsl … ?>块
|
||||
|
||||
```text
|
||||
<?tsl
|
||||
|
||||
//这里可以写TSL代码…
|
||||
|
||||
>
|
||||
这里可以写 TSL 代码…
|
||||
?>
|
||||
```
|
||||
|
||||
当代码应用了<?tslx>标记后,以后的代码都被解析成文本,如果仍然需要在<?tslx>后执行TSL代码,就需要把代码写在<?tsl和 ?>中间。标识符和代码可以写在一行或多行,如果写在一行,<?tsl和代码必须用空格分开。代码中可以出现多次<?tsl … ?>块。但是不能嵌套。
|
||||
|
||||
上面的代码可以写成:
|
||||
|
||||
```text
|
||||
<?tslx>
|
||||
|
||||
<HTML>
|
||||
|
||||
<Body>
|
||||
|
||||
<html>
|
||||
<body>
|
||||
<p>
|
||||
|
||||
<?tsl write("TSL Script");?>
|
||||
|
||||
<?tsl Write("TSL Script");?>
|
||||
</p>
|
||||
|
||||
</Body>
|
||||
|
||||
</HTML>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
###### <?= ?>块
|
||||
|
||||
在<?tslx>环境下,可以使用<?= ?>来简化输出,输出的模式为:
|
||||
在 `<?tslx>` 环境下,可以使用 `<?= ?>` 简化输出,模式为:
|
||||
|
||||
<?=<p1>[,p2..pn]?>
|
||||
```text
|
||||
<?= <p1>[, p2 .. pn] ?>
|
||||
```
|
||||
|
||||
例如要输出当前时间:
|
||||
|
||||
<?="现在是:",DateTimeToStr(Now())?>
|
||||
```text
|
||||
<?="现在是:", DateTimeToStr(Now())?>
|
||||
```
|
||||
|
||||
##### 输出
|
||||
|
||||
TSL使用Write()和Writeln()2个函数把内容输出到网页中。
|
||||
TSL 使用 `Write()`/`WriteLn()` 输出内容,格式为 `Write(p1, p2, ..., pn)`。
|
||||
`WriteLn()` 会追加换行,但浏览器可能忽略连续空白。
|
||||
|
||||
格式为 Write(p1,p2,…,pn);
|
||||
|
||||
把参数p1、p2、…、pn连接起来输出.
|
||||
|
||||
Writeln()和write的参数一样,同时输出回车和换行。但是浏览器解释HTML有时会忽略换行回车,把连在一起的空白字符解析成一个空格,这一点需要注意。
|
||||
|
||||
TSL还可以使用echo操作符号输出内容,使用的效果和write相同,但是:
|
||||
|
||||
格式为Echo <p1>[,p2…pn]
|
||||
|
||||
此外,在<?TSLX>块中还可以采用<?=<p1>[,p2..pn] ?>的模式来输出。
|
||||
TSL 也支持 `echo` 操作符:`echo <p1>[, p2 .. pn]`。
|
||||
在 `<?tslx>` 块中还可使用 `<?= <p1>[, p2 .. pn] ?>` 简化输出。
|
||||
|
||||
##### HTML表单处理
|
||||
|
||||
当一个表单体交给 TSL 脚本时,表单中的信息会自动在脚本中可用。TSL可以轻松的访问这些信息,例如下面的表单:
|
||||
|
||||
```text
|
||||
<form action="foo.tsl" method="POST">
|
||||
|
||||
Name: <input type="text" name="username"><br />
|
||||
|
||||
Email: <input type="text" name="email"><br />
|
||||
|
||||
<input type="submit" name="submit" value="Submit me!" />
|
||||
|
||||
Name: <input type="text" name="username"><br />
|
||||
Email: <input type="text" name="email"><br />
|
||||
<input type="submit" name="submit" value="Submit me!" />
|
||||
</form>
|
||||
```
|
||||
|
||||
Tsl可以提取上面表单的数据,方法是使用
|
||||
|
||||
HttpGetQueryValueByName(Name:String):String
|
||||
TSL 可以通过 `HttpGetQueryValueByName(name: string): string` 取表单字段。
|
||||
|
||||
示例:
|
||||
|
||||
<?tsl
|
||||
|
||||
write("Name:",HttpGetQueryValueByName("name"),"<br>");
|
||||
|
||||
write("Email:",HttpGetQueryValueByName("email"));
|
||||
|
||||
>
|
||||
```tsl
|
||||
Write("Name:", HttpGetQueryValueByName("name"), "<br>");
|
||||
Write("Email:", HttpGetQueryValueByName("email"));
|
||||
```
|
||||
|
||||
为了使用简单,TSL使用HttpGetQueryValueByName方法,也可以提取get表单数据,和
|
||||
|
||||
@@ -303,7 +278,9 @@ Query_String 方式(URL中在之后的信息)的数据。
|
||||
|
||||
示例:
|
||||
|
||||
```text
|
||||
http://www.webiste.com/foo.tsl?name=jack&email=jack@abc.com
|
||||
```
|
||||
|
||||
可以用上面的方式提取数据
|
||||
|
||||
|
||||
Reference in New Issue
Block a user