1.1 --- a/cgi-bin/loona.lua Sun Mar 11 13:53:27 2007 +0100
1.2 +++ b/cgi-bin/loona.lua Sun Mar 11 15:01:41 2007 +0100
1.3 @@ -99,7 +99,8 @@
1.4 srcprofile = srcprofile or self.profile
1.5 lang = lang or self.lang
1.6 local contentdir = self.config.contentdir
1.7 - local src = ("%s/%s_%s"):format(contentdir, srcprofile or self.profile, lang)
1.8 + local src = ("%s/%s_%s"):format(contentdir, srcprofile or self.profile,
1.9 + lang)
1.10 assert(posix.stat(src, "mode") == "directory",
1.11 self:dbmsg("Not a directory", src))
1.12 local dst = ("%s/%s_%s"):format(contentdir, newprofile, lang)
1.13 @@ -119,7 +120,6 @@
1.14
1.15
1.16 function loona:publishprofile(profile, lang)
1.17 -
1.18 lang = lang or self.lang
1.19 local contentdir = self.config.contentdir
1.20 local newpath = ("%s/current_%s"):format(contentdir, lang)
1.21 @@ -147,7 +147,8 @@
1.22 self:recursesections(self.sections, function(self, s, e, path)
1.23 path = path and path .. "/" .. e.name or e.name
1.24 if not e.notvisible then
1.25 - loona:dumphtml { requestpath = path, requestlang = lang, htmlext = ext }
1.26 + loona:dumphtml { requestpath = path, requestlang = lang,
1.27 + htmlext = ext }
1.28 end
1.29 return path
1.30 end)
1.31 @@ -163,20 +164,21 @@
1.32 if f and f ~= "tmp" then
1.33 local success, msg = remove(htdocs .. "/" .. e)
1.34 success, msg = remove(cache .. "/" .. e)
1.35 - assert(success, self:dbmsg("Could not purge cached HTML file", msg))
1.36 + assert(success,
1.37 + self:dbmsg("Could not purge cached HTML file", msg))
1.38 end
1.39 end
1.40 -
1.41 for e in tek.util.readdir(cache) do
1.42 local f = e:match("^(.*%.html%.?%w*)%.tmp$")
1.43 if f then
1.44 local success, msg = rename(cache .. "/" .. e, cache .. "/" .. f)
1.45 - assert(success, self:dbmsg("Could not update cached HTML file", msg))
1.46 + assert(success,
1.47 + self:dbmsg("Could not update cached HTML file", msg))
1.48 success, msg = rename(htdocs .. "/" .. e, htdocs .. "/" .. f)
1.49 - assert(success, self:dbmsg("Could not update cached HTML file", msg))
1.50 + assert(success,
1.51 + self:dbmsg("Could not update cached HTML file", msg))
1.52 end
1.53 end
1.54 -
1.55 end
1.56
1.57
1.58 @@ -438,7 +440,8 @@
1.59 -- external link (opens in a new window), no argument propagation
1.60
1.61 function loona:elink(target, text)
1.62 - return self:ilink(target, text or target, not self.config.extlinksamewindow and
1.63 + return self:ilink(target, text or target,
1.64 + not self.config.extlinksamewindow and
1.65 ' class="extlink" onclick="void(window.open(this.href, \'\', \'\')); return false;"')
1.66 end
1.67
1.68 @@ -482,8 +485,8 @@
1.69
1.70 local newent = { name = "new", label = "[+]", action="actionnew=true" }
1.71
1.72 -function loona:rmenu(level, linkf, path)
1.73 - local sub = (self.authuser and level == #self.submenus + 1) and
1.74 +function loona:rmenu(level, linkf, path, addnew)
1.75 + local sub = (addnew and level == #self.submenus + 1) and
1.76 { name = "new", entries = { }} or self.submenus[level]
1.77 if sub and sub.entries then
1.78 local visible = { }
1.79 @@ -492,7 +495,7 @@
1.80 table.insert(visible, e)
1.81 end
1.82 end
1.83 - if self.authuser then
1.84 + if addnew then
1.85 table.insert(visible, newent)
1.86 end
1.87 if #visible > 0 then
1.88 @@ -514,12 +517,13 @@
1.89 end
1.90
1.91 function loona:menulink(path, label, active, ...)
1.92 - self:out(('<a %shref="%s">%s</a>\n'):format(active and 'class="active" ' or "",
1.93 - self:href(path, unpack(arg)), label))
1.94 + self:out(('<a %shref="%s">%s</a>\n'):format(active and
1.95 + 'class="active" ' or "", self:href(path, unpack(arg)), label))
1.96 end
1.97
1.98 function loona:menu(level, linkf)
1.99 - self:rmenu(level or 1, linkf or menulink)
1.100 + local addnew = self.authuser and not self.ispubprofile
1.101 + self:rmenu(level or 1, linkf or menulink, nil, addnew)
1.102 end
1.103
1.104
1.105 @@ -563,7 +567,8 @@
1.106
1.107 -- get profile
1.108
1.109 - local checkprofile = self.authuser and self.args.profile or self.pubprofile or "default"
1.110 + local checkprofile =
1.111 + self.authuser and self.args.profile or self.pubprofile or "default"
1.112 for _, lang in ipairs(self.langs) do
1.113 if profiles[checkprofile .. "_" .. lang] then
1.114 self.profile = checkprofile
1.115 @@ -575,6 +580,8 @@
1.116 assert(self.profile and self.lang, "Invalid profile or language")
1.117
1.118
1.119 + self.ispubprofile = self.profile == self.pubprofile
1.120 +
1.121 -- write back language and profile
1.122
1.123 self.args.lang = self.lang ~= self.config.deflang and self.lang or nil
1.124 @@ -583,7 +590,8 @@
1.125
1.126 -- determine content directory pathname and section filename
1.127
1.128 - self.contentdir = ("%s/%s_%s"):format(self.config.contentdir, self.profile, self.lang)
1.129 + self.contentdir =
1.130 + ("%s/%s_%s"):format(self.config.contentdir, self.profile, self.lang)
1.131 self.indexfname = self.contentdir .. "/.sections"
1.132
1.133 -- load sections
1.134 @@ -628,12 +636,15 @@
1.135 assert(not editname:match("%W"),
1.136 dbmsg("Invalid section name", editname))
1.137 if not (section and (section.subs or section)[editname]) then
1.138 - local newpath =
1.139 - (self.sectionpath and (self.sectionpath .. "/")) .. editname
1.140 + local newpath = (self.sectionpath and
1.141 + (self.sectionpath .. "/")) .. editname
1.142 local s = self:addpath(newpath, { name = editname,
1.143 - label = self.args.editlabel ~= "" and self.args.editlabel or nil,
1.144 - title = self.args.edittitle ~= "" and self.args.edittitle or nil,
1.145 - redirect = self.args.editredirect ~= "" and self.args.editredirect or nil,
1.146 + label = self.args.editlabel ~= "" and
1.147 + self.args.editlabel or nil,
1.148 + title = self.args.edittitle ~= "" and
1.149 + self.args.edittitle or nil,
1.150 + redirect = self.args.editredirect ~= "" and
1.151 + self.args.editredirect or nil,
1.152 hidden = self.args.editvisibility and true,
1.153 secret = self.args.editsecrecy and true,
1.154 secure = self.args.editsecure and true,
1.155 @@ -657,8 +668,10 @@
1.156 self.section.hidden = self.args.editvisibility and true
1.157 self.section.secret = self.args.editsecrecy and true
1.158 self.section.secure = self.args.editsecure and true
1.159 - self.section.label = self.args.editlabel ~= "" and self.args.editlabel or nil
1.160 - self.section.title = self.args.edittitle ~= "" and self.args.edittitle or nil
1.161 + self.section.label = self.args.editlabel ~= "" and
1.162 + self.args.editlabel or nil
1.163 + self.section.title = self.args.edittitle ~= "" and
1.164 + self.args.edittitle or nil
1.165 self.section.redirect =
1.166 self.args.editredirect ~= "" and self.args.editredirect or nil
1.167 save = true
1.168 @@ -669,7 +682,7 @@
1.169
1.170 local t, i = self:checkpath(self.sectionpath)
1.171 if t and i > 1 then
1.172 - if self.profile == self.pubprofile and not self.args.actionconfirm then
1.173 + if self.ispubprofile and not self.args.actionconfirm then
1.174 useralert = {
1.175 text = self.locale.ALERT_MOVE_SECTION_IN_PUBLISHED_PROFILE,
1.176 confirm =
1.177 @@ -690,7 +703,7 @@
1.178
1.179 local t, i = self:checkpath(self.sectionpath)
1.180 if t and i < #t then
1.181 - if self.profile == self.pubprofile and not self.args.actionconfirm then
1.182 + if self.ispubprofile and not self.args.actionconfirm then
1.183 useralert = {
1.184 text = self.locale.ALERT_MOVE_SECTION_IN_PUBLISHED_PROFILE,
1.185 confirm =
1.186 @@ -795,7 +808,7 @@
1.187
1.188 if not self.args.actionconfirm then
1.189 useralert = {
1.190 - text = self.profile == self.pubprofile and
1.191 + text = self.ispubprofile and
1.192 self.locale.ALERT_DELETE_SECTION_IN_PUBLISHED_PROFILE or
1.193 self.locale.ALERT_DELETE_SECTION,
1.194 confirm =
2.1 --- a/cgi-bin/loona/editable.lua Sun Mar 11 13:53:27 2007 +0100
2.2 +++ b/cgi-bin/loona/editable.lua Sun Mar 11 15:01:41 2007 +0100
2.3 @@ -67,7 +67,7 @@
2.4 --
2.5 hidden = true
2.6 table.insert(functions, function()%>
2.7 - <%if loona.profile == loona.pubprofile then%>
2.8 + <%if loona.ispubprofile then%>
2.9 <h2><span class="warn"><%=loona.locale.WARNING_YOU_ARE_IN_PUBLISHED_PROFILE%></span></h2>
2.10 <%end%>
2.11 <form action="<%=loona.document%>" method="post" accept-charset="utf-8">
2.12 @@ -143,7 +143,7 @@
2.13 elseif loona.args.actioneditprops and editkey == "main" then
2.14 hidden = true
2.15 table.insert(functions, function()%>
2.16 - <%if loona.profile == loona.pubprofile then%>
2.17 + <%if loona.ispubprofile then%>
2.18 <h2><span class="warn"><%=loona.locale.WARNING_YOU_ARE_IN_PUBLISHED_PROFILE%></span></h2>
2.19 <%end%>
2.20 <form action="<%=loona.document%>" method="post" accept-charset="utf-8">
2.21 @@ -244,7 +244,7 @@
2.22 <%hiddenvars()%>
2.23 </fieldset>
2.24 </form>
2.25 - <%if loona.profile ~= loona.pubprofile then%>
2.26 + <%if not loona.ispubprofile then%>
2.27 <form action="<%=loona.document%>" method="post" accept-charset="utf-8">
2.28 <fieldset>
2.29 <legend>
2.30 @@ -269,7 +269,7 @@
2.31 <%end)
2.32 elseif loona.args.actionedit and editkey == loona.args.editkey then
2.33 if not loona.section.redirect then
2.34 - extramsg = loona.profile == loona.pubprofile and
2.35 + extramsg = loona.ispubprofile and
2.36 loona.locale.WARNING_YOU_ARE_IN_PUBLISHED_PROFILE
2.37 edit = loadcontent(contentdir, fname):gsub("\194\160", " ") -- TODO
2.38 changed = loona.section and (loona.section.revisiondate or loona.section.creationdate)
2.39 @@ -395,12 +395,12 @@
2.40 <%=loona.authuser%> :
2.41 <%=loona:uilink(loona.sectionpath, "[" .. loona.locale.PROFILE .. "]", "actioneditprofiles=true", "editkey=" .. editkey)%> :
2.42 <%=loona.profile%>_<%=loona.lang%>
2.43 - <%if loona.pubprofile == loona.profile then%>
2.44 + <%if loona.ispubprofile then%>
2.45 <span class="warn">[<%=loona.locale.PUBLIC%>]</span>
2.46 <%end%>
2.47 - <%=loona.sectionpath%>
2.48 <%end%>
2.49 - <%if loona.section and loona.profile ~= loona.pubprofile then%>
2.50 + <%if loona.section and not loona.ispubprofile then%>
2.51 <%=loona:uilink(loona.sectionpath, "[" .. loona.locale.EDIT .. "]", "actionedit=true", "editkey=" .. editkey)%>
2.52 <%if editkey == "main" then%>
2.53 - <%=loona:uilink(loona.sectionpath, "[" .. loona.locale.PROPERTIES .. "]", "actioneditprops=true", "editkey=" .. editkey)%>