Software /
code /
prosody-modules
Changeset
146:2620bc59cca3
mod_muc_log_http: bugfix: multiple roomlogs in the same overview
bugfix: don't show empty years
author | Thilo Cestonaro <thilo@cestona.ro> |
---|---|
date | Mon, 29 Mar 2010 14:34:03 +0200 |
parents | 145:890140ade4e5 |
children | 147:4db80a46b064 |
files | mod_muc_log_http/muc_log_http/mod_muc_log_http.lua |
diffstat | 1 files changed, 11 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_muc_log_http/muc_log_http/mod_muc_log_http.lua Thu Mar 25 00:09:10 2010 +0100 +++ b/mod_muc_log_http/muc_log_http/mod_muc_log_http.lua Mon Mar 29 14:34:03 2010 +0200 @@ -214,7 +214,7 @@ if i < days + 1 then local tmp = tostring("<span style='color:#DDDDDD'>"..tostring(i).."</span>"); if dayCallback ~= nil and dayCallback.callback ~= nil then - tmp = dayCallback.callback(dayCallback.path, i, month, year); + tmp = dayCallback.callback(dayCallback.path, i, month, year, dayCallback.room); end if tmp == nil then tmp = tostring("<span style='color:#DDDDDD'>"..tostring(i).."</span>"); @@ -266,24 +266,27 @@ if tonumber(year) <= 99 then year = year + 2000; end - local htmlStr = "<div name='yearDiv' style='padding: 40px; text-align: center;'>" .. html.year.title:gsub("###YEAR###", tostring(year)); + local htmlStr = ""; for i=1, 12 do tmp = createMonth(i, year, dayCallback); if tmp then htmlStr = htmlStr .. "<div style='float: left; padding: 5px;'>\n" .. tmp .. "</div>\n"; end end - return htmlStr .. "</div><br style='clear:both;'/> \n"; + if htmlStr ~= "" then + return "<div name='yearDiv' style='padding: 40px; text-align: center;'>" .. html.year.title:gsub("###YEAR###", tostring(year)) .. htmlStr .. "</div><br style='clear:both;'/> \n"; + end + return ""; end -local function perDayCallback(path, day, month, year) +local function perDayCallback(path, day, month, year, room) local year = year; if year > 2000 then year = year - 2000; end local bareDay = str_format("%.02d%.02d%.02d", year, month, day); - local attributes, err = lfs.attributes(path.."/"..bareDay) - if attributes ~= nil and attributes.mode == "directory" then + local attributes, err = lfs.attributes(path.."/"..bareDay.."/"..room..".dat") + if attributes ~= nil and attributes.mode == "file" then local s = html.days.bit; s = s:gsub("###BARE_DAY###", bareDay); s = s:gsub("###DAY###", day); @@ -314,7 +317,7 @@ for folder in lfs.dir(path) do local year, month, day = folder:match("^(%d%d)(%d%d)(%d%d)"); if year ~= nil and alreadyDoneYears[year] == nil then - days = createYear(year, {callback=perDayCallback, path=path}) .. days; + days = createYear(year, {callback=perDayCallback, path=path, room=node}) .. days; alreadyDoneYears[year] = true; end end @@ -575,7 +578,7 @@ for i=1, #data, 1 do local stanza = lom.parse(data[i]); if stanza ~= nil and stanza.attr ~= nil and stanza.attr.time ~= nil then - local timeStuff = html.day.time:gsub("###TIME###", stanza.attr.time); + local timeStuff = html.day.time:gsub("###TIME###", stanza.attr.time):gsub("###UTC###", stanza.attr.utc or stanza.attr.time); if stanza[1] ~= nil then local nick; local tmp;