playbook/docs/tsl/syntax_book/function/11_web_development.md

13 KiB
Raw Blame History

Web开发支撑

内容

  • TSL的Web支持
  • .Web Tools

TSL的Web支持

内容
  • 介绍
  • 运行模式
  • WEB服务器配置方法
  • 程序结构
  • 输出
  • HTML表单处理
介绍

TSL 可用于 Web 开发,下面是一个简单示例:

<?tslx>
<html>
<title>TSL Web Page</title>
<body>
<?tsl
WriteLn("First TSL Web page");
?>
</body>
</html>

与 PHP类似, TSL代码被嵌入HTML代码中做一些事情

与JAVAScript客户端不同的是TSL代码在服务器端执行在客户端看不到TSL代码只能看到由TSL生成的HTML代码。

运行模式

Tsl脚本可以以纯cgi的模式执行也可以用Apache 1.x, 2.x的Module运行还可以支持以IIS的过滤器来运行此外还内置支持了纯CGI对FastCGI的支撑。

WEB服务器配置方法

如需要使用TSL的WEB解释器请将安装TSL的目录加入系统路径中。

以下是各类WEB服务器的配置方法

内容
  • IIS
  • Apache 2.2
  • Apache 1.x
IIS

注意需要在IIS管理器里的Web服务扩展里允许所有CGI扩展和所有未知ISAPI

####### 内容

  • IIS Module模式
  • IIS CGI模式

####### IIS Module模式

请在IIS管理器里加入IIS_TSL.dll模块关联.tsl类型。

####### IIS CGI模式

请在IIS管理器里加入TSLCGI.exe关联.tsl类型。

Apache 2.2

Apache 2.2与其2.0版本做了比较大的修改所以TSL取消了模块对2.0的支持当然CGI模式在各种版本下均支持。如需要使用模块请下载Apache 2.2的版本。

####### 内容

  • Apache 2.2 Module模式
  • Apache 2.X CGI模式

####### Apache 2.2 Module模式

在 httpd.conf 中加入:

LoadModule tsl_module C:/Tinysoft/tsl/MOD_TSL2.dll
AddType tslscript-handler .tsl
AddHandler tslscript-handler .tsl

####### Apache 2.X CGI模式

在 httpd.conf 中加入:

<Directory "C:/Tinysoft/tsl">
  AllowOverride None
  Options None
  Order allow,deny
  Allow from all
</Directory>

AddHandler tslscript-handler .tsl
ScriptAlias /tsl/ "c:/Tinysoft/tsl/"
Action tslscript-handler "/tsl/TSLCgi.exe"

或者:

AddHandler cgi-script .tsl

并在 .tsl 第一行加入:

#!C:/Tinysoft/tsl/tslCgi.exe
Apache 1.x

虽然目前Apache的主要版本已经升级为2.2但是Apache 1.x的版本使用依然很广泛由于Apache 1.x的版本与2.2版本差异非常之大所以TSL语言会继续支持Apache 1.x版本。

####### 内容

  • Apache 1.x Module模式
  • Apache 1.x CGI模式

####### Apache 1.x Module模式

在 httpd.conf 中加入:

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 中加入:

<Directory "C:/Tinysoft/tsl">
  AllowOverride None
  Options None
  Order allow,deny
  Allow from all
</Directory>

ScriptAlias /tsl/ "c:/Tinysoft/tsl/"
AddHandler application/tslcgi .tsl
Action application/tslcgi "/tsl/tslcgi.exe"

或者:

AddHandler cgi-script .tsl

并在 .tsl 第一行加入:

#!C:/Tinysoft/tsl/tslCgi.exe
程序结构

与 PHP 不同TSL 脚本默认是程序而非 HTML 文本。

下面的脚本会直接执行:

message := "this is a tsl script";
WriteLn(message);

若要输出完整 HTML 结构,可显式输出:

Write(
    "<html>\n" +
    "<body>\n" +
    "<p>TSL Script</p>\n" +
    "</body>\n" +
    "</html>\n"
);
内容
  • 标记
<?tslx> 标记

