changeset 179:af6143756a9e

mod_muc_log_http: started new prosody theme
author Thilo Cestonaro <thilo@cestona.ro>
date Thu, 17 Jun 2010 11:16:12 +0200
parents 62f47a93b5b7
children f29be6c49501
files mod_muc_log_http/muc_log_http/mod_muc_log_http.lua mod_muc_log_http/muc_log_http/themes/prosody/components_bit.html mod_muc_log_http/muc_log_http/themes/prosody/components_body.html mod_muc_log_http/muc_log_http/themes/prosody/day_bann.html mod_muc_log_http/muc_log_http/themes/prosody/day_body.html mod_muc_log_http/muc_log_http/themes/prosody/day_dayLink.html mod_muc_log_http/muc_log_http/themes/prosody/day_kick.html mod_muc_log_http/muc_log_http/themes/prosody/day_message.html mod_muc_log_http/muc_log_http/themes/prosody/day_messageMe.html mod_muc_log_http/muc_log_http/themes/prosody/day_presence_join.html mod_muc_log_http/muc_log_http/themes/prosody/day_presence_leave.html mod_muc_log_http/muc_log_http/themes/prosody/day_presence_statusChange.html mod_muc_log_http/muc_log_http/themes/prosody/day_presence_statusText.html mod_muc_log_http/muc_log_http/themes/prosody/day_reason.html mod_muc_log_http/muc_log_http/themes/prosody/day_time.html mod_muc_log_http/muc_log_http/themes/prosody/day_title.html mod_muc_log_http/muc_log_http/themes/prosody/day_titleChange.html mod_muc_log_http/muc_log_http/themes/prosody/days_bit.html mod_muc_log_http/muc_log_http/themes/prosody/days_body.html mod_muc_log_http/muc_log_http/themes/prosody/doc.html mod_muc_log_http/muc_log_http/themes/prosody/month_day.html mod_muc_log_http/muc_log_http/themes/prosody/month_emptyDay.html mod_muc_log_http/muc_log_http/themes/prosody/month_footer.html mod_muc_log_http/muc_log_http/themes/prosody/month_header.html mod_muc_log_http/muc_log_http/themes/prosody/month_weekDay.html mod_muc_log_http/muc_log_http/themes/prosody/rooms_bit.html mod_muc_log_http/muc_log_http/themes/prosody/rooms_body.html mod_muc_log_http/muc_log_http/themes/prosody/year_title.html
diffstat 28 files changed, 197 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mod_muc_log_http/muc_log_http/mod_muc_log_http.lua	Mon Jun 14 22:13:33 2010 +0800
+++ b/mod_muc_log_http/muc_log_http/mod_muc_log_http.lua	Thu Jun 17 11:16:12 2010 +0200
@@ -214,7 +214,7 @@
         if i < days + 1 then
             local tmp = tostring("<span style='color:#DDDDDD'>"..tostring(i).."</span>");
             if dayCallback ~= nil and dayCallback.callback ~= nil then
-                tmp = dayCallback.callback(dayCallback.path, i, month, year, dayCallback.room);
+                tmp = dayCallback.callback(dayCallback.path, i, month, year, dayCallback.room, dayCallback.webPath);
             end
 			if tmp == nil then
             	tmp = tostring("<span style='color:#DDDDDD'>"..tostring(i).."</span>");
@@ -279,7 +279,8 @@
 	return "";
 end
 
-local function perDayCallback(path, day, month, year, room)
+local function perDayCallback(path, day, month, year, room, webPath)
+	local webPath = webPath or ""
 	local year = year;
 	if year > 2000 then
 		year = year - 2000;
@@ -288,7 +289,7 @@
 	local attributes, err = lfs.attributes(path.."/"..bareDay.."/"..room..".dat")
 	if attributes ~= nil and attributes.mode == "file" then
 		local s = html.days.bit;
-		s = s:gsub("###BARE_DAY###", bareDay);
+		s = s:gsub("###BARE_DAY###", webPath .. bareDay);
 		s = s:gsub("###DAY###", day);
 		return s;
 	end
@@ -302,21 +303,61 @@
 	local node, host, resource = splitJid(bareRoomJid);
 	local path = data_getpath(node, host, datastore);
 	local room = nil;
+	local nextRoom = "";
+	local previousRoom = "";
+	local rooms = "";
 	local attributes = nil;
