Mercurial > prosody-modules
comparison mod_muc_log_http/muc_log_http/mod_muc_log_http.lua @ 392:369e665ae471
mod_muc_log_http: Show proper time period in the headline.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Mon, 25 Jul 2011 02:21:40 +0500 |
parents | 99e7ef4fc7d2 |
children | 20ef4a289d7d |
comparison
equal
deleted
inserted
replaced
391:99e7ef4fc7d2 | 392:369e665ae471 |
---|---|
289 if room._data.hidden then | 289 if room._data.hidden then |
290 room = nil | 290 room = nil |
291 end | 291 end |
292 end | 292 end |
293 if attributes ~= nil and room ~= nil then | 293 if attributes ~= nil and room ~= nil then |
294 local first = 1; | |
295 local alreadyDoneYears = {}; | 294 local alreadyDoneYears = {}; |
296 local temptime = {day=0, month=0, year=0}; | |
297 topic = room._data.subject or "(no subject)" | 295 topic = room._data.subject or "(no subject)" |
298 if topic:len() > 135 then | 296 if topic:len() > 135 then |
299 topic = topic:sub(1, topic:find(" ", 120)) .. " ..." | 297 topic = topic:sub(1, topic:find(" ", 120)) .. " ..." |
300 end | 298 end |
301 local folders = {}; | 299 local folders = {}; |
302 for folder in lfs.dir(path) do table.insert(folders, folder); end | 300 for folder in lfs.dir(path) do table.insert(folders, folder); end |
303 table.sort(folders); | 301 table.sort(folders); |
304 for _, folder in ipairs(folders) do | 302 for _, folder in ipairs(folders) do |
305 local year, month, day = folder:match("^(%d%d)(%d%d)(%d%d)"); | 303 local year, month, day = folder:match("^(%d%d)(%d%d)(%d%d)"); |
306 if year ~= nil and alreadyDoneYears[year] == nil then | 304 if year then |
307 temptime.day = tonumber(day) | 305 to = tostring(os_date("%B %Y", os_time({ day=tonumber(day), month=tonumber(month), year=2000+tonumber(year) }))); |
308 temptime.month = tonumber(month) | 306 if since == "" then since = to; end |
309 temptime.year = 2000 + tonumber(year) | 307 if not alreadyDoneYears[year] then |
310 if first == 1 then | 308 module:log("debug", "creating overview for: %s", to); |
311 to = tostring(os_date("%B %Y", os_time(temptime))) | 309 days = createYear(year, {callback=perDayCallback, path=path, room=node}) .. days; |
312 first = 0 | 310 alreadyDoneYears[year] = true; |
313 end | 311 end |
314 | |
315 since = tostring(os_date("%B %Y", os_time(temptime))) | |
316 module:log("debug", "creating overview for: " .. tostring(since)) | |
317 days = createYear(year, {callback=perDayCallback, path=path, room=node}) .. days; | |
318 alreadyDoneYears[year] = true; | |
319 end | 312 end |
320 end | 313 end |
321 end | 314 end |
322 | 315 |
323 tmp = html.days.body:gsub("###DAYS_STUFF###", days); | 316 tmp = html.days.body:gsub("###DAYS_STUFF###", days); |