标记后续文本为 HTML 代码,原文输出到网页上,直到出现 <?tsl

上面的代码可以使用这种标记方式:

<?tslx>
<html>
<body>
<p>TSL Script</p>
</body>
</html>
<?tsl
这里可以写 TSL 代码…
?>

当代码应用了标记后以后的代码都被解析成文本如果仍然需要在后执行TSL代码就需要把代码写在中间。标识符和代码可以写在一行或多行如果写在一行块。但是不能嵌套。

上面的代码可以写成:

<?tslx>
<html>
<body>
<p>
<?tsl Write("TSL Script");?>
</p>
</body>
</html>

<?tslx> 环境下,可以使用 <?= ?> 简化输出,模式为:

<?= <p1>[, p2 .. pn] ?>

例如要输出当前时间:

<?="现在是:", DateTimeToStr(Now())?>
输出

TSL 使用 Write()/WriteLn() 输出内容,格式为 Write(p1, p2, ..., pn)WriteLn() 会追加换行,但浏览器可能忽略连续空白。

TSL 也支持 echo 操作符:echo <p1>[, p2 .. pn]。 在 <?tslx> 块中还可使用 <?= <p1>[, p2 .. pn] ?> 简化输出。

HTML表单处理

当一个表单体交给 TSL 脚本时表单中的信息会自动在脚本中可用。TSL可以轻松的访问这些信息例如下面的表单

<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!" />
</form>

TSL 可以通过 HttpGetQueryValueByName(name: string): string 取表单字段。

示例:

Write("Name:", HttpGetQueryValueByName("name"), "<br>");
Write("Email:", HttpGetQueryValueByName("email"));

为了使用简单TSL使用HttpGetQueryValueByName方法也可以提取get表单数据

Query_String 方式(URL中在之后的信息)的数据。

示例:

http://www.webiste.com/foo.tsl?name=jack&email=jack@abc.com

可以用上面的方式提取数据

.Web Tools

内容
  • 表格样式
  • 单元格
  • 图形配置
  • 展示范例
  • 中间函数
表格样式
内容
  • Web_tb_arrow
  • Web_tb_bar
  • Web_tb_gradient
  • Web_tb_npbar
  • Web_tb_npgridbar
Web_tb_arrow
  • Web_tb_arrow
  • Web_tb_bar
  • Web_tb_gradient
  • Web_tb_npbar
  • Web_tb_npgridbar
Web_tb_bar
  • Web_tb_arrow
  • Web_tb_bar
  • Web_tb_gradient
  • Web_tb_npbar
  • Web_tb_npgridbar
Web_tb_gradient
  • Web_tb_arrow
  • Web_tb_bar
  • Web_tb_gradient
  • Web_tb_npbar
  • Web_tb_npgridbar
Web_tb_npbar
  • Web_tb_arrow
  • Web_tb_bar
  • Web_tb_gradient
  • Web_tb_npbar
  • Web_tb_npgridbar
Web_tb_npgridbar
  • Web_tb_arrow
  • Web_tb_bar
  • Web_tb_gradient
  • Web_tb_npbar
  • Web_tb_npgridbar
单元格
内容
  • 背景
  • 富文本
  • 迷你图
背景

####### 内容

  • Web_css_bgbar
  • Web_css_bgcolor
  • Web_css_bghist

####### Web_css_bgbar

  • Web_css_bgbar
  • Web_css_bgcolor
  • Web_css_bghist

####### Web_css_bgcolor

  • Web_css_bgbar
  • Web_css_bgcolor
  • Web_css_bghist

####### Web_css_bghist

  • Web_css_bgbar
  • Web_css_bgcolor
  • Web_css_bghist
富文本

####### 内容

  • Web_richtext_zdbgcolor

####### Web_richtext_zdbgcolor

  • Web_richtext_zdbgcolor
迷你图

####### 内容

  • Web_spark_hist
  • Web_spark_nphist

####### Web_spark_hist

  • Web_spark_hist
  • Web_spark_nphist

####### Web_spark_nphist

  • Web_spark_hist
  • Web_spark_nphist
