diff -r 1aa894db3585 -r 0d8cc6971cdb mod_http_index/mod_http_index.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_http_index/mod_http_index.lua Thu Nov 20 14:48:46 2014 +0100
@@ -0,0 +1,145 @@
+local st = require "util.stanza";
+local url = require"socket.url";
+
+module:depends"http";
+
+-- local dump = require"util.serialization".new"dump".serialize;
+
+local function template(data)
+ --[[ DOC
+ Like util.template, but deals with plain text
+ Returns a closure that is called with a table of values
+ {name} is substituted for values["name"] and is XML escaped
+ {name!} is substituted without XML escaping
+ {name?} is optional and is replaced with an empty string if no value exists
+ ]]
+ return function(values)
+ return (data:gsub("{([^}]-)(%p?)}", function (name, opt)
+ local value = values[name];
+ if value then
+ if opt ~= "!" then
+ return st.xml_escape(value);
+ end
+ return value;
+ elseif opt == "?" then
+ return "";
+ end
+ end));
+ end
+end
+
+-- TODO Move templates into files
+local base = template(template[[
+
+
+