Mercurial > prosody-modules
comparison mod_muc_log_http/muc_log_http/mod_muc_log_http.lua @ 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 | 445efff314c4 |
children | af6143756a9e |
comparison
equal
deleted
inserted
replaced
145:890140ade4e5 | 146:2620bc59cca3 |
---|---|
212 end | 212 end |
213 end | 213 end |
214 if i < days + 1 then | 214 if i < days + 1 then |
215 local tmp = tostring("<span style='color:#DDDDDD'>"..tostring(i).."</span>"); | 215 local tmp = tostring("<span style='color:#DDDDDD'>"..tostring(i).."</span>"); |
216 if dayCallback ~= nil and dayCallback.callback ~= nil then | 216 if dayCallback ~= nil and dayCallback.callback ~= nil then |
217 tmp = dayCallback.callback(dayCallback.path, i, month, year); | 217 tmp = dayCallback.callback(dayCallback.path, i, month, year, dayCallback.room); |
218 end | 218 end |
219 if tmp == nil then | 219 if tmp == nil then |
220 tmp = tostring("<span style='color:#DDDDDD'>"..tostring(i).."</span>"); | 220 tmp = tostring("<span style='color:#DDDDDD'>"..tostring(i).."</span>"); |
221 else | 221 else |
222 logAvailableForMinimumOneDay = true; | 222 logAvailableForMinimumOneDay = true; |
264 local year = year; | 264 local year = year; |
265 local tmp; | 265 local tmp; |
266 if tonumber(year) <= 99 then | 266 if tonumber(year) <= 99 then |
267 year = year + 2000; | 267 year = year + 2000; |
268 end | 268 end |
269 local htmlStr = "<div name='yearDiv' style='padding: 40px; text-align: center;'>" .. html.year.title:gsub("###YEAR###", tostring(year)); | 269 local htmlStr = ""; |
270 for i=1, 12 do | 270 for i=1, 12 do |
271 tmp = createMonth(i, year, dayCallback); | 271 tmp = createMonth(i, year, dayCallback); |
272 if tmp then | 272 if tmp then |
273 htmlStr = htmlStr .. "<div style='float: left; padding: 5px;'>\n" .. tmp .. "</div>\n"; | 273 htmlStr = htmlStr .. "<div style='float: left; padding: 5px;'>\n" .. tmp .. "</div>\n"; |
274 end | 274 end |
275 end | 275 end |
276 return htmlStr .. "</div><br style='clear:both;'/> \n"; | 276 if htmlStr ~= "" then |
277 end | 277 return "<div name='yearDiv' style='padding: 40px; text-align: center;'>" .. html.year.title:gsub("###YEAR###", tostring(year)) .. htmlStr .. "</div><br style='clear:both;'/> \n"; |
278 | 278 end |
279 local function perDayCallback(path, day, month, year) | 279 return ""; |
280 end | |
281 | |
282 local function perDayCallback(path, day, month, year, room) | |
280 local year = year; | 283 local year = year; |
281 if year > 2000 then | 284 if year > 2000 then |
282 year = year - 2000; | 285 year = year - 2000; |
283 end | 286 end |
284 local bareDay = str_format("%.02d%.02d%.02d", year, month, day); | 287 local bareDay = str_format("%.02d%.02d%.02d", year, month, day); |
285 local attributes, err = lfs.attributes(path.."/"..bareDay) | 288 local attributes, err = lfs.attributes(path.."/"..bareDay.."/"..room..".dat") |
286 if attributes ~= nil and attributes.mode == "directory" then | 289 if attributes ~= nil and attributes.mode == "file" then |
287 local s = html.days.bit; | 290 local s = html.days.bit; |
288 s = s:gsub("###BARE_DAY###", bareDay); | 291 s = s:gsub("###BARE_DAY###", bareDay); |
289 s = s:gsub("###DAY###", day); | 292 s = s:gsub("###DAY###", day); |
290 return s; | 293 return s; |
291 end | 294 end |
312 if attributes ~= nil and room ~= nil then | 315 if attributes ~= nil and room ~= nil then |
313 local alreadyDoneYears = {}; | 316 local alreadyDoneYears = {}; |
314 for folder in lfs.dir(path) do | 317 for folder in lfs.dir(path) do |
315 local year, month, day = folder:match("^(%d%d)(%d%d)(%d%d)"); | 318 local year, month, day = folder:match("^(%d%d)(%d%d)(%d%d)"); |
316 if year ~= nil and alreadyDoneYears[year] == nil then | 319 if year ~= nil and alreadyDoneYears[year] == nil then |
317 days = createYear(year, {callback=perDayCallback, path=path}) .. days; | 320 days = createYear(year, {callback=perDayCallback, path=path, room=node}) .. days; |
318 alreadyDoneYears[year] = true; | 321 alreadyDoneYears[year] = true; |
319 end | 322 end |
320 end | 323 end |
321 end | 324 end |
322 | 325 |
573 local data = data_load(node, host, datastore .. "/" .. bare_day); | 576 local data = data_load(node, host, datastore .. "/" .. bare_day); |
574 if data ~= nil then | 577 if data ~= nil then |
575 for i=1, #data, 1 do | 578 for i=1, #data, 1 do |
576 local stanza = lom.parse(data[i]); | 579 local stanza = lom.parse(data[i]); |
577 if stanza ~= nil and stanza.attr ~= nil and stanza.attr.time ~= nil then | 580 if stanza ~= nil and stanza.attr ~= nil and stanza.attr.time ~= nil then |
578 local timeStuff = html.day.time:gsub("###TIME###", stanza.attr.time); | 581 local timeStuff = html.day.time:gsub("###TIME###", stanza.attr.time):gsub("###UTC###", stanza.attr.utc or stanza.attr.time); |
579 if stanza[1] ~= nil then | 582 if stanza[1] ~= nil then |
580 local nick; | 583 local nick; |
581 local tmp; | 584 local tmp; |
582 | 585 |
583 -- grep nick from "from" resource | 586 -- grep nick from "from" resource |