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开发,下面是一个简单的示例

<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中加入 AllowOverride None Options None Order allow,deny Allow from all AddHandler tslscript-handler .tsl ScriptAlias /tsl/ "c:/Tinysoft/tsl/" Action tslscript-handler "/tsl/TSLCgi.exe" 或者在httpd.conf中加入 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中加入 AllowOverride None Options None Order allow,deny Allow from all ScriptAlias /tsl/ "c:/Tinysoft/tsl/" AddHandler application/tslcgi .tsl Action application/tslcgi "/tsl/tslcgi.exe" 或者在httpd.conf中加入 AddHandler cgi-script .tsl 并且在.tsl的第一行加入#!C:/Tinysoft/tsl/tslCgi.exe ##### 程序结构 与PHP不同TSL脚本默认是程序而非HTML文本。 下面的脚本会直接执行 s:="this is a tsl script"; writeln(s); 如果要输出完整的HTML结构需要编写下面的代码 write(" <HTML>

TSL Script

</HTML> "); ###### 内容 - 标记 - 块
<?tslx> 标记

标记下面文字是HTML代码代码将会原文输出到网页上.直到出现<?tsl ,

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

<HTML>

TSL Script

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

上面的代码可以写成:

<HTML>

</HTML>

在环境下,可以使用来简化输出,输出的模式为:

[,p2..pn]?>

例如要输出当前时间:

输出

TSL使用Write()和Writeln()2个函数把内容输出到网页中。

格式为 Write(p1,p2,…,pn);

把参数p1、p2、…、pn连接起来输出.

Writeln()和write的参数一样同时输出回车和换行。但是浏览器解释HTML有时会忽略换行回车把连在一起的空白字符解析成一个空格这一点需要注意。

TSL还可以使用echo操作符号输出内容使用的效果和write相同但是

格式为Echo [,p2…pn]

此外,在块中还可以采用[,p2..pn] ?>的模式来输出。

HTML表单处理

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

Name:

Email:

Tsl可以提取上面表单的数据方法是使用

HttpGetQueryValueByName(Name:String):String

示例:

"); 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