+	local since = "";
+	local to = "";
+	local topic = "";
 	
 	path = path:gsub("/[^/]*$", "");
 	attributes = lfs.attributes(path);
 	if muc_hosts ~= nil and muc_hosts[host] and prosody.hosts[host] ~= nil and prosody.hosts[host].muc ~= nil and prosody.hosts[host].muc.rooms[bareRoomJid] ~= nil then
+		local found = 0;
+		for jid, room in pairs(prosody.hosts[host].muc.rooms) do
+			local node = splitJid(jid)
+			if not room._data.hidden and node then
+				if found == 0 then
+					previousRoom = node
+				elseif found == 1 then
+					nextRoom = node
+					found = -1
+				end
+				if jid == bareRoomJid then
+					found = 1
+				end
+
+				rooms = rooms .. html.days.rooms.bit:gsub("###ROOM###", node);
+			end
+		end
+
 		room = prosody.hosts[host].muc.rooms[bareRoomJid];
 		if room._data.hidden then
 			room = nil
 		end
 	end
 	if attributes ~= nil and room ~= nil then
+		local first = 1;
 		local alreadyDoneYears = {};
+		local temptime = {day=0, month=0, year=0};
+		topic = room._data.subject
+		if topic:len() > 60 then
+			topic = topic:sub(1, topic:find(" ", 50)) .. " ..."
+		end
 		for folder in lfs.dir(path) do
 			local year, month, day = folder:match("^(%d%d)(%d%d)(%d%d)");
 			if year ~= nil and alreadyDoneYears[year] == nil then
+				temptime.day = tonumber(day)
+				temptime.month = tonumber(month)
+				temptime.year = 2000 + tonumber(year)
+				if first == 1 then
+					to = tostring(os_date("%B %Y", os_time(temptime)))
+					first = 0
+				end
+
+				since = tostring(os_date("%B %Y", os_time(temptime)))
+				module:log("debug", "creating overview for: " .. tostring(since))
 				days = createYear(year, {callback=perDayCallback, path=path, room=node}) .. days;
 				alreadyDoneYears[year] = true;
 			end
@@ -325,6 +366,12 @@
 	
 	if days ~= "" then
 		tmp = html.days.body:gsub("###DAYS_STUFF###", days);
+		tmp = tmp:gsub("###PREVIOUS_ROOM###", previousRoom == "" and node or previousRoom);
+		tmp = tmp:gsub("###NEXT_ROOM###", nextRoom == "" and node or nextRoom);
+		tmp = tmp:gsub("###ROOMS###", rooms);
+		tmp = tmp:gsub("###ROOMTOPIC###", topic);
+		tmp = tmp:gsub("###SINCE###", since);
+		tmp = tmp:gsub("###TO###", to);
 		return tmp:gsub("###JID###", bareRoomJid);
 	end
 end
@@ -571,6 +618,19 @@
 	local year, month, day = bare_day:match("^(%d%d)(%d%d)(%d%d)");
 	local previousDay = findPreviousDay(bareRoomJid, bare_day);
 	local nextDay = findNextDay(bareRoomJid, bare_day);
+	local temptime = {day=0, month=0, year=0};
+	local path = data_getpath(node, host, datastore);
+	path = path:gsub("/[^/]*$", "");
+	local calendar = ""
+
+	if tonumber(year) <= 99 then
+		year = year + 2000;
+	end
+
+	temptime.day = tonumber(day)
+	temptime.month = tonumber(month)
+	temptime.year = tonumber(year)
+	calendar = createMonth(temptime.month, temptime.year, {callback=perDayCallback, path=path, room=node, webPath="../"}) or ""
 	
 	if bare_day ~= nil then
 		local data = data_load(node, host, datastore .. "/" .. bare_day);
@@ -609,14 +669,15 @@
 		end
 		if ret ~= "" then
 			if nextDay then
-				nextDay = html.day.dayLink:gsub("###DAY###", nextDay):gsub("###TEXT###", "next day &gt;&gt;")
+				nextDay = html.day.dayLink:gsub("###DAY###", nextDay):gsub("###TEXT###", "&gt;")
 			end
 			if previousDay then
-				previousDay = html.day.dayLink:gsub("###DAY###", previousDay):gsub("###TEXT###", "&lt;&lt; previous day");
+				previousDay = html.day.dayLink:gsub("###DAY###", previousDay):gsub("###TEXT###", "&lt;");
 			end
 			ret = ret:gsub("%%", "%%%%");
 			tmp = html.day.body:gsub("###DAY_STUFF###", ret):gsub("###JID###", bareRoomJid);
