# HG changeset patch # User Thilo Cestonaro # Date 1269866043 -7200 # Node ID 2620bc59cca36d41dc4b5d32c040b0e5538dcc17 # Parent 890140ade4e534ce4efd357d039bf1cb60f28056 mod_muc_log_http: bugfix: multiple roomlogs in the same overview bugfix: don't show empty years diff -r 890140ade4e5 -r 2620bc59cca3 mod_muc_log_http/muc_log_http/mod_muc_log_http.lua --- 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(""..tostring(i)..""); 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(""..tostring(i)..""); @@ -266,24 +266,27 @@ if tonumber(year) <= 99 then year = year + 2000; end - local htmlStr = "
" .. html.year.title:gsub("###YEAR###", tostring(year)); + local htmlStr = ""; for i=1, 12 do tmp = createMonth(i, year, dayCallback); if tmp then htmlStr = htmlStr .. "
\n" .. tmp .. "
\n"; end end - return htmlStr .. "

\n"; + if htmlStr ~= "" then + return "
" .. html.year.title:gsub("###YEAR###", tostring(year)) .. htmlStr .. "

\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;