图形配置
内容
  • Web_fig_box
  • Web_fig_heatmap
  • Web_fig_histogram
  • Web_fig_radar
  • Web_fig_tree_decomp
  • Web_fig_violin
Web_fig_box
  • Web_fig_box
  • Web_fig_heatmap
  • Web_fig_histogram
  • Web_fig_radar
  • Web_fig_tree_decomp
  • Web_fig_violin
Web_fig_heatmap
  • Web_fig_box
  • Web_fig_heatmap
  • Web_fig_histogram
  • Web_fig_radar
  • Web_fig_tree_decomp
  • Web_fig_violin
Web_fig_histogram
  • Web_fig_box
  • Web_fig_heatmap
  • Web_fig_histogram
  • Web_fig_radar
  • Web_fig_tree_decomp
  • Web_fig_violin
Web_fig_radar
  • Web_fig_box
  • Web_fig_heatmap
  • Web_fig_histogram
  • Web_fig_radar
  • Web_fig_tree_decomp
  • Web_fig_violin
Web_fig_tree_decomp
  • Web_fig_box
  • Web_fig_heatmap
  • Web_fig_histogram
  • Web_fig_radar
  • Web_fig_tree_decomp
  • Web_fig_violin
Web_fig_violin
  • Web_fig_box
  • Web_fig_heatmap
  • Web_fig_histogram
  • Web_fig_radar
  • Web_fig_tree_decomp
  • Web_fig_violin
展示范例
内容
  • Demo_framestyle_constyle_dotweb
  • Demo_framestyle_constyle_net
  • Demo_framestyle_heatmaptb_net
  • Demo_framestyle_net
  • Demo_framestyle_web
  • Demo_framestyle_data
Demo_framestyle_constyle_dotweb
  • Demo_framestyle_constyle_dotweb
  • Demo_framestyle_constyle_net
  • Demo_framestyle_heatmaptb_net
  • Demo_framestyle_net
  • Demo_framestyle_web
  • Demo_framestyle_data
Demo_framestyle_constyle_net
  • Demo_framestyle_constyle_dotweb
  • Demo_framestyle_constyle_net
  • Demo_framestyle_heatmaptb_net
  • Demo_framestyle_net
  • Demo_framestyle_web
  • Demo_framestyle_data
Demo_framestyle_heatmaptb_net
  • Demo_framestyle_constyle_dotweb
  • Demo_framestyle_constyle_net
  • Demo_framestyle_heatmaptb_net
  • Demo_framestyle_net
  • Demo_framestyle_web
  • Demo_framestyle_data
Demo_framestyle_net
  • Demo_framestyle_constyle_dotweb
  • Demo_framestyle_constyle_net
  • Demo_framestyle_heatmaptb_net
  • Demo_framestyle_net
  • Demo_framestyle_web
  • Demo_framestyle_data
Demo_framestyle_web
  • Demo_framestyle_constyle_dotweb
  • Demo_framestyle_constyle_net
  • Demo_framestyle_heatmaptb_net
  • Demo_framestyle_net
  • Demo_framestyle_web
  • Demo_framestyle_data
Demo_framestyle_data
  • Demo_framestyle_constyle_dotweb
  • Demo_framestyle_constyle_net
  • Demo_framestyle_heatmaptb_net
  • Demo_framestyle_net
  • Demo_framestyle_web
  • Demo_framestyle_data
中间函数
内容
  • Kerneldensityestimator
  • Web_color_theme
  • Web_color_triscale
  • Web_dict2tabletree
  • Web_format
  • Web_getcolorscalebyrgbarr
  • Web_getdefultcolor
  • Web_getlineargradient
  • Web_gettdbar
  • Web_html_span
  • Web_html_table
  • Web_table2dicttree
Kerneldensityestimator
  • Kerneldensityestimator
  • Web_color_theme
  • Web_color_triscale
  • Web_dict2tabletree
  • Web_format
  • Web_getcolorscalebyrgbarr
  • Web_getdefultcolor
  • Web_getlineargradient
  • Web_gettdbar
  • Web_html_span
  • Web_html_table
  • Web_table2dicttree
