New Upstream Snapshot - lua-cgi
Ready changes
Summary
Merged new upstream version: 6.0.2+git20220727.1.5bc3091 (was: 5.2~alpha2).
Diff
diff --git a/Makefile b/Makefile
index 8c3577b..83dde23 100755
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@
PREFIX= /usr/local
# System's lua directory (where Lua libraries are installed)
-LUA_DIR= $(PREFIX)/share/lua/5.1
+LUA_DIR= $(PREFIX)/share/lua/5.2
CGILUA_DIR= $(LUA_DIR)/cgilua
CGILUA_LUAS= src/cgilua/authentication.lua src/cgilua/cookies.lua src/cgilua/dispatcher.lua src/cgilua/loader.lua src/cgilua/lp.lua src/cgilua/mime.lua src/cgilua/post.lua src/cgilua/readuntil.lua src/cgilua/serialize.lua src/cgilua/session.lua src/cgilua/urlcode.lua
diff --git a/README b/README
deleted file mode 100755
index ca4fb93..0000000
--- a/README
+++ /dev/null
@@ -1,125 +0,0 @@
-CGILua 5.1.4
-http://keplerproject.org/cgilua
-
-Overview
-
-CGILua is a tool for creating dynamic Web pages and manipulating input data
-from Web forms. CGILua allows the separation of logic and data handling from
-the generation of pages, making it easy to develop web applications with Lua.
-
-One of advantages of CGILua is its abstraction of the underlying Web server.
-CGILua can be used with a variety of Web servers and, for each server, with
-different launchers. A launcher is responsible for the interaction of CGILua
-and the Web server, for example using ISAPI on IIS or mod_lua on Apache.
-The reference implementation of CGILua launchers is Kepler.
-
-CGILua is free software and uses the same license as Lua 5.1.
-
-You can also install CGILua using LuaRocks:
-luarocks install cgilua
-
-History
-
-Version 5.1.4 [22/Mar/2010]
-
- * fixed file upload reentrancy
- * new launchers for cgilua that do not depend on kepler_init
- * Correction on mkurlpath
-
-Version 5.1.3 [9/Mar/2009]
-
- * Strips utf-8 BOM from templates in lp.include
- * Fixed reentrancy bug
- * Fixed reset of cgilua.urlpath
-
-Version 5.1.2 [19/May/2008]
-
- * Added the cgilua.authentication module
- * cgilua.print now separates arguments with tabs, like Lua print
- * Now print and write are aliases to cgilua.print and cgilua.put.
- * Now strips an eventual #! from top of Lua Pages files
- * CGILua can now process sequential requests in the same Lua state
- * Better error handling. Wraps error message in valid HTML
- * Bug fixed: CGILua was ignoring CGILUA_TMP in Windows
- * Corrected the URL handling for the dispatcher (bug found by Ronaldo Sugii)
- * Better URL handling for different locales
- * Handling multiple values in the generated URL (patch by Matt Campbell)
- * Fixed file handle leak in loader.lua
- * Fixed bug [#2630] - Including new files (bug found by Bruno Massa)
-
-Version 5.1.1 [21/Nov/2007]
-
- * Changed the security policy for scripts. Now scripts have access to all Lua globals, including the debug and os packages. It is up to the application developer to choose what policy to use
- * If you are using Kepler, it is strongly suggested that you replace your previous CGILua config.lua file with the new one installed by Kepler and then merge the differences
- * Added the cgilua.dispatcher module
- * Added default handlers for a set of MIME types. The default handlers return only the content-type and conten-lenght headers for the files.
- * Added functions cgilua.splitonfirst and cgilua.splitonlast
- * Added functions cgilua.tmpfile and cgilua.tmpname
- * Changed the use of "/test" for the session temporary directory checking (bug found by Yuri Takhteyev)
- * Corrected the use of cgilua.QUERY in the session handling (bug found by Jim Madsen)
- * Better handling of "application/xml" POST content types (patch by Ignacio Burgueño)
- * Fixed Bug [#1910] - Bug in byte accounting in post.lua (found by Greg Bell)
-
-Version 5.1.0 [23/Aug/2007]
-
- * Uses Lua 5.1
- * Added function cgilua.print (that uses tostring on its parameters)
- * Added a generic dispatcher and the concept of CGILua Apps
- * Replaced the cgi table used until CGILua 5.0 by two others cgilua.QUERY and cgilua.POST)
- * Added fake "package" table to enable the user/programmer to create modules with global visibility
- * Bug fix: return of HTTP status code
- * Bug fix: close method was recreating the session file
- * Correcting how LP handles strings with CR characters (Lua 5.0 would not mind, but Lua 5.1 does)
- * Fixed a bug with lighttpd
-
-Version 5.0.1 [20/Sep/2006]
-
- * Uses Compat-5.1 Release 5.
- * Caches Lua Pages template strings.
- * New configuration examples.
- * Improvements in the Session library.
- * Removed the debug package from the user scripts environment.
- * POST handling bug fixes (related to the text/plain content type).
-
-Version 5.0 [23/Jul/2005]
-
- * CGILua distribution includes now only the Lua files, the launchers have been moved to Kepler.
- * The Stable library is now distributed with VEnv.
- * Fixed a file upload bug in the CGI and Xavante launchers.
- * cgilua.lp.include() now accepts an environment to run the preprocessed file in it.
-
-Version 5.0 beta 2 [23/Dec/2004]
-
- * Distribution bug fix: stable.lua was missing
-
-Version 5.0 beta [15/Dec/2004]
-
- * New ISAPI and Servlet Launchers.
- * New Error Handling features.
- * New persistent data feature (Stable).
- * Uses the package model for Lua 5.1.
- * Simpler User Session API.
- * Small bug corrections
-
-Version 5.0 alpha 3 [8/Jun/2004]
-Version 5.0 alpha [21/Apr/2004]
-
-Incompatibility with previous CGILua versions (5.0, 4.0 and 3.x)
-
- * CGILua 5.1 uses Lua 5.1.
- * The cgi table is now deprecated. See Receiving parameters for a more detailed explanation.
- * The template tags have changed. See Lua pages for a more detailed explanation.
- * The use of getenv calls to obtain CGI variables should be replaced by cgilua.servervariable calls.
-
-Credits
-
-CGILua 5.1
- CGILua 5.1 is being maintained by André Carregal and Tomás Guisasola with contributions from Fábio Mascarenhas and others from the Kepler mailing list.
-CGILua 5.0
- CGILua 5.0 was completely redesigned by Roberto Ierusalimschy, André Carregal and Tomás Guisasola as part of the Kepler Project. The implementation is compatible with Lua 5.0 and was coded by Tomás Guisasola with invaluable contributions by Ana Lúcia de Moura, Fábio Mascarenhas and Danilo Tuler. CGILua 5.0 development was sponsored by Fábrica Digital, FINEP and CNPq.
-CGILua 4.0
- Ana Lúcia de Moura adapted CGILua 3.2 to Lua 4.0, reimplemented some code and added a few improvements but this version was not officially distributed.
-CGILua 3.x
- CGILua was born as the evolution of an early system developed by Renato Ferreira Borges and André Clínio at TeCGraf. At the time (circa 1995) there were no CGI tools available and everything was done with shell scripts!
- However, the main contribution to CGILua 3 was done by Anna Hester, who consolidated the whole tool and developed a consistent distribution with versions 3.1 and 3.2 (the number was an effort to follow Lua version numbers). This version was widely used on a great variety of systems.
-
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e666b2d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,159 @@
+<div align="center">
+ <img src="./docs/cgi-128.gif" width="128" />
+ <h1>CGILua 6</h1>
+</div>
+
+<br/>
+
+http://lunarmodules.github.io/cgilua/
+
+## Overview
+
+CGILua is a tool for creating dynamic Web pages and manipulating input data
+from Web forms. CGILua allows the separation of logic and data handling from
+the generation of pages, making it easy to develop web applications with Lua.
+
+One of advantages of CGILua is its abstraction of the underlying Web server.
+CGILua can be used with a variety of Web servers and, for each server, with
+different launchers. A launcher is responsible for the interaction of CGILua
+and the Web server, for example using ISAPI on IIS or mod_lua on Apache.
+
+CGILua is free software and uses the same license as Lua 5.x (MIT).
+
+You can install CGILua using [LuaRocks](https://luarocks.org):
+
+```
+luarocks install cgilua
+```
+
+## History
+
+Version 6.0.2 [04/Jul/2020]
+
+* Fix for preventing formatting errors
+* Small LDoc corrections
+
+Version 6.0.1 [17/May/2019]
+
+* Bug correction on redirections
+* Version variables definition
+* Other minor corrections
+
+Version 6.0.0 [05/Nov/2018]
+
+* Adapted CGILua SAPI launcher to explore all WSAPI features
+* SAPI layer removed
+* Several fixes
+* Lua 5.3 compatibility
+
+Version 5.2.1 [22/Apr/2015]
+
+* Uses Lua 5.2
+
+Version 5.1.4 [22/Mar/2010]
+
+* fixed file upload reentrancy
+* new launchers for cgilua that do not depend on kepler_init
+* Correction on mkurlpath
+
+Version 5.1.3 [9/Mar/2009]
+
+* Strips utf-8 BOM from templates in lp.include
+* Fixed reentrancy bug
+* Fixed reset of cgilua.urlpath
+
+Version 5.1.2 [19/May/2008]
+
+* Added the cgilua.authentication module
+* cgilua.print now separates arguments with tabs, like Lua print
+* Now print and write are aliases to cgilua.print and cgilua.put.
+* Now strips an eventual #! from top of Lua Pages files
+* CGILua can now process sequential requests in the same Lua state
+* Better error handling. Wraps error message in valid HTML
+* Bug fixed: CGILua was ignoring CGILUA_TMP in Windows
+* Corrected the URL handling for the dispatcher (bug found by Ronaldo Sugii)
+* Better URL handling for different locales
+* Handling multiple values in the generated URL (patch by Matt Campbell)
+* Fixed file handle leak in loader.lua
+* Fixed bug [#2630] - Including new files (bug found by Bruno Massa)
+
+Version 5.1.1 [21/Nov/2007]
+
+* Changed the security policy for scripts. Now scripts have access to all Lua globals, including the debug and os packages. It is up to the application developer to choose what policy to use
+* If you are using Kepler, it is strongly suggested that you replace your previous CGILua config.lua file with the new one installed by Kepler and then merge the differences
+* Added the cgilua.dispatcher module
+* Added default handlers for a set of MIME types. The default handlers return only the content-type and content-lenght headers for the files.
+* Added functions cgilua.splitonfirst and cgilua.splitonlast
+* Added functions cgilua.tmpfile and cgilua.tmpname
+* Changed the use of "/test" for the session temporary directory checking (bug found by Yuri Takhteyev)
+* Corrected the use of cgilua.QUERY in the session handling (bug found by Jim Madsen)
+* Better handling of "application/xml" POST content types (patch by Ignacio Burgueño)
+* Fixed Bug [#1910] - Bug in byte accounting in post.lua (found by Greg Bell)
+
+Version 5.1.0 [23/Aug/2007]
+
+* Uses Lua 5.1
+* Added function cgilua.print (that uses tostring on its parameters)
+* Added a generic dispatcher and the concept of CGILua Apps
+* Replaced the cgi table used until CGILua 5.0 by two others cgilua.QUERY and cgilua.POST)
+* Added fake "package" table to enable the user/programmer to create modules with global visibility
+* Bug fix: return of HTTP status code
+* Bug fix: close method was recreating the session file
+* Correcting how LP handles strings with CR characters (Lua 5.0 would not mind, but Lua 5.1 does)
+* Fixed a bug with lighttpd
+
+Version 5.0.1 [20/Sep/2006]
+
+* Uses Compat-5.1 Release 5.
+* Caches Lua Pages template strings.
+* New configuration examples.
+* Improvements in the Session library.
+* Removed the debug package from the user scripts environment.
+* POST handling bug fixes (related to the text/plain content type).
+
+Version 5.0 [23/Jul/2005]
+
+* CGILua distribution includes now only the Lua files, the launchers have been moved to Kepler.
+* The Stable library is now distributed with VEnv.
+* Fixed a file upload bug in the CGI and Xavante launchers.
+* cgilua.lp.include() now accepts an environment to run the preprocessed file in it.
+
+Version 5.0 beta 2 [23/Dec/2004]
+
+* Distribution bug fix: stable.lua was missing
+
+Version 5.0 beta [15/Dec/2004]
+
+* New ISAPI and Servlet Launchers.
+* New Error Handling features.
+* New persistent data feature (Stable).
+* Uses the package model for Lua 5.1.
+* Simpler User Session API.
+* Small bug corrections
+
+Version 5.0 alpha 3 [8/Jun/2004]
+Version 5.0 alpha [21/Apr/2004]
+
+## Credits
+
+* CGILua 6.0 - CGILua 6.0 is maintained by Tomás Guisasola, including contributions from the
+ community, including several commits by Peter Melnichenko and João Dutra Bastos. João worked
+ sponsored by the Google Summer of Code program. His project was "Adapt CGILua SAPI launcher
+ to explore all WSAPI features".
+* CGILua 5.2 - CGILua 5.2 was maintained by Tomás Guisasola with contributions from Fábio
+ Mascarenhas, Carla Ourofino and others from the community.
+* CGILua 5.1 - CGILua 5.1 was maintained by André Carregal and Tomás Guisasola with contributions
+ from Fábio Mascarenhas and others from the Kepler mailing list.
+* CGILua 5.0 - CGILua 5.0 was completely redesigned by Roberto Ierusalimschy, André Carregal and
+ Tomás Guisasola as part of the Kepler Project. The implementation is compatible with Lua 5.0
+ and was coded by Tomás Guisasola with invaluable contributions by Ana Lúcia de Moura, Fábio
+ Mascarenhas and Danilo Tuler. CGILua 5.0 development was sponsored by Fábrica Digital,
+ FINEP and CNPq.
+* CGILua 4.0 - Ana Lúcia de Moura adapted CGILua 3.2 to Lua 4.0, reimplemented some code and
+ added a few improvements but this version was not officially distributed.
+* CGILua 3.x - CGILua was born as the evolution of an early system developed by Renato Ferreira
+ Borges and André Clínio at TeCGraf. At the time (circa 1995) there were no CGI tools available
+ and everything was done with shell scripts! However, the main contribution to CGILua 3 was done
+ by Anna Hester, who consolidated the whole tool and developed a consistent distribution with
+ versions 3.1 and 3.2 (the number was an effort to follow Lua version numbers).
+ This version was widely used on a great variety of systems.
diff --git a/debian/changelog b/debian/changelog
index 16b8f69..2bb40d6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-lua-cgi (5.2~alpha2-2) UNRELEASED; urgency=medium
+lua-cgi (6.0.2+git20220727.1.5bc3091-1) UNRELEASED; urgency=medium
* Trim trailing whitespace.
* Use secure copyright file specification URI.
@@ -8,8 +8,9 @@ lua-cgi (5.2~alpha2-2) UNRELEASED; urgency=medium
* Use secure URI in Vcs control header Vcs-Git.
* Update Vcs-* headers from URL redirect.
* Use canonical URL in Vcs-Git.
+ * New upstream snapshot.
- -- Debian Janitor <janitor@jelmer.uk> Wed, 21 Sep 2022 17:33:33 -0000
+ -- Debian Janitor <janitor@jelmer.uk> Wed, 08 Feb 2023 17:01:36 -0000
lua-cgi (5.2~alpha2-1) unstable; urgency=low
diff --git a/debian/patches/0002-Non-minimized-version-of-jquery-to-adhere-DFSG.patch b/debian/patches/0002-Non-minimized-version-of-jquery-to-adhere-DFSG.patch
index 807d11b..17c0f4b 100644
--- a/debian/patches/0002-Non-minimized-version-of-jquery-to-adhere-DFSG.patch
+++ b/debian/patches/0002-Non-minimized-version-of-jquery-to-adhere-DFSG.patch
@@ -7,11 +7,10 @@ Subject: Non minimized version of jquery to adhere DFSG
1 file changed, 3408 insertions(+)
create mode 100644 examples/jquery/jquery-1.2.3.js
-diff --git a/examples/jquery/jquery-1.2.3.js b/examples/jquery/jquery-1.2.3.js
-new file mode 100644
-index 0000000..2e43a82
+Index: lua-cgi.git/examples/jquery/jquery-1.2.3.js
+===================================================================
--- /dev/null
-+++ b/examples/jquery/jquery-1.2.3.js
++++ lua-cgi.git/examples/jquery/jquery-1.2.3.js
@@ -0,0 +1,3408 @@
+(function(){
+/*
diff --git a/doc/br/index.html b/doc/br/index.html
deleted file mode 100755
index abf2e8e..0000000
--- a/doc/br/index.html
+++ /dev/null
@@ -1,162 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html>
-<head>
- <title>CGILua: geração de scripts para a Web usando Lua</title>
- <link rel="stylesheet" href="http://www.keplerproject.org/doc.css" type="text/css"/>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-</head>
-<body>
-
-<div id="container">
-
-<div id="product">
- <div id="product_logo"><a href="http://www.keplerproject.org"><img alt="Logotipo do CGILua" src="cgi-128.gif"/></a></div>
- <div id="product_name"><big><b>CGILua</b></big></div>
- <div id="product_description">Geração de scripts para a Web usando Lua</div>
-</div> <!-- id="product" -->
-
-<div id="main">
-
-<div id="navigation">
-<h1>CGILua</h1>
- <ul>
- <li><strong>Início</strong>
- <ul>
- <li><a href="index.html#overview">Visão geral</a></li>
- <li><a href="index.html#status">Status</a></li>
- <li><a href="index.html#download">Download</a></li>
- <li><a href="index.html#history">Histórico</a></li>
- <li><a href="index.html#incompatibility">Incompatibilidades</a></li>
- <li><a href="index.html#credits">Créditos</a></li>
- <li><a href="index.html#contact">Fale conosco</a></li>
- </ul>
- </li>
- <li><a href="manual.html">Manual</a>
- <ul>
- <li><a href="manual.html#intro">Introdução</a></li>
- <li><a href="manual.html#installation">Instalação</a></li>
- <li><a href="manual.html#config">Configuração</a></li>
- <li><a href="manual.html#scripts">Lua Scripts</a></li>
- <li><a href="manual.html#templates">Lua Pages</a></li>
- <li><a href="manual.html#parameters">Parâmetros</a></li>
- </ul>
- </li>
- <li><a href="reference.html">Referência</a>
- <ul>
- <li><a href="reference.html#headers">Cabeçalhos</a></li>
- <li><a href="reference.html#contents">Geração de conteúdo</a></li>
- <li><a href="reference.html#prep">Lua Pages</a></li>
- <li><a href="reference.html#variables">Variáveis do CGILua</a></li>
- <li><a href="reference.html#error_handling">Tratamento de erros</a></li>
- <li><a href="reference.html#behavior">Comportamento do CGILua</a></li>
- <li><a href="reference.html#urlcode">Codificação de URL</a></li>
- <li><a href="reference.html#auxiliar">Funções auxiliares</a></li>
- <li><a href="reference.html#index">Índice alfabético</a></li>
- </ul>
- </li>
- <li><a href="libraries.html">Bibliotecas</a>
- <ul>
- <li><a href="libraries.html#cookies">Cookies</a></li>
- <li><a href="libraries.html#serialize">Serialize</a></li>
- <li><a href="libraries.html#session">Session</a></li>
- </ul>
- </li>
- <li><a href="sapi.html">SAPI</a></li>
- <li><a href="license.html">Licenças</a></li>
- </ul>
-</div> <!-- id="navigation" -->
-
-<div id="content">
-
-
-<h2><a name="overview"></a>Visão geral</h2>
-<p>O CGILua é uma ferramenta que permite criar páginas Web dinâmicas e manipular a inserção de dados por meio de formulários Web. O CGILua permite separar o tratamento dos dados e a lógica do processo de geração de páginas, facilitando o desenvolvimento de aplicativos Web em Lua.
-
-Uma das vantagens do CGILua é sua capacidade de abstrair o servidor Web utilizado. Você pode desenvolver um aplicativo em CGILua para um servidor Web e executá-lo em qualquer outro servidor Web compatível com CGILua. </p>
-
-<p>O CGILua é um software livre que usa a mesma <a href="license.html">licença</a> da Lua 5.0.</p>
-
-<h2><a name="status"></a>Status</h2>
-<p>A versão atual é a 5.0.</p>
-
-<h2><a name="download"></a>Download</h2>
-
-<p>O download do CGILua pode ser feito em código fonte na sua página no <a href="http://luaforge.net/projects/cgilua/files">LuaForge</a>.</p>
-
-
-<h2><a name="history"></a>Histórico</h2>
-
-<dl>
- <dt><strong>Versão 5.0</strong> [23 de julho de 2005]</dt>
- <dd>
- <ul>
- <li>A distribuição do CGILua passa a incluir apenas os arquivos Lua. Os disparadores foram movidos para o <a href="http://www.keplerproject.org/kepler/">Kepler</a>.</li>
- <li>A biblioteca <a href="http://www.keplerproject.org/venv/manual.html#reference">Stable</a> passou a ser distribuída com <a href="http://www.keplerproject.org/venv/">VEnv</a>.</li>
- <li>Correção de um problema de upload de arquivo nos disparadores CGI e Xavante.</li>
- <li><code>cgilua.lp.include()</code> passa a aceitar um ambiente com o qual executa o arquivo preprocessado.</li>
- </ul>
- </dd>
- <dt><strong>Versão 5.0 beta 2</strong> [23 de dezembro de 2004]</dt>
- <dd>
- <ul>
- <li>Correção de problema de distribuição: stable.lua estava ausente</li>
- </ul>
- </dd>
- <dt><strong>Versão 5.0 beta</strong> [15 de dezembro de 2004]</dt>
- <dd>
- <ul>
- <li>Novos disparadores ISAPI e Servlet.</li>
- <li>Novos recursos de tratamento de erros.</li>
- <li>Novo recurso de dados persistentes (Stable).</li>
- <li>Uso do <a href="http://www.keplerproject.org/compat/">modelo de pacote</a> de Lua 5.1.</li>
- <li>API de usuário <a href="libraries.html#session">Session</a> mais simples.</li>
- <li>Correções de pequenos problemas</li>
- </ul>
- </dd>
- <dt><strong>Versão 5.0 alfa 3</strong> [8 de junho de 2004]</dt>
- <dd></dd>
- <dt><strong>Versão 5.0 alfa</strong> [21 de abril de 2004]</dt>
- <dd></dd>
-</dl>
-
-<h2><a name="incompatibility"></a>Incompatibilidade com versões anteriores do CGILua (4.0 e 3.x)</h2>
-
-<ul>
- <li>O CGILua 5.0 usa o <a href="http://www.lua.org">Lua 5.0</a>.</li>
- <li>A tabela <code>cgi</code> passou a permitir valores do tipo tabela. Consulte <a href="manual.html#parameters">Recebimento de parâmetros</a> para obter uma explicação detalhada.</li>
- <li>As tags de templates foram alteradas. Consulte <a href="manual.html#templates">Lua Pages</a> para obter uma explicação detalhada.</li>
- <li>O uso de chamadas <code>getenv</code> para obter variáveis CGI deve ser substituído por chamadas <a href="reference.html#servervariable"><code>cgilua.servervariable</code></a>.</li>
-</ul>
-
-<h2><a name="credits"></a>Créditos</h2>
-
-<dl>
- <dt><strong>CGILua 5.0</strong></dt>
- <dd>O CGILua 5.0 foi totalmente reelaborado por Roberto Ierusalimschy, André Carregal e Tomás Guisasola, como parte do <a href="http://www.keplerproject.org">Projeto Kepler</a>. A implementação é compatível com a Lua 5.0 e foi codificada por Tomás Guisasola, com as valiosas contribuições de Ana Lúcia de Moura, Fábio Mascarenhas e Danilo Tuler. O desenvolvimento do CGILua 5.0 foi patrocinado pela <a href="http://www.fabricadigital.com.br">Fábrica Digital</a>, pela <a href="http://www.finep.gov.br/">FINEP</a> e pelo <a href="http://www.cnpq.br/">CNPq</a>.</dd>
-
- <dt><strong>CGILua 4.0</strong></dt>
- <dd>Ana Lúcia de Moura adaptou o CGILua 3.2 para Lua 4.0, reimplementou alguns trechos do código e acrescentou alguns aperfeiçoamentos, mas essa versão não foi distribuída oficialmente.</dd>
-
- <dt><strong>CGILua 3.x</strong></dt>
- <dd>O CGILua surgiu como a evolução de um sistema originário desenvolvido por Renato Ferreira Borges e André Clínio no <a href="http://www.tecgraf.puc-rio.br">TeCGraf</a>. Na época (circa 1995) não estavam disponíveis ferramentas em CGI e tudo era feito com scripts de shell!<br /> Porém, a principal contribuição ao CGILua 3 foi dada por Anna Hester, que consolidou toda a ferramenta e desenvolveu uma distribuição consistente com as versões 3.1 e 3.2 (o número foi um esforço para seguir os números de versão da Lua). Essa versão foi amplamente utilizada em uma grande variedade de sistemas.</dd>
-</dl>
-
-
-<h2><a name="contact"></a>Fale conosco</h2>
-<p>Para obter mais informações, entre em <a href="mailto:info-NO-SPAM-THANKS@keplerproject.org">contato</a>. Seus comentários são importantes!</p>
-
-
-</div> <!-- id="content" -->
-
-</div> <!-- id="main" -->
-
-<div id="about">
- <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="XHTML 1.0 válido!" height="31" width="88" /></a></p>
- <p><small>$Id: index.html,v 1.3 2005/11/03 18:48:57 carregal Exp $</small></p>
-</div> <!-- id="about" -->
-
-</div> <!-- id="container" -->
-
-</body>
-</html>
diff --git a/doc/br/libraries.html b/doc/br/libraries.html
deleted file mode 100755
index 4fa1b7c..0000000
--- a/doc/br/libraries.html
+++ /dev/null
@@ -1,143 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html>
-<head>
- <title>CGILua: geração de scripts para a Web usando Lua</title>
- <link rel="stylesheet" href="http://www.keplerproject.org/doc.css" type="text/css"/>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-</head>
-<body>
-
-<div id="container">
-
-<div id="product">
- <div id="product_logo"><a href="http://www.keplerproject.org"><img alt="Logotipo do CGILua" src="cgi-128.gif"/></a></div>
- <div id="product_name"><big><strong>CGILua</strong></big></div>
- <div id="product_description">Geração de scripts para a Web usando Lua</div>
-</div> <!-- id="product" -->
-
-<div id="main">
-
-<div id="navigation">
-<h1>CGILua</h1>
- <ul>
- <li><a href="index.html">Início</a>
- <ul>
- <li><a href="index.html#overview">Visão geral</a></li>
- <li><a href="index.html#status">Status</a></li>
- <li><a href="index.html#download">Download</a></li>
- <li><a href="index.html#history">Histórico</a></li>
- <li><a href="index.html#incompatibility">Incompatibilidades</a></li>
- <li><a href="index.html#credits">Créditos</a></li>
- <li><a href="index.html#contact">Fale conosco</a></li>
- </ul>
- </li>
- <li><a href="manual.html">Manual</a>
- <ul>
- <li><a href="manual.html#intro">Introdução</a></li>
- <li><a href="manual.html#installation">Instalação</a></li>
- <li><a href="manual.html#config">Configuração</a></li>
- <li><a href="manual.html#scripts">Lua Scripts</a></li>
- <li><a href="manual.html#templates">Lua Pages</a></li>
- <li><a href="manual.html#parameters">Parâmetros</a></li>
- </ul>
- </li>
- <li><a href="reference.html">Referência</a>
- <ul>
- <li><a href="reference.html#headers">Cabeçalhos</a></li>
- <li><a href="reference.html#contents">Geração de conteúdo</a></li>
- <li><a href="reference.html#prep">Lua Pages</a></li>
- <li><a href="reference.html#variables">Variáveis do CGILua</a></li>
- <li><a href="reference.html#error_handling">Tratamento de erros</a></li>
- <li><a href="reference.html#behavior">Comportamento do CGILua</a></li>
- <li><a href="reference.html#urlcode">Codificação de URL</a></li>
- <li><a href="reference.html#auxiliar">Funções auxiliares</a></li>
- <li><a href="reference.html#index">Índice alfabético</a></li>
- </ul>
- </li>
- <li><strong>Bibliotecas</strong>
- <ul>
- <li><a href="libraries.html#cookies">Cookies</a></li>
- <li><a href="libraries.html#serialize">Serialize</a></li>
- <li><a href="libraries.html#session">Session</a></li>
- </ul>
- </li>
- <li><a href="sapi.html">SAPI</a></li>
- <li><a href="license.html">Licenças</a></li>
- </ul>
-</div> <!-- id="navigation" -->
-
-<div id="content">
-
-<h2>Visão geral</h2>
-
-<p>O CGILua inclui um conjunto de bibliotecas externas que permite o tratamento de cookies, dados serializados e sessões. Para usar essas bibliotecas, basta usar a instrução <code>require</code> para solicitá-las no arquivo <code>config.lua</code> do CGILua.</p>
-
-<h2><a name="cookies"></a>Cookies</h2>
-
-<dl class="reference">
- <dt><a name="get"></a><strong><code>cgilua.cookies.get (name)</code></strong></dt>
- <dd>Obtém o valor do cookie com o <code>name</code> fornecido.<br/> Retorna uma string com o valor do cookie.</dd>
-
- <dt><a name="set"></a><strong><code>cgilua.cookies.set (name, value[, options])</code></strong></dt>
- <dd>Define o valor <code>value</code> do cookie com um <code>name</code> dado. Os nomes e valores de campos na tabela <code>options</code> são usados nos atributos do cookie. Esta função deve ser chamada antes do envio dos cabeçalhos HTTP e antes da geração de qualquer resultado.<br/> Não retorna nada.</dd>
-
- <dt><a name="sethtml"></a><strong><code>cgilua.cookies.sethtml (name, value[, options])</code></strong></dt>
- <dd>Define o valor <code>value</code> do cookie com um <code>name</code> dado. Esta função gera um elemento HTML <code><meta></code>, assim, ela deve ser chamada depois de produzida a tag HTML <code><head></code> e antes da tag <code></head></code> correspondente.<br/> Não retorna nada.</dd>
-
- <dt><a name="delete"></a><strong><code>cgilua.cookies.delete (name[, options])</code></strong></dt>
- <dd>Exclui um cookie com um <code>name</code> dado (define o valor como <code>xxx</code>).<br /> Não retorna nada.</dd>
-</dl>
-
-<hr/>
-
-<h2><a name="serialize"></a>Serialize</h2>
-
-<dl class="reference">
- <dt><strong><code>cgilua.serialize (table, outfunc[, indent[, prefix]])</code></strong></dt>
- <dd>Serializa uma <code>table</code> usando <code>outfunc</code> como a função usada para gerar o resultado; <code>indent</code> como uma string opcional com o padrão de identação; <code>prefix</code> como uma string opcional com o prefixo de identação (usado para armazenar o recuo real entre as chamadas recursivas).<br/> Observe que há algumas restrições: os valores dos tipos <em>function</em> e <em>userdata</em> não podem ser serializados; as tabelas que contêm ciclos também não podem ser serializadas.<br/> Não retorna nada.</dd>
-</dl>
-
-<hr/>
-
-<h2><a name="session"></a>Session</h2>
-
-<dl class="reference">
- <dt><a name="close"></a><strong><code>cgilua.session.close ()</code></strong></dt>
- <dd>Fecha a sessão de usuário. Salva todos os dados em <code>cgilua.session.data</code> no sistema de armazenamento em uso (normalmente, o sistema de arquivos). Esta função deve ser chamada depois que o script terminar de ser executado. Para garantir que isso ocorra, recomenda-se usar a <a href="reference.html#addclosefunction">addclosefunction</a> no arquivo de configuração.<br/> Não retorna nada.</dd>
-
- <dt><a name="data"></a><strong><code>cgilua.session.data</code></strong></dt>
- <dd>Tabela que contém os dados sobre a sessão de usuário.</dd>
-
- <dt><a name="delete"></a><strong><code>cgilua.session.delete (id)</code></strong></dt>
- <dd>Exclui uma sessão. O argumento <code>id</code> é o identificador da sessão.<br/> Não retorna nada.</dd>
-
- <dt><a name="load"></a><strong><code>cgilua.session.load (id)</code></strong></dt>
- <dd>Carrega dados de uma sessão. O argumento <code>id</code> é o identificador da sessão.<br/> Retorna uma tabela com os dados da sessão ou <code>nil</code> seguido de uma mensagem de erro.</dd>
-
- <dt><a name="new"></a><strong><code>cgilua.session.new ()</code></strong></dt>
- <dd>Cria um novo identificador de sessão.<br/> Retorna o novo identificador de sessão.</dd>
-
- <dt><a name="open"></a><strong><code>cgilua.session.open ()</code></strong></dt>
- <dd>Abre a sessão de usuário. Cria a tabela <code>cgilua.session.data</code>. Esta função deve ser chamada imediatamente antes da execução do script, mas após o processamento dos cabeçalhos da solicitação. Para garantir que isso ocorra, recomenda-se usar a <a href="reference.html#addopenfunction">addopenfunction</a> no arquivo de configuração.<br/> Não retorna nada.</dd>
-
- <dt><a name="save"></a><strong><code>cgilua.session.save (id, data)</code></strong></dt>
- <dd>Salva <code>data</code> em uma sessão com um <code>id</code>.<br /> Não retorna nada.</dd>
-
- <dt><a name="setsessiondir"></a><strong><code>cgilua.session.setsessiondir (path)</code></strong></dt>
- <dd>Define o diretório temporário da sessão. O argumento <code>path</code> é uma string com o novo diretório.<br/> Não retorna nada.</dd>
-</dl>
-
-</div> <!-- id="content" -->
-
-</div> <!-- id="main" -->
-
-<div id="about">
- <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="XHTML 1.0 válido!" height="31" width="88" /></a></p>
- <p><small>$Id: libraries.html,v 1.3 2005/11/03 18:48:57 carregal Exp $</small></p>
-</div> <!-- id="about" -->
-
-</div> <!-- id="container" -->
-
-</body>
-</html>
diff --git a/doc/br/license.html b/doc/br/license.html
deleted file mode 100755
index 343c8e0..0000000
--- a/doc/br/license.html
+++ /dev/null
@@ -1,102 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html>
-<head>
- <title>CGILua: geração de scripts para a Web usando Lua</title>
- <link rel="stylesheet" href="http://www.keplerproject.org/doc.css" type="text/css"/>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-</head>
-<body>
-
-<div id="container">
-
-<div id="product">
- <div id="product_logo"><a href="http://www.keplerproject.org"><img alt="Logotipo do CGILua" src="cgi-128.gif"/></a></div>
- <div id="product_name"><big><b>CGILua</b></big></div>
- <div id="product_description">Geração de scripts para a Web usando Lua</div>
-</div> <!-- id="product" -->
-
-<div id="main">
-
-<div id="navigation">
-<h1>CGILua</h1>
- <ul>
- <li><a href="index.html">Início</a>
- <ul>
- <li><a href="index.html#overview">Visão geral</a></li>
- <li><a href="index.html#status">Status</a></li>
- <li><a href="index.html#download">Download</a></li>
- <li><a href="index.html#history">Histórico</a></li>
- <li><a href="index.html#incompatibility">Incompatibilidades</a></li>
- <li><a href="index.html#credits">Créditos</a></li>
- <li><a href="index.html#contact">Fale conosco</a></li>
- </ul>
- </li>
- <li><a href="manual.html">Manual</a>
- <ul>
- <li><a href="manual.html#intro">Introdução</a></li>
- <li><a href="manual.html#installation">Instalação</a></li>
- <li><a href="manual.html#config">Configuração</a></li>
- <li><a href="manual.html#scripts">Lua Scripts</a></li>
- <li><a href="manual.html#templates">Lua Pages</a></li>
- <li><a href="manual.html#parameters">Parâmetros</a></li>
- </ul>
- </li>
- <li><a href="reference.html">Referência</a>
- <ul>
- <li><a href="reference.html#headers">Cabeçalhos</a></li>
- <li><a href="reference.html#contents">Geração de conteúdo</a></li>
- <li><a href="reference.html#prep">Lua Pages</a></li>
- <li><a href="reference.html#variables">Variáveis do CGILua</a></li>
- <li><a href="reference.html#error_handling">Tratamento de erros</a></li>
- <li><a href="reference.html#behavior">Comportamento do CGILua</a></li>
- <li><a href="reference.html#urlcode">Codificação de URL</a></li>
- <li><a href="reference.html#auxiliar">Funções auxiliares</a></li>
- <li><a href="reference.html#index">Índice alfabético</a></li>
- </ul>
- </li>
- <li><a href="libraries.html">Bibliotecas</a>
- <ul>
- <li><a href="libraries.html#cookies">Cookies</a></li>
- <li><a href="libraries.html#serialize">Serialize</a></li>
- <li><a href="libraries.html#session">Session</a></li>
- </ul>
- </li>
- <li><a href="sapi.html">SAPI</a></li>
- <li><strong>Licenças</strong></li>
- </ul>
-</div> <!-- id="navigation" -->
-
-<div id="content">
-
-<h2>Licença</h2>
-
-<p>O CGILua é um software livre: ele pode ser usado com fins acadêmicos e comerciais sem custo algum. Não há royalties ou restrições do tipo "copyleft" da GNU. O CGILua é classificado como um software <a href="http://www.opensource.org/docs/definition.html">Open Source</a> (código aberto). Suas licenças são compatíveis com <a href="http://www.gnu.org/licenses/gpl.html">GPL</a>. O CGILua não é de domínio público e o <a href="http://www.keplerproject.org">Kepler Project</a> mantém o seu direito autoral. Os detalhes legais estão listados abaixo.</p>
-
-<p>A idéia da licença é a de que você fique livre para usar o CGILua com qualquer objetivo sem incorrer em despesas e sem ter que pedir autorização para isso. Nossa única exigência é que, caso você realmente use o CGILua, então, o devido crédito seja dado por meio da inclusão do aviso de copyright apropriado em seu produto ou na documentação correspondente.</p>
-
-<p>A biblioteca do CGILua foi desenvolvida e implementada por Roberto Ierusalimschy, André Carregal e Tomás Guisasola. A implementação não deriva de softwares licenciados.</p>
-
-<hr/>
-
-<p>Copyright © 2003-2005 The Kepler Project.</p>
-
-<p>Por meio deste, concede-se permissão gratuita a qualquer pessoa que obtenha uma cópia deste software e dos arquivos da documentação associada (o "Software") para trabalhar com o Software sem restrições, incluindo, sem limitação, os direitos de usar, copiar, modificar, mesclar, publicar, distribuir, sublicenciar e/ou vender cópias do Software, e de permitir a pessoas a quem o Software seja fornecido de assim fazê-lo, sujeitando-se às seguintes condições:</p>
-
-<p>O aviso de copyright acima e esta permissão devem ser incluídos em todas as cópias ou em partes significativas do Software.</p>
-
-<p>O SOFTWARE É FORNECIDO "NO ESTADO EM QUE ESTIVER", SEM GARANTIAS DE QUALQUER TIPO, EXPLÍCITAS OU IMPLÍCITAS, INCLUINDO, SEM LIMITAÇÃO, AS GARANTIAS DE COMERCIALIZAÇÃO, ADEQUAÇÃO A UM DETERMINADO OBJETIVO E NÃO INFRAÇÃO. EM CIRCUNSTÂNCIA ALGUMA OS AUTORES OU OS DETENTORES DO COPYRIGHT SERÃO CONSIDERADOS RESPONSÁVEIS POR QUAISQUER REIVINDICAÇÕES, DANOS OU OUTRAS RESPONSABILIDADES, POR MEIO DE CONTRATO, DANOS OU OUTROS RELACIONADOS OU EM DECORRÊNCIA DO USO DO SOFTWARE OU OUTRAS AÇÕES NO MESMO.</p>
-
-</div> <!-- id="content" -->
-
-</div> <!-- id="main" -->
-
-<div id="about">
- <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="XHTML 1.0 válido!" height="31" width="88" /></a></p>
- <p><small>$Id: license.html,v 1.3 2005/11/03 18:48:57 carregal Exp $</small></p>
-</div> <!-- id="about" -->
-
-</div> <!-- id="container" -->
-
-</body>
-</html>
diff --git a/doc/br/manual.html b/doc/br/manual.html
deleted file mode 100755
index 654220f..0000000
--- a/doc/br/manual.html
+++ /dev/null
@@ -1,270 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html>
-<head>
- <title>CGILua: geração de scripts para a Web usando Lua</title>
- <link rel="stylesheet" href="http://www.keplerproject.org/doc.css" type="text/css"/>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-</head>
-<body>
-
-<div id="container">
-
-<div id="product">
- <div id="product_logo"><a href="http://www.keplerproject.org"><img alt="Logotipo do CGILua" src="cgi-128.gif"/></a></div>
- <div id="product_name"><big><strong>CGILua</strong></big></div>
- <div id="product_description">Geração de scripts para a Web usando Lua</div>
-</div> <!-- id="product" -->
-
-<div id="main">
-
-<div id="navigation">
-<h1>CGILua</h1>
- <ul>
- <li><a href="index.html">Início</a>
- <ul>
- <li><a href="index.html#overview">Visão geral</a></li>
- <li><a href="index.html#status">Status</a></li>
- <li><a href="index.html#download">Download</a></li>
- <li><a href="index.html#history">Histórico</a></li>
- <li><a href="index.html#incompatibility">Incompatibilidades</a></li>
- <li><a href="index.html#credits">Créditos</a></li>
- <li><a href="index.html#contact">Fale conosco</a></li>
- </ul>
- </li>
- <li><strong>Manual</strong>
- <ul>
- <li><a href="manual.html#intro">Introdução</a></li>
- <li><a href="manual.html#installation">Instalação</a></li>
- <li><a href="manual.html#config">Configuração</a></li>
- <li><a href="manual.html#scripts">Lua Scripts</a></li>
- <li><a href="manual.html#templates">Lua Pages</a></li>
- <li><a href="manual.html#parameters">Parâmetros</a></li>
- </ul>
- </li>
- <li><a href="reference.html">Referência</a>
- <ul>
- <li><a href="reference.html#headers">Cabeçalhos</a></li>
- <li><a href="reference.html#contents">Geração de conteúdo</a></li>
- <li><a href="reference.html#prep">Lua Pages</a></li>
- <li><a href="reference.html#variables">Variáveis do CGILua</a></li>
- <li><a href="reference.html#error_handling">Tratamento de erros</a></li>
- <li><a href="reference.html#behavior">Comportamento do CGILua</a></li>
- <li><a href="reference.html#urlcode">Codificação de URL</a></li>
- <li><a href="reference.html#auxiliar">Funções auxiliares</a></li>
- <li><a href="reference.html#index">Índice alfabético</a></li>
- </ul>
- </li>
- <li><a href="libraries.html">Bibliotecas</a>
- <ul>
- <li><a href="libraries.html#cookies">Cookies</a></li>
- <li><a href="libraries.html#serialize">Serialize</a></li>
- <li><a href="libraries.html#session">Session</a></li>
- </ul>
- </li>
- <li><a href="sapi.html">SAPI</a></li>
- <li><a href="license.html">Licenças</a></li>
- </ul>
-</div> <!-- id="navigation" -->
-
-<div id="content">
-
-<h2><a name="intro"></a>Introdução</h2>
-
-<p>O CGILua usa <a href="http://www.lua.org">Lua</a> como a linguagem de scripts do servidor para criar páginas Web dinâmicas. O CGILua oferece suporte a <a href="manual.html#scripts">Lua Scripts</a> puros e a <a href="manual.html#templates">Lua Pages</a> (.lp). Um Lua Script é, basicamente, um programa em Lua que cria todo o conteúdo de uma página Web e o retorna para o cliente. Uma Lua Page é um arquivo de texto com marcações (HTML, XML etc.) que incorpora código Lua usando algumas tags especiais. Essas tags são processadas pelo CGILua e a página resultante é retornada para o cliente.</p>
-
-<p>Os Lua Scripts e as Lua Pages são igualmente fáceis de usar e a opção por um deles depende, primariamente, das características da página resultante. Enquanto as Lua Pages são mais convenientes para separar a lógica e o formato, os Lua Scripts são mais adequados para criar páginas de estrutura mais simples, mas que requeiram uma quantidade significativamente maior de processamento interno.</p>
-
-<p>Ao permitir a combinação desses dois métodos, o CGILua dá aos desenvolvedores de aplicativos Web uma maior flexibilidade quando os dois requisitos estão presentes. Para obter uma descrição detalhada de ambos os métodos de criação de scripts e alguns exemplos práticos, consulte <a href="#scripts">Lua Scripts</a> e <a href="#templates">Lua Pages</a>.</p>
-
-<p>A arquitetura do CGILua é dividida em duas camadas. O nível inferior é representado pela API do servidor (<a href="sapi.html">SAPI</a>) e o mais alto, pela API do próprio CGILua. SAPI é a interface entre o servidor Web e a API do CGILua, precisando portanto ser implementada em cada servidor Web e método de disparo empregado.</p>
-
-<p>O CGILua e a API do CGILua são implementados usando-se apenas a SAPI e são totalmente transportáveis entre disparadores e os servidores Web compatíveis. Dessa maneira, qualquer Lua Script ou Lua Page pode ser usada por qualquer disparador.</p>
-
-<h2><a name="installation"></a>Instalação</h2>
-
-<p>O CGILua segue o <a href="http://www.keplerproject.org/compat/">modelo de pacotes</a> de Lua 5.1 e, conseqüentemente, precisa ser "instalado". Consulte a seção <a href="http://www.keplerproject.org/compat/manual.html#configuration">Configuração do Compat-5.1</a> para obter informações sobre como instalar corretamente o módulo.</p>
-
-
-<h2><a name="config"></a>Configuração</h2>
-
-<p>O CGILua 5.0 oferece um único arquivo de configuração, chamado <code>config.lua</code>, e um conjunto de funções para alterar a configuração padrão do CGILua. Esse arquivo pode ser colocado em qualquer lugar em <code>LUA_PATH</code> para facilitar a atualização do CGILua sem a substituição do <code>config.lua</code> existente.</p>
-
-<p>Alguns usos do <code>config.lua</code> são:</p>
-
-<dl>
- <dt><strong>Tratadores de scripts</strong></dt>
- <dd>Você pode adicionar novos tratadores de CGILua usando <a href="reference.html#addscripthandler"><code>cgilua.addscripthandler</code></a> (consulte também <a href="reference.html#buildplainhandler"><code>cgilua.buildplainhandler</code></a> e <a href="reference.html#buildprocesshandler"><code>cgilua.buildprocesshandler</code></a> para obter as funções que criam tratadores simples).
- </dd>
- <dt><strong>Tamanhos de dados POST</strong></dt>
- <dd>Altere os limites de tamanho dos dados POST usando <a href="reference.html#setmaxinput"><code>cgilua.setmaxinput</code></a> e <a href="reference.html#setmaxfilesize"><code>cgilua.setmaxfilesize</code></a>.
- </dd>
- <dt><strong>Abertura e fechamento de funções</strong></dt>
- <dd>Você pode adicionar suas funções ao ciclo de vida útil do CGILua usando <a href="reference.html#addopenfunction"><code>cgilua.addopenfunction</code></a> e <a href="reference.html#addclosefunction"><code>cgilua.addclosefunction</code></a>. Essas funções são executadas imediatamente antes e depois da execução do script, mesmo quando ocorrer um erro no processamento do script.</dd>
-</dl>
-
-<h2><a name="error_handling"></a>Tratamento de erros</h2>
-
-<p>Há três funções para tratamento de erros no CGILua:</p>
-
-<p>A função <a href="reference.html#seterrorhandler"><code>cgilua.seterrorhandler</code></a> define o <em>tratador de erro</em>, uma função chamada pela Lua logo após ocorrer um erro. O tratador de erro tem acesso à pilha de execução antes da ocorrência do erro, assim, ele pode gerar uma mensagem de erro usando as informações da pilha. Lua também possui uma função para fazer isso: <code>debug.traceback</code>.</p>
-
-<p>A função <a href="reference.html#seterroroutput"><code>cgilua.seterroroutput</code></a> define a função que decide o que deve ser feito com a mensagem de erro. Ele pode ser enviado para o cliente, gravado em um arquivo de log ou enviado para um endereço de email (com a ajuda do <a href="http://luasocket.luaforge.net/">LuaSocket</a> ou do <a href="http://www.keplerproject.org/lualogging/">LuaLogging</a>, por exemplo).</p>
-
-<p>A função <a href="reference.html#errorlog"><code>cgilua.errorlog</code></a> é fornecida para gravar diretamente no arquivo de log de erros do servidor HTTP.</p>
-
-<h2><a name="scripts"></a>Lua Scripts</h2>
-
-<p>Os Lua Scripts são arquivos de texto que contêm código Lua válido. Esse estilo de uso adota uma forma de programação para Web mais "rústica", na qual um programa é responsável pela geração da página resultante. Os Lua Scripts têm a extensão padrão <code>.lua</code>.</p>
-
-<p>Para gerar um documento Web (HTML, XML, WML, CSS etc.) válido, o Lua Script deve obedecer a uma ordem esperada pelo HTTP para produzir a saída, primeiro enviando os <a href="reference.html#headers">cabeçalhos</a> corretos e, depois, enviando o <a href="reference.html#contents">conteúdo</a> real do documento.</p>
-
-<p>O CGILua tem algumas funções que facilitam essas tarefas, por exemplo, <a href="reference.html#htmlheader"><code>cgilua.htmlheader</code></a> para produzir o cabeçalho de um documento HTML e <a href="reference.html#put"><code>cgilua.put</code></a> para enviar o conteúdo do documento (ou parte dele).</p>
-
-<p>Por exemplo, um documento HTML que exiba a frase "Olá mundo!" pode ser gerado com este Lua Script:</p>
-
-<pre class="example">
-cgilua.htmlheader()
-cgilua.put([[
-<html>
-<head>
- <title>Olá mundo</title>
-</head>
-<body>
- <strong>Olá mundo!</strong>
-</body>
-</html>]])
-</pre>
-
-<p>Observe que o exemplo acima gera uma página "fixa": embora ela seja gerada no momento da execução, a página não contém informações "variáveis". Isso significa que o mesmo documento poderia ser gerado diretamente com um simples arquivo HTML estático. No entanto, os Lua Scripts são especialmente úteis quando o documento contém informações que não sejam conhecidas de antemão ou que mudem de acordo com os parâmetros passados. Nesse caso, é necessário gerar uma página "dinâmica".</p>
-
-<p>Outro exemplo fácil pode ser mostrado, desta vez, usando uma estrutura de controle Lua, variáveis e o operador de concatenação:</p>
-
-<pre class="example">
-cgilua.htmlheader()
-
-if cgi.language == 'english' then
- greeting = 'Hello World!'
-elseif cgi.language == 'portuguese' then
- greeting = 'Olá Mundo!'
-else
- greeting = '[unknown language]'
-end
-
-cgilua.put('<html>')
-cgilua.put('<head>')
-cgilua.put(' <title>'..greeting..'</title>')
-cgilua.put('</head>')
-cgilua.put('<body>')
-cgilua.put(' <strong>'..greeting..'</strong>')
-cgilua.put('</body>')
-cgilua.put('</html>')
-</pre>
-
-<p>No exemplo acima, o uso de <code><em>cgi.language</em></code> indica que <em>language</em> foi passado para o Lua Script como um <a href="manual.html#parameters">parâmetro do CGILua</a>, oriundo de um campo de formulário HTML (via POST) ou da URL usada para ativá-lo (via GET). O CGILua decodifica automaticamente esses parâmetros para que você possa usá-los à vontade em Lua Scripts e Lua Pages.</p>
-
-<h2><a name="templates"></a>Lua Pages</h2>
-
-<p>Uma Lua Page é um arquivo de modelo (template) com texto que será processado pelo CGILua antes de o servidor HTTP enviá-lo para o cliente. O CGILua não processa o texto, ele procura algumas marcações especiais que inserem o código Lua no arquivo. Depois que essas marcações são processadas e mescladas no arquivo de template, os resultados são enviados para o cliente.</p>
-
-<p>As Lua Pages têm a extensão padrão <code>.lp</code>. Elas são uma maneira mais simples de criar uma página dinâmica porque eliminam a necessidade de enviar os cabeçalhos HTTP. Em geral, Lua Pages são páginas HTML, portanto, o CGILua envia automaticamente o cabeçalho HTML.</p>
-
-<p>Como há algumas restrições quanto aos usos de cabeçalhos HTTP, ocasionalmente, será preciso usar um Lua Script em vez de uma Lua Page.</p>
-
-<p>As marcações fundamentais de uma Lua Page são:</p>
-
-<dl>
- <dt><strong><code><?lua <em>chunk</em> ?></code></strong></dt>
- <dd>Processa e mescla os resultados da execução do <em>chunk</em> Lua, no qual a marcação está localizada no template. A forma alternativa <code><% <em>chunk</em> %></code> também pode ser usada.</dd>
-
- <dt><strong><code><?lua= <em>expression</em> ?></code></strong></dt>
- <dd>Processa e mescla a avaliação de uma <em>expression</em> em Lua, na qual a marcação está localizada no template. A forma alternativa <code><%= <em>expression</em> %></code> também pode ser usada.</dd>
-</dl>
-
-<p>Observe que a marcação de término não pode estar dentro de um chunk de código ou uma expressão Lua, mesmo que esteja entre aspas. O pré-processador de Lua Pages apenas faz substituições globais no template, procurando um par correspondente de marcações e gerando o código Lua correspondente para obter o mesmo resultado que o Lua Script equivalente.</p>
-
-<p>O segundo exemplo da seção anterior pode ser escrito usando uma Lua Page como esta:</p>
-
-<pre class="example">
-<html>
-<?lua
-if cgi.language == 'english' then
- greeting = 'Hello World!'
-elseif cgi.language == 'portuguese' then
- greeting = 'Olá Mundo!'
-else
- greeting = '[unknown language]'
-end
-?>
-<head>
- <title><%= greeting %></title>
-</head>
-<body>
- <>strong<%= greeting %></strong>
-</body>
-</html>
-</pre>
-
-<p>As tags HTML e as tags de Lua Page podem ser livremente intercambiadas. Porém, como ocorre em outras linguagens de template, considera-se uma boa prática não usar lógica Lua explícita em templates. A abordagem recomendada é usar apenas chamadas de funções que retornam chunks de conteúdo, dessa forma, nesse exemplo, pressupondo-se que a função <code>getGreeting</code> tenha sido definida em outro ponto como</p>
-
-<pre class="example">
-function getGreeting()
- local greeting
- if cgi.language == 'english' then
- greeting = 'Hello World!'
- elseif cgi.language == 'portuguese' then
- greeting = 'Olá Mundo!'
- else
- greeting = '[unknown language]'
- end
- return greeting
-end
-</pre>
-
-<p>a Lua Page poderia ser reescrita desta maneira:</p>
-
-<pre class="example">
-<html>
-<head>
- <title><%= getGreeting() %></title>
-</head>
-<body>
- <strong><%= getGreeting() %></strong>
-</body>
-</html>
-</pre>
-
-<h2><a name="parameters"></a>Recebimento de parâmetros: a tabela <code>cgi</code></h2>
-
-<p>O CGILua oferece uma maneira unificada de acessar dados passados para os scripts no método HTTP usado (GET ou POST). Independentemente do método usado no cliente, todos os parâmetros serão fornecidos dentro da tabela <code>cgi</code>.</p>
-
-<p>Normalmente, todos os tipos de parâmetros estarão disponíveis como strings. Se o valor de um parâmetro for um número, ele será convertido na representação de string correspondente.</p>
-
-<p>Há apenas duas exceções nas quais o valor será uma tabela Lua. O primeiro caso ocorre em uploads de arquivos, no qual a tabela correspondente terá estes campos:</p>
-
-<dl>
- <dt><strong>filename</strong></dt>
- <dd>o nome do arquivo como fornecido pelo cliente.</dd>
-
- <dt><strong>filesize</strong></dt>
- <dd>o tamanho do arquivo em bytes.</dd>
-
- <dt><strong>file</strong></dt>
- <dd>o <em>handler</em> do arquivo temporário. O arquivo deve ser copiado porque o CGILua o removerá após a conclusão do script.</dd>
-</dl>
-
-<p>O outro caso que usa tabelas Lua ocorre quando há mais de um valor associado ao mesmo nome de parâmetro. Isso acontece no caso de uma lista de seleção com vários valores; mas também ocorre quando o formulário tiver dois ou mais elementos com o mesmo atributo <code>name</code> (possivelmente porque um estava em um formulário e o outro, na <em>query string</em>). Todos os valores serão inseridos em uma tabela indexada, na ordem em que foram tratados.</p>
-
-</div> <!-- id="content" -->
-
-</div> <!-- id="main" -->
-
-<div id="about">
- <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="XHTML 1.0 válido!" height="31" width="88" /></a></p>
- <p><small>$Id: manual.html,v 1.3 2005/11/03 18:48:57 carregal Exp $</small></p>
-</div> <!-- id="about" -->
-
-</div> <!-- id="container" -->
-
-</body>
-</html>
diff --git a/doc/br/reference.html b/doc/br/reference.html
deleted file mode 100755
index 3419cf4..0000000
--- a/doc/br/reference.html
+++ /dev/null
@@ -1,252 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html>
-<head>
- <title>CGILua: geração de scripts para a Web usando Lua</title>
- <link rel="stylesheet" href="http://www.keplerproject.org/doc.css" type="text/css"/>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-</head>
-<body>
-
-<div id="container">
-
-<div id="product">
- <div id="product_logo"><a href="http://www.keplerproject.org"><img alt="Logotipo do CGILua" src="cgi-128.gif"/></a></div>
- <div id="product_name"><big><strong>CGILua</strong></big></div>
- <div id="product_description">Geração de scripts para a Web usando Lua</div>
-</div> <!-- id="product" -->
-
-<div id="main">
-
-<div id="navigation">
-<h1>CGILua</h1>
- <ul>
- <li><a href="index.html">Início</a>
- <ul>
- <li><a href="index.html#overview">Visão geral</a></li>
- <li><a href="index.html#status">Status</a></li>
- <li><a href="index.html#download">Download</a></li>
- <li><a href="index.html#history">Histórico</a></li>
- <li><a href="index.html#incompatibility">Incompatibilidades</a></li>
- <li><a href="index.html#credits">Créditos</a></li>
- <li><a href="index.html#contact">Fale conosco</a></li>
- </ul>
- </li>
- <li><a href="manual.html">Manual</a>
- <ul>
- <li><a href="manual.html#intro">Introdução</a></li>
- <li><a href="manual.html#installation">Instalação</a></li>
- <li><a href="manual.html#config">Configuração</a></li>
- <li><a href="manual.html#scripts">Lua Scripts</a></li>
- <li><a href="manual.html#templates">Lua Pages</a></li>
- <li><a href="manual.html#parameters">Parâmetros</a></li>
- </ul>
- </li>
- <li><strong>Referência</strong>
- <ul>
- <li><a href="reference.html#headers">Cabeçalhos</a></li>
- <li><a href="reference.html#contents">Geração de conteúdo</a></li>
- <li><a href="reference.html#prep">Lua Pages</a></li>
- <li><a href="reference.html#variables">Variáveis do CGILua</a></li>
- <li><a href="reference.html#error_handling">Tratamento de erros</a></li>
- <li><a href="reference.html#behavior">Comportamento do CGILua</a></li>
- <li><a href="reference.html#urlcode">Codificação de URL</a></li>
- <li><a href="reference.html#auxiliar">Funções auxiliares</a></li>
- <li><a href="reference.html#index">Índice alfabético</a></li>
-
- </ul>
- </li>
- <li><a href="libraries.html">Bibliotecas</a>
- <ul>
- <li><a href="libraries.html#cookies">Cookies</a></li>
- <li><a href="libraries.html#serialize">Serialize</a></li>
- <li><a href="libraries.html#session">Session</a></li>
- </ul>
- </li>
- <li><a href="sapi.html">SAPI</a></li>
- <li><a href="license.html">Licenças</a></li>
- </ul>
-</div> <!-- id="navigation" -->
-
-<div id="content">
-
-
-<h2><a name="headers"></a>Cabeçalhos</h2>
-
-<p>As funções de cabeçalho são usadas para alterar os cabeçalhos de resposta HTTP e consistem em:</p>
-
-<dl class="reference">
- <dt><a name="contentheader"></a><strong><code>cgilua.contentheader (type, subtype)</code></strong></dt>
- <dd>Envia um cabeçalho <em>Content-type</em> com os valores dados de tipo e subtipo.<br/> Ambos os argumentos são strings: <code>type</code> é o tipo do cabeçalho; <code>subtype</code> é o subtipo do cabeçalho.<br/> Não retorna nada.</dd>
-
- <dt><a name="header"></a><strong><code>cgilua.header (header, value)</code></strong></dt>
- <dd>Envia um cabeçalho genérico. Esta função <em>não</em> deve ser usada para gerar um cabeçalho <em>Content-type</em> ou <em>Location</em>.<br/> Ambos os argumentos são strings: <code>header</code> é o nome do cabeçalho e <code>value</code>, seu valor.<br/> Não retorna nada.</dd>
-
- <dt><a name="htmlheader"></a><strong><code>cgilua.htmlheader ()</code></strong></dt>
- <dd>Envia o cabeçalho de um arquivo HTML (<em>Content-type: text/html</em>).<br/> Não retorna nada.</dd>
-
- <dt><a name="redirect"></a><strong><code>cgilua.redirect (url, args)</code></strong></dt>
- <dd>Envia o cabeçalho para forçar o redirecionamento para a URL dada, adicionando os parâmetros na tabela <code>args</code> relativos à nova URL.<br/> O primeiro argumento (<code>url</code>) é a URL à qual o navegador deve ser redirecionado; o segundo (<code>args</code>) é uma tabela opcional que pode conter pares <em>nome = valor</em> que serão codificados para formar um URL válido (consulte a função <a href="#encodetable">cgilua.urlcode.encodetable</a>).<br/> Não retorna nada.</dd>
-</dl>
-
-
-<h2><a name="contents"></a>Geração de conteúdo</h2>
-
-<p>As funções de geração de conteúdo são usadas para produzir texto para a resposta e gerar URLs no formato do CGILua. Elas consistem em:</p>
-
-<dl class="reference">
- <dt><a name="mkabsoluteurl"></a><strong><code>cgilua.mkabsoluteurl (path)</code></strong></dt>
- <dd>Cria uma URL absoluta contendo <code>path</code> da URL dada.<br/> Retorna a URL absoluta resultante.</dd>
-
- <dt><a name="mkurlpath"></a><strong><code>cgilua.mkurlpath (script [, args])</code></strong></dt>
- <dd>Cria o caminho de uma URL a ser usado como link para um <code>script</code> CGILua usando a tabela opcional de argumentos (<code>args</code>). Os argumentos são usados na URL como parâmetros de string de consulta.<br/> Retorna a URL resultante.</dd>
-
- <dt><a name="put"></a><strong><code>cgilua.put (string)</code></strong></dt>
- <dd>Envia a <code>string</code> dada para o cliente.<br/> Não retorna nada.</dd>
-</dl>
-
-<h2><a name="lp"></a>Lua Pages</h2>
-
-<p>As funções de Lua Pages são usadas para processar templates Lua Pages e definir o comportamento desse processamento. Elas consistem em:</p>
-
-<dl class="reference">
- <dt><a name="handlelp"></a><strong><code>cgilua.handlelp (filename)</code></strong></dt>
- <dd>Equivale a <a href="include"><code>cgilua.lp.include</code></a>, mas envia o cabeçalho HTML antes do arquivo pré-processado.<br/> Não retorna nada.</dd>
-
- <dt><a name="include"></a><strong><code>cgilua.lp.include (filename)</code></strong></dt>
- <dd>Pré-processa um template Lua Page (fornecido por <code>filename</code>) e envia o resultado para o cliente.<br/> Não retorna nada.</dd>
-
- <dt><a name="setcompatmode"></a><strong><code>cgilua.lp.setcompatmode (boolean)</code></strong></dt>
- <dd>Ativa e desativa o modo de compatibilidade. A ativação fará com que o pré-processador de Lua Pages entenda as estruturas de <em>campos de expressão</em> e <em>campos de código</em> usadas por versões anteriores do CGILua.<br/> Não retorna nada.</dd>
-
- <dt><a name="setoutfunc"></a><strong><code>cgilua.lp.setoutfunc (funcname)</code></strong></dt>
- <dd>Define o nome da função de resultado de templates. O pré-processador Lua Pages gera chamadas para a função com o <code>funcname</code> fornecido (uma string).<br/> Não retorna nada.</dd>
-
- <dt><a name="translate"></a><strong><code>cgilua.lp.translate (string)</code></strong></dt>
- <dd>Usa o pré-processador Lua Pages para gerar uma string correspondente ao código Lua que executa expressões e/ou chunks em Lua dentro da <code>string</code> fornecida.<br/> Retorna uma string com o código Lua resultante.</dd>
-</dl>
-
-
-<h2><a name="variables"></a>Variáveis do CGILua</h2>
-
-<p>As variáveis do CGILua oferecem informações sobre o script em processamento e as <a href="sapi.html#servervariable">variáveis de ambiente do CGI</a>. Elas consistem em atributos e funções:</p>
-
-<dl class="reference">
- <dt><a name="script_file"></a><strong><code>cgilua.script_file</code></strong></dt>
- <dd>O nome do arquivo do script em execução. Obtido de <a href="#script_path"><code>cgilua.script_path</code></a>.</dd>
-
- <dt><a name="script_path"></a><strong><code>cgilua.script_path</code></strong></dt>
- <dd>O caminho completo do arquivo do script em execução. Esta variável normalmente é igual à <a href="sapi.html#servervariable">variável de ambiente do CGI</a> <code>PATH_TRANSLATED</code>.</dd>
-
- <dt><a name="script_pdir"></a><strong><code>cgilua.script_pdir</code></strong></dt>
- <dd>O diretório do script em execução. Obtido de <a href="#script_path"><code>cgilua.script_path</code></a>.</dd>
-
- <dt><a name="script_vdir"></a><strong><code>cgilua.script_vdir</code></strong></dt>
- <dd>O diretório virtual do script em execução. Obtido de <a href="#script_vpath"><code>cgilua.script_vpath</code></a>.</dd>
-
- <dt><a name="script_vpath"></a><strong><code>cgilua.script_vpath</code></strong></dt>
- <dd>O caminho virtual completo do arquivo do script em execução. Equivale à <a href="sapi.html#servervariable">variável de ambiente do CGI</a> <code>PATH_INFO</code>.</dd>
-
- <dt><a name="servervariable"></a><strong><code>cgilua.servervariable (varname)</code></strong></dt>
- <dd>Retorna uma string com o valor da variável de ambiente do CGI que corresponde a <code>varname</code>. Para obter uma lista das variáveis do CGI, consulte <a href="sapi.html#servervariable">SAPI.Request.servervariable</a>.</dd>
-
- <dt><a name="urlpath"></a><strong><code>cgilua.urlpath</code></strong></dt>
- <dd>O nome do script. Equivale à <a href="sapi.html#servervariable">variável de ambiente do CGI</a> <code>SCRIPT_NAME</code>.</dd>
-</dl>
-
-<h2><a name="error_handling"></a>Tratamento de erros</h2>
-
-<p>As funções de tratamento de erros do CGILua permitem a redefinição de como os erros são tratados e apresentados ao usuário. Elas consistem em:</p>
-
-<dl class="reference">
- <dt><a name="errorlog"></a><strong><code>cgilua.errorlog (string)</code></strong></dt>
- <dd>Envia a <code>string</code> dada para o arquivo de log de erros.<br/> Não retorna nada.</dd>
-
- <dt><a name="seterrorhandler"></a><strong><code>cgilua.seterrorhandler (func)</code></strong></dt>
- <dd>Define a tratador de erros como <code>func</code>. Esta função é chamada pela Lua quando ocorre um erro. Ela recebe a mensagem de erro gerada pela Lua e é responsável por gerar e retornar o erro correto que deve ser usado pelo CGILua.<br/> Não retorna nada.</dd>
-
- <dt><a name="seterroroutput"></a><strong><code>cgilua.seterroroutput (func)</code></strong></dt>
- <dd>Define a função responsável pela apresentação de erros como <code>func</code>. Esta função é chamada pela Lua para gerar o resultado do erro.<br/> Não retorna nada.</dd>
-</dl>
-
-<h2><a name="behavior"></a>Comportamento do CGILua</h2>
-
-<p>O comportamento do CGILua pode ser configurado com o uso deste conjunto de funções:</p>
-
-<dl class="reference">
- <dt><a name="addclosefunction"></a><strong><code>cgilua.addclosefunction (func)</code></strong></dt>
- <dd>Define uma função (<code>func</code>) para ser chamada após a execução do CGILua.<br/> Não retorna nada.</dd>
-
- <dt><a name="addopenfunction"></a><strong><code>cgilua.addopenfunction (func)</code></strong></dt>
- <dd>Define uma função (<code>func</code>) para ser chamada antes da execução do CGILua.<br/> Não retorna nada.</dd>
-
- <dt><a name="addscripthandler"></a><strong><code>cgilua.addscripthandler (ext, func)</code></strong></dt>
- <dd>Define uma função (<code>func</code>) para pré-processar os arquivos com uma determinada extensão (<code>ext</code>). A configuração padrão usa <a href="#doscript"><code>cgilua.doscript</code></a> para processar Lua Scripts (arquivos <code>.lua</code>) e <a href="#handlelp"><code>cgilua.handlelp</code></a> para processar Lua Pages (arquivos <code>.lp</code>).<br/> Não retorna nada.</dd>
-
- <dt><a name="buildplainhandler"></a><strong><code>cgilua.buildplainhandler (type, subtype)</code></strong></dt>
- <dd>Cria um <em>tratador de scripts</em> que envia o cabeçalho fornecido e o arquivo sem formatação solicitado. O cabeçalho <em>Content-type</em> é formado pelos dois argumentos; a função criada recebe um <em>nome de arquivo</em> como único argumento e retorna o nome de arquivo dado sem alterações.<br/> Retorna uma função.</dd>
-
- <dt><a name="buildprocesshandler"></a><strong><code>cgilua.buildprocesshandler (type, subtype)</code></strong></dt>
- <dd>Cria um <em>tratador de scripts</em> que envia o cabeçalho fornecido e o arquivo processado solicitado. O cabeçalho <em>Content-type</em> é formado pelos dois argumentos; a função criada recebe um <em>nome de arquivo</em> como único argumento e retorna o nome de arquivo dado pré-processado pela função <a href="#include">cgilua.lp.include</a>.<br/> Retorna uma função.</dd>
-
- <dt><a name="setlibdir"></a><strong><code>cgilua.setlibdir (dir)</code></strong></dt>
- <dd>Define o diretório de bibliotecas padrão do CGILua. Esse valor é usado para criar o <code>LUA_PATH</code> usado pela função <code>require</code> (<code>require</code> é redefinida pelo CGILua).<br/> Não retorna nada.</dd>
-
- <dt><a name="setmaxfilesize"></a><strong><code>cgilua.setmaxfilesize (size)</code></strong></dt>
- <dd>Define o <code>tamanho</code> máximo (em bytes) de cada arquivo cujo upload seja feito. Esse valor é limitado pelo <em>tamanho máximo de entrada total</em> (consulte <a href="#setmaxinput">cgilua.setmaxinput</a>). Esta função só passa a vigorar se usada antes do processamento dos dados de POST, portanto, seu uso em scripts é irrelevante.<br/> Não retorna nada.</dd>
-
- <dt><a name="setmaxinput"></a><strong><code>cgilua.setmaxinput (size)</code></strong></dt>
- <dd>Define o <code>tamanho</code> de <em>entrada total máxima</em> permitido (em bytes). Esta função só passa a vigorar se usada antes do processamento dos dados de POST, portanto, seu uso em scripts é irrelevante.<br/> Não retorna nada.</dd>
-</dl>
-
-<h2><a name="urlcode"></a>Funções de codificação de URL</h2>
-
-<p>As funções de codificação do CGILua permitem que o processamento de strings de URL seja feito de maneira simples:</p>
-
-<dl class="reference">
- <dt><a name="encodetable"></a><strong><code>cgilua.urlcode.encodetable (table)</code></strong></dt>
- <dd><em>Codifica em formato URL</em> os elementos de uma <code>tabela</code>, criando uma string usada como URL para informar dados/parâmetros a outro script.<br/> Retorna uma string representando a tabela de argumentos codificada.</dd>
-
- <dt><a name="escape"></a><strong><code>cgilua.urlcode.escape (string)</code></strong></dt>
- <dd><em>Codifica em formato URL</em> uma <code>string</code>.<br/> Retorna a string codificada.</dd>
-
- <dt><a name="insertfield"></a><strong><code>cgilua.urlcode.insertfield (args, name, value)</code></strong></dt>
- <dd>Adiciona o valor (<code>value</code>) fornecido ao campo indexado por um nome (<code>nome</code>) na tabela <code>args</code>. Se o campo já tiver um valor, será transformado em uma tabela com esse valor no índice <code>1</code> e o novo valor no índice <code>2</code>. Outros valores serão acrescentados no final da <em>parte array</em> da tabela criada.<br/> Não retorna nada.</dd>
-
- <dt><a name="parsequery"></a><strong><code>cgilua.urlcode.parsequery (query, args)</code></strong></dt>
- <dd>Analisa os dados codificados em formato URL do pedido. Isso pode ser a parte <code>query</code> da URL do script ou dos dados POST codificados em URL. Cada par <em>nome = valor</em> codificado é inserido na tabela <code>args</code>.<br/> Não retorna nada.</dd>
-
- <dt><a name="unescape"></a><strong><code>cgilua.urlcode.unescape (string)</code></strong></dt>
- <dd>Decodifica uma <code>string</code> que usa o formato URL.<br/> Retorna a string decodificada.</dd>
-</dl>
-
-<h2><a name="auxiliar"></a>Funções auxiliares</h2>
-
-<dl class="reference">
- <dt><a name="doscript"></a><strong><code>cgilua.doscript (filepath)</code></strong></dt>
- <dd>Executa um arquivo (dado por <code>filepath</code>). Gera um erro se ocorrer. Em caso de êxito, retorna os valores retornados pela execução.</dd>
-
- <dt><a name="pack"></a><strong><code>cgilua.pack (...)</code></strong></dt>
- <dd>Retorna uma nova tabela que armazena todos os argumentos passados.</dd>
-
- <dt><a name="splitpath"></a><strong><code>cgilua.splitpath (path)</code></strong></dt>
- <dd>Retorna duas strings com as partes "diretório" e "arquivo" do <code>path</code> fornecido.</dd>
-</dl>
-
-<h2><a name="index"></a>Índice alfabético</h2>
-
-<a href="#addclosefunction">addclosefunction</a><br/> <a href="#addopenfunction">addopenfunction</a><br/> <a href="#addscripthandler">addscripthandler</a><br/> <a href="#buildplainhandler">buildplainhandler</a><br/> <a href="#buildprocesshandler">buildprocesshandler</a><br/> <a href="#contentheader">contentheader</a><br/> <a href="#doscript">doscript</a><br/> <a href="#encodetable">encodetable (urlcode)</a><br/> <a href="#errorlog">errorlog</a><br/> <a href="#escape">escape (urlcode)</a><br/> <a href="#header">header</a><br/> <a href="#htmlheader">htmlheader</a><br/> <a href="#include">include (lp)</a><br/> <a href="#insertfield">insertfield (urlcode)</a><br/> <a href="#mkabsoluteurl">mkabsoluteurl</a><br/> <a href="#mkurlpath">mkurlpath</a><br/> <a href="#pack">pack</a><br/> <a href="#parsequery">parsequery (urlcode)</a><br/> <a href="#handlelp">handlelp</a><br/> <a href="#lp">lp</a><br/> <a href="#put">put</a><br/> <a href="#redirect">redirect</a><br/> <a href="#script_file">script_file</a><br/> <a href="#script_path">script_path</a><br/> <a href="#script_pdir">script_pdir</a><br/> <a href="#script_vdir">script_vdir</a><br/> <a href="#script_vpath">script_vpath</a><br/> <a href="#servervariable">servervariable</a><br/> <a href="#setcompatmode">setcompatmode (lp)</a><br/> <a href="#seterrorhandler">seterrorhandler</a><br/> <a href="#seterroroutput">seterroroutput</a><br/> <a href="#setlibdir">setlibdir</a><br/> <a href="#setmaxfilesize">setmaxfilesize</a><br/> <a href="#setmaxinput">setmaxinput</a><br/> <a href="#setoutfunc">setoutfunc (lp)</a><br/> <a href="#splitpath">splitpath</a><br/> <a href="#urlcode">urlcode</a><br/> <a href="#unescape">unescape (urlcode)</a><br/> <a href="#urlpath">urlpath</a><br/>
-
-</div> <!-- id="content" -->
-
-</div> <!-- id="main" -->
-
-<div id="about">
- <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="XHTML 1.0 válido!" height="31" width="88" /></a></p>
- <p><small>$Id: reference.html,v 1.4 2005/11/03 18:48:57 carregal Exp $</small></p>
-</div> <!-- id="about" -->
-
-</div> <!-- id="container" -->
-
-</body>
-</html>
diff --git a/doc/br/sapi.html b/doc/br/sapi.html
deleted file mode 100755
index 532cbb9..0000000
--- a/doc/br/sapi.html
+++ /dev/null
@@ -1,152 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html>
-<head>
- <title>CGILua: geração de scripts para a Web usando Lua</title>
- <link rel="stylesheet" href="http://www.keplerproject.org/doc.css" type="text/css"/>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-</head>
-<body>
-
-<div id="container">
-
-<div id="product">
- <div id="product_logo"><a href="http://www.keplerproject.org"><img alt="Logotipo do CGILua" src="cgi-128.gif"/></a></div>
- <div id="product_name"><big><strong>CGILua</strong></big></div>
- <div id="product_description">Geração de scripts para a Web usando Lua</div>
-</div> <!-- id="product" -->
-
-<div id="main">
-
-<div id="navigation">
-<h1>CGILua</h1>
- <ul>
- <li><a href="index.html">Início</a>
- <ul>
- <li><a href="index.html#overview">Visão geral</a></li>
- <li><a href="index.html#status">Status</a></li>
- <li><a href="index.html#download">Download</a></li>
- <li><a href="index.html#history">Histórico</a></li>
- <li><a href="index.html#incompatibility">Incompatibilidades</a></li>
- <li><a href="index.html#credits">Créditos</a></li>
- <li><a href="index.html#contact">Fale conosco</a></li>
- </ul>
- </li>
- <li><a href="manual.html">Manual</a>
- <ul>
- <li><a href="manual.html#intro">Introdução</a></li>
- <li><a href="manual.html#installation">Instalação</a></li>
- <li><a href="manual.html#config">Configuração</a></li>
- <li><a href="manual.html#scripts">Lua Scripts</a></li>
- <li><a href="manual.html#templates">Lua Pages</a></li>
- <li><a href="manual.html#parameters">Parâmetros</a></li>
- </ul>
- </li>
- <li><a href="reference.html">Referência</a>
- <ul>
- <li><a href="reference.html#headers">Cabeçalhos</a></li>
- <li><a href="reference.html#contents">Geração de conteúdo</a></li>
- <li><a href="reference.html#prep">Lua Pages</a></li>
- <li><a href="reference.html#variables">Variáveis do CGILua</a></li>
- <li><a href="reference.html#error_handling">Tratamento de erros</a></li>
- <li><a href="reference.html#behavior">Comportamento do CGILua</a></li>
- <li><a href="reference.html#urlcode">Codificação de URL</a></li>
- <li><a href="reference.html#auxiliar">Funções auxiliares</a></li>
- <li><a href="reference.html#index">Índice alfabético</a></li>
- </ul>
- </li>
- <li><a href="libraries.html">Bibliotecas</a>
- <ul>
- <li><a href="libraries.html#cookies">Cookies</a></li>
- <li><a href="libraries.html#serialize">Serialize</a></li>
- <li><a href="libraries.html#session">Session</a></li>
- </ul>
- </li>
- <li><strong>SAPI</strong></li>
- <li><a href="license.html">Licenças</a></li>
- </ul>
-</div> <!-- id="navigation" -->
-
-<div id="content">
-
-<h2>API do servidor</h2>
-
-<p>A API do servidor (SAPI) é um conjunto de funções que abstrai o servidor Web e o disparador usado. Um disparador de SAPI é o mecanismo que permite a um servidor Web executar e comunicar-se com o CGILua e os aplicativos Web. A SAPI permite a abstração de uma série de detalhes internos, fazendo com que o CGILua seja muito mais portátil, já que transportar o CGILua para uma nova plataforma significa simplesmente escrever um disparador de SAPI para a plataforma de destino.</p>
-
-<p>No momento, o CGILua oferece suporte a Apache, Microsoft IIS, Tomcat e Xavante como servidores Web, e a CGI, FastCGI, mod_lua, ISAPI e servlets como disparadores.</p>
-
-<p>As funções são separadas em dois pacotes: <code>SAPI.Request</code> e <code>SAPI.Response</code>:</p>
-
-<dl class="reference">
- <dt><strong><code>SAPI.Request.getpostdata ([n])</code></strong></dt>
- <dd>Obtém um bloco de <em>dados de POST</em>. O parâmetro opcional <em>n</em> é o número de bytes para ler (o tamanho de bloco padrão será usado se nenhum parâmetro for informado).<br /> Retorna o bloco como uma string Lua.</dd>
-
- <dt><a href="#servervariable"><strong><code>SAPI.Request.servervariable (string)</code></strong></a></dt>
- <dd>Obtém o valor de uma variável de ambiente do servidor. O argumento pode ser uma das <a href="http://hoohoo.ncsa.uiuc.edu/cgi/env.html">variáveis CGI</a> definidas, embora nem todos os servidores implementem o conjunto completo de variáveis. O conjunto consiste em:<br />
- <ul>
- <li><strong><code>AUTH_TYPE</code></strong> - se o servidor suportar autenticação de usuário e o script estiver protegido, este é o método de autenticação específico ao protocolo usado para validar o usuário.</li>
-
- <li><strong><code>CONTENT_LENGTH</code></strong> - o tamanho do conteúdo como fornecido pelo cliente.</li>
-
- <li><strong><code>CONTENT_TYPE</code></strong> - para consultas que têm informações anexadas, por exemplo, HTTP POST e PUT, este é o tipo de conteúdo dos dados.</li>
-
- <li><strong><code>GATEWAY_INTERFACE</code></strong> - a revisão da especificação CGI com a qual esse servidor é compatível. Formato: CGI/revisão</li>
-
- <li><strong><code>PATH_INFO</code></strong> - informações adicionais sobre o caminho, conforme fornecidas pelo cliente. Em outras palavras, os scripts podem ser acessados por meio dos respectivos nomes de caminho virtual, seguidos de informações adicionais no final desse caminho. As informações adicionais são enviadas como PATH_INFO. Essas informações devem ser decodificadas pelo servidor se vierem de uma URL antes de serem passadas para o script CGI.</li>
-
- <li><strong><code>PATH_TRANSLATED</code></strong> - o servidor fornece uma versão convertida de PATH_INFO, que realiza quaisquer mapeamentos de virtual para físico no caminho.</li>
-
- <li><strong><code>QUERY_STRING</code></strong> - as informações inseridas após o "?" na URL que fez referência a esse script. Essas são as informações da consulta e não devem ser decodificadas. Esta variável deve ser sempre definida quando houver informações da consulta, qualquer que seja a decodificação da linha de comando.</li>
-
- <li><strong><code>REMOTE_ADDR</code></strong> - o endereço IP do host remoto que faz o pedido.</li>
-
- <li><strong><code>REMOTE_HOST</code></strong> - o nome do host que faz o pedido. Se o servidor não tiver essas informações, ele define REMOTE_ADDR e não define esta variável.</li>
-
- <li><strong><code>REMOTE_IDENT</code></strong> - se o servidor HTTP oferecer suporte à identificação RFC 931, esta variável será definida com o nome do usuário remoto recuperado do servidor. O uso desta variável deve ser limitado apenas à conexão.</li>
-
- <li><strong><code>REMOTE_USER</code></strong> - se o servidor oferecer suporte à autenticação de usuário e o script estiver protegido, este é o nome de usuário com o qual eles foram autenticados.</li>
-
- <li><strong><code>REQUEST_METHOD</code></strong> - o método com o qual o pedido foi feito. Para HTTP, isto equivale a "GET", "HEAD", "POST" etc.</li>
-
- <li><strong><code>SCRIPT_NAME</code></strong> - um caminho virtual para o script em execução, usado em URLs auto-referentes.</li>
-
- <li><strong><code>SERVER_NAME</code></strong> - o nome do host do servidor, o alias do DNS ou o endereço IP como exibido em URLs auto-referentes.</li>
-
- <li><strong><code>SERVER_PORT</code></strong> - o número da porta à qual o pedido foi enviado.</li>
-
- <li><strong><code>SERVER_PROTOCOL</code></strong> - o nome e a revisão do protocolo de informações com o qual este pedido foi enviado. Formato: protocolo/revisão</li>
-
- <li><strong><code>SERVER_SOFTWARE</code></strong> - o nome e a versão do software do servidor Web que responde ao pedido (e executa o gateway). Formato: nome/versão</li>
- </ul>
- Além desses, as linhas do cabeçalho recebidas do cliente, se houver, são colocadas no ambiente com o prefixo <code>HTTP_</code> seguido do nome do cabeçalho. Quaisquer caracteres <code>-</code> (hífen) no nome do cabeçalho são alterados para caracteres <code>_</code> (sublinhado). O servidor pode excluir quaisquer cabeçalhos que já tenha processado, por exemplo, <em>Authorization</em>, <em>Content-type</em> e <em>Content-length</em>. Se necessário, o servidor pode optar por excluir todos ou qualquer um desses cabeçalhos se a inclusão exceder algum limite do ambiente do sistema.<br />
- Retorna uma string.</dd>
-
- <dt><strong><code>SAPI.Response.contenttype (string)</code></strong></dt>
- <dd>Envia o cabeçalho <em>Content-type</em> para o cliente. A string fornecida está na forma "<em>tipo</em>/<em>subtipo</em>". Esta função deve ser chamada antes que qualquer saída seja enviada com o uso de <code>SAPI.Response.write</code>.<br /> Não retorna nada.</dd>
-
- <dt><strong><code>SAPI.Response.errorlog (string)</code></strong></dt>
- <dd>Gera uma saída de erro usando a string fornecida.<br /> Não retorna nada.</dd>
-
- <dt><strong><code>SAPI.Response.header (header, value)</code></strong></dt>
- <dd>Envia um cabeçalho genérico para o cliente. O primeiro argumento deve ser o nome do cabeçalho, por exemplo, "Set-Cookie". O segundo deve ser o valor. Esta função não deve ser usada em substituição às funções <code>SAPI.Response.contenttype</code> ou <code>SAPI.Response.redirect</code>.<br /> Não retorna nada.</dd>
-
- <dt><strong><code>SAPI.Response.redirect (url)</code></strong></dt>
- <dd>Envia o cabeçalho <em>Location</em> para o cliente. A <code>url</code> fornecida deve ser uma string.<br /> Não retorna nada.</dd>
-
- <dt><strong><code>SAPI.Response.write (string)</code></strong></dt>
- <dd>Gera uma saída usando a string fornecida.<br /> Não retorna nada.</dd>
-</dl>
-
-</div> <!-- id="content" -->
-
-</div> <!-- id="main" -->
-
-<div id="about">
- <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="XHTML 1.0 válido!" height="31" width="88" /></a></p>
- <p><small>$Id: sapi.html,v 1.3 2005/11/03 18:48:57 carregal Exp $</small></p>
-</div> <!-- id="about" -->
-
-</div> <!-- id="container" -->
-
-</body>
-</html>
diff --git a/doc/us/cgi-128.gif b/doc/us/cgi-128.gif
deleted file mode 100755
index 5392a8f..0000000
Binary files a/doc/us/cgi-128.gif and /dev/null differ
diff --git a/doc/br/cgi-128.gif b/docs/cgi-128.gif
similarity index 100%
rename from doc/br/cgi-128.gif
rename to docs/cgi-128.gif
diff --git a/docs/doc.css b/docs/doc.css
new file mode 100644
index 0000000..3aef4ed
--- /dev/null
+++ b/docs/doc.css
@@ -0,0 +1,212 @@
+body {
+ color: #47555c;
+ font-size: 16px;
+ font-family: "Open Sans", sans-serif;
+ margin: 0;
+ padding: 0;
+ background: #eff4ff;
+}
+
+a:link { color: #008fee; }
+a:visited { color: #008fee; }
+a:hover { color: #22a7ff; }
+
+h1 { font-size:26px; }
+h2 { font-size:24px; }
+h3 { font-size:18px; }
+h4 { font-size:16px; }
+
+hr {
+ height: 1px;
+ background: #c1cce4;
+ border: 0px;
+ margin: 20px 0;
+}
+
+code {
+ font-family: "Open Sans Mono", "Andale Mono", monospace;
+}
+
+tt {
+ font-family: "Open Sans Mono", "Andale Mono", monospace;
+}
+
+body, td, th {
+}
+
+textarea, pre, tt {
+ font-family: "Open Sans Mono", "Andale Mono", monospace;
+}
+
+img {
+ border-width: 0px;
+}
+
+.example {
+ background-color: #323744;
+ color: white;
+ font-size: 16px;
+ padding: 16px 24px;
+ border-radius: 2px;
+ overflow-x: auto;
+}
+
+div.header, div.footer {
+}
+
+#container {
+}
+
+#product {
+ background-color: white;
+ padding: 10px;
+ height: 130px;
+ border-bottom: solid #d3dbec 1px;
+}
+
+#product big {
+ font-size: 42px;
+}
+#product strong {
+ font-weight: normal;
+}
+
+#product_logo {
+ float: right;
+}
+
+#product_name {
+ padding-top: 15px;
+ padding-left: 30px;
+ font-size: 42px;
+ font-weight: normal;
+}
+
+#product_description {
+ padding-left: 30px;
+ color: #757779;
+}
+
+#main {
+ background: #eff4ff;
+ margin: 0;
+}
+
+#navigation {
+ width: 100%;
+ background-color: rgb(44,62,103);
+ padding: 10px;
+ margin: 0;
+}
+
+#navigation h1 {
+ display: none;
+}
+
+#navigation a:hover {
+ text-decoration: underline;
+}
+
+#navigation ul li a {
+ color: rgb(136, 208, 255);
+ font-weight: bold;
+ text-decoration: none;
+}
+
+#navigation ul li li a {
+ color: rgb(136, 208, 255);
+ font-weight: normal;
+ text-decoration: none;
+}
+
+#navigation ul {
+ display: inline;
+ color: white;
+ padding: 0px;
+ padding-top: 10px;
+ padding-bottom: 10px;
+}
+
+#navigation li {
+ display: inline;
+ list-style-type: none;
+ padding-left: 5px;
+ padding-right: 5px;
+}
+
+#navigation li {
+ padding: 10px;
+ padding: 10px;
+}
+
+#navigation li li {
+}
+
+#navigation li:hover a {
+ color: rgb(166, 238, 255);
+}
+
+#content {
+ padding: 20px;
+ width: 800px;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+#about {
+ display: none;
+}
+
+dl.reference {
+ background-color: white;
+ padding-left: 20px;
+ padding-right: 20px;
+ padding-bottom: 20px;
+ border: solid #d3dbec 1px;
+}
+
+dl.reference dt {
+ padding: 5px;
+ padding-top: 25px;
+ color: #637bbc;
+}
+
+dl.reference dl dt {
+ padding-top: 5px;
+ color: #637383;
+}
+
+dl.reference dd {
+}
+
+@media print {
+ body {
+ font: 10pt "Times New Roman", "TimeNR", Times, serif;
+ }
+ a {
+ font-weight:bold; color: #004080; text-decoration: underline;
+ }
+ #main {
+ background-color: #ffffff; border-left: 0px;
+ }
+ #container {
+ margin-left: 2%; margin-right: 2%; background-color: #ffffff;
+ }
+ #content {
+ margin-left: 0px; padding: 1em; border-left: 0px; border-right: 0px; background-color: #ffffff;
+ }
+ #navigation {
+ display: none;
+ }
+ #product_logo {
+ display: none;
+ }
+ #about img {
+ display: none;
+ }
+ .example {
+ font-family: "Andale Mono", monospace;
+ font-size: 8pt;
+ page-break-inside: avoid;
+ }
+}
diff --git a/doc/us/index.html b/docs/index.html
similarity index 78%
rename from doc/us/index.html
rename to docs/index.html
index d7cbd89..e14355b 100755
--- a/doc/us/index.html
+++ b/docs/index.html
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>CGILua: Building Web Scripts with Lua</title>
- <link rel="stylesheet" href="http://www.keplerproject.org/doc.css" type="text/css"/>
+ <link rel="stylesheet" href="doc.css" type="text/css"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
@@ -11,10 +11,10 @@
<div id="container">
<div id="product">
- <div id="product_logo"><a href="http://www.keplerproject.org">
+ <div id="product_logo">
<img alt="CGILua logo" src="cgi-128.gif"/>
- </a></div>
- <div id="product_name"><big><b>CGILua</b></big></div>
+ </div>
+ <div id="product_name"><big><strong>CGILua</strong></big></div>
<div id="product_description">Building Web Scripts with Lua</div>
</div> <!-- id="product" -->
@@ -35,39 +35,10 @@
</ul>
</li>
<li><a href="manual.html">Manual</a>
- <ul>
- <li><a href="manual.html#intro">Introduction</a></li>
- <li><a href="manual.html#installation">Installation</a></li>
- <li><a href="manual.html#config">Configuration</a></li>
- <li><a href="manual.html#scripts">Lua Scripts</a></li>
- <li><a href="manual.html#templates">Lua Pages</a></li>
- <li><a href="manual.html#parameters">Parameters</a></li>
- <li><a href="manual.html#dispatching">Dispatching</a></li>
- <li><a href="manual.html#authentication">Authentication</a></li>
- <li><a href="manual.html#error_handling">Error Handling</a></li>
- </ul>
</li>
<li><a href="reference.html">Reference</a>
- <ul>
- <li><a href="reference.html#headers">Headers</a></li>
- <li><a href="reference.html#contents">Content Generation</a></li>
- <li><a href="reference.html#prep">Lua Pages</a></li>
- <li><a href="reference.html#variables">CGILua Variables</a></li>
- <li><a href="reference.html#error_handling">Error Handling</a></li>
- <li><a href="reference.html#behavior">CGILua Behavior</a></li>
- <li><a href="reference.html#urlcode">URL Encoding</a></li>
- <li><a href="reference.html#auxiliar">Auxiliary functions</a></li>
- <li><a href="reference.html#index">Alphabetic Index</a></li>
- </ul>
</li>
<li><a href="libraries.html">Libraries</a>
- <ul>
- <li><a href="libraries.html#authentication">Authentication</a></li>
- <li><a href="libraries.html#cookies">Cookies</a></li>
- <li><a href="libraries.html#dispatcher">Dispatcher</a></li>
- <li><a href="libraries.html#serialize">Serialize</a></li>
- <li><a href="libraries.html#session">Session</a></li>
- </ul>
</li>
<li><a href="sapi.html">SAPI</a></li>
<li><a href="license.html">License</a></li>
@@ -88,8 +59,6 @@ One of advantages of CGILua is its abstraction of the underlying Web server.
CGILua can be used with a variety of Web servers and, for each server, with
different launchers. A launcher is responsible for the interaction of CGILua
and the Web server, for example using ISAPI on IIS or mod_lua on Apache.
-The reference implementation of CGILua launchers is
-<a href="http://www.keplerproject.org/kepler/">Kepler</a>.
</p>
<p>
@@ -99,7 +68,7 @@ as Lua 5.1.
<h2><a name="status"></a>Status</h2>
-<p>Current version is 5.1.4</p>
+<p>Current version is 5.2</p>
<h2><a name="download"></a>Download</h2>
@@ -115,6 +84,32 @@ luarocks install cgilua
<h2><a name="history"></a>History</h2>
<dl>
+ <dt><strong>Version 6.0.2</strong> [04/Jul/2020]
+ <dd><ul>
+ <li>Fix for preventing formatting errors</li>
+ <li>Small LDoc corrections</li>
+ </ul></dd>
+
+ <dt><strong>Version 6.0.1</strong> [17/May/2019]
+ <dd><ul>
+ <li>Bug correction on redirections</li>
+ <li>Version variables definition</li>
+ <li>Other minor corrections</li>
+ </ul></dd>
+
+ <dt><strong>Version 6.0.0</strong> [05/Nov/2018]
+ <dd><ul>
+ <li>Adapted CGILua SAPI launcher to explore all WSAPI features</li>
+ <li>SAPI layer removed</li>
+ <li>Several fixes</li>
+ <li>Lua 5.3 compatibility</li>
+ </ul></dd>
+
+ <dt><strong>Version 5.2</strong> [22/Apr/2015]</dt>
+ <dd><ul>
+ <li>Code adapted to work with Lua 5.1 and Lua 5.2</li>
+ </ul></dd>
+
<dt><strong>Version 5.1.4</strong> [22/Mar/2010]</dt>
<dd><ul>
<li>Fixes file upload reentrancy</li>
@@ -193,7 +188,7 @@ luarocks install cgilua
</ul>
</dd>
- <dt><strong><a href="http://keplerproject.org/cgilua/5.0">Version 5.0.1</a></strong> [20/Sep/2006]</dt>
+ <dt><strong>Version 5.0.1</strong> [20/Sep/2006]</dt>
<dd>
<ul>
<li>Uses Compat-5.1 Release 5.</li>
@@ -210,9 +205,8 @@ luarocks install cgilua
<dd>
<ul>
<li>CGILua distribution includes now only the Lua files, the launchers
- have been moved to <a href="http://www.keplerproject.org/kepler/">Kepler</a>.</li>
- <li>The <a href="http://www.keplerproject.org/venv/manual.html#reference">Stable</a>
- library is now distributed with <a href="http://www.keplerproject.org/venv/">VEnv</a>.</li>
+ have been moved to Kepler.</li>
+ <li>The Stable library is now distributed with VEnv.</li>
<li>Fixed a file upload bug in the CGI and Xavante launchers.</li>
<li><code>cgilua.lp.include()</code> now accepts an environment to run
the preprocessed file in it.</li>
@@ -232,8 +226,7 @@ luarocks install cgilua
<li>New ISAPI and Servlet Launchers.</li>
<li>New Error Handling features.</li>
<li>New persistent data feature (Stable).</li>
- <li>Uses the <a href="http://www.keplerproject.org/compat/">package model</a>
- for Lua 5.1.</li>
+ <li>Uses the package model for Lua 5.1.</li>
<li>Simpler User <a href="libraries.html#session">Session</a> API.</li>
<li>Small bug corrections</li>
</ul>
@@ -248,7 +241,14 @@ luarocks install cgilua
<h2><a name="incompatibility"></a>Incompatibility with previous CGILua versions (5.0, 4.0 and 3.x)</h2>
-<ul>
+<dt><strong>CGILua 5.2</strong></dt>
+<dd><ul>
+ <li>All CGILua 5.2 modules return a table when loaded.</li>
+ <li>Function <code>cgilua.lp.include</code> ...
+</ul></dd>
+
+<dt><strong>CGILua 5.1</strong></dt>
+<dd><ul>
<li>CGILua 5.1 uses <a href="http://www.lua.org">Lua 5.1</a>.</li>
<li>The <code>cgi</code> table is now deprecated. See
<a href="manual.html#parameters">Receiving parameters</a> for a more
@@ -260,22 +260,37 @@ luarocks install cgilua
should be replaced by
<a href="reference.html#servervariable"><code>cgilua.servervariable</code></a>
calls.</li>
-</ul>
+</ul></dd>
<h2><a name="credits"></a>Credits</h2>
<dl>
+ <dt><strong>CGILua 6.0</strong></dt>
+ <dd>
+ CGILua 6.0 is maintained by Tomás Guisasola, including contributions from the
+ community, including several commits by Peter Melnichenko and João Dutra Bastos. João worked
+ sponsored by the Google Summer of Code program. His project was "Adapt CGILua SAPI launcher
+ to explore all WSAPI features".
+ </dd>
+
+ <dt><strong>CGILua 5.2</strong></dt>
+ <dd>
+ CGILua 5.2 is being maintained by Tomás Guisasola
+ with contributions from Fábio Mascarenhas, Carla Ourofino
+ and others from the community.
+ </dd>
+
<dt><strong>CGILua 5.1</strong></dt>
<dd>
CGILua 5.1 is being maintained by André Carregal and
Tomás Guisasola with contributions from Fábio Mascarenhas
- and others from the Kepler <a href="http://luaforge.net/mail/?group_id=104">mailing list</a>.
+ and others from the Kepler mailing list.
</dd>
<dt><strong>CGILua 5.0</strong></dt>
<dd>CGILua 5.0 was completely redesigned by Roberto Ierusalimschy,
André Carregal and Tomás Guisasola as part of the
- <a href="http://www.keplerproject.org">Kepler Project</a>.
+ Kepler Project.
The implementation is compatible with Lua 5.0 and was coded by
Tomás Guisasola with invaluable contributions by Ana
Lúcia de Moura, Fábio Mascarenhas and Danilo Tuler.
@@ -306,25 +321,13 @@ luarocks install cgilua
<h2><a name="contact"></a>Contact us</h2>
<p>
-For more information please
-<a href="mailto:info-NO-SPAM-THANKS@keplerproject.org">contact us</a>.
-Comments are welcome!
-</p>
-
-<p>
-You can also reach other CGILua developers and users on the Kepler
-Project <a href="http://luaforge.net/mail/?group_id=104">mailing list</a>.
+To report bugs, visit the <a href="https://github.com/lunarmodules/cgilua">GitHub project</a>.
</p>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
-<div id="about">
- <p><a href="http://validator.w3.org/check?uri=referer">Valid XHTML 1.0!</a></p>
- <p><small>$Id: index.html,v 1.68 2009/03/09 23:37:18 carregal Exp $</small></p>
-</div> <!-- id="about" -->
-
</div> <!-- id="container" -->
</body>
diff --git a/doc/us/libraries.html b/docs/libraries.html
similarity index 84%
rename from doc/us/libraries.html
rename to docs/libraries.html
index 6def244..16f89f7 100755
--- a/doc/us/libraries.html
+++ b/docs/libraries.html
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>CGILua: Building Web Scripts with Lua</title>
- <link rel="stylesheet" href="http://www.keplerproject.org/doc.css" type="text/css"/>
+ <link rel="stylesheet" href="doc.css" type="text/css"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
@@ -11,9 +11,9 @@
<div id="container">
<div id="product">
- <div id="product_logo"><a href="http://www.keplerproject.org">
+ <div id="product_logo">
<img alt="CGILua logo" src="cgi-128.gif"/>
- </a></div>
+ </div>
<div id="product_name"><big><strong>CGILua</strong></big></div>
<div id="product_description">Building Web Scripts with Lua</div>
</div> <!-- id="product" -->
@@ -24,41 +24,10 @@
<h1>CGILua</h1>
<ul>
<li><a href="index.html">Home</a>
- <ul>
- <li><a href="index.html#overview">Overview</a></li>
- <li><a href="index.html#status">Status</a></li>
- <li><a href="index.html#download">Download</a></li>
- <li><a href="index.html#history">History</a></li>
- <li><a href="index.html#incompatibility">Incompatibilities</a></li>
- <li><a href="index.html#credits">Credits</a></li>
- <li><a href="index.html#contact">Contact us</a></li>
- </ul>
</li>
<li><a href="manual.html">Manual</a>
- <ul>
- <li><a href="manual.html#intro">Introduction</a></li>
- <li><a href="manual.html#installation">Installation</a></li>
- <li><a href="manual.html#config">Configuration</a></li>
- <li><a href="manual.html#scripts">Lua Scripts</a></li>
- <li><a href="manual.html#templates">Lua Pages</a></li>
- <li><a href="manual.html#parameters">Parameters</a></li>
- <li><a href="manual.html#dispatching">Dispatching</a></li>
- <li><a href="manual.html#authentication">Authentication</a></li>
- <li><a href="manual.html#error_handling">Error Handling</a></li>
- </ul>
</li>
<li><a href="reference.html">Reference</a>
- <ul>
- <li><a href="reference.html#headers">Headers</a></li>
- <li><a href="reference.html#contents">Content Generation</a></li>
- <li><a href="reference.html#prep">Lua Pages</a></li>
- <li><a href="reference.html#variables">CGILua Variables</a></li>
- <li><a href="reference.html#error_handling">Error Handling</a></li>
- <li><a href="reference.html#behavior">CGILua Behavior</a></li>
- <li><a href="reference.html#urlcode">URL Encoding</a></li>
- <li><a href="reference.html#auxiliar">Auxiliary functions</a></li>
- <li><a href="reference.html#index">Alphabetic Index</a></li>
- </ul>
</li>
<li><strong>Libraries</strong>
<ul>
diff --git a/doc/us/license.html b/docs/license.html
similarity index 57%
rename from doc/us/license.html
rename to docs/license.html
index 0a0457b..a0b9be3 100755
--- a/doc/us/license.html
+++ b/docs/license.html
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>CGILua: Building Web Scripts with Lua</title>
- <link rel="stylesheet" href="http://www.keplerproject.org/doc.css" type="text/css"/>
+ <link rel="stylesheet" href="doc.css" type="text/css"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
@@ -11,10 +11,10 @@
<div id="container">
<div id="product">
- <div id="product_logo"><a href="http://www.keplerproject.org">
+ <div id="product_logo">
<img alt="CGILua logo" src="cgi-128.gif"/>
- </a></div>
- <div id="product_name"><big><b>CGILua</b></big></div>
+ </div>
+ <div id="product_name"><big><strong>CGILua</strong></big></div>
<div id="product_description">Building Web Scripts with Lua</div>
</div> <!-- id="product" -->
@@ -24,50 +24,12 @@
<h1>CGILua</h1>
<ul>
<li><a href="index.html">Home</a>
- <ul>
- <li><a href="index.html#overview">Overview</a></li>
- <li><a href="index.html#status">Status</a></li>
- <li><a href="index.html#download">Download</a></li>
- <li><a href="index.html#history">History</a></li>
- <li><a href="index.html#incompatibility">Incompatibilities</a></li>
- <li><a href="index.html#credits">Credits</a></li>
- <li><a href="index.html#contact">Contact us</a></li>
- </ul>
</li>
<li><a href="manual.html">Manual</a>
- <ul>
- <li><a href="manual.html#intro">Introduction</a></li>
- <li><a href="manual.html#installation">Installation</a></li>
- <li><a href="manual.html#config">Configuration</a></li>
- <li><a href="manual.html#scripts">Lua Scripts</a></li>
- <li><a href="manual.html#templates">Lua Pages</a></li>
- <li><a href="manual.html#parameters">Parameters</a></li>
- <li><a href="manual.html#dispatching">Dispatching</a></li>
- <li><a href="manual.html#authentication">Authentication</a></li>
- <li><a href="manual.html#error_handling">Error Handling</a></li>
- </ul>
</li>
<li><a href="reference.html">Reference</a>
- <ul>
- <li><a href="reference.html#headers">Headers</a></li>
- <li><a href="reference.html#contents">Content Generation</a></li>
- <li><a href="reference.html#prep">Lua Pages</a></li>
- <li><a href="reference.html#variables">CGILua Variables</a></li>
- <li><a href="reference.html#error_handling">Error Handling</a></li>
- <li><a href="reference.html#behavior">CGILua Behavior</a></li>
- <li><a href="reference.html#urlcode">URL Encoding</a></li>
- <li><a href="reference.html#auxiliar">Auxiliary functions</a></li>
- <li><a href="reference.html#index">Alphabetic Index</a></li>
- </ul>
</li>
<li><a href="libraries.html">Libraries</a>
- <ul>
- <li><a href="libraries.html#authentication">Authentication</a></li>
- <li><a href="libraries.html#cookies">Cookies</a></li>
- <li><a href="libraries.html#dispatcher">Dispatcher</a></li>
- <li><a href="libraries.html#serialize">Serialize</a></li>
- <li><a href="libraries.html#session">Session</a></li>
- </ul>
</li>
<li><a href="sapi.html">SAPI</a></li>
<li><strong>License</strong></li>
@@ -84,9 +46,7 @@ restrictions. CGILua qualifies as
<a href="http://www.opensource.org/docs/definition.html">Open Source</a>
software. Its licenses are compatible with
<a href="http://www.gnu.org/licenses/gpl.html">GPL</a>. CGILua is not in
-the public domain and the
-<a href="http://www.keplerproject.org">Kepler Project</a> keep its copyright.
-The legal details are below.</p>
+the public domain. The legal details are below.</p>
<p>The spirit of the license is that you are free to use CGILua for any purpose
at no cost without having to ask us. The only requirement is that if you do use
@@ -99,7 +59,8 @@ derived from licensed software.</p>
<hr/>
-<p>Copyright © 2003 Kepler Project.</p>
+<p>Copyright © 2003-2009 Kepler Project.</p>
+<p>Copyright © 2009-2022 The CGILua Authors.</p>
<p>Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/doc/us/manual.html b/docs/manual.html
similarity index 79%
rename from doc/us/manual.html
rename to docs/manual.html
index ca62d7a..58e48bb 100755
--- a/doc/us/manual.html
+++ b/docs/manual.html
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>CGILua: Building Web Scripts with Lua</title>
- <link rel="stylesheet" href="http://www.keplerproject.org/doc.css" type="text/css"/>
+ <link rel="stylesheet" href="doc.css" type="text/css"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
@@ -11,9 +11,9 @@
<div id="container">
<div id="product">
- <div id="product_logo"><a href="http://www.keplerproject.org">
+ <div id="product_logo">
<img alt="CGILua logo" src="cgi-128.gif"/>
- </a></div>
+ </div>
<div id="product_name"><big><strong>CGILua</strong></big></div>
<div id="product_description">Building Web Scripts with Lua</div>
</div> <!-- id="product" -->
@@ -24,15 +24,6 @@
<h1>CGILua</h1>
<ul>
<li><a href="index.html">Home</a>
- <ul>
- <li><a href="index.html#overview">Overview</a></li>
- <li><a href="index.html#status">Status</a></li>
- <li><a href="index.html#download">Download</a></li>
- <li><a href="index.html#history">History</a></li>
- <li><a href="index.html#incompatibility">Incompatibilities</a></li>
- <li><a href="index.html#credits">Credits</a></li>
- <li><a href="index.html#contact">Contact us</a></li>
- </ul>
</li>
<li><strong>Manual</strong>
<ul>
@@ -48,26 +39,8 @@
</ul>
</li>
<li><a href="reference.html">Reference</a>
- <ul>
- <li><a href="reference.html#headers">Headers</a></li>
- <li><a href="reference.html#contents">Content Generation</a></li>
- <li><a href="reference.html#prep">Lua Pages</a></li>
- <li><a href="reference.html#variables">CGILua Variables</a></li>
- <li><a href="reference.html#error_handling">Error Handling</a></li>
- <li><a href="reference.html#behavior">CGILua Behavior</a></li>
- <li><a href="reference.html#urlcode">URL Encoding</a></li>
- <li><a href="reference.html#auxiliar">Auxiliary functions</a></li>
- <li><a href="reference.html#index">Alphabetic Index</a></li>
- </ul>
</li>
<li><a href="libraries.html">Libraries</a>
- <ul>
- <li><a href="libraries.html#authentication">Authentication</a></li>
- <li><a href="libraries.html#cookies">Cookies</a></li>
- <li><a href="libraries.html#dispatcher">Dispatcher</a></li>
- <li><a href="libraries.html#serialize">Serialize</a></li>
- <li><a href="libraries.html#session">Session</a></li>
- </ul>
</li>
<li><a href="sapi.html">SAPI</a></li>
<li><a href="license.html">License</a></li>
@@ -114,8 +87,6 @@ method used.
<p>
A launcher is responsible for the interaction of CGILua and the Web server,
implementing SAPI for example using ISAPI on IIS or mod_lua on Apache.
-The reference implementation of CGILua launchers is
-<a href="http://www.keplerproject.org/kepler/">Kepler</a>.
</p>
<p>
@@ -170,11 +141,6 @@ luarocks install cgilua
<h2><a name="config"></a>Configuration</h2>
-<p>
-The Kepler distribution of CGILua 5.1 offers a single configuration file, called <code>config.lua</code>.
-This file can be used to alter the default CGILua behaviour and is located in the Kepler configuration directory.
-</p>
-
<p>Some of the uses of <code>config.lua</code> customization are:</p>
<dl>
@@ -215,7 +181,7 @@ use something like:
<pre class="example">
cgilua.addopenfunction (function ()
- cgilua.doif ("env.lua")
+ cgilua.doif ("env.lua")
end)
</pre>
@@ -224,7 +190,7 @@ If every script needs to load a module (such as the sessions library), you can d
</p>
<pre class="example">
-require"cgilua.session"
+require("cgilua.session")
cgilua.session.setsessiondir(CGILUA_TMP)
cgilua.addopenfunction (cgilua.session.open)
cgilua.addclosefunction (cgilua.session.close)
@@ -247,11 +213,11 @@ very beginning of each script that needs to use sessions):
</p>
<pre class="example">
-require"cgilua.session"
+require("cgilua.session")
cgilua.session.setsessiondir(CGILUA_TMP)
cgilua.enablesession = function ()
- cgilua.session.open ()
- cgilua.addclosefunction (cgilua.session.close)
+ cgilua.session.open ()
+ cgilua.addclosefunction (cgilua.session.close)
end
</pre>
@@ -264,14 +230,14 @@ but not in other application's private directory. To implement this you could do
<pre class="example">
local app_lib_dir = {
- ["/virtual/path/"] = "/absolute/path/lib/",
+ ["/virtual/path/"] = "/absolute/path/lib/",
}
local package = package
cgilua.addopenfunction (function ()
- local app = app_lib_dir[cgilua.script_vdir]
- if app then
- package.path = app..'/?.lua'..';'..package.path
- end
+ local app = app_lib_dir[cgilua.script_vdir]
+ if app then
+ package.path = app..'/?.lua'..';'..package.path
+ end
end)
</pre>
@@ -335,11 +301,11 @@ variables, and the concatenation operator:
cgilua.htmlheader()
if cgilua.QUERY.language == 'english' then
- greeting = 'Hello World!'
+ greeting = 'Hello World!'
elseif cgilua.QUERY.language == 'portuguese' then
- greeting = 'Olá Mundo!'
+ greeting = 'Olá Mundo!'
else
- greeting = '[unknown language]'
+ greeting = '[unknown language]'
end
cgilua.put('<html>')
@@ -441,15 +407,15 @@ was definied in file <code>functions.lua</code> as follows:
<pre class="example">
function getGreeting()
- local greeting
- if cgilua.QUERY.language == 'english' then
- greeting = 'Hello World!'
- elseif cgilua.QUERY.language == 'portuguese' then
- greeting = 'Olá Mundo!'
- else
- greeting = '[unknown language]'
- end
- return greeting
+ local greeting
+ if cgilua.QUERY.language == 'english' then
+ greeting = 'Hello World!'
+ elseif cgilua.QUERY.language == 'portuguese' then
+ greeting = 'Olá Mundo!'
+ else
+ greeting = '[unknown language]'
+ end
+ return greeting
end
</pre>
@@ -482,7 +448,7 @@ A Lua Script could do that using a loop like:
<pre class="example">
cgilua.put("<ul>")
for i, item in ipairs(list) do
- cgilua.put("<li>"..item.."</li>")
+ cgilua.put("<li>"..item.."</li>")
end
cgilua.put("</ul>")
</pre>
@@ -493,9 +459,9 @@ The equivalent loop in Lua Page would be:
<pre class="example">
<ul>
- <% for i, item in ipairs(list) do %>
- <li><%= item %></li>
- <% end %>
+ <% for i, item in ipairs(list) do %>
+ <li><%= item %></li>
+ <% end %>
</ul>
</pre>
@@ -542,7 +508,7 @@ in an indexed table in the order in which they are handled.
<h2><a name="dispatching"></a>Dispatching</h2>
<p>
-If you want to use more sophisticated URLs, the Kepler distribution includes a dispatching script
+In the <code>examples</code> folder you can find a dispatching script
called <code>app.lua</code> that can be used to handle URLs in the format
<code>.../app.lua/<em>app_name</em>/<em>path_info</em></code> in a standard way.
URLs in this format are said to refer to CGILua spplications, which consists in a standard loading
@@ -566,7 +532,7 @@ follow a convention similar to <a href="http://www.rubyonrails.org/">Rails</a>.
</p>
<pre class="example">
-require"cgilua.dispatcher"
+require("cgilua.dispatcher")
return cgilua.dispatcher.route{"/$controller/$action/$ID", handle, "rails"}
</pre>
@@ -599,16 +565,16 @@ and assumes three different participants.
<p>
The first one is the controller script, which is responsible for centralizing the user authentication control
and deciding if the application should continue depending on a user being logged in or not. An example of such
-controller would be the <code>app.lua</code> dispatcher script distributed with Kepler. As most of the controllers
+controller would be the <code>app.lua</code> dispatcher script in <code>examples/</code>. As most of the controllers
would do, it checks for the presence of an authenticated user and redirects to the checking script when that fails:
</p>
<pre class="example">
-- checks for authenticated users
if not cgilua.authentication.username() then
- cgilua.redirect(cgilua.authentication.checkURL())
+ cgilua.redirect(cgilua.authentication.checkURL())
else
- -- continues with the application flow
+ -- continues with the application flow
end
</pre>
@@ -635,25 +601,26 @@ local pass = cgilua.POST.pass
local logged, err, logoutURL
if cgilua.authentication then
- logged, err = cgilua.authentication.check(username, pass)
- username = cgilua.authentication.username() or ""
- logoutURL = cgilua.authentication.logoutURL()
+ logged, err = cgilua.authentication.check(username, pass)
+ username = cgilua.authentication.username() or ""
+ logoutURL = cgilua.authentication.logoutURL()
else
- logged = false
- err = "No authentication configured!"
- username = ""
+ logged = false
+ err = "No authentication configured!"
+ username = ""
end
if logged and username then
- -- goes back to the application
- cgilua.redirect(cgilua.authentication.refURL())
+ -- goes back to the application
+ cgilua.redirect(cgilua.authentication.refURL())
else
- err = err or ""
- -- displays the login form which submits to this same script
- cgilua.htmlheader()
- cgilua.lp.include ("login.lp", {
- logged = logged, errorMsg = err, username = username,
- cgilua = cgilua, logoutURL = logoutURL})
+ err = err or ""
+ -- displays the login form which submits to this same script
+ cgilua.htmlheader()
+ cgilua.lp.include ("login.lp", {
+ logged = logged, errorMsg = err, username = username,
+ cgilua = cgilua, logoutURL = logoutURL
+ })
end
</pre>
@@ -668,10 +635,10 @@ The login form for this example can be fount at <code>/examples/login.lp</code>
<% else %>
<p style="color:#ff0000"><%= errorMsg %> </p>
<form method="post" action="" >
- User name: <input name="username" maxlength="20" size="20" value="<%= username %>" ><br />
- Password: <input name="pass" type="password" maxlength="20" size="20"><br />
- <input type="submit" value="Login">
- <input type="reset" value="Reset">
+ User name: <input name="username" maxlength="20" size="20" value="<%= username %>" ><br />
+ Password: <input name="pass" type="password" maxlength="20" size="20"><br />
+ <input type="submit" value="Login">
+ <input type="reset" value="Reset">
</form>
<% end %>
</pre>
@@ -703,8 +670,8 @@ The function
defines the function that decides what to do with the error message. It could
be sent to the client's browser, written to a log file or sent to an e-mail
address (with the help of
-<a href="http://luasocket.luaforge.net/">LuaSocket</a> or
-<a href="http://www.keplerproject.org/lualogging/">LuaLogging</a> for example).
+<a href="http://github.com/lunarmodules/luasocket/">LuaSocket</a> or
+<a href="http://github.com/lunarmodules/lualogging/">LuaLogging</a> for example).
</p>
<p>
@@ -723,58 +690,58 @@ piece of code:
<pre class="example">
local ip = cgilua.servervariable"REMOTE_ADDR"
local developers_machines = {
- ["192.168.0.20"] = true,
- ["192.168.0.27"] = true,
- ["192.168.0.30"] = true,
+ ["192.168.0.20"] = true,
+ ["192.168.0.27"] = true,
+ ["192.168.0.30"] = true,
}
local function mail (s)
- require"cgilua.serialize"
- require"socket.smtp"
- -- Build the message
- local msg = {}
- table.insert (msg, tostring(s))
- -- Tries to obtain the REFERER URL
- table.insert (msg, tostring (cgilua.servervariable"HTTP_REFERER"))
- table.insert (msg, cgilua.servervariable"SERVER_NAME"..
- cgilua.servervariable"SCRIPT_NAME")
- -- CGI parameters
- table.insert (msg, "CGI")
- cgilua.serialize(cgi, function (s) table.insert (msg, s) end)
- table.insert (msg, tostring (os.date()))
- table.insert (msg, tostring (ip))
- table.insert (msg, "Cookies:")
- table.insert (msg, tostring (cgilua.servervariable"HTTP_COOKIE" or "no cookies"))
- -- Formats message according to LuaSocket-2.0b3
- local source = socket.smtp.message {
- headers = { subject = "Script Error", },
- body = table.concat (msg, '\n'),
- }
- -- Sends the message
- local r, e = socket.smtp.send {
- from = "sender@my.domain.net",
- rcpt = "developers@my.domain.net",
- source = source,
- }
+ require"cgilua.serialize"
+ require"socket.smtp"
+ -- Build the message
+ local msg = {}
+ table.insert (msg, tostring(s))
+ -- Tries to obtain the REFERER URL
+ table.insert (msg, tostring (cgilua.servervariable"HTTP_REFERER"))
+ table.insert (msg, cgilua.servervariable"SERVER_NAME"..
+ cgilua.servervariable"SCRIPT_NAME")
+ -- CGI parameters
+ table.insert (msg, "CGI")
+ cgilua.serialize(cgi, function (s) table.insert (msg, s) end)
+ table.insert (msg, tostring (os.date()))
+ table.insert (msg, tostring (ip))
+ table.insert (msg, "Cookies:")
+ table.insert (msg, tostring (cgilua.servervariable"HTTP_COOKIE" or "no cookies"))
+ -- Formats message according to LuaSocket-2.0b3
+ local source = socket.smtp.message {
+ headers = { subject = "Script Error", },
+ body = table.concat (msg, '\n'),
+ }
+ -- Sends the message
+ local r, e = socket.smtp.send {
+ from = "sender@my.domain.net",
+ rcpt = "developers@my.domain.net",
+ source = source,
+ }
end
if developers_machines[ip] then
- -- Developer's error treatment: write to the display
- cgilua.seterroroutput (function (msg)
- cgilua.errorlog (msg)
- cgilua.errorlog (cgilua.servervariable"REMOTE_ADDR")
- cgilua.errorlog (os.date())
- cgilua.htmlheader ()
- msg = string.gsub (string.gsub (msg, "\n", "<br>\n"), "\t", " ")
- cgilua.put (msg)
- end)
+ -- Developer's error treatment: write to the display
+ cgilua.seterroroutput (function (msg)
+ cgilua.errorlog (msg)
+ cgilua.errorlog (cgilua.servervariable"REMOTE_ADDR")
+ cgilua.errorlog (os.date())
+ cgilua.htmlheader ()
+ msg = string.gsub (string.gsub (msg, "\n", "<br>\n"), "\t", " ")
+ cgilua.put (msg)
+ end)
else
- -- User's error treatment: shows a standard page and sends an e-mail to
- -- the developer
- cgilua.seterroroutput (function (s)
- cgilua.htmlheader ()
- cgilua.put"<h1>An error occurred</h1>\n"
- cgilua.put"The responsible is being informed."
- mail (s)
- end)
+ -- User's error treatment: shows a standard page and sends an e-mail to
+ -- the developer
+ cgilua.seterroroutput (function (s)
+ cgilua.htmlheader ()
+ cgilua.put"<h1>An error occurred</h1>\n"
+ cgilua.put"The responsible is being informed."
+ mail (s)
+ end)
end
</pre>
@@ -790,8 +757,8 @@ containing all possible information to help reproduce the situation.
</div> <!-- id="main" -->
<div id="about">
- <p><a href="http://validator.w3.org/check?uri=referer">Valid XHTML 1.0!</a></p>
- <p><small>$Id: manual.html,v 1.27 2008/05/19 18:13:36 carregal Exp $</small></p>
+ <p><a href="http://validator.w3.org/check?uri=referer">Valid XHTML 1.0!</a></p>
+ <p><small>$Id: manual.html,v 1.27 2008/05/19 18:13:36 carregal Exp $</small></p>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
diff --git a/doc/us/reference.html b/docs/reference.html
similarity index 92%
rename from doc/us/reference.html
rename to docs/reference.html
index e4728f3..ebc95b1 100755
--- a/doc/us/reference.html
+++ b/docs/reference.html
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>CGILua: Building Web Scripts with Lua</title>
- <link rel="stylesheet" href="http://www.keplerproject.org/doc.css" type="text/css"/>
+ <link rel="stylesheet" href="doc.css" type="text/css"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
@@ -11,9 +11,9 @@
<div id="container">
<div id="product">
- <div id="product_logo"><a href="http://www.keplerproject.org">
+ <div id="product_logo">
<img alt="CGILua logo" src="cgi-128.gif"/>
- </a></div>
+ </div>
<div id="product_name"><big><strong>CGILua</strong></big></div>
<div id="product_description">Building Web Scripts with Lua</div>
</div> <!-- id="product" -->
@@ -24,28 +24,8 @@
<h1>CGILua</h1>
<ul>
<li><a href="index.html">Home</a>
- <ul>
- <li><a href="index.html#overview">Overview</a></li>
- <li><a href="index.html#status">Status</a></li>
- <li><a href="index.html#download">Download</a></li>
- <li><a href="index.html#history">History</a></li>
- <li><a href="index.html#incompatibility">Incompatibilities</a></li>
- <li><a href="index.html#credits">Credits</a></li>
- <li><a href="index.html#contact">Contact us</a></li>
- </ul>
</li>
<li><a href="manual.html">Manual</a>
- <ul>
- <li><a href="manual.html#intro">Introduction</a></li>
- <li><a href="manual.html#installation">Installation</a></li>
- <li><a href="manual.html#config">Configuration</a></li>
- <li><a href="manual.html#scripts">Lua Scripts</a></li>
- <li><a href="manual.html#templates">Lua Pages</a></li>
- <li><a href="manual.html#parameters">Parameters</a></li>
- <li><a href="manual.html#dispatching">Dispatching</a></li>
- <li><a href="manual.html#authentication">Authentication</a></li>
- <li><a href="manual.html#error_handling">Error Handling</a></li>
- </ul>
</li>
<li><strong>Reference</strong>
<ul>
@@ -62,13 +42,6 @@
</ul>
</li>
<li><a href="libraries.html">Libraries</a>
- <ul>
- <li><a href="libraries.html#authentication">Authentication</a></li>
- <li><a href="libraries.html#cookies">Cookies</a></li>
- <li><a href="libraries.html#dispatcher">Dispatcher</a></li>
- <li><a href="libraries.html#serialize">Serialize</a></li>
- <li><a href="libraries.html#session">Session</a></li>
- </ul>
</li>
<li><a href="sapi.html">SAPI</a></li>
<li><a href="license.html">License</a></li>
diff --git a/doc/us/sapi.html b/docs/sapi.html
similarity index 78%
rename from doc/us/sapi.html
rename to docs/sapi.html
index 7ea82b1..a142fea 100755
--- a/doc/us/sapi.html
+++ b/docs/sapi.html
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>CGILua: Building Web Scripts with Lua</title>
- <link rel="stylesheet" href="http://www.keplerproject.org/doc.css" type="text/css"/>
+ <link rel="stylesheet" href="doc.css" type="text/css"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
@@ -11,9 +11,9 @@
<div id="container">
<div id="product">
- <div id="product_logo"><a href="http://www.keplerproject.org">
+ <div id="product_logo">
<img alt="CGILua logo" src="cgi-128.gif"/>
- </a></div>
+ </div>
<div id="product_name"><big><strong>CGILua</strong></big></div>
<div id="product_description">Building Web Scripts with Lua</div>
</div> <!-- id="product" -->
@@ -24,50 +24,12 @@
<h1>CGILua</h1>
<ul>
<li><a href="index.html">Home</a>
- <ul>
- <li><a href="index.html#overview">Overview</a></li>
- <li><a href="index.html#status">Status</a></li>
- <li><a href="index.html#download">Download</a></li>
- <li><a href="index.html#history">History</a></li>
- <li><a href="index.html#incompatibility">Incompatibilities</a></li>
- <li><a href="index.html#credits">Credits</a></li>
- <li><a href="index.html#contact">Contact us</a></li>
- </ul>
</li>
<li><a href="manual.html">Manual</a>
- <ul>
- <li><a href="manual.html#intro">Introduction</a></li>
- <li><a href="manual.html#installation">Installation</a></li>
- <li><a href="manual.html#config">Configuration</a></li>
- <li><a href="manual.html#scripts">Lua Scripts</a></li>
- <li><a href="manual.html#templates">Lua Pages</a></li>
- <li><a href="manual.html#parameters">Parameters</a></li>
- <li><a href="manual.html#dispatching">Dispatching</a></li>
- <li><a href="manual.html#authentication">Authentication</a></li>
- <li><a href="manual.html#error_handling">Error Handling</a></li>
- </ul>
</li>
<li><a href="reference.html">Reference</a>
- <ul>
- <li><a href="reference.html#headers">Headers</a></li>
- <li><a href="reference.html#contents">Content Generation</a></li>
- <li><a href="reference.html#prep">Lua Pages</a></li>
- <li><a href="reference.html#variables">CGILua Variables</a></li>
- <li><a href="reference.html#error_handling">Error Handling</a></li>
- <li><a href="reference.html#behavior">CGILua Behavior</a></li>
- <li><a href="reference.html#urlcode">URL Encoding</a></li>
- <li><a href="reference.html#auxiliar">Auxiliary functions</a></li>
- <li><a href="reference.html#index">Alphabetic Index</a></li>
- </ul>
</li>
<li><a href="libraries.html">Libraries</a>
- <ul>
- <li><a href="libraries.html#authentication">Authentication</a></li>
- <li><a href="libraries.html#cookies">Cookies</a></li>
- <li><a href="libraries.html#dispatcher">Dispatcher</a></li>
- <li><a href="libraries.html#serialize">Serialize</a></li>
- <li><a href="libraries.html#session">Session</a></li>
- </ul>
</li>
<li><strong>SAPI</strong></li>
<li><a href="license.html">License</a></li>
@@ -80,7 +42,7 @@
<p>The Server API (SAPI) allows the abstraction of a series of internal web server details
and allows CGILua to be used over <a href="http://wsapi.luaforge.net/">WSAPI</a>.
-Kepler is the reference implementation of WSAPI and currently supports Apache,
+The reference implementation of WSAPI currently supports Apache,
Microsoft IIS and Xavante as Web servers, and CGI, FastCGI, as WSAPI connectors.
Xavante has a native WSAPI connector.
</p>
diff --git a/examples/index.lp b/examples/index.lp
index 69996c8..db41ede 100755
--- a/examples/index.lp
+++ b/examples/index.lp
@@ -4,7 +4,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
- <title>Welcome to Kepler!</title>
+ <title>Welcome to CGILua!</title>
<link rel="stylesheet" href="css/doc.css" type="text/css"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
@@ -14,47 +14,46 @@
<div id="container">
<div id="product">
- <div id="product_logo"><a href="http://www.keplerproject.org">
- <img src="img/keplerproject.gif" alt="Kepler Project logo" /></a>
</div>
- <div id="product_name"><big><strong></strong></big></div>
+ <div id="product_name"><big><strong>CGILua</strong></big></div>
<div id="product_description">Welcome page</div>
</div> <!-- id="product" -->
<div id="main">
<div id="navigation">
+
<%
-local mods = {}
-for file in lfs.dir("doc") do
- local attr = lfs.attributes ("doc/"..file)
- if attr.mode == "directory" and file ~= "." and file ~= ".." then
- table.insert(mods, file)
+local files = {}
+for file in lfs.dir("docs") do
+ local attr = lfs.attributes ("docs/"..file)
+ if file:match("html$") then
+ table.insert(files, file)
end
end
-table.sort(mods)
+table.sort(files)
%>
-<h1>Kepler</h1>
- <ul>
- <li><strong>Documentation</strong>
- <ul>
- <%
- for _,file in ipairs(mods) do
- %>
- <li><strong><a href="doc/<%= file %>/index.html"><%= file %></a></strong></li>
- <%
- end
- if not next(mods) then
- %>
- <li><strong>(None)</strong></li>
- <%
- end
- %>
- </ul>
- </li>
- <li><a href="test.lp">Tests</a></li>
- </ul>
+<h1>CGILua</h1>
+
+<ul>
+<li><a href="docs/index.html">Documentation</a></li>
+<ul>
+ <%
+ for _,file in ipairs(files) do
+ %>
+ <li><strong><a href="docs/<%= file %>"><%= file %></a></strong></li>
+ <%
+ end
+ if not next(mods) then
+ %>
+ <li><strong>(None)</strong></li>
+ <%
+ end
+ %>
+</ul>
+<li><a href="test.lp">Tests</a></li>
+</ul>
</div> <!-- id="navigation" -->
<div id="content">
@@ -78,32 +77,10 @@ It serves both as a documentation index and as a simple example of a dynamic Lua
From here you can also run some <a href="test.lp">tests</a>.
</p>
-<h2>Contact us</h2>
-
-<p>
-For more information on Kepler modules please
-<a href="mailto:info-NO-SPAM-THANKS@keplerproject.org">contact us</a>.
-Comments are welcome!
-</p>
-
-<p>
-You can also reach other Kepler developers and users on the Kepler
-Project <a href="http://luaforge.net/mail/?group_id=104">mailing list</a>.
-</p>
-
-<p>
-Copyright 2004-2007 - <a href="http://www.keplerproject.org">Kepler Project</a>
-</p>
-
</div> <!-- id="content" -->
</div> <!-- id="main" -->
-<div id="about">
- <p><a href="http://validator.w3.org/check?uri=referer">Valid XHTML 1.0</a></p>
- <p><small>$Id: index.lp,v 1.1 2008/06/30 14:29:59 carregal Exp $</small></p>
-</div> <!-- id="about" -->
-
</div> <!-- id="container" -->
</body>
</html>
diff --git a/examples/test.lp b/examples/test.lp
index 517f0f2..7433b2f 100755
--- a/examples/test.lp
+++ b/examples/test.lp
@@ -10,7 +10,7 @@
<%
require"cgilua.cookies"
if cgilua.POST.user then
- cgilua.cookies.sethtml("cookie_kepler", cgilua.POST.user)
+ cgilua.cookies.sethtml("cookie_cgilua", cgilua.POST.user)
end
%>
</head>
@@ -20,9 +20,6 @@
<div id="container">
<div id="product">
- <div id="product_logo"><a href="http://www.keplerproject.org">
- <img src="img/keplerproject.gif" alt="Kepler Project logo" /></a>
- </div>
<div id="product_name"><big><strong></strong></big></div>
<div id="product_description">CGILua simple tests</div>
</div> <!-- id="product" -->
@@ -30,37 +27,38 @@
<div id="main">
<div id="navigation">
+
<%
-local mods = {}
-for file in lfs.dir("doc") do
- local attr = lfs.attributes ("doc/"..file)
- if attr.mode == "directory" and file ~= "." and file ~= ".." then
- table.insert(mods, file)
+local files = {}
+for file in lfs.dir("docs") do
+ local attr = lfs.attributes ("docs/"..file)
+ if file:match("html$") then
+ table.insert(files, file)
end
end
-table.sort(mods)
+table.sort(files)
%>
-<h1>Kepler</h1>
- <ul>
- <li><a href="index.lp">Documentation</a>
- <ul>
- <%
- for _,file in ipairs(mods) do
- %>
- <li><strong><a href="doc/<%= file %>/index.html"><%= file %></a></strong></li>
- <%
- end
- if not next(mods) then
- %>
- <li><strong>(None)</strong></li>
- <%
- end
- %>
- </ul>
- </li>
- <li><strong>Tests</strong></li>
- </ul>
+<h1>CGILua</h1>
+
+<ul>
+<li><a href="docs/index.html">Documentation</a></li>
+<ul>
+ <%
+ for _,file in ipairs(files) do
+ %>
+ <li><strong><a href="docs/<%= file %>"><%= file %></a></strong></li>
+ <%
+ end
+ if not next(mods) then
+ %>
+ <li><strong>(None)</strong></li>
+ <%
+ end
+ %>
+</ul>
+<li><a href="test.lp">Tests</a></li>
+</ul>
</div> <!-- id="navigation" -->
<div id="content">
@@ -95,7 +93,7 @@ Here you should see the values posted before the ones shown above
</p>
<p>
-cookie_kepler = <%= cgilua.cookies.get("cookie_kepler") or "(not set)" %>
+cookie_cgilua = <%= cgilua.cookies.get("cookie_cgilua") or "(not set)" %>
</p>
<h2>File Upload</h2>
diff --git a/rockspec/cgilua-5.1.4-1.rockspec b/rockspec/cgilua-5.1.4-1.rockspec
index 8d0840b..3f5b936 100755
--- a/rockspec/cgilua-5.1.4-1.rockspec
+++ b/rockspec/cgilua-5.1.4-1.rockspec
@@ -3,7 +3,7 @@ package = "CGILua"
version = "5.1.4-1"
source = {
- url = "http://github.com/downloads/keplerproject/cgilua/cgilua-5.1.4.tar.gz"
+ url = "http://github.com/downloads/lunarmodules/cgilua/cgilua-5.1.4.tar.gz"
}
description = {
diff --git a/rockspec/cgilua-5.2-1.rockspec b/rockspec/cgilua-5.2-2.rockspec
old mode 100755
new mode 100644
similarity index 87%
rename from rockspec/cgilua-5.2-1.rockspec
rename to rockspec/cgilua-5.2-2.rockspec
index 95568ca..fbe2b2d
--- a/rockspec/cgilua-5.2-1.rockspec
+++ b/rockspec/cgilua-5.2-2.rockspec
@@ -1,9 +1,10 @@
package = "CGILua"
-version = "5.2-1"
+version = "5.2-2"
source = {
- url = "http://github.com/downloads/keplerproject/cgilua/cgilua-5.2.tar.gz"
+ url = "https://github.com/lunarmodules/cgilua/archive/v5.2a2.tar.gz",
+ dir = "cgilua-5.2a2",
}
description = {
@@ -15,7 +16,9 @@ description = {
server, with different launchers. A launcher is responsible for the
interaction of CGILua and the Web server, for example using ISAPI on
IIS or mod_lua on Apache.
- ]]
+ ]],
+ homepage = "http://lunarmodules.github.io/cgilua",
+ license = "MIT/X11",
}
dependencies = {
diff --git a/rockspec/cgilua-5.2.1-1.rockspec b/rockspec/cgilua-5.2.1-1.rockspec
new file mode 100644
index 0000000..cd11967
--- /dev/null
+++ b/rockspec/cgilua-5.2.1-1.rockspec
@@ -0,0 +1,55 @@
+package = "CGILua"
+
+version = "5.2.1-1"
+
+source = {
+ url = "https://github.com/lunarmodules/cgilua/archive/v5.2.1.tar.gz",
+ dir = "cgilua-5.2.1",
+ md5 = "2125c0d4b583672463f2417555590e0d",
+}
+
+description = {
+ summary = "Tool for creating dynamic Web pages and manipulating data from Web forms",
+ detailed = [[
+ CGILua allows the separation of logic and data handling from the
+ generation of pages, making it easy to develop web applications with
+ Lua. CGILua can be used with a variety of Web servers and, for each
+ server, with different launchers. A launcher is responsible for the
+ interaction of CGILua and the Web server, for example using ISAPI on
+ IIS or mod_lua on Apache.
+ ]],
+ homepage = "http://lunarmodules.github.io/cgilua",
+ license = "MIT/X11",
+}
+
+dependencies = {
+ "lua >= 5.2",
+ "luafilesystem >= 1.6.0",
+}
+
+local CGILUA_LUAS = { "src/cgilua/authentication.lua",
+ "src/cgilua/cookies.lua",
+ "src/cgilua/dispatcher.lua",
+ "src/cgilua/loader.lua",
+ "src/cgilua/lp.lua",
+ "src/cgilua/mime.lua",
+ "src/cgilua/post.lua",
+ "src/cgilua/readuntil.lua",
+ "src/cgilua/serialize.lua",
+ "src/cgilua/session.lua",
+ "src/cgilua/urlcode.lua" }
+
+build = {
+ type = "builtin",
+ modules = {
+ cgilua = "src/cgilua/cgilua.lua"
+ },
+ copy_directories = { "examples", "doc", "tests" },
+ install = { bin = { "src/launchers/cgilua.cgi", "src/launchers/cgilua.fcgi" } }
+}
+
+for i = 1, #CGILUA_LUAS do
+ local file = CGILUA_LUAS[i]
+ local mod = "cgilua." .. file:match("^src/cgilua/([^%.]+)%.lua$")
+ build.modules[mod] = file
+end
diff --git a/rockspec/cgilua-6.0.0-0.rockspec b/rockspec/cgilua-6.0.0-0.rockspec
new file mode 100644
index 0000000..4b81140
--- /dev/null
+++ b/rockspec/cgilua-6.0.0-0.rockspec
@@ -0,0 +1,55 @@
+package = "CGILua"
+version = "6.0.0-0"
+
+source = {
+ url = "https://github.com/lunarmodules/cgilua",
+ dir = "cgilua-6.0.0-0",
+}
+
+description = {
+ summary = "Tool for creating dynamic Web pages and manipulating data from Web forms",
+ detailed = [[
+ CGILua allows the separation of logic and data handling from the
+ generation of pages, making it easy to develop web applications with
+ Lua. CGILua can be used with a variety of Web servers and, for each
+ server, with different launchers. A launcher is responsible for the
+ interaction of CGILua and the Web server, for example using ISAPI on
+ IIS or mod_lua on Apache.
+ ]],
+ homepage = "http://lunarmodules.github.io/cgilua",
+ license = "MIT/X11",
+}
+
+dependencies = {
+ "lua >= 5.2",
+ "luafilesystem >= 1.6.0",
+}
+
+build = {
+ type = "builtin",
+ modules = {
+ ["cgilua.main"] = "src/cgilua/main.lua",
+ ["cgilua.authentication"] = "src/cgilua/authentication.lua",
+ ["cgilua.cookies"] = "src/cgilua/cookies.lua",
+ ["cgilua.dispatcher"] = "src/cgilua/dispatcher.lua",
+ ["cgilua.loader"] = "src/cgilua/loader.lua",
+ ["cgilua.lp"] = "src/cgilua/lp.lua",
+ ["cgilua.mime"] = "src/cgilua/mime.lua",
+ ["cgilua.post"] = "src/cgilua/post.lua",
+ ["cgilua.readuntil"] = "src/cgilua/readuntil.lua",
+ ["cgilua.serialize"] = "src/cgilua/serialize.lua",
+ ["cgilua.session"] = "src/cgilua/session.lua",
+ ["cgilua.urlcode"] = "src/cgilua/urlcode.lua"
+ },
+ install = {
+ bin = {
+ "src/launchers/cgilua.cgi",
+ "src/launchers/cgilua.fcgi",
+ },
+ },
+ copy_directories = {
+ "examples",
+ "doc",
+ "tests"
+ },
+}
diff --git a/rockspec/cgilua-6.0.1-0.rockspec b/rockspec/cgilua-6.0.1-0.rockspec
new file mode 100644
index 0000000..48937eb
--- /dev/null
+++ b/rockspec/cgilua-6.0.1-0.rockspec
@@ -0,0 +1,55 @@
+package = "CGILua"
+version = "6.0.1-0"
+
+source = {
+ url = "https://github.com/lunarmodules/cgilua",
+ dir = "cgilua-6.0.1-0",
+}
+
+description = {
+ summary = "Tool for creating dynamic Web pages and manipulating data from Web forms",
+ detailed = [[
+ CGILua allows the separation of logic and data handling from the
+ generation of pages, making it easy to develop web applications with
+ Lua. CGILua can be used with a variety of Web servers and, for each
+ server, with different launchers. A launcher is responsible for the
+ interaction of CGILua and the Web server, for example using ISAPI on
+ IIS or mod_lua on Apache.
+ ]],
+ homepage = "http://lunarmodules.github.io/cgilua",
+ license = "MIT/X11",
+}
+
+dependencies = {
+ "lua >= 5.2",
+ "luafilesystem >= 1.6.0",
+}
+
+build = {
+ type = "builtin",
+ modules = {
+ ["cgilua.main"] = "src/cgilua/main.lua",
+ ["cgilua.authentication"] = "src/cgilua/authentication.lua",
+ ["cgilua.cookies"] = "src/cgilua/cookies.lua",
+ ["cgilua.dispatcher"] = "src/cgilua/dispatcher.lua",
+ ["cgilua.loader"] = "src/cgilua/loader.lua",
+ ["cgilua.lp"] = "src/cgilua/lp.lua",
+ ["cgilua.mime"] = "src/cgilua/mime.lua",
+ ["cgilua.post"] = "src/cgilua/post.lua",
+ ["cgilua.readuntil"] = "src/cgilua/readuntil.lua",
+ ["cgilua.serialize"] = "src/cgilua/serialize.lua",
+ ["cgilua.session"] = "src/cgilua/session.lua",
+ ["cgilua.urlcode"] = "src/cgilua/urlcode.lua"
+ },
+ install = {
+ bin = {
+ "src/launchers/cgilua.cgi",
+ "src/launchers/cgilua.fcgi",
+ },
+ },
+ copy_directories = {
+ "examples",
+ "doc",
+ "tests"
+ },
+}
diff --git a/rockspec/cgilua-6.0.2-0.rockspec b/rockspec/cgilua-6.0.2-0.rockspec
new file mode 100644
index 0000000..c2f2428
--- /dev/null
+++ b/rockspec/cgilua-6.0.2-0.rockspec
@@ -0,0 +1,55 @@
+package = "CGILua"
+version = "6.0.2-0"
+
+source = {
+ url = "git+ssh://git@github.com:lunarmodules/cgilua.git",
+ tag = "6.0.2",
+}
+
+description = {
+ summary = "Tool for creating dynamic Web pages and manipulating data from Web forms",
+ detailed = [[
+ CGILua allows the separation of logic and data handling from the
+ generation of pages, making it easy to develop web applications with
+ Lua. CGILua can be used with a variety of Web servers and, for each
+ server, with different launchers. A launcher is responsible for the
+ interaction of CGILua and the Web server, for example using ISAPI on
+ IIS or mod_lua on Apache.
+ ]],
+ homepage = "http://lunarmodules.github.io/cgilua",
+ license = "MIT/X11",
+}
+
+dependencies = {
+ "lua >= 5.2",
+ "luafilesystem >= 1.6.0",
+}
+
+build = {
+ type = "builtin",
+ modules = {
+ ["cgilua.main"] = "src/cgilua/main.lua",
+ ["cgilua.authentication"] = "src/cgilua/authentication.lua",
+ ["cgilua.cookies"] = "src/cgilua/cookies.lua",
+ ["cgilua.dispatcher"] = "src/cgilua/dispatcher.lua",
+ ["cgilua.loader"] = "src/cgilua/loader.lua",
+ ["cgilua.lp"] = "src/cgilua/lp.lua",
+ ["cgilua.mime"] = "src/cgilua/mime.lua",
+ ["cgilua.post"] = "src/cgilua/post.lua",
+ ["cgilua.readuntil"] = "src/cgilua/readuntil.lua",
+ ["cgilua.serialize"] = "src/cgilua/serialize.lua",
+ ["cgilua.session"] = "src/cgilua/session.lua",
+ ["cgilua.urlcode"] = "src/cgilua/urlcode.lua"
+ },
+ install = {
+ bin = {
+ "src/launchers/cgilua.cgi",
+ "src/launchers/cgilua.fcgi",
+ },
+ },
+ copy_directories = {
+ "examples",
+ "doc",
+ "tests"
+ },
+}
diff --git a/rockspec/cgilua-6.0.3-0.rockspec b/rockspec/cgilua-6.0.3-0.rockspec
new file mode 100644
index 0000000..38e3be7
--- /dev/null
+++ b/rockspec/cgilua-6.0.3-0.rockspec
@@ -0,0 +1,55 @@
+package = "CGILua"
+version = "6.0.3-0"
+
+source = {
+ url = "git+ssh://git@github.com:lunarmodules/cgilua.git",
+ tag = "6.0.3",
+}
+
+description = {
+ summary = "Tool for creating dynamic Web pages and manipulating data from Web forms",
+ detailed = [[
+ CGILua allows the separation of logic and data handling from the
+ generation of pages, making it easy to develop web applications with
+ Lua. CGILua can be used with a variety of Web servers and, for each
+ server, with different launchers. A launcher is responsible for the
+ interaction of CGILua and the Web server, for example using ISAPI on
+ IIS or mod_lua on Apache.
+ ]],
+ homepage = "http://lunarmodules.github.io/cgilua",
+ license = "MIT/X11",
+}
+
+dependencies = {
+ "lua >= 5.2",
+ "luafilesystem >= 1.6.0",
+}
+
+build = {
+ type = "builtin",
+ modules = {
+ ["cgilua.main"] = "src/cgilua/main.lua",
+ ["cgilua.authentication"] = "src/cgilua/authentication.lua",
+ ["cgilua.cookies"] = "src/cgilua/cookies.lua",
+ ["cgilua.dispatcher"] = "src/cgilua/dispatcher.lua",
+ ["cgilua.loader"] = "src/cgilua/loader.lua",
+ ["cgilua.lp"] = "src/cgilua/lp.lua",
+ ["cgilua.mime"] = "src/cgilua/mime.lua",
+ ["cgilua.post"] = "src/cgilua/post.lua",
+ ["cgilua.readuntil"] = "src/cgilua/readuntil.lua",
+ ["cgilua.serialize"] = "src/cgilua/serialize.lua",
+ ["cgilua.session"] = "src/cgilua/session.lua",
+ ["cgilua.urlcode"] = "src/cgilua/urlcode.lua"
+ },
+ install = {
+ bin = {
+ "src/launchers/cgilua.cgi",
+ "src/launchers/cgilua.fcgi",
+ },
+ },
+ copy_directories = {
+ "examples",
+ "docs",
+ "tests"
+ },
+}
diff --git a/rockspec/cgilua-cvs-4.rockspec b/rockspec/cgilua-cvs-5.rockspec
similarity index 92%
rename from rockspec/cgilua-cvs-4.rockspec
rename to rockspec/cgilua-cvs-5.rockspec
index 003ab82..7818e25 100755
--- a/rockspec/cgilua-cvs-4.rockspec
+++ b/rockspec/cgilua-cvs-5.rockspec
@@ -1,6 +1,6 @@
package = "CGILua"
-version = "cvs-4"
+version = "cvs-5"
description = {
summary = "Tool for creating dynamic Web pages and manipulating data from Web forms",
@@ -20,7 +20,7 @@ dependencies = {
}
source = {
- url = "git://github.com/keplerproject/cgilua.git",
+ url = "git://github.com/lunarmodules/cgilua.git",
}
local CGILUA_LUAS = { "src/cgilua/authentication.lua",
@@ -41,7 +41,7 @@ build = {
cgilua = "src/cgilua/cgilua.lua"
},
install = { bin = { "src/launchers/cgilua.cgi", "src/launchers/cgilua.fcgi" } },
- copy_directories = { "examples", "doc" }
+ copy_directories = { "examples", "docs" }
}
for i = 1, #CGILUA_LUAS do
diff --git a/src/cgilua/authentication.lua b/src/cgilua/authentication.lua
index de27918..c8b6a35 100755
--- a/src/cgilua/authentication.lua
+++ b/src/cgilua/authentication.lua
@@ -22,9 +22,9 @@ local md5=require"md5"
local cookies = require"cgilua.cookies"
local cgilua = require"cgilua"
+local urlcode = require"cgilua.urlcode"
local string = require"string"
local math = require"math"
-local error = error
local M = {}
@@ -88,7 +88,7 @@ function M.username()
if configuration.tokenPersistence == "url" then
token = M.getToken()
elseif configuration.tokenPersistence == "cookie" then
- token = cgilua.cookies.get(configuration.tokenName)
+ token = cookies.get(configuration.tokenName)
end
if token then
authenticatedUserData = md5.decrypt(M.decodeURLbase64(token), configuration.criptKey)
@@ -119,9 +119,9 @@ local function setUser(username)
local cryptedUserData = cryptUserData()
if configuration.tokenPersistence == "url" then
M.setToken(cryptedUserData)
- cgilua.cookies.delete(configuration.tokenName) -- removes an eventual previous cookie token
+ cookies.delete(configuration.tokenName) -- removes an eventual previous cookie token
elseif configuration.tokenPersistence == "cookie" then
- cgilua.cookies.set(configuration.tokenName, cryptedUserData)
+ cookies.set(configuration.tokenName, cryptedUserData)
M.setToken() -- remove an eventual previous token from the URLs
end
end
@@ -130,7 +130,7 @@ end
-- User logout, clear everything
function M.logout()
setUser()
- cgilua.cookies.delete(configuration.tokenName)
+ cookies.delete(configuration.tokenName)
M.setToken()
cgilua.QUERY.logout = nil
end
@@ -171,7 +171,7 @@ function M.checkURL(ref, tologout)
if configuration.tokenPersistence == "url" then
token = M.getToken()
elseif configuration.tokenPersistence == "cookie" then
- token = cgilua.cookies.get(configuration.tokenName)
+ token = cookies.get(configuration.tokenName)
end
-- As HTTP header referer information can violate privacy,
@@ -197,8 +197,8 @@ end
function M.refURL()
local url
local baseURL = cgilua.QUERY.ref or configuration.checkURL
- if string.find(baseURL, "\?") then
- url = string.gsub(baseURL, "\?", "?"..configuration.tokenName.."="..cryptUserData().."&")
+ if string.find(baseURL, "%?") then
+ url = string.gsub(baseURL, "%?", "?"..configuration.tokenName.."="..cryptUserData().."&")
else
url = baseURL.."?"..configuration.tokenName.."="..cryptUserData()
end
diff --git a/src/cgilua/cgilua.lua b/src/cgilua/cgilua.lua
deleted file mode 100755
index bdce5ac..0000000
--- a/src/cgilua/cgilua.lua
+++ /dev/null
@@ -1,648 +0,0 @@
-----------------------------------------------------------------------------
--- CGILua library.
---
--- @release $Id: cgilua.lua,v 1.85 2009/06/28 22:42:34 tomas Exp $
-----------------------------------------------------------------------------
-
-local _G = assert(_G)
-local urlcode = require"cgilua.urlcode"
-local lp = require"cgilua.lp"
-local lfs = require"lfs"
-local debug = require"debug"
-local assert, error, ipairs, select, tostring, type, unpack, xpcall = assert, error, ipairs, select, tostring, type, unpack, xpcall
-local pairs = pairs
-local gsub, format, strfind, strlower, strsub, match = string.gsub, string.format, string.find, string.lower, string.sub, string.match
-local setmetatable = setmetatable
-local _open = io.open
-local tinsert, tremove, concat = table.insert, table.remove, table.concat
-local date = os.date
-local os_tmpname = os.tmpname
-local getenv = os.getenv
-local remove = os.remove
-local seeall = package.seeall
-
-lp.setoutfunc ("cgilua.put")
-lp.setcompatmode (true)
-
-
-local M = {
- _COPYRIGHT = "Copyright (C) 2003-2013 Kepler Project",
- _DESCRIPTION = "CGILua is a tool for creating dynamic Web pages and manipulating input data from forms",
- _VERSION = "CGILua 5.2",
-}
-
---
--- Internal state variables.
-local SAPI
-local _default_errorhandler = debug.traceback
-local _errorhandler = _default_errorhandler
-local _default_erroroutput = function (msg)
- if type(msg) ~= "string" and type(msg) ~= "number" then
- msg = format ("bad argument #1 to 'error' (string expected, got %s)", type(msg))
- end
-
- -- Logging error
- SAPI.Response.errorlog (msg)
- SAPI.Response.errorlog (" ")
-
- SAPI.Response.errorlog (SAPI.Request.servervariable"REMOTE_ADDR")
- SAPI.Response.errorlog (" ")
-
- SAPI.Response.errorlog (date())
- SAPI.Response.errorlog ("\n")
-
- -- Building user message
- msg = gsub (gsub (msg, "\n", "<br>\n"), "\t", " ")
- SAPI.Response.contenttype ("text/html")
- SAPI.Response.write ("<html><head><title>CGILua Error</title></head><body>" .. msg .. "</body></html>")
-end
-local _erroroutput = _default_erroroutput
-local _default_maxfilesize = 512 * 1024
-local _maxfilesize = _default_maxfilesize
-local _default_maxinput = 1024 * 1024
-local _maxinput = _default_maxinput
-M.script_path = false
-
---
--- Header functions
-
-----------------------------------------------------------------------------
--- Sends a header.
--- @name header
--- @class function
--- @param header String with the header.
--- @param value String with the corresponding value.
-----------------------------------------------------------------------------
-function M.header (...)
- return SAPI.Response.header (...)
-end
-
-----------------------------------------------------------------------------
--- Sends a Content-type header.
--- @param type String with the type of the header.
--- @param subtype String with the subtype of the header.
-----------------------------------------------------------------------------
-function M.contentheader (type, subtype)
- SAPI.Response.contenttype (type..'/'..subtype)
-end
-
-----------------------------------------------------------------------------
--- Sends the HTTP header "text/html".
-----------------------------------------------------------------------------
-function M.htmlheader()
- SAPI.Response.contenttype ("text/html")
-end
-
-----------------------------------------------------------------------------
--- Sends an HTTP header redirecting the browser to another URL
--- @param url String with the URL.
--- @param args Table with the arguments (optional).
-----------------------------------------------------------------------------
-function M.redirect (url, args)
- if strfind(url,"^https?:") then
- local params=""
- if args then
- params = "?"..urlcode.encodetable(args)
- end
- return SAPI.Response.redirect(url..params)
- else
- return SAPI.Response.redirect(M.mkabsoluteurl(M.mkurlpath(url,args)))
- end
-end
-
-----------------------------------------------------------------------------
--- Returns a server variable
--- @name servervariable
--- @class function
--- @param name String with the name of the server variable.
--- @return String with the value of the server variable.
-----------------------------------------------------------------------------
-function M.servervariable (...)
- return SAPI.Request.servervariable (...)
-end
-
-----------------------------------------------------------------------------
--- Primitive error output function
--- @param msg String (or number) with the message.
--- @param level String with the error level (optional).
-----------------------------------------------------------------------------
-function M.errorlog (msg, level)
- local t = type(msg)
- if t == "string" or t == "number" then
- SAPI.Response.errorlog (msg, level)
- else
- error ("bad argument #1 to `cgilua.errorlog' (string expected, got "..t..")", 2)
- end
-end
-
-----------------------------------------------------------------------------
--- Converts all its arguments to strings before sending them to the server.
-----------------------------------------------------------------------------
-function M.print (...)
- local args = { ... }
- for i = 1, select("#",...) do
- args[i] = tostring(args[i])
- end
- SAPI.Response.write (concat(args,"\t"))
- SAPI.Response.write ("\n")
-end
-
-----------------------------------------------------------------------------
--- Function 'put' sends its arguments (basically strings of HTML text)
--- to the server
--- Its basic implementation is to use Lua function 'write', which writes
--- each of its arguments (strings or numbers) to file _OUTPUT (a file
--- handle initialized with the file descriptor for stdout)
--- @name put
--- @class function
--- @param s String (or number) with output.
-----------------------------------------------------------------------------
-function M.put (...)
- return SAPI.Response.write (...)
-end
-
--- Returns the current errorhandler
-function M._geterrorhandler(msg)
- return _errorhandler(msg)
-end
-
-----------------------------------------------------------------------------
--- Executes a function using the CGILua error handler.
--- @param f Function to be called.
-----------------------------------------------------------------------------
-function M.pcall (f)
- local results = {xpcall (f, _errorhandler)}
- local ok = results[1]
- tremove(results, 1)
- if ok then
- if #results == 0 then results = { true } end
- return unpack(results)
- else
- _erroroutput (unpack(results))
- end
-end
-
-local function buildscriptenv()
- local env = { cgilua = M, print = M.print, write = M.put }
- setmetatable(env, { __index = _G, __newindex = _G })
- return env
-end
-
-----------------------------------------------------------------------------
--- Execute a script
--- If an error is found, Lua's error handler is called and this function
--- does not return
--- @param filename String with the name of the file to be processed.
--- @return The result of the execution of the file.
-----------------------------------------------------------------------------
-function M.doscript (filename)
- local env = buildscriptenv()
- local f, err = loadfile(filename, "bt", env)
- if not f then
- error (format ("Cannot execute `%s'. Exiting.\n%s", filename, err))
- else
- return M.pcall(f)
- end
-end
-
-----------------------------------------------------------------------------
--- Execute the file if there is no "file error".
--- If an error is found, and it is not a "file error", Lua 'error'
--- is called and this function does not return
--- @param filename String with the name of the file to be processed.
--- @return The result of the execution of the file or nil (in case the
--- file does not exists or if it cannot be opened).
--- @return It could return an error message if the file cannot be opened.
-----------------------------------------------------------------------------
-function M.doif (filename)
- if not filename then return end -- no file
- local f, err = _open(filename)
- if not f then return nil, err end -- no file (or unreadable file)
- f:close()
- return M.doscript (filename)
-end
-
----------------------------------------------------------------------------
--- Set the maximum "total" input size allowed (in bytes)
--- @param nbytes Number of the maximum size (in bytes) of the whole POST data.
----------------------------------------------------------------------------
-function M.setmaxinput(nbytes)
- _maxinput = nbytes
-end
-
----------------------------------------------------------------------------
--- Set the maximum size for an "uploaded" file (in bytes)
--- Might be less or equal than _maxinput.
--- @param nbytes Number of the maximum size (in bytes) of a file.
----------------------------------------------------------------------------
-function M.setmaxfilesize(nbytes)
- _maxfilesize = nbytes
-end
-
-
--- Default path for temporary files
-M.tmp_path = CGILUA_TMP or getenv("TEMP") or getenv ("TMP") or "/tmp"
-
--- Default function for temporary names
--- @returns a temporay name using os.tmpname
-function M.tmpname ()
- local tempname = os_tmpname()
- -- Lua os.tmpname returns a full path in Unix, but not in Windows
- -- so we strip the eventual prefix
- tempname = gsub(tempname, "(/tmp/)", "")
- return tempname
-end
-
-local _tmpfiles = {}
-
----------------------------------------------------------------------------
--- Returns a temporary file in a directory using a name generator
--- @param dir Base directory for the temporary file
--- @param namefunction Name generator function
----------------------------------------------------------------------------
-function M.tmpfile(dir, namefunction)
- dir = dir or M.tmp_path
- namefunction = namefunction or M.tmpname
- local tempname = namefunction()
- local filename = dir.."/"..tempname
- local file, err = _open(filename, "w+b")
- if file then
- tinsert(_tmpfiles, {name = filename, file = file})
- end
- return file, err
-end
-
-
-----------------------------------------------------------------------------
--- Preprocess the content of a mixed HTML file and output a complete
--- HTML document ( a 'Content-type' header is inserted before the
--- preprocessed HTML )
--- @param filename String with the name of the file to be processed.
--- @param env Optional environment
-----------------------------------------------------------------------------
-function M.handlelp (filename, env)
- env = env or buildscriptenv()
- M.htmlheader ()
- lp.include (filename, env)
-end
-
-----------------------------------------------------------------------------
--- Builds a handler that sends a header and the contents of the given file.
--- Sends the contents of the file to the output without processing it.
--- @param type String with the type of the header.
--- @param subtype String with the subtype of the header.
--- @return Function (which receives a filename as argument) that produces
--- the header and copies the content of the given file.
-----------------------------------------------------------------------------
-function M.buildplainhandler (type, subtype)
- return function (filename)
- local fh, err = _open (filename, "rb")
- local contents = ""
- if fh then
- contents = fh:read("*a")
- fh:close()
- else
- error(err)
- end
- M.header("Content-Lenght", #contents)
- M.contentheader (type, subtype)
- M.put (contents)
- end
-end
-
-----------------------------------------------------------------------------
--- Builds a handler that sends a header and the processed file.
--- Processes the file as a Lua Page.
--- @param type String with the type of the header.
--- @param subtype String with the subtype of the header.
--- @return Function (which receives a filename as argument) that produces
--- the header and processes the given file.
-----------------------------------------------------------------------------
-function M.buildprocesshandler (type, subtype)
- return function (filename)
- local env = buildscriptenv()
- M.contentheader (type, subtype)
- lp.include (filename, env)
- end
-end
-
-----------------------------------------------------------------------------
--- Builds the default handler table from cgilua.mime
-----------------------------------------------------------------------------
-local function buildhandlers()
- local mime = require "cgilua.mime"
- for ext, mediatype in pairs(mime) do
- local t, st = match(mediatype, "([^/]*)/([^/]*)")
- M.addscripthandler(ext, M.buildplainhandler(t, st))
- end
-end
-
-----------------------------------------------------------------------------
--- Create an URL path to be used as a link to a CGILua script
--- @param script String with the name of the script.
--- @param args Table with arguments to script (optional).
--- @return String in URL format.
-----------------------------------------------------------------------------
-function M.mkurlpath (script, args)
- -- URL-encode the parameters to be passed do the script
- local params = ""
- if args then
- params = "?"..urlcode.encodetable(args)
- end
- if strsub(script,1,1) == '/' or M.script_vdir == '/' then
- return script .. params
- else
- return M.script_vdir .. script .. params
- end
-end
-
-----------------------------------------------------------------------------
--- Create an absolute URL containing the given URL path
--- @param path String with the path.
--- @param protocol String with the name of the protocol (default = "http").
--- @return String in URL format.
-----------------------------------------------------------------------------
-function M.mkabsoluteurl (path, protocol)
- protocol = protocol or "http"
- if path:sub(1,1) ~= '/' then
- path = '/'..path
- end
- return format("%s://%s:%s%s",
- protocol,
- M.servervariable"SERVER_NAME",
- M.servervariable"SERVER_PORT",
- path)
-end
-
-----------------------------------------------------------------------------
--- Extract the "directory" and "file" parts of a path
--- @param path String with a path.
--- @return String with the directory part.
--- @return String with the file part.
-----------------------------------------------------------------------------
-function M.splitonlast (path, sep)
- local dir,file = match(path,"^(.-)([^:/\\]*)$")
- return dir,file
-end
-
-M.splitpath = M.splitonlast -- compatibility with previous versions
-
-----------------------------------------------------------------------------
--- Extracts the first and remaining parts of a path
--- @param path separator (defaults to "/")
--- @return String with the extracted part.
--- @return String with the remaining path.
-----------------------------------------------------------------------------
-function M.splitonfirst(path, sep)
- local first, rest = match(path, "^/([^:/\\]*)(.*)")
- return first, rest
-end
-
---
--- Define variables and build the cgilua.POST, cgilua.GET tables.
---
-local function getparams ()
- local requestmethod = M.servervariable"REQUEST_METHOD"
- -- Fill in the POST table.
- M.POST = {}
- if requestmethod == "POST" then
- M.post.parsedata {
- read = SAPI.Request.getpostdata,
- discardinput = ap and ap.discard_request_body,
- content_type = M.servervariable"CONTENT_TYPE",
- content_length = M.servervariable"CONTENT_LENGTH",
- maxinput = _maxinput,
- maxfilesize = _maxfilesize,
- args = M.POST,
- }
- end
- -- Fill in the QUERY table.
- M.QUERY = {}
- urlcode.parsequery (M.servervariable"QUERY_STRING", M.QUERY)
-end
-
---
--- Stores all script handlers and the file extensions used to identify
--- them. Loads the default
-local _script_handlers = {}
---
--- Default handler.
--- Sends the contents of the file to the output without processing it.
--- This relies in the browser being able to discover the content type
--- which is not reliable.
--- @param filename String with the name of the file.
---
-local function default_handler (filename)
- local fh, err = _open (filename, "rb")
- local contents
- if fh then
- contents = fh:read("*a")
- fh:close()
- else
- error(err)
- end
- M.header("Content-Lenght", #contents)
- M.put ("\n")
- M.put (contents)
-end
-
-----------------------------------------------------------------------------
--- Add a script handler.
--- @param file_extension String with the lower-case extension of the script.
--- @param func Function to handle this kind of scripts.
-----------------------------------------------------------------------------
-function M.addscripthandler (file_extension, func)
- assert (type(file_extension) == "string", "File extension must be a string")
- if strfind (file_extension, '%.', 1) then
- file_extension = strsub (file_extension, 2)
- end
- file_extension = strlower(file_extension)
- assert (type(func) == "function", "Handler must be a function")
-
- _script_handlers[file_extension] = func
-end
-
----------------------------------------------------------------------------
--- Obtains the handler corresponding to the given script path.
--- @param path String with a script path.
--- @return Function that handles it or nil.
-----------------------------------------------------------------------------
-function M.getscripthandler (path)
- local i,f, ext = strfind (path, "%.([^.]+)$")
- return _script_handlers[strlower(ext or '')]
-end
-
----------------------------------------------------------------------------
--- Execute the given path with the corresponding handler.
--- @param path String with a script path.
--- @return The returned values from the script.
----------------------------------------------------------------------------
-function M.handle (path)
- local h = M.getscripthandler (path) or default_handler
- return h (path)
-end
-
----------------------------------------------------------------------------
--- Sets "errorhandler" function
--- This function is called by Lua when an error occurs.
--- It receives the error message generated by Lua and it is resposible
--- for the final message which should be returned.
--- @param Function.
----------------------------------------------------------------------------
-function M.seterrorhandler (f)
- local tf = type(f)
- if tf == "function" then
- _errorhandler = f
- else
- error (format ("Invalid type: expected `function', got `%s'", tf))
- end
-end
-
----------------------------------------------------------------------------
--- Defines the "erroroutput" function
--- This function is called to generate the error output.
--- @param Function.
----------------------------------------------------------------------------
-function M.seterroroutput (f)
- local tf = type(f)
- if tf == "function" then
- _erroroutput = f
- else
- error (format ("Invalid type: expected `function', got `%s'", tf))
- end
-end
-
---
--- Stores all close functions in order they are set.
-local _close_functions = {
-}
-
----------------------------------------------------------------------------
--- Adds a function to be executed after the script.
--- @param f Function to be registered.
----------------------------------------------------------------------------
-function M.addclosefunction (f)
- local tf = type(f)
- if tf == "function" then
- tinsert (_close_functions, f)
- else
- error (format ("Invalid type: expected `function', got `%s'", tf))
- end
-end
-
---
--- Close function.
---
-local function close()
- for i = #_close_functions, 1, -1 do
- _close_functions[i]()
- end
-end
-
---
--- Stores all open functions in order they are set.
-local _open_functions = {
-}
-
----------------------------------------------------------------------------
--- Adds a function to be executed before the script.
--- @param f Function to be registered.
----------------------------------------------------------------------------
-function M.addopenfunction (f)
- local tf = type(f)
- if tf == "function" then
- tinsert (_open_functions, f)
- else
- error (format ("Invalid type: expected `function', got `%s'", tf))
- end
-end
-
---
--- Open function.
--- Call all defined open-functions in the order they were created.
---
-local function open()
- for i = #_open_functions, 1, -1 do
- _open_functions[i]()
- end
-end
-
---
--- Resets CGILua's state.
---
-local function reset ()
- M.script_path = false
- M.script_vpath, M.pdir, M.use_executable_name, M.urlpath, M.script_vdir, M.script_pdir,
- M.script_file, M.authentication, M.app_name =
- nil, nil, nil, nil, nil, nil, nil, nil, nil
- _maxfilesize = _default_maxfilesize
- _maxinput = _default_maxinput
- -- Error Handling
- _errorhandler = _default_errorhandler
- _erroroutput = _default_erroroutput
- -- Handlers
- _script_handlers = {}
- _open_functions = {}
- _close_functions = {}
- -- clean temporary files
- for i, v in ipairs(_tmpfiles) do
- _tmpfiles[i] = nil
- v.file:close()
- local _, err = remove(v.name)
- if err then
- error(err)
- end
- end
-end
-
----------------------------------------------------------------------------
--- Request processing.
----------------------------------------------------------------------------
-function M.main ()
- SAPI = _G.SAPI
- buildhandlers()
- -- Default handler values
- M.addscripthandler ("lua", M.doscript)
- M.addscripthandler ("lp", M.handlelp)
- -- Looks for an optional loader module
- M.pcall (function () M.loader = require"cgilua.loader" end)
-
- -- post.lua needs to be loaded after cgilua.lua is compiled
- M.pcall (function () M.post = require"cgilua.post" end)
-
- if M.loader then
- M.loader.init()
- end
-
- -- Build QUERY/POST tables
- if not M.pcall (getparams) then return nil end
-
- local result
- -- Executes the optional loader module
- if M.loader then
- M.loader.run()
- end
-
- -- Changing curent directory to the script's "physical" dir
- local curr_dir = lfs.currentdir ()
- M.pcall (function () lfs.chdir (M.script_pdir) end)
-
- -- Opening functions
- M.pcall (open)
-
- -- Executes the script
- result, err = M.pcall (function () return M.handle (M.script_file) end)
-
- -- Closing functions
- M.pcall (close)
- -- Changing to original directory
- M.pcall (function () lfs.chdir (curr_dir) end)
-
- -- Cleanup
- reset ()
- if result then -- script executed ok!
- return result
- end
-end
-
-return M
diff --git a/src/cgilua/cookies.lua b/src/cgilua/cookies.lua
index 17a7323..cf90e78 100755
--- a/src/cgilua/cookies.lua
+++ b/src/cgilua/cookies.lua
@@ -4,19 +4,19 @@
-- @release $Id: cookies.lua,v 1.8 2008/04/24 13:42:04 mascarenhas Exp $
----------------------------------------------------------------------------
-local cgilua = require"cgilua"
local os = require"os"
local string = require"string"
local urlcode = require"cgilua.urlcode"
+local cgilua = require"cgilua"
local error = error
-local format, gsub, strfind = string.format, string.gsub, string.find
+local format, gsub, strfind, strmatch = string.format, string.gsub, string.find, string.match
local date = os.date
local escape, unescape = urlcode.escape, urlcode.unescape
-local header = SAPI.Response.header
-local write = SAPI.Response.write
-local servervariable = SAPI.Request.servervariable
+local header = cgilua.Response.header
+local write = cgilua.Response.write
+local servervariable = cgilua.servervariable
local M = {}
@@ -81,7 +81,7 @@ function M.get (name)
cookies = ";" .. cookies .. ";"
cookies = gsub(cookies, "%s*;%s*", ";") -- remove extra spaces
local pattern = ";" .. name .. "=(.-);"
- local _, __, value = strfind(cookies, pattern)
+ local value = strmatch(cookies, pattern)
return value and unescape(value)
end
diff --git a/src/cgilua/dispatcher.lua b/src/cgilua/dispatcher.lua
index 8d66784..23c3b25 100755
--- a/src/cgilua/dispatcher.lua
+++ b/src/cgilua/dispatcher.lua
@@ -1,6 +1,9 @@
-- CGILua dispatcher module
-- @release $Id: dispatcher.lua,v 1.8 2007/12/07 18:49:49 carregal Exp $
+local cgilua = require"cgilua"
+local urlcode = require"cgilua.urlcode"
+local unpack = table.unpack or unpack
-- Checks if an URL matches a route pattern
local function route_match(url, pattern)
@@ -35,7 +38,7 @@ end
local function route_url(map_name, params, queryargs)
local queryparams = ""
if queryargs then
- queryparams = "?"..cgilua.urlcode.encodetable(queryargs)
+ queryparams = "?"..urlcode.encodetable(queryargs)
end
for i, v in ipairs(route_URLs) do
local pattern, f, name = unpack(v)
@@ -59,7 +62,7 @@ local function route(URLs)
URLs = {URLs}
end
route_URLs = URLs
- f, args = route_map(cgilua.script_vpath)
+ local f, args = route_map(cgilua.script_vpath)
if f then
return f(args)
diff --git a/src/cgilua/loader.lua b/src/cgilua/loader.lua
index 0430e61..ce648eb 100755
--- a/src/cgilua/loader.lua
+++ b/src/cgilua/loader.lua
@@ -61,7 +61,7 @@ function M.run()
elseif lfs.attributes(document_root.."/index.lp") then
cgilua.script_vpath = "/index.lp"
else
- error("Kepler is correctly configured, but you didn't provide a script!")
+ error("CGILua is correctly configured, but you didn't provide a script!")
end
end
-- checks if PATH_INFO refers to a valid file and ajusts the settings accordingly
diff --git a/src/cgilua/lp.lua b/src/cgilua/lp.lua
index 49f2487..13faaff 100755
--- a/src/cgilua/lp.lua
+++ b/src/cgilua/lp.lua
@@ -4,7 +4,8 @@
-- @release $Id: lp.lua,v 1.15 2008/12/11 17:40:24 mascarenhas Exp $
----------------------------------------------------------------------------
-local assert, error, loadstring = assert, error, loadstring
+local assert, error = assert, error
+local load = loadstring or load
local find, format, gsub, strsub, char = string.find, string.format, string.gsub, string.sub, string.char
local concat, tinsert = table.concat, table.insert
local open = io.open
@@ -101,13 +102,16 @@ local cache = {}
-- @return Function with the resulting translation.
function M.compile (string, chunkname, env)
- local s, err = cache[string]
+ local s = cache[string]
if not s then
s = M.translate (string)
cache[string] = s
end
- f, err = load (s, chunkname, "bt", env)
+ local f, err = load (s, chunkname, "bt", env)
if not f then error (err, 3) end
+ if _VERSION == "Lua 5.1" then
+ setfenv(f, env)
+ end
return f
end
diff --git a/src/cgilua/main.lua b/src/cgilua/main.lua
new file mode 100755
index 0000000..6809696
--- /dev/null
+++ b/src/cgilua/main.lua
@@ -0,0 +1,749 @@
+----------------------------------------------------------------------------
+-- CGILua library.
+--
+-- @release $Id: cgilua.lua,v 1.85 2009/06/28 22:42:34 tomas Exp $
+----------------------------------------------------------------------------
+
+local urlcode = require"cgilua.urlcode"
+local lp = require"cgilua.lp"
+local lfs = require"lfs"
+local debug = require"debug"
+local assert, error, ipairs, select, tostring, type, xpcall = assert, error, ipairs, select, tostring, type, xpcall
+local unpack = table.unpack or unpack
+local pairs = pairs
+local gsub, format, strfind, strlower, strsub, match = string.gsub, string.format, string.find, string.lower, string.sub, string.match
+local setmetatable = setmetatable
+local _open = io.open
+local tinsert, tremove, concat = table.insert, table.remove, table.concat
+local date = os.date
+local os_tmpname = os.tmpname
+local getenv = os.getenv
+local remove = os.remove
+lp.setoutfunc ("cgilua.put")
+lp.setcompatmode (true)
+
+-- Module return in first require
+local cgilua = {
+ _COPYRIGHT = "Copyright (C) 2003-2009 Kepler Project; Copyright (C) 2010-2022 The CGILua Authors.",
+ _DESCRIPTION = "CGILua is a tool for creating dynamic Web pages and manipulating input data from forms",
+ _VERSION = "CGILua 6.0",
+}
+
+-- local functions and variables
+local L = {
+
+}
+
+
+local function build_library_objects(enviroment, response)
+ local M = {
+ _COPYRIGHT = cgilua._COPYRIGHT,
+ _DESCRIPTION = cgilua._DESCRIPTION,
+ _VERSION = cgilua._VERSION,
+ }
+ --[[
+ ######################################################################
+ ######################################################################
+ ###################### Public ########################################
+ ######################################################################
+ ######################################################################
+ ]]
+
+ ---------------------------------------------------------------------------
+ -- gets an enviroment variable
+ ---------------------------------------------------------------------------
+ M.servervariable = function (name)
+ return enviroment[name]
+ end;
+
+ ---------------------------------------------------------------------------
+ -- Build Response table
+ ---------------------------------------------------------------------------
+ M.Response = {
+ contenttype = function (header)
+ response:content_type(header)
+ end,
+ errorlog = function (msg, errlevel)
+ enviroment.error:write (msg)
+ end,
+ header = function (header, value)
+ if response.headers[header] then
+ if type(response.headers[header]) == "table" then
+ table.insert(response.headers[header], value)
+ else
+ response.headers[header] = { response.headers[header], value }
+ end
+ else
+ response.headers[header] = value
+ end
+ end,
+ redirect = function (url)
+ response.status = 302
+ response.headers["Location"] = url
+ end,
+ status = response.status,
+ write = function (...)
+ response:write({...})
+ end,
+ }
+
+ ---------------------------------------------------------------------------
+ -- set response status
+ ---------------------------------------------------------------------------
+ M.setstatus = function (st)
+ response.status = st
+ end
+
+ ---------------------------------------------------------------------------
+ -- Adds a function to be executed before the script.
+ -- @param f Function to be registered.
+ ---------------------------------------------------------------------------
+ M.addopenfunction = function (f)
+ local tf = type(f)
+ if tf == "function" then
+ tinsert (L._open_functions, f)
+ else
+ error (format ("Invalid type: expected `function', got `%s'", tf))
+ end
+ end
+
+ ---------------------------------------------------------------------------
+ -- Adds a function to be executed after the script.
+ -- @param f Function to be registered.
+ ---------------------------------------------------------------------------
+ M.addclosefunction = function (f)
+ local tf = type(f)
+ if tf == "function" then
+ tinsert (L._close_functions, f)
+ else
+ error (format ("Invalid type: expected `function', got `%s'", tf))
+ end
+ end
+
+ ----------------------------------------------------------------------------
+ -- Add a script handler.
+ -- @param file_extension String with the lower-case extension of the script.
+ -- @param func Function to handle this kind of scripts.
+ ----------------------------------------------------------------------------
+ M.addscripthandler = function (file_extension, func)
+ assert (type(file_extension) == "string", "File extension must be a string")
+ if strfind(file_extension, '%.') then
+ file_extension = strsub (file_extension, 2)
+ end
+ file_extension = strlower(file_extension)
+ assert (type(func) == "function", "Handler must be a function")
+
+ L._script_handlers[file_extension] = func
+ end
+
+ ---------------------------------------------------------------------------
+ -- Obtains the handler corresponding to the given script path.
+ -- @param path String with a script path.
+ -- @return Function that handles it or nil.
+ ----------------------------------------------------------------------------
+ M.getscripthandler = function (path)
+ local ext = match(path, "%.([^.]+)$")
+ return L._script_handlers[strlower(ext or '')]
+ end
+
+ ---------------------------------------------------------------------------
+ -- Execute the given path with the corresponding handler.
+ -- @param path String with a script path.
+ -- @return The returned values from the script.
+ ---------------------------------------------------------------------------
+ M.handle = function (path)
+ local h = M.getscripthandler (path) or default_handler
+ return h (path)
+ end
+
+ ---------------------------------------------------------------------------
+ -- Sets "errorhandler" function
+ -- This function is called by Lua when an error occurs.
+ -- It receives the error message generated by Lua and it is resposible
+ -- for the final message which should be returned.
+ -- @param f Function.
+ ---------------------------------------------------------------------------
+ M.seterrorhandler = function (f)
+ local tf = type(f)
+ if tf == "function" then
+ L.errorhandler = f
+ else
+ error (format ("Invalid type: expected `function', got `%s'", tf))
+ end
+ end
+
+ ---------------------------------------------------------------------------
+ -- Defines the "erroroutput" function
+ -- This function is called to generate the error output.
+ -- @param f Function.
+ ---------------------------------------------------------------------------
+ M.seterroroutput = function (f)
+ local tf = type(f)
+ if tf == "function" then
+ L.erroroutput = f
+ else
+ error (format ("Invalid type: expected `function', got `%s'", tf))
+ end
+ end
+
+
+ ---------------------------------------------------------------------------
+ -- Returns a temporary file in a directory using a name generator
+ -- @param dir Base directory for the temporary file
+ -- @param namefunction Name generator function
+ ---------------------------------------------------------------------------
+ M.tmpfile = function (dir, namefunction)
+ dir = dir or M.tmp_path
+ namefunction = namefunction or M.tmpname
+ local tempname = namefunction()
+ local filename = dir.."/"..tempname
+ local file, err = _open(filename, "w+b")
+ if file then
+ tinsert(L._tmpfiles, {name = filename, file = file})
+ end
+ return file, err
+ end
+
+
+ ----------------------------------------------------------------------------
+ -- Preprocess the content of a mixed HTML file and output a complete
+ -- HTML document ( a 'Content-type' header is inserted before the
+ -- preprocessed HTML )
+ -- @param filename String with the name of the file to be processed.
+ -- @param env Optional environment
+ ----------------------------------------------------------------------------
+ M.handlelp = function (filename, env)
+ env = env or L.buildscriptenv()
+ M.htmlheader ()
+ lp.include (filename, env)
+ end
+
+ ----------------------------------------------------------------------------
+ -- Builds a handler that sends a header and the contents of the given file.
+ -- Sends the contents of the file to the output without processing it.
+ -- @param type String with the type of the header.
+ -- @param subtype String with the subtype of the header.
+ -- @return Function (which receives a filename as argument) that produces
+ -- the header and copies the content of the given file.
+ ----------------------------------------------------------------------------
+ M.buildplainhandler = function (type, subtype)
+ return function (filename)
+ local fh, err = _open (filename, "rb")
+ local contents = ""
+ if fh then
+ contents = fh:read("*a")
+ fh:close()
+ else
+ error(err)
+ end
+ M.header("Content-Lenght", #contents)
+ M.contentheader (type, subtype)
+ M.put (contents)
+ end
+ end
+
+ ----------------------------------------------------------------------------
+ -- Builds a handler that sends a header and the processed file.
+ -- Processes the file as a Lua Page.
+ -- @param type String with the type of the header.
+ -- @param subtype String with the subtype of the header.
+ -- @return Function (which receives a filename as argument) that produces
+ -- the header and processes the given file.
+ ----------------------------------------------------------------------------
+ M.buildprocesshandler = function (type, subtype)
+ return function (filename)
+ local env = L.buildscriptenv()
+ M.contentheader (type, subtype)
+ lp.include (filename, env)
+ end
+ end
+
+ ----------------------------------------------------------------------------
+ -- Create an URL path to be used as a link to a CGILua script
+ -- @param script String with the name of the script.
+ -- @param args Table with arguments to script (optional).
+ -- @return String in URL format.
+ ----------------------------------------------------------------------------
+ M.mkurlpath = function (script, args)
+ -- URL-encode the parameters to be passed do the script
+ local params = ""
+ if args then
+ params = "?"..urlcode.encodetable(args)
+ end
+ if strsub(script,1,1) == '/' or M.script_vdir == '/' then
+ return script .. params
+ else
+ return M.script_vdir .. script .. params
+ end
+ end
+
+ ----------------------------------------------------------------------------
+ -- Create an absolute URL containing the given URL path
+ -- @param path String with the path.
+ -- @param protocol String with the name of the protocol (default = "http").
+ -- @return String in URL format.
+ ----------------------------------------------------------------------------
+ M.mkabsoluteurl = function (path, protocol)
+ protocol = protocol or "http"
+ if path:sub(1,1) ~= '/' then
+ path = '/'..path
+ end
+ return format("%s://%s:%s%s",
+ protocol,
+ M.servervariable"SERVER_NAME",
+ M.servervariable"SERVER_PORT",
+ path)
+ end
+
+ ----------------------------------------------------------------------------
+ -- Extract the "directory" and "file" parts of a path
+ -- @param path String with a path.
+ -- @return String with the directory part.
+ -- @return String with the file part.
+ ----------------------------------------------------------------------------
+ M.splitonlast = function (path)
+ local dir,file = match(path,"^(.-)([^:/\\]*)$")
+ return dir,file
+ end
+
+ M.splitpath = M.splitonlast -- compatibility with previous versions
+
+ ----------------------------------------------------------------------------
+ -- Extracts the first and remaining parts of a path
+ -- @return String with the extracted part.
+ -- @return String with the remaining path.
+ ----------------------------------------------------------------------------
+ M.splitonfirst = function (path)
+ local first, rest = match(path, "^/([^:/\\]*)(.*)")
+ return first, rest
+ end
+
+
+ ----------------------------------------------------------------------------
+ -- Execute a script
+ -- If an error is found, Lua's error handler is called and this function
+ -- does not return
+ -- @param filename String with the name of the file to be processed.
+ -- @return The result of the execution of the file.
+ ----------------------------------------------------------------------------
+ M.doscript = function (filename)
+ local env = L.buildscriptenv()
+ local f, err = loadfile(filename, "bt", env)
+ if not f then
+ error (format ("Cannot execute `%s'. Exiting.\n%s", filename, err))
+ else
+ if _VERSION == "Lua 5.1" then
+ setfenv(f, env)
+ end
+ return M.pcall(f)
+ end
+ end
+
+ ----------------------------------------------------------------------------
+ -- Execute the file if there is no "file error".
+ -- If an error is found, and it is not a "file error", Lua 'error'
+ -- is called and this function does not return
+ -- @param filename String with the name of the file to be processed.
+ -- @return The result of the execution of the file or nil (in case the
+ -- file does not exists or if it cannot be opened).
+ -- @return It could return an error message if the file cannot be opened.
+ ----------------------------------------------------------------------------
+ M.doif = function (filename)
+ if not filename then return end -- no file
+ local f, err = _open(filename)
+ if not f then return nil, err end -- no file (or unreadable file)
+ f:close()
+ return M.doscript (filename)
+ end
+
+ ---------------------------------------------------------------------------
+ -- Set the maximum "total" input size allowed (in bytes)
+ -- @param nbytes Number of the maximum size (in bytes) of the whole POST data.
+ ---------------------------------------------------------------------------
+ M.setmaxinput = function(nbytes)
+ L.maxinput = nbytes
+ end
+
+ ---------------------------------------------------------------------------
+ -- Set the maximum size for an "uploaded" file (in bytes)
+ -- Might be less or equal than L.maxinput.
+ -- @param nbytes Number of the maximum size (in bytes) of a file.
+ ---------------------------------------------------------------------------
+ M.setmaxfilesize = function(nbytes)
+ L.maxfilesize = nbytes
+ end
+
+ ---------------------------------------------------------------------------
+ -- Default path for temporary files
+ ---------------------------------------------------------------------------
+ M.tmp_path = CGILUA_TMP or getenv("TEMP") or getenv ("TMP") or "/tmp"
+
+ ---------------------------------------------------------------------------
+ -- Default function for temporary names
+ -- @return a temporay name using os.tmpname
+ ---------------------------------------------------------------------------
+ M.tmpname = function ()
+ local tempname = os_tmpname()
+ -- Lua os.tmpname returns a full path in Unix, but not in Windows
+ -- so we strip the eventual prefix
+ tempname = gsub(tempname, "(/tmp/)", "")
+ return tempname
+ end
+
+ ----------------------------------------------------------------------------
+ -- Sends a header.
+ -- @name header
+ -- @class function
+ -- @param header String with the header.
+ -- @param value String with the corresponding value.
+ ----------------------------------------------------------------------------
+ M.header = function (...)
+ return M.Response.header (...)
+ end
+
+ ----------------------------------------------------------------------------
+ -- Sends a Content-type header.
+ -- @param type String with the type of the header.
+ -- @param subtype String with the subtype of the header.
+ ----------------------------------------------------------------------------
+ M.contentheader = function (type, subtype)
+ M.Response.contenttype (type..'/'..subtype)
+ end
+
+ ----------------------------------------------------------------------------
+ -- Sends the HTTP header "text/html".
+ ----------------------------------------------------------------------------
+ M.htmlheader = function ()
+ M.Response.contenttype ("text/html")
+ end
+
+ ----------------------------------------------------------------------------
+ -- Sends an HTTP header redirecting the browser to another URL
+ -- @param url String with the URL.
+ -- @param args Table with the arguments (optional).
+ ----------------------------------------------------------------------------
+ M.redirect = function (url, args)
+ if strfind(url,"^https?:") then
+ local params=""
+ if args then
+ params = "?"..urlcode.encodetable(args)
+ end
+ return M.Response.redirect(url..params)
+ else
+ local protocol = (M.servervariable"SERVER_PORT" == "443") and "https" or "http"
+ return M.Response.redirect(M.mkabsoluteurl(M.mkurlpath(url,args), protocol))
+ end
+ end
+
+ ----------------------------------------------------------------------------
+ -- Primitive error output function
+ -- @param msg String (or number) with the message.
+ -- @param level String with the error level (optional).
+ ----------------------------------------------------------------------------
+ M.errorlog = function (msg, level)
+ local t = type(msg)
+ if t == "string" or t == "number" then
+ M.Response.errorlog (msg, level)
+ else
+ error ("bad argument #1 to `cgilua.errorlog' (string expected, got "..t..")", 2)
+ end
+ end
+
+ ----------------------------------------------------------------------------
+ -- Converts all its arguments to strings before sending them to the server.
+ ----------------------------------------------------------------------------
+ M.print = function (...)
+ local args = { ... }
+ for i = 1, select("#",...) do
+ args[i] = tostring(args[i])
+ end
+ M.Response.write (concat(args,"\t"))
+ M.Response.write ("\n")
+ end
+
+ ----------------------------------------------------------------------------
+ -- Function 'put' sends its arguments (basically strings of HTML text)
+ -- to the server
+ -- Its basic implementation is to use Lua function 'write', which writes
+ -- each of its arguments (strings or numbers) to file _OUTPUT (a file
+ -- handle initialized with the file descriptor for stdout)
+ -- @name put
+ -- @class function
+ -- @param s String (or number) with output.
+ ----------------------------------------------------------------------------
+ M.put = function (...)
+ return M.Response.write (...)
+ end
+
+ ----------------------------------------------------------------------------
+ -- Returns the current errorhandler
+ ----------------------------------------------------------------------------
+ M._geterrorhandler = function(msg)
+ return L.errorhandler(msg)
+ end
+
+ ----------------------------------------------------------------------------
+ -- Executes a function using the CGILua error handler.
+ -- @param f Function to be called.
+ ----------------------------------------------------------------------------
+ M.pcall = function (f)
+ local results = {xpcall (f, L.errorhandler)}
+ local ok = results[1]
+ tremove(results, 1)
+ if ok then
+ if #results == 0 then results = { true } end
+ return unpack(results)
+ else
+ L.erroroutput (unpack(results))
+ end
+ end
+
+
+ --[[
+ ######################################################################
+ ######################################################################
+ ###################### Local #########################################
+ ######################################################################
+ ######################################################################
+ ]]
+
+ ----------------------------------------------------------------------
+ -- Internal state variables.
+ ----------------------------------------------------------------------
+ L.default_errorhandler = debug.traceback
+ L.errorhandler = L.default_errorhandler
+ L.default_erroroutput = function (msg)
+ if type(msg) ~= "string" and type(msg) ~= "number" then
+ msg = format ("bad argument #1 to 'error' (string expected, got %s)", type(msg))
+ end
+
+ -- Logging error
+ M.Response.errorlog (msg)
+ M.Response.errorlog (" ")
+
+ M.Response.errorlog (M.servervariable"REMOTE_ADDR")
+ M.Response.errorlog (" ")
+
+ M.Response.errorlog (date())
+ M.Response.errorlog ("\n")
+
+ -- Building user message
+ msg = gsub (gsub (msg, "\n", "<br>\n"), "\t", " ")
+ M.Response.contenttype ("text/html")
+ M.Response.write ("<html><head><title>CGILua Error</title></head><body>" .. msg .. "</body></html>")
+ end
+ L.erroroutput = L.default_erroroutput
+ L.default_maxfilesize = 512 * 1024
+ L.maxfilesize = L.default_maxfilesize
+ L.default_maxinput = 1024 * 1024
+ L.maxinput = L.default_maxinput
+ L.script_path = false
+
+ ----------------------------------------------------------------------
+ -- Define variables and build the cgilua.POST and cgilua.GET tables.
+ ----------------------------------------------------------------------
+ L.getparams = function()
+ local requestmethod = M.servervariable"REQUEST_METHOD"
+ -- Fill in the POST table.
+ M.POST = {}
+ if requestmethod == "POST" then
+ M.post.parsedata {
+ read = function (n) return enviroment.input:read(n) end;
+ discardinput = ap and ap.discard_request_body,
+ content_type = M.servervariable"CONTENT_TYPE",
+ content_length = M.servervariable"CONTENT_LENGTH",
+ maxinput = L.maxinput,
+ maxfilesize = L.maxfilesize,
+ args = M.POST,
+ }
+ end
+ -- Fill in the QUERY table.
+ M.QUERY = {}
+ urlcode.parsequery (M.servervariable"QUERY_STRING", M.QUERY)
+ end
+
+ ----------------------------------------------------------------------------
+ -- Builds the default handler table from cgilua.mime
+ ----------------------------------------------------------------------------
+ L.buildhandlers = function()
+ local mime = require "cgilua.mime"
+ for ext, mediatype in pairs(mime) do
+ local t, st = match(mediatype, "([^/]*)/([^/]*)")
+ M.addscripthandler(ext, M.buildplainhandler(t, st))
+ end
+ end
+
+ ----------------------------------------------------------------------
+ --
+ ----------------------------------------------------------------------
+ L.buildscriptenv = function()
+ local env = { cgilua = M, print = M.print, write = M.put }
+ setmetatable(env, { __index = _G, __newindex = _G })
+ return env
+ end
+
+ ----------------------------------------------------------------------
+ --
+ ----------------------------------------------------------------------
+ L._tmpfiles = { }
+
+ ----------------------------------------------------------------------
+ -- Stores all script handlers and the file extensions used to identify
+ -- them. Loads the default
+ ----------------------------------------------------------------------
+ L._script_handlers = { }
+
+ ----------------------------------------------------------------------
+ -- Default handler.
+ -- Sends the contents of the file to the output without processing it.
+ -- This relies in the browser being able to discover the content type
+ -- which is not reliable.
+ -- @param filename String with the name of the file.
+ ----------------------------------------------------------------------
+ L.default_handler = function (filename)
+ local fh, err = _open (filename, "rb")
+ local contents
+ if fh then
+ contents = fh:read("*a")
+ fh:close()
+ else
+ error(err)
+ end
+ M.header("Content-Lenght", #contents)
+ M.put ("\n")
+ M.put (contents)
+ end
+
+ ----------------------------------------------------------------------
+ -- Stores all close functions in order they are set.
+ ----------------------------------------------------------------------
+ L._close_functions = {
+ }
+
+ ----------------------------------------------------------------------
+ -- Close function.
+ ----------------------------------------------------------------------
+ L.close = function ()
+ for i = #L._close_functions, 1, -1 do
+ L._close_functions[i]()
+ end
+ end
+
+ ----------------------------------------------------------------------
+ -- Stores all open functions in order they are set.
+ ----------------------------------------------------------------------
+ L._open_functions = {
+ }
+
+ ----------------------------------------------------------------------
+ -- Open function.
+ -- Call all defined open-functions in the order they were created.
+ ----------------------------------------------------------------------
+ L.open = function ()
+ for i = #L._open_functions, 1, -1 do
+ L._open_functions[i]()
+ end
+ end
+
+ ----------------------------------------------------------------------
+ -- Resets CGILua's state.
+ ----------------------------------------------------------------------
+ L.reset = function ()
+ L.script_path = false
+ M.script_vpath, M.pdir, M.use_executable_name, M.urlpath, M.script_vdir, M.script_pdir,
+ M.script_file, M.authentication, M.app_name =
+ nil, nil, nil, nil, nil, nil, nil, nil, nil
+ L.maxfilesize = L.default_maxfilesize
+ L.maxinput = L.default_maxinput
+ -- Error Handling
+ L.errorhandler = L.default_errorhandler
+ L.erroroutput = L.default_erroroutput
+ -- Handlers
+ L._script_handlers = {}
+ L._open_functions = {}
+ L._close_functions = {}
+ -- clean temporary files
+ for i, v in ipairs(L._tmpfiles) do
+ L._tmpfiles[i] = nil
+ v.file:close()
+ local _, err = remove(v.name)
+ if err then
+ error(err)
+ end
+ end
+ M.Response = nil;
+ end
+
+ return M;
+end
+
+
+---------------------------------------------------------------------------
+-- Request processing.
+-- env: enviroment variables
+-- response: the response object
+---------------------------------------------------------------------------
+function cgilua.main (enviroment, response)
+ --validade response parameter
+ assert(type(response) == "table", "invalid parameter: response")
+ assert(response.content_type, "invalid parameter: response need to have a method content_type()")
+ assert(response.write, "invalid parameter: response need to have a method write()")
+ assert(response.headers, "invalid parameter: response need to have a atribute headers")
+ assert(response.status, "invalid parameter: response need to have a atribute status")
+
+ -- enviroment variables
+ _G.CGILUA_APPS = _G.CGILUA_APPS or enviroment.DOCUMENT_ROOT .. "/cgilua"
+ _G.CGILUA_CONF = _G.CGILUA_CONF or enviroment.DOCUMENT_ROOT .. "/cgilua"
+ _G.CGILUA_TMP = _G.CGILUA_TMP or os.getenv("TMP") or os.getenv("TEMP") or "/tmp"
+ _G.CGILUA_ISDIRECT = true
+
+ -- build library objects
+ local M = build_library_objects (enviroment, response);
+ package.loaded.cgilua = M;
+
+ -- Main function
+ L.buildhandlers()
+ -- Default handler values
+ M.addscripthandler ("lua", M.doscript)
+ M.addscripthandler ("lp", M.handlelp)
+ -- Looks for an optional loader module
+ M.pcall (function () M.loader = require"cgilua.loader" end)
+
+ -- post.lua needs to be loaded after cgilua.lua is compiled
+ M.pcall (function () M.post = require"cgilua.post" end)
+
+ if M.loader then
+ M.loader.init()
+ end
+
+ -- Build QUERY/POST tables
+ if not M.pcall (L.getparams) then return nil end
+
+ -- Executes the optional loader module
+ if M.loader then
+ M.loader.run()
+ end
+
+ -- Changing curent directory to the script's "physical" dir
+ local curr_dir = lfs.currentdir ()
+ M.pcall (function () lfs.chdir (M.script_pdir) end)
+
+ -- Opening functions
+ M.pcall (L.open)
+
+ -- Executes the script
+ -- "return" is not used anywhere
+ M.pcall (function () return M.handle (M.script_file) end)
+
+ -- Closing functions
+ M.pcall (L.close)
+ -- Changing to original directory
+ M.pcall (function () lfs.chdir (curr_dir) end)
+
+ -- Cleanup
+ L.reset ()
+
+ return response:finish();
+end
+
+return cgilua
diff --git a/src/cgilua/post.lua b/src/cgilua/post.lua
index 413b05e..97dc32b 100755
--- a/src/cgilua/post.lua
+++ b/src/cgilua/post.lua
@@ -13,27 +13,21 @@
-- maxfilesize = 512 * 1024,
-- args = params,
-- }
---
--- @release $Id: post.lua,v 1.17 2008/04/03 21:55:28 mascarenhas Exp $
----------------------------------------------------------------------------
local iterate = require"cgilua.readuntil".iterate
local urlcode = require"cgilua.urlcode"
local tmpfile = require"cgilua".tmpfile
-local assert, error, pairs, tonumber, tostring, type = assert, error, pairs, tonumber, tostring, type
-local getn, tinsert = table.getn, table.insert
-local format, gsub, strfind, strlower, strlen = string.format, string.gsub, string.find, string.lower, string.len
-local min = math.min
---local iterate = cgilua.readuntil.iterate
---local urlcode = cgilua.urlcode
---local tmpfile = cgilua.tmpfile
+local assert, error, pairs, tonumber, type = assert, error, pairs, tonumber, type
+local tinsert, tconcat = table.insert, table.concat
+local format, gmatch, strfind, strlower, strlen, strmatch = string.format, string.gmatch, string.find, string.lower, string.len, string.match
+local floor, min = math.floor, math.min
-- environment for processing multipart/form-data input
local boundary = nil -- boundary string that separates each 'part' of input
local maxfilesize = nil -- maximum size for file upload
local maxinput = nil -- maximum size of total POST data
-local inputfile = nil -- temporary file for inputting form-data
local bytesleft = nil -- number of bytes yet to be read
local content_type = nil -- request's content-type
-- local functions
@@ -46,20 +40,24 @@ local read = nil -- basic read function
-- Extract the boundary string from CONTENT_TYPE metavariable
--
local function getboundary ()
- local _,_,boundary = strfind (content_type, "boundary%=(.-)$")
- return "--"..boundary
+ local boundary = strmatch(content_type, "boundary=(.*)$")
+ if boundary then
+ return "--"..boundary
+ else
+ error("Error processing multipart/form-data.\nMissing boundary")
+ end
end
--
-- Create a table containing the headers of a multipart/form-data field
--
local function breakheaders (hdrdata)
- local headers = {}
- gsub (hdrdata, '([^%c%s:]+):%s+([^\n]+)', function(type,val)
- type = strlower(type)
- headers[type] = val
- end)
- return headers
+ local headers = {}
+ for name, value in gmatch(hdrdata, '([^%c%s:]+):%s+([^\n]+)') do
+ name = strlower(name)
+ headers[name] = value
+ end
+ return headers
end
--
@@ -71,11 +69,11 @@ end
--
local function readfieldheaders ()
local EOH = "\r\n\r\n" -- <CR><LF><CR><LF>
- local hdrdata = ""
- local out = function (str) hdrdata = hdrdata..str end
+ local hdrparts = {}
+ local out = function (str) tinsert(hdrparts, str) end
if readuntil (EOH, out) then
-- parse headers
- return breakheaders (hdrdata)
+ return breakheaders (tconcat(hdrparts))
else
-- no header found
return nil
@@ -86,28 +84,28 @@ end
-- Extract a field name (and possible filename) from its disposition header
--
local function getfieldnames (headers)
- local disposition_hdr = headers["content-disposition"]
- local attrs = {}
- if disposition_hdr then
- gsub(disposition_hdr, ';%s*([^%s=]+)="(.-)"', function(attr, val)
- attrs[attr] = val
- end)
- else
- error("Error processing multipart/form-data."..
- "\nMissing content-disposition header")
- end
- return attrs.name, attrs.filename
+ local disposition_hdr = headers["content-disposition"]
+ if not disposition_hdr then
+ error("Error processing multipart/form-data."..
+ "\nMissing content-disposition header")
+ end
+
+ local attrs = {}
+ for attr, value in gmatch(disposition_hdr, ';%s*([^%s=]+)="(.-)"') do
+ attrs[attr] = value
+ end
+ return attrs.name, attrs.filename
end
--
-- Read the contents of a 'regular' field to a string
--
local function readfieldcontents ()
- local value = ""
+ local parts = {}
local boundaryline = "\r\n"..boundary
- local out = function (str) value = value..str end
+ local out = function (str) tinsert(parts, str) end
if readuntil (boundaryline, out) then
- return value
+ return tconcat(parts)
else
error("Error processing multipart/form-data.\nUnexpected end of input\n")
end
@@ -129,7 +127,7 @@ local function fileupload (filename)
local sl = strlen (str)
if bytesread + sl > maxfilesize then
discardinput (bytesleft)
- error (format ("Maximum file size (%d kbytes) exceeded while uploading `%s'", maxfilesize / 1024, filename))
+ error (format ("Maximum file size (%d kbytes) exceeded while uploading `%s'", floor(maxfilesize / 1024), filename))
end
file:write (str)
bytesread = bytesread + sl
@@ -174,7 +172,8 @@ end
-- in its content-disposition header) a temporary file is created
-- and the field contents are written to it. In this case,
-- [[value]] has a table that contains the temporary file handle
--- (key 'file') and the file name (key 'filename'). Optional headers
+-- (key 'file'), the file name (key 'filename') and size of the file in bytes
+-- (key 'filesize'). Optional headers
-- included in the field description are also inserted into this table,
-- as (header_type=value) pairs.
--
@@ -182,16 +181,7 @@ end
-- contents.
--
local function Main (inputsize, args)
-
- -- create a temporary file for processing input data
- local inputf,err = tmpfile()
- if inputf == nil then
- discardinput(inputsize)
- error("Cannot create a temporary file.\n"..err)
- end
-
-- set the environment for processing the multipart/form-data
- inputfile = inputf
bytesleft = inputsize
maxfilesize = maxfilesize or inputsize
boundary = getboundary()
@@ -222,10 +212,10 @@ end
-- Initialize the library by setting the dependent functions:
-- content_type = value of "Content-type" header
-- content_length = value of "Content-length" header
--- read = function that can read POST data
--- discardinput (optional) = function that discard POST data
--- maxinput (optional) = limit of POST data (in bytes)
--- maxfilesize (optional) = limit of uploaded file(s) (in bytes)
+-- read = function that reads POST data
+-- discardinput (optional) = function that discards POST data
+-- maxinput (optional) = size limit of POST data (in bytes)
+-- maxfilesize (optional) = size limit applied to each uploaded file (in bytes)
--
local function init (defs)
assert (defs.read)
@@ -274,7 +264,7 @@ return {
bytesleft = inputsize
discardinput(inputsize)
error(format("Total size of incoming data (%d KB) exceeds configured maximum (%d KB)",
- inputsize /1024, maxinput / 1024))
+ floor(inputsize /1024), floor(maxinput / 1024)))
end
-- process the incoming data according to its content type
@@ -286,10 +276,9 @@ return {
urlcode.parsequery (read (inputsize), defs.args)
elseif strfind(contenttype, "multipart/form-data", 1, true) then
Main (inputsize, defs.args)
- elseif strfind (contenttype, "application/xml", 1, true) or strfind (contenttype, "text/xml", 1, true) or strfind (contenttype, "text/plain", 1, true) then
- tinsert (defs.args, read (inputsize))
else
- error("Unsupported Media Type: "..contenttype)
+ local input = read(inputsize)
+ tinsert (defs.args, input)
end
end,
}
diff --git a/src/cgilua/readuntil.lua b/src/cgilua/readuntil.lua
index 0f88b9a..7348af7 100755
--- a/src/cgilua/readuntil.lua
+++ b/src/cgilua/readuntil.lua
@@ -20,7 +20,7 @@ return {
local dellen = strlen(del)
local i, e
while true do
- i, e = strfind(current, del, 1, 1)
+ i, e = strfind(current, del, 1, true)
if i then break end
local new = inp()
if not new then break end
@@ -28,7 +28,7 @@ return {
local endcurrent = strsub(current, -dellen+1)
local border = endcurrent .. strsub(new, 1, dellen-1)
if strlen(current) < dellen or strlen(new) < dellen or
- strfind(border, del, 1, 1) then
+ strfind(border, del, 1, true) then
-- move last part of `current' to new block
current = strsub(current, 1, -dellen)
new = endcurrent .. new
diff --git a/src/cgilua/session.lua b/src/cgilua/session.lua
index e191b0a..166c802 100755
--- a/src/cgilua/session.lua
+++ b/src/cgilua/session.lua
@@ -9,7 +9,7 @@ local lfs = require"lfs"
local serialize = require"cgilua.serialize".serialize
local assert, error, ipairs, loadfile, next, tostring, type = assert, error, ipairs, loadfile, next, tostring, type
-local format, gsub, strfind, strsub = string.format, string.gsub, string.find, string.sub
+local format, gsub, strfind = string.format, string.gsub, string.find
local tinsert = table.insert
local _open = io.open
local remove, time = os.remove, os.time
@@ -225,8 +225,8 @@ end
-- This function should be called after the script is executed.
----------------------------------------------------------------------------
function M.close ()
- if next (cgilua.session.data) then
- M.save (id, cgilua.session.data)
+ if next (M.data) then
+ M.save (id, M.data)
id = nil
end
end
diff --git a/src/cgilua/urlcode.lua b/src/cgilua/urlcode.lua
index 88bf365..4bc3c55 100755
--- a/src/cgilua/urlcode.lua
+++ b/src/cgilua/urlcode.lua
@@ -81,7 +81,7 @@ function M.parsequery (query, args)
local insertfield, unescape = M.insertfield, M.unescape
gsub (query, "([^&=]+)=([^&=]*)&?",
function (key, val)
- M.insertfield (args, unescape(key), unescape(val))
+ insertfield (args, unescape(key), unescape(val))
end)
end
end
diff --git a/src/launchers/cgilua.cgi b/src/launchers/cgilua.cgi
index 6df1ba1..0480f50 100755
--- a/src/launchers/cgilua.cgi
+++ b/src/launchers/cgilua.cgi
@@ -9,14 +9,16 @@ pcall(require, "luarocks.require")
local common = require "wsapi.common"
local cgi = require "wsapi.cgi"
-local sapi = require "wsapi.sapi"
-
+local cgilua = require "cgilua.main"
+
local arg_filename = (...)
-local function sapi_loader(wsapi_env)
+local response = require "wsapi.response"
+local res = response.new()
+
+local function cgi_loader(wsapi_env)
common.normalize_paths(wsapi_env, arg_filename, "cgilua.cgi")
- return sapi.run(wsapi_env)
+ return cgilua.main(wsapi_env, res)
end
-cgi.run(sapi_loader)
-
\ No newline at end of file
+cgi.run(cgi_loader)
\ No newline at end of file
diff --git a/src/launchers/cgilua.fcgi b/src/launchers/cgilua.fcgi
index 4333589..20123fd 100644
--- a/src/launchers/cgilua.fcgi
+++ b/src/launchers/cgilua.fcgi
@@ -6,6 +6,7 @@
pcall(require, "luarocks.require")
+local fastcgi = require "wsapi.fastcgi"
local common = require "wsapi.common"
local ok, err = pcall(require, "wsapi.fastcgi")
@@ -30,4 +31,4 @@ local sapi_loader = common.make_isolated_launcher{
"PATH_TRANSLATED" }
}
-wsapi.fastcgi.run(sapi_loader)
+fastcgi.run(sapi_loader)
diff --git a/tests/test_lib.lua b/tests/test_lib.lua
index d40bdd3..38c3bc5 100755
--- a/tests/test_lib.lua
+++ b/tests/test_lib.lua
@@ -1,6 +1,6 @@
#!/usr/bin/env cgilua.cgi
local function getfield (t, f)
- for w in string.gfind(f, "[%w_]+") do
+ for w in string.gmatch(f, "[%w_]+") do
if not t then return nil end
t = t[w]
end
diff --git a/tests/test_main.lua b/tests/test_main.lua
index 10380cc..568759a 100755
--- a/tests/test_main.lua
+++ b/tests/test_main.lua
@@ -20,7 +20,7 @@ cgilua.serialize (cgilua.POST, cgilua.put)
cgilua.put "<br>\n"
cgilua.put ("Remote address: "..cgilua.servervariable"REMOTE_ADDR")
cgilua.put "<br>\n"
-cgilua.put ("Is persistent = "..tostring (SAPI.Info.ispersistent).."<br>\n")
+--cgilua.put ("Is persistent = "..tostring (SAPI.Info.ispersistent).."<br>\n")
cgilua.put ("ap="..tostring(ap).."<br>\n")
cgilua.put ("lfcgi="..tostring(lfcgi).."<br>\n")
diff --git a/tests/test_session.lua b/tests/test_session.lua
index aff75f5..90a1544 100755
--- a/tests/test_session.lua
+++ b/tests/test_session.lua
@@ -1,7 +1,7 @@
#!/usr/bin/env cgilua.cgi
cgilua.session = require"cgilua.session"
-cgilua.session.setdir"/tmp/"
-cgilua.session.enable ()
+cgilua.session.setsessiondir"/tmp/"
+cgilua.session.enablesession ()
function pt (tab)
for i, v in pairs (tab) do
diff --git a/tests/test_variables.lp b/tests/test_variables.lp
index 3a57e82..7abeaf5 100755
--- a/tests/test_variables.lp
+++ b/tests/test_variables.lp
@@ -1,4 +1,5 @@
#!/usr/bin/env cgilua.cgi
+
<table>
<% for _, var in pairs { "SERVER_SOFTWARE", "SERVER_NAME", "GATEWAY_INTERFACE", "SERVER_PROTOCOL", "SERVER_PORT", "REQUEST_METHOD", "PATH_INFO", "PATH_TRANSLATED", "SCRIPT_NAME", "QUERY_STRING", "REMOTE_HOST", "REMOTE_ADDR", "AUTH_TYPE", "REMOTE_USER", "REMOTE_IDENT", "CONTENT_TYPE", "CONTENT_LENGTH", "HTTP_REFERER", "HTTP_COOKIE", "SCRIPT_FILENAME", "DOCUMENT_ROOT", } do %>
<tr><td><%= var %><td>=<td>"<%= cgilua.servervariable(var) or "<i>not defined</i>"%>"</tr>