diff --git a/main.lua b/main.lua
index 7e7f02b..85defa3 100755
--- a/main.lua
+++ b/main.lua
@@ -1,10 +1,31 @@
#!/usr/bin/env lua
local fcgi = require"fcgi"
+local etlua = require"etlua"
apps = {
yqtemplate = require"yqtemplate"
}
+local template = etlua.compile[[
+
+
+
+ Annwan's CGI scripts
+
+
+ <% if app and app ~= nil then %>
+ No such application: <%= app -%>
+ <% end %>
+ Available Applications
+
+ <% for name, appdata in pairs(apps) do %>
+ - ><%=name -%>: <%= appdata.desc -%>
+ <% end %>
+
+
+
+]]
+
while fcgi.accept() do
app = fcgi.getenv("DOCUMENT_URI"):sub(6)
appfn = apps[app]
@@ -12,20 +33,9 @@ while fcgi.accept() do
appfn.run(fcgi)
else
fcgi.print"Content-Type: text/html; charset=utf-8\r\n\r\n"
- fcgi.print[[
-
-Annwan's CGI scripts
-]]
- if app and app ~= "" then
- fcgi.print("No such application: " .. app .. "
\n")
- end
- fcgi.print("Available applications:
")
- for n, x in pairs(apps) do
- fcgi.print("- " .. n .. " " .. x.desc .. "
")
- end
- fcgi.print[[
-
-
-]]
+ fcgi.print(template{
+ app = app,
+ apps = apps
+ })
end
end