[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Web development with Lua
- From: Luciano de Souza <luchyanus@...>
- Date: Mon, 17 Oct 2011 11:22:03 -0200
Step by step, let me describe what I could understand.
I use Ubuntu 10.10 and I have installed lua5.1, luarocks and apache.
The CGILUa documentation is appropriate to beginers, so I started to it.
The first step is to install cgilua, so:
luarocks install cgilua
Now, it's time to move cgilua from /home/luciano/.luarocks.. to a path
accessible from Lua interpreter.
/usr/lib/lua/5.1 is a very good option, since luasql and other Lua
libraries are already there.
I don't understand if cgilua can be used with Apache, but I know other
implementations under the Keppler Project can't.
If Apache is supported, now I need to create an example and,
considering it is a cgi application, to move it to /usr/lib/cgi-bin.
For each file, I should give permissions with: "sudo chmod +X".
In thesis, I would be ready to run my first example.
Is this the procedure?
2. The usage
A PHP like style is a pleasant way to code. So I wanted Lua pages. If I
understand, I can imagine two files:
test.lp - with the template
functions.lua - with a brand new bilion of Lua functions created by me.
In test.lp, I will have something like this:
<?lua loadfile('functions.lua') ?>
<title> <%=title %> </title>
<% for row in pairs(query) do %>
<tr><td><% row.name %></td><td><% row.phone %> </td></tr>
<% end %>
This could be a query from a database or simple an iteration of a Lua table.
If I am able to show something and process some user input, well, I have
enough to play a little bit. If I was correctly described the process
above, I have any idea how to show something. But how to process inputs?
<input type = "text" name = "name">
In the HTML code, I have created an input box identified with the
In Lua code, I will have something like:
contact:add(name, phone, address)
But how to connect "name", the Lua variable and "name", the HTML variable?
Am I in the correct way?
Em 17-10-2011 08:48, Pierre Chapuis escreveu:
On Mon, 17 Oct 2011 08:33:07 -0200, Luciano de Souza wrote:
I am sure Bamboo and Kepler are very good frameworks. I don't know,
but frameworks, in terms of productivity, are really so useful. But,
now, desiring to start in the simplest way, perhaps is more intersting
to test LunarCGI or Haserl.
Kepler is not a framework. It is a projects that provides a whole Web
stack for Lua. At least one of the components it provides (Orbit) is
a MVC framework but you don't need to use it.
CGILua is similar to LunarCGI, but sadly I just found out that it
is no longer maintained :(
Another choice for you could be to use WSAPI  directly. Maybe
you will find it too low level but I've done it and it is not as
complicated as it seems.