Web_color_theme
  • Kerneldensityestimator
  • Web_color_theme
  • Web_color_triscale
  • Web_dict2tabletree
  • Web_format
  • Web_getcolorscalebyrgbarr
  • Web_getdefultcolor
  • Web_getlineargradient
  • Web_gettdbar
  • Web_html_span
  • Web_html_table
  • Web_table2dicttree
Web_color_triscale
  • Kerneldensityestimator
  • Web_color_theme
  • Web_color_triscale
  • Web_dict2tabletree
  • Web_format
  • Web_getcolorscalebyrgbarr
  • Web_getdefultcolor
  • Web_getlineargradient
  • Web_gettdbar
  • Web_html_span
  • Web_html_table
  • Web_table2dicttree
Web_dict2tabletree
  • Kerneldensityestimator
  • Web_color_theme
  • Web_color_triscale
  • Web_dict2tabletree
  • Web_format
  • Web_getcolorscalebyrgbarr
  • Web_getdefultcolor
  • Web_getlineargradient
  • Web_gettdbar
  • Web_html_span
  • Web_html_table
  • Web_table2dicttree
Web_format
  • Kerneldensityestimator
  • Web_color_theme
  • Web_color_triscale
  • Web_dict2tabletree
  • Web_format
  • Web_getcolorscalebyrgbarr
  • Web_getdefultcolor
  • Web_getlineargradient
  • Web_gettdbar
  • Web_html_span
  • Web_html_table
  • Web_table2dicttree
Web_getcolorscalebyrgbarr
  • Kerneldensityestimator
  • Web_color_theme
  • Web_color_triscale
  • Web_dict2tabletree
  • Web_format
  • Web_getcolorscalebyrgbarr
  • Web_getdefultcolor
  • Web_getlineargradient
  • Web_gettdbar
  • Web_html_span
  • Web_html_table
  • Web_table2dicttree
Web_getdefultcolor
  • Kerneldensityestimator
  • Web_color_theme
  • Web_color_triscale
  • Web_dict2tabletree
  • Web_format
  • Web_getcolorscalebyrgbarr
  • Web_getdefultcolor
  • Web_getlineargradient
  • Web_gettdbar
  • Web_html_span
  • Web_html_table
  • Web_table2dicttree
Web_getlineargradient
  • Kerneldensityestimator
  • Web_color_theme
  • Web_color_triscale
  • Web_dict2tabletree
  • Web_format
  • Web_getcolorscalebyrgbarr
  • Web_getdefultcolor
  • Web_getlineargradient
  • Web_gettdbar
  • Web_html_span
  • Web_html_table
  • Web_table2dicttree
Web_gettdbar
  • Kerneldensityestimator
  • Web_color_theme
  • Web_color_triscale
  • Web_dict2tabletree
  • Web_format
  • Web_getcolorscalebyrgbarr
  • Web_getdefultcolor
  • Web_getlineargradient
  • Web_gettdbar
  • Web_html_span
  • Web_html_table
  • Web_table2dicttree
Web_html_span
  • Kerneldensityestimator
  • Web_color_theme
  • Web_color_triscale
  • Web_dict2tabletree
  • Web_format
  • Web_getcolorscalebyrgbarr
  • Web_getdefultcolor
  • Web_getlineargradient
  • Web_gettdbar
  • Web_html_span
  • Web_html_table
  • Web_table2dicttree
Web_html_table
  • Kerneldensityestimator
  • Web_color_theme
  • Web_color_triscale
  • Web_dict2tabletree
  • Web_format
  • Web_getcolorscalebyrgbarr
  • Web_getdefultcolor
  • Web_getlineargradient
  • Web_gettdbar
  • Web_html_span
  • Web_html_table
  • Web_table2dicttree
Web_table2dicttree
  • Kerneldensityestimator
  • Web_color_theme
  • Web_color_triscale
  • Web_dict2tabletree
  • Web_format
  • Web_getcolorscalebyrgbarr
  • Web_getdefultcolor
  • Web_getlineargradient
  • Web_gettdbar
  • Web_html_span
  • Web_html_table
  • Web_table2dicttree