-			tmp = tmp:gsub("###YEAR###", year):gsub("###MONTH###", month):gsub("###DAY###", day);
+			tmp = tmp:gsub("###CALENDAR###", calendar);
+			tmp = tmp:gsub("###DATE###", tostring(os_date("%A, %B %d, %Y", os_time(temptime)))); 
 			tmp = tmp:gsub("###TITLE_STUFF###", html.day.title:gsub("###TITLE###", roomSubject));
 			tmp = tmp:gsub("###STATUS_CHECKED###", config.showStatus and "checked='checked'" or "");
 			tmp = tmp:gsub("###JOIN_CHECKED###", config.showJoin and "checked='checked'" or "");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/components_bit.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,1 @@
+<a href="###COMPONENT###/">###COMPONENT###</a><br />
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/components_body.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,3 @@
+<h2>Available Multi-User Chats:</h2><hr /><p>
+###COMPONENTS_STUFF###
+</p><hr />
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/day_bann.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,1 @@
+###TIME_STUFF###<font class="muc_bann"> *** ###VICTIM### got banned###REASON_STUFF###</font><br />
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/day_body.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,9 @@
+<h2>Logs for ###JID### on 20###YEAR###/###MONTH###/###DAY###</h2>
+<p>###TITLE_STUFF###</p>
+<font class="join_link"><a href="http://speeqe.com/room/###JID###/" target="_blank">Join room via speeqe.com</a></font><br />
+###PREVIOUS_LINK###   ###NEXT_LINK###<br />
+<input type="checkbox" onclick="showHide('joinLeave')" ###JOIN_CHECKED###/>show/hide joins and leaves</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+<input type="checkbox" onclick="showHide('status')" ###STATUS_CHECKED###/>show/hide status changes</button>
+<hr /><div id="main" style="overflow: auto;">
+###DAY_STUFF###
+</div><hr />
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/day_dayLink.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,1 @@
+<a href="../###DAY###/">###TEXT###</a>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/day_kick.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,1 @@
+###TIME_STUFF###<font class="muc_kick"> *** ###VICTIM### got kicked###REASON_STUFF###</font><br />
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/day_message.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,1 @@
+###TIME_STUFF###<font class="muc_msg_nick">&lt;###NICK###&gt;</font> ###MSG###<br />
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/day_messageMe.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,1 @@
+###TIME_STUFF###<font class="muc_msg_me">*###NICK### ###MSG###</font><br />
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/day_presence_join.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,1 @@
+<div name="joinLeave" style="display: ###SHOWHIDE###;">###TIME_STUFF###<font class="muc_join"> *** ###NICK### has joined the room</font><br /></div>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/day_presence_leave.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,1 @@
+<div name="joinLeave" style="display: ###SHOWHIDE###;">###TIME_STUFF###<font class="muc_leave"> *** ###NICK### has left the room</font><br /></div>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/day_presence_statusChange.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,1 @@
+<div name="status" style="display: ###SHOWHIDE###;">###TIME_STUFF###<font class="muc_statusChange"> *** ###NICK### shows as "###SHOW###"###STATUS_STUFF###</font><br /></div>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/day_presence_statusText.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,1 @@
+ and his status message is "###STATUS###"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/day_reason.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,1 @@
+, the reason was "###REASON###"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/day_time.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,1 @@
+<a name="###TIME###" href="####TIME###" class="timestuff">[###TIME###]</a> 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/day_title.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,1 @@
+Subject: <font class="muc_title">###TITLE###</font>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/day_titleChange.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,1 @@
+###TIME_STUFF###<font class="muc_titleChange"> *** ###NICK### changed the title to "###TITLE###"</font><br />
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/days_bit.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,1 @@
+<a href="###BARE_DAY###/">###DAY###</a><br />
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/days_body.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,42 @@
+
+			<div class="title">	
+				<span class="date" />
+				<span class="room_jid">###ROOM###@<a class="component" href="###COMPONENT###/">###COMPONENT###</a></span><br />
+				<span class="join_links">(join via <a href="###xmpp-link###">client</a> / <a href="###speeqe-link###">speeqe</a>)</span>
+
+			</div>
+
+			<div>
+				<span class="calendar">
+					<table rules="groups" cellpadding="5">
+						<thead>
+							<tr>
+								<td colspan="7">
+									<center>
+
+										<a class="nav" href="###previous_room###">&lt;</a>
+										<a class="nav" href="###rooms_on_component###">^</a>
+										<a class="nav" href="###next_room###">&gt;</a>
+									</center>
+								</td>
+							</tr>
+						</thead>
+						<tbody style="border: solid black 1px;">
+
+							<tr>
+								<th class="weekday">List of rooms for this component</th>
+							</tr>
+						</tbody>
+					</table>
+				</span>
+				<span class="room_topic"> <!-- Topic sollte auf X Zeichen begrenzt und dann durch "..." Punkt beenedet werden.  -->
+					http://spectrum.im | Welcome to the Spectrum support channel! | We are looking for package maintainers. | Logs: http://logs.spectrum.im/spectrum/
+				</span><br /><br />
+
+			</div>
+			
+			<div class="clear"></div>
+			
+			<div class="logs">###DAYS_STUFF###</div>
+			
+			<div class="footer"><img alt="Powered by Prosody" src="http://prosody.im/files/powered_by_prosody_80x30.png"></div>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/doc.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,47 @@
+<html>
+	<head>
+		<meta content="text/html; charset=ISO-8859-1"	http-equiv="content-type">
+
+		<title>###TITLE###</title>
+
+		<style type="text/css">
+			<!--
+				body, html {background-color: #FFFFFF;}
+				div.border {margin-left: 20pt; margin-right: 20pt;}
+				div.title {border-bottom: #f29b00 solid 3pt; padding-bottom: 3px; width: 100%;}
+				div.title {color: #000000; font-size: 24px; font-weight: bold; font-family: sans-serif; letter-spacing: 3px; text-decoration: none; margin-bottom: 3pt; }
+			
+				div.title .date {float:right; }
+			
+				div.footer {margin-top: 20pt; text-align: center;}
+			
+				.clear {clear: both;}
+
+				span.room_topic {color: #000000; font-size: 18px; font-family: sans-serif;}
+				span.room_jid {text-decoration: none;}
+				span.calendar {float: right; margin-left: 10pt;}
+				span.join_links {font-size: 9px; font-family: Verdana; letter-spacing: 1px;}
+				span.settings {}
+
+				div.logs {}
+				div.muc_settings {}
+
+				a {color: #6197df; text-decoration: none;}
+
+				a.nav {color: #6197df; font-family: monospace; letter-spacing: 7px; font-size: 24px; text-decoration: none;}
+				a.log {color: #6197df; text-decoration: none;}
+				a.log_today {color: #f29b00; text-decoration: none;}
+
+				.day {color: #DDDDDD; font: 12px Verdana; height: 17px; text-align: center; valign: middle;}
+				.weekday {font: 10px Verdana; height: 17px; color: #FFFFFF; background-color: #000000;}
+			//-->
+		</style>
+	</head>
+
+	<body>
+		<div class="border">
+###BODY_STUFF###
+		</div><!-- /border -->
+	</body>
+</html>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/month_day.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,1 @@
+    <td class="day" valign="middle" align="center">###DAY###</td>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/month_emptyDay.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,1 @@
+    <td class="day">&nbsp;</td>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/month_footer.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,1 @@
+</tbody></table>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/month_header.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,5 @@
+<table rules="groups" cellpadding="5">
+<thead><tr><td colspan="7"><center><H2><font size="2" face="Verdana">###TITLE###</font></H2></center></td></tr></thead>
+<tbody style="border: solid black 1px;">
+<tr>
+###WEEKDAYS###</tr>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/month_weekDay.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,1 @@
+    <th class="weekday" valign="middle" align="center">###DAY###</th>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/rooms_bit.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,1 @@
+<a href="###ROOM###/">###ROOM###</a><br />
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/rooms_body.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,3 @@
+<h2>Available rooms on ###COMPONENT###:</h2><hr /><p>
+###ROOMS_STUFF###
+</p><hr />
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_log_http/muc_log_http/themes/prosody/year_title.html	Thu Jun 17 11:16:12 2010 +0200
@@ -0,0 +1,1 @@
+<center><font style="font: bold 16px Verdana;"><a name="###YEAR###">###YEAR###</a></font></center>
\ No newline at end of file