Comparison

mod_http_muc_log/mod_http_muc_log.lua @ 1550:1b2823b41f7f

mod_http_muc_log: Strip some whitespace
author Kim Alvefur <zash@zash.se>
date Sat, 08 Nov 2014 15:54:49 +0100
parent 1549:f9f8bf82ece7
child 1552:81b3599c02fb
comparison
equal deleted inserted replaced
1549:f9f8bf82ece7 1550:1b2823b41f7f
73 ]] 73 ]]
74 74
75 local dates_template = template(base{ 75 local dates_template = template(base{
76 title = "Logs for room {room}"; 76 title = "Logs for room {room}";
77 body = [[ 77 body = [[
78 <base href="{room}/"> 78 <base href="{room}/">
79 <nav> 79 <nav>
80 <a href="..">↑</a> 80 <a href="..">↑</a>
81 </nav> 81 </nav>
82 <ul> 82 <ul>
83 {lines!}</ul> 83 {lines!}</ul>
84 ]]; 84 ]];
85 }) 85 })
86 86
87 local date_line_template = template[[ 87 local date_line_template = template[[
88 <li><a href="{date}">{date}</a></li> 88 <li><a href="{date}">{date}</a></li>
89 ]]; 89 ]];
90 90
91 local page_template = template(base{ 91 local page_template = template(base{
92 title = "Logs for room {room} on {date}"; 92 title = "Logs for room {room} on {date}";
93 body = [[ 93 body = [[
94 <nav> 94 <nav>
95 <a class="prev" href="{prev}">←</a> 95 <a class="prev" href="{prev}">←</a>
96 <a class="up" href="../{room}">↑</a> 96 <a class="up" href="../{room}">↑</a>
97 <a class="next" href="{next}">→</a> 97 <a class="next" href="{next}">→</a>
98 </nav> 98 </nav>
99 <ul> 99 <ul>
100 {logs!} 100 {logs!}
101 </ul> 101 </ul>
102 ]]; 102 ]];
103 }); 103 });
104 104
105 local line_templates = { 105 local line_templates = {
106 ["message<groupchat"] = template[[ 106 ["message<groupchat"] = template[[
107 <li id="{key}" class="{st_name}"><a href="#{key}"><time>{time}</time></a><dl><dt>{nick}</dt><dd>{body}</dd></dl></li> 107 <li id="{key}" class="{st_name}"><a href="#{key}"><time>{time}</time></a><dl><dt>{nick}</dt><dd>{body}</dd></dl></li>
108 ]]; 108 ]];
109 ["message<groupchat<subject"] = template[[ 109 ["message<groupchat<subject"] = template[[
110 <li id="{key}" class="{st_name} action subject"><a href="#{key}"><time>{time}</time></a><dl><dt>{nick}</dt><dd>changed subject to {subject}</dd></dl></li> 110 <li id="{key}" class="{st_name} action subject"><a href="#{key}"><time>{time}</time></a><dl><dt>{nick}</dt><dd>changed subject to {subject}</dd></dl></li>
111 ]]; 111 ]];
112 ["presence"] = template[[ 112 ["presence"] = template[[
113 <li id="{key}" class="action join"><a href="#{key}"><time>{time}</time></a><dl><dt>{nick}</dt><dd>joined</dd></dl></li> 113 <li id="{key}" class="action join"><a href="#{key}"><time>{time}</time></a><dl><dt>{nick}</dt><dd>joined</dd></dl></li>
114 ]]; 114 ]];
115 ["presence<unavailable"] = template[[ 115 ["presence<unavailable"] = template[[
116 <li id="{key}" class="action leave"><a href="#{key}"><time>{time}</time></a><dl><dt>{nick}</dt><dd>left</dd></dl></li> 116 <li id="{key}" class="action leave"><a href="#{key}"><time>{time}</time></a><dl><dt>{nick}</dt><dd>left</dd></dl></li>
117 ]]; 117 ]];
118 }; 118 };
119 119
120 local room_list_template = template(base{ 120 local room_list_template = template(base{
121 title = "Rooms on {host}"; 121 title = "Rooms on {host}";
122 body = [[ 122 body = [[
123 <dl> 123 <dl>
124 {rooms!} 124 {rooms!}
125 </dl> 125 </dl>
126 ]]; 126 ]];
127 }); 127 });
128 128
129 local room_item_template = template[[ 129 local room_item_template = template[[
130 <dt><a href="{room}">{name}</a></dt> 130 <dt><a href="{room}">{name}</a></dt>
131 <dd>{description?}</dd> 131 <dd>{description?}</dd>
219 module:log("debug", "Find next date with messages"); 219 module:log("debug", "Find next date with messages");
220 for key, message, when in archive:find(room, { 220 for key, message, when in archive:find(room, {
221 ["start"] = datetime.parse(date.."T00:00:00Z") + 86401; 221 ["start"] = datetime.parse(date.."T00:00:00Z") + 86401;
222 limit = math.huge; 222 limit = math.huge;
223 }) do 223 }) do
224 next_when = when; 224 next_when = when;
225 module:log("debug", "Next message: %s", datetime.datetime(when)); 225 module:log("debug", "Next message: %s", datetime.datetime(when));
226 break; 226 break;
227 end 227 end
228 228
229 module:log("debug", "Find prev date with messages"); 229 module:log("debug", "Find prev date with messages");
230 for key, message, when in archive:find(room, { 230 for key, message, when in archive:find(room, {
231 ["end"] = datetime.parse(date.."T00:00:00Z") - 1; 231 ["end"] = datetime.parse(date.."T00:00:00Z") - 1;
232 limit = math.huge; 232 limit = math.huge;
233 reverse = true; 233 reverse = true;
234 }) do 234 }) do
235 prev_when = when; 235 prev_when = when;
236 module:log("debug", "Previous message: %s", datetime.datetime(when)); 236 module:log("debug", "Previous message: %s", datetime.datetime(when));
237 break; 237 break;
238 end 238 end
239 239
240 return page_template{ 240 return page_template{
241 room = room; 241 room = room;
242 date = date; 242 date = date;