1.1 --- a/Makefile Sun Mar 11 12:42:52 2007 +0100
1.2 +++ b/Makefile Sun Mar 11 13:45:39 2007 +0100
1.3 @@ -68,5 +68,4 @@
1.4 -rm -Rf $(CONTENTDIR)
1.5 -rm -Rf $(VARDIR)
1.6 -rm cgi-bin/tek/*.o cgi-bin/tek/*.so cgi-bin/tek/web/*.o cgi-bin/tek/web/*.so
1.7 - -rm -f $(HTDIR)/*.html
1.8 -
1.9 + -rm -f $(HTDIR)/*.html $(HTDIR)/*.html.*
2.1 --- a/README Sun Mar 11 12:42:52 2007 +0100
2.2 +++ b/README Sun Mar 11 13:45:39 2007 +0100
2.3 @@ -155,12 +155,21 @@
2.4 DocumentRoot "/www/loona/mycompany.com/htdocs"
2.5 ScriptAlias /cgi-bin/ "/www/loona/mycompany.com/cgi-bin/"
2.6 <Directory "/www/loona/mycompany.com/htdocs">
2.7 + Options +MultiViews
2.8 AddHandler lua-script .lua
2.9 Action lua-script /cgi-bin/loona.cgi
2.10 DirectoryIndex index.html index.lua
2.11 </Directory>
2.12 </VirtualHost>
2.13 -
2.14 +
2.15 + The {{MultiViews}} option is only needed for multilingual sites. If a profile
2.16 + exists for more than one language, LOona renders static HTML pages with a
2.17 + language suffix added to their filename, like so:
2.18 +
2.19 + index.html.en
2.20 + index.html.fr
2.21 + index.html.jp
2.22 +
2.23 - 8. You should now be able to login to an empty LOona site at
2.24 {{http://mycompany.com/}}, and complete your setup using a
2.25 browser.
3.1 --- a/cgi-bin/loona.lua Sun Mar 11 12:42:52 2007 +0100
3.2 +++ b/cgi-bin/loona.lua Sun Mar 11 13:45:39 2007 +0100
3.3 @@ -15,8 +15,6 @@
3.4 require "tek.web.markup"
3.5 require "tek.util"
3.6
3.7 - local io = require "io"
3.8 -
3.9
3.10 local boxed_G = {
3.11 string = string, table = table,
3.12 @@ -41,7 +39,7 @@
3.13
3.14
3.15 _VERSION = 3
3.16 -_REVISION = 0
3.17 +_REVISION = 1
3.18
3.19
3.20 local function lookupname(tab, val)
3.21 @@ -131,16 +129,29 @@
3.22 success, msg = rename(tmppath, newpath)
3.23 assert(success, self:dbmsg("Cannot put symlink in place", msg))
3.24
3.25 + -- get languages of the current profile
3.26 +
3.27 + local plangs = { }
3.28 + local lmatch = "^" .. self.profile .. "_(%w+)$"
3.29 + for e in tek.util.readdir(self.config.contentdir) do
3.30 + local l = e:match(lmatch)
3.31 + if l then
3.32 + table.insert(plangs, l)
3.33 + end
3.34 + end
3.35 +
3.36 -- Unroll site to static HTML
3.37
3.38 - self:recursesections(self.sections, function(self, s, e, path)
3.39 - path = path and path .. "/" .. e.name or e.name
3.40 - if not e.notvisible then
3.41 - io.stderr:write("render... " .. path .. "\n")
3.42 - loona:dumphtml { requestpath = path }
3.43 - end
3.44 - return path
3.45 - end)
3.46 + for _, lang in ipairs(plangs) do
3.47 + local ext = (#plangs == 1 and ".html") or (".html." .. lang)
3.48 + self:recursesections(self.sections, function(self, s, e, path)
3.49 + path = path and path .. "/" .. e.name or e.name
3.50 + if not e.notvisible then
3.51 + loona:dumphtml { requestpath = path, requestlang = lang, htmlext = ext }
3.52 + end
3.53 + return path
3.54 + end)
3.55 + end
3.56
3.57 -- Update file cache
3.58
3.59 @@ -148,7 +159,8 @@
3.60 local cache = self.config.htmlcachedir
3.61
3.62 for e in tek.util.readdir(cache) do
3.63 - if e:match("^.*%.html$") then
3.64 + local f = e:match("^.*%.html%.?(%w*)$")
3.65 + if f and f ~= "tmp" then
3.66 local success, msg = remove(htdocs .. "/" .. e)
3.67 success, msg = remove(cache .. "/" .. e)
3.68 assert(success, self:dbmsg("Could not purge cached HTML file", msg))
3.69 @@ -156,7 +168,7 @@
3.70 end
3.71
3.72 for e in tek.util.readdir(cache) do
3.73 - local f = e:match("^(.*%.html)%.tmp$")
3.74 + local f = e:match("^(.*%.html%.?%w*)%.tmp$")
3.75 if f then
3.76 local success, msg = rename(cache .. "/" .. e, cache .. "/" .. f)
3.77 assert(success, self:dbmsg("Could not update cached HTML file", msg))
3.78 @@ -514,8 +526,10 @@
3.79 function loona:init()
3.80
3.81 -- get list of languages, in order of preference
3.82 + -- TODO: respect quality parameter, not just order
3.83
3.84 - self.langs = { self.args.lang and self.args.lang:match("^%w+$") }
3.85 + local l = self.requestlang or self.args.lang
3.86 + self.langs = { l and l:match("^%w+$") }
3.87 if self.config.browserlang then
3.88 local s = getenv("HTTP_ACCEPT_LANGUAGE")
3.89 while s do
3.90 @@ -992,11 +1006,17 @@
3.91
3.92
3.93 function loona:execute(fname)
3.94 - self:indexdynamic() -- TODO: this a solution?
3.95 + self:indexdynamic()
3.96 fname = fname or self.requesthandler
3.97 local parsed, msg = self:loadhtml(open(fname), "loona:out", fname)
3.98 assert(parsed, self:dbmsg("HTML/Lua parsing failed", msg))
3.99 self:runboxed(parsed)
3.100 +
3.101 +
3.102 + local fh = open("/tmp/dump", "wb")
3.103 + tek.dump(self, function(s) fh:write(s) end)
3.104 +
3.105 +
3.106 return self
3.107 end
3.108
3.109 @@ -1048,8 +1068,8 @@
3.110 if not o:isdynamic() then
3.111 local path = o.sectionname
3.112 path = path == o.config.defname and "index" or path
3.113 - local srcname = o.config.htdocsdir .. "/" .. path .. ".html"
3.114 - local dstname = o.config.htmlcachedir .. "/" .. path .. ".html.tmp"
3.115 + local srcname = o.config.htdocsdir .. "/" .. path .. o.htmlext
3.116 + local dstname = o.config.htmlcachedir .. "/" .. path .. o.htmlext .. ".tmp"
3.117 local fh, msg = open(srcname .. ".tmp", "wb")
3.118 assert(fh, self:dbmsg("Could not write cached HTML", msg))
3.119 fh:write(unpack(outbuf))
4.1 --- a/cgi-bin/loona/editable.lua Sun Mar 11 12:42:52 2007 +0100
4.2 +++ b/cgi-bin/loona/editable.lua Sun Mar 11 13:45:39 2007 +0100
4.3 @@ -394,7 +394,7 @@
4.4 <a name="preview"></a>
4.5 <%=loona.authuser%> :
4.6 <%=loona:uilink(loona.sectionpath, "[" .. loona.locale.PROFILE .. "]", "actioneditprofiles=true", "editkey=" .. editkey)%> :
4.7 - <%=loona.profile%> (<%=loona.lang%>)
4.8 + <%=loona.profile%>_<%=loona.lang%>
4.9 <%if loona.pubprofile == loona.profile then%>
4.10 <span class="warn">[<%=loona.locale.PUBLIC%>]</span>
4.11 <%end%>