Mercurial > prosody-modules
comparison mod_muc_log_http/mod_muc_log_http.lua @ 104:dc0fe152cadc
mod_muc_log_http: show only months where log is actually available
author | Thilo Cestonaro <thilo@cestona.ro> |
---|---|
date | Wed, 02 Dec 2009 23:41:06 +0100 |
parents | a10ab09096e2 |
children | f535306535f9 |
comparison
equal
deleted
inserted
replaced
103:0491aa849c91 | 104:dc0fe152cadc |
---|---|
283 local dow = tostring(os_date("%a", time)) | 283 local dow = tostring(os_date("%a", time)) |
284 local title = tostring(os_date("%B", time)); | 284 local title = tostring(os_date("%B", time)); |
285 local weekDays = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"}; | 285 local weekDays = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"}; |
286 local weekDay = 0; | 286 local weekDay = 0; |
287 local weeks = 1; | 287 local weeks = 1; |
288 local logAvailableForMinimumOneDay = false; | |
288 | 289 |
289 local weekDaysHtml = ""; | 290 local weekDaysHtml = ""; |
290 for _, tmp in ipairs(weekDays) do | 291 for _, tmp in ipairs(weekDays) do |
291 weekDaysHtml = weekDaysHtml .. html.month.weekDay:gsub("###DAY###", tmp) .. "\n"; | 292 weekDaysHtml = weekDaysHtml .. html.month.weekDay:gsub("###DAY###", tmp) .. "\n"; |
292 end | 293 end |
305 break; | 306 break; |
306 end | 307 end |
307 end | 308 end |
308 end | 309 end |
309 if i < days + 1 then | 310 if i < days + 1 then |
310 tmp = tostring(i); | 311 local tmp = tostring("<font color='#DDDDDD'>"..tostring(i).."</font>"); |
311 if dayCallback ~= nil and dayCallback.callback ~= nil then | 312 if dayCallback ~= nil and dayCallback.callback ~= nil then |
312 tmp = dayCallback.callback(dayCallback.path, i, month, year); | 313 tmp = dayCallback.callback(dayCallback.path, i, month, year); |
313 end | 314 end |
315 if tmp == nil then | |
316 tmp = tostring("<font color='#DDDDDD'>"..tostring(i).."</font>"); | |
317 else | |
318 logAvailableForMinimumOneDay = true; | |
319 end | |
314 htmlStr = htmlStr .. html.month.day:gsub("###DAY###", tmp) .. "\n"; | 320 htmlStr = htmlStr .. html.month.day:gsub("###DAY###", tmp) .. "\n"; |
315 end | 321 end |
316 | 322 |
317 if i >= days then | 323 if i >= days then |
318 break; | 324 break; |
343 weekDay = 1 | 349 weekDay = 1 |
344 htmlStr = htmlStr .. "</tr>\n"; | 350 htmlStr = htmlStr .. "</tr>\n"; |
345 end | 351 end |
346 end | 352 end |
347 htmlStr = htmlStr .. html.month.footer; | 353 htmlStr = htmlStr .. html.month.footer; |
348 return htmlStr; | 354 if logAvailableForMinimumOneDay then |
355 return htmlStr; | |
356 end | |
349 end | 357 end |
350 | 358 |
351 local function createYear(year, dayCallback) | 359 local function createYear(year, dayCallback) |
352 local year = year; | 360 local year = year; |
361 local tmp; | |
353 if tonumber(year) <= 99 then | 362 if tonumber(year) <= 99 then |
354 year = year + 2000; | 363 year = year + 2000; |
355 end | 364 end |
356 local htmlStr = "<div name='yearDiv' style='padding: 40px; text-align: center;'>" .. html.year.title:gsub("###YEAR###", tostring(year)); | 365 local htmlStr = "<div name='yearDiv' style='padding: 40px; text-align: center;'>" .. html.year.title:gsub("###YEAR###", tostring(year)); |
357 for i=1, 12 do | 366 for i=1, 12 do |
358 htmlStr = htmlStr .. "<div style='float: left; padding: 5px;'>\n" .. createMonth(i, year, dayCallback) .. "</div>\n"; | 367 tmp = createMonth(i, year, dayCallback); |
368 if tmp then | |
369 htmlStr = htmlStr .. "<div style='float: left; padding: 5px;'>\n" .. tmp .. "</div>\n"; | |
370 end | |
359 end | 371 end |
360 return htmlStr .. "</div><div style='clear:left;'/> \n"; | 372 return htmlStr .. "</div><br style='clear:both;'/> \n"; |
361 end | 373 end |
362 | 374 |
363 local function perDayCallback(path, day, month, year) | 375 local function perDayCallback(path, day, month, year) |
364 local year = year; | 376 local year = year; |
365 if year > 2000 then | 377 if year > 2000 then |
370 if attributes ~= nil and attributes.mode == "directory" then | 382 if attributes ~= nil and attributes.mode == "directory" then |
371 local s = html.days.bit; | 383 local s = html.days.bit; |
372 s = s:gsub("###BARE_DAY###", bareDay); | 384 s = s:gsub("###BARE_DAY###", bareDay); |
373 s = s:gsub("###DAY###", day); | 385 s = s:gsub("###DAY###", day); |
374 return s; | 386 return s; |
375 else | 387 end |
376 return tostring("<font color='#DDDDDD'>"..day.."</font>"); | 388 return; |
377 end | |
378 end | 389 end |
379 | 390 |
380 local function generateDayListSiteContentByRoom(bareRoomJid) | 391 local function generateDayListSiteContentByRoom(bareRoomJid) |
381 local days = ""; | 392 local days = ""; |
382 local arrDays = {}; | 393 local arrDays = {}; |