I thought it would be fun if I could write a DPI filter as easily as this: #!/usr/lib/dillo/bin/lua-dpi -- -*- lua -*- dpi [[ Content-type: text/html <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'> <html> <head><title>Hello World - Lua DPI</title></head> <body> From inside a Dillo DPI, Lua says "Hello World!". </body> </html> ]] Well, now I can! http://starurchin.org/dillo/dillo_lua_dpi.png It's still just a toy at the moment, but I'm pleased with it. Regards, Jeremy Henty
On Fri, Nov 26, 2010 at 05:05:26PM +0000, Jeremy Henty wrote:
I thought it would be fun if I could write a DPI filter as easily as this:
#!/usr/lib/dillo/bin/lua-dpi -- -*- lua -*-
dpi [[ Content-type: text/html
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'> <html> <head><title>Hello World - Lua DPI</title></head> <body> From inside a Dillo DPI, Lua says "Hello World!". </body> </html> ]]
Well, now I can!
http://starurchin.org/dillo/dillo_lua_dpi.png
It's still just a toy at the moment, but I'm pleased with it.
Hey nice! What's that lua-dpi? Is it a lua script? Can we have a look at it? Cheers, Johannes
On Sat, Nov 27, 2010 at 09:28:21PM +0100, Johannes Hofmann wrote:
What's that lua-dpi?
It's a small C program that embeds the Lua interpreter and extends its state with a global function called "dpi". I implemented "dpi" by modifying the main() function of the hello DPI filter in the Dillo source. Once lua-dpi has set up the Lua state it takes its first argument as the name of a Lua script which it loads and runs.
Can we have a look at it?
It's a patch to the Dillo source. I'm attaching it. I have made it minimally intrusive: the code is in a new directory called dpi/lua and the only changes to existing files are one-liner changes to dpi/Makefile.am (to make the build recurse into the lua subdirectory) and configure.in (to create dpi/lua/Makefile). NB: I have renamed the dpi to "lua" instead of "starurchin", so the URL is now "dpi:/lua/". Also, if you install Dillo to a prefix other than "/usr" you will have to change the #! line of lua.filter.dpi to match (that's a bug that I will fix if this project gets serious). The current API is much too simple to do anything non-trivial. I think the final version will look more like this: dpi(function (request) url = request.url; html = ...; request:reply(html); end); Regards, Jeremy Henty
On Fri, Nov 26, 2010 at 05:05:26PM +0000, Jeremy Henty wrote:
I thought it would be fun if I could write a DPI filter as easily as this:
#!/usr/lib/dillo/bin/lua-dpi -- -*- lua -*-
dpi [[ Content-type: text/html
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'> <html> <head><title>Hello World - Lua DPI</title></head> <body> From inside a Dillo DPI, Lua says "Hello World!". </body> </html> ]]
Well, now I can!
http://starurchin.org/dillo/dillo_lua_dpi.png
It's still just a toy at the moment, but I'm pleased with it.
Nice! For a few years I've entertained the idea of having lua scripting in dillo. Not only dpi, but also inside. Looks like dpi filters/servers are a good start. -- Cheers Jorge.-
On Tue, Nov 30, 2010 at 12:21:05PM -0300, Jorge Arellano Cid wrote:
For a few years I've entertained the idea of having lua scripting in dillo. Not only dpi, but also inside. Looks like dpi filters/servers are a good start.
I think Lua is a good match for Dillo - it's designed to be statically embedded and like Dillo it puts a very high premium on being small and fast. My original motivation was thinking of all the work it take to write eg. a proper fully-featured HTTPS dpi and thinking "it would be *so* much easier to do this in a scripting language instead of C/C++". Regards, Jeremy Henty
participants (3)
-
jcid@dillo.org
-
Johannes.Hofmann@gmx.de
-
onepoint@starurchin.org