comparison mod_http_muc_log/mod_http_muc_log.lua @ 1562:bc9cfd1c5391

mod_http_muc_log: Hide prev/next when on the edge of the archive
author Kim Alvefur <zash@zash.se>
date Sun, 09 Nov 2014 17:18:12 +0100
parents 2eaf4833969a
children 49ba05d75119
comparison
equal deleted inserted replaced
1561:2eaf4833969a 1562:bc9cfd1c5391
69 nav a.up{font-size:smaller;} 69 nav a.up{font-size:smaller;}
70 nav a.prev{float:left;} 70 nav a.prev{float:left;}
71 nav a.next{float:right;} 71 nav a.next{float:right;}
72 nav a.next::after{content:" →";} 72 nav a.next::after{content:" →";}
73 nav a.prev::before{content:"← ";} 73 nav a.prev::before{content:"← ";}
74 nav a:empty::after,nav a:empty::before{content:""}
74 a:link,a:visited{color:#2e3436;text-decoration:none;} 75 a:link,a:visited{color:#2e3436;text-decoration:none;}
75 a:link:hover,a:visited:hover{color:#3465a4;} 76 a:link:hover,a:visited:hover{color:#3465a4;}
76 ul,ol{padding:0;} 77 ul,ol{padding:0;}
77 li{list-style:none;} 78 li{list-style:none;}
78 hr{display:none;} 79 hr{display:none;}
270 st_name = item.name; 271 st_name = item.name;
271 st_type = item.attr.type; 272 st_type = item.attr.type;
272 }, i + 1; 273 }, i + 1;
273 end 274 end
274 275
275 local next_when = datetime.parse(date.."T12:00:00Z") + 86400; 276 local next_when = "";
276 local prev_when = datetime.parse(date.."T12:00:00Z") - 86400; 277 local prev_when = "";
277 278
278 module:log("debug", "Find next date with messages"); 279 module:log("debug", "Find next date with messages");
279 for key, message, when in archive:find(room, { 280 for key, message, when in archive:find(room, {
280 ["start"] = datetime.parse(date.."T00:00:00Z") + 86400; 281 ["start"] = datetime.parse(date.."T00:00:00Z") + 86400;
281 limit = math.huge; 282 limit = math.huge;
282 }) do 283 }) do
283 next_when = when; 284 next_when = datetime.date(when);
284 module:log("debug", "Next message: %s", datetime.datetime(when)); 285 module:log("debug", "Next message: %s", datetime.datetime(when));
285 break; 286 break;
286 end 287 end
287 288
288 module:log("debug", "Find prev date with messages"); 289 module:log("debug", "Find prev date with messages");
289 for key, message, when in archive:find(room, { 290 for key, message, when in archive:find(room, {
290 ["end"] = datetime.parse(date.."T00:00:00Z") - 1; 291 ["end"] = datetime.parse(date.."T00:00:00Z") - 1;
291 limit = math.huge; 292 limit = math.huge;
292 reverse = true; 293 reverse = true;
293 }) do 294 }) do
294 prev_when = when; 295 prev_when = datetime.date(when);
295 module:log("debug", "Previous message: %s", datetime.datetime(when)); 296 module:log("debug", "Previous message: %s", datetime.datetime(when));
296 break; 297 break;
297 end 298 end
298 299
299 return page_template{ 300 return page_template{
300 canonical = module:http_url() .. "/" .. path; 301 canonical = module:http_url() .. "/" .. path;
301 host = module.host; 302 host = module.host;
302 room = room; 303 room = room;
303 date = date; 304 date = date;
304 logs = table.concat(logs); 305 logs = table.concat(logs);
305 next = datetime.date(next_when); 306 next = next_when;
306 prev = datetime.date(prev_when); 307 prev = prev_when;
307 }; 308 };
308 end 309 end
309 310
310 local function list_rooms(event) 311 local function list_rooms(event)
311 local room_list, i = {}, 1; 312 local room_list, i = {}, 1;