Mercurial > prosody-modules
annotate mod_muc_log_http/muc_log_http/mod_muc_log_http.lua @ 530:3cc17ef98be0
mod_register_redirect: stick to one code "punctuation" style.
author | Marco Cirillo <maranda@lightwitch.org> |
---|---|
date | Sat, 07 Jan 2012 18:11:39 +0000 |
parents | 20ef4a289d7d |
children | 1a575bcbc843 |
rev | line source |
---|---|
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
1 -- Copyright (C) 2009 Thilo Cestonaro |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
2 -- |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
3 -- This project is MIT/X11 licensed. Please see the |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
4 -- COPYING file in the source package for more information. |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
5 -- |
102
a10ab09096e2
mod_muc_log_http: double check if muc_hosts is not nil, less logging, config var renamed to http_port back again
Thilo Cestonaro <thilo@cestona.ro>
parents:
101
diff
changeset
|
6 |
264
07c17b60229a
mod_muc_log_http: Mark as global.
Waqas Hussain <waqas20@gmail.com>
parents:
194
diff
changeset
|
7 module:set_global(); |
07c17b60229a
mod_muc_log_http: Mark as global.
Waqas Hussain <waqas20@gmail.com>
parents:
194
diff
changeset
|
8 |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
9 local prosody = prosody; |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
10 local tabSort = table.sort; |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
11 local tonumber = _G.tonumber; |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
12 local tostring = _G.tostring; |
116
f68a781efe81
mod_muc_log_http: support escaped urls
Thilo Cestonaro <thilo@cestona.ro>
parents:
115
diff
changeset
|
13 local strchar = string.char; |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
14 local strformat = string.format; |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
15 local splitJid = require "util.jid".split; |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
16 local config_get = require "core.configmanager".get; |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
17 local httpserver = require "net.httpserver"; |
344
2b0f2160fc61
mod_muc_log_http: Fix room name encoding/decoding (for UTF-8 room names)
Joseph Wallace <JosephWallace@letu.edu>
parents:
343
diff
changeset
|
18 local urlencode = require "net.http".urlencode; |
2b0f2160fc61
mod_muc_log_http: Fix room name encoding/decoding (for UTF-8 room names)
Joseph Wallace <JosephWallace@letu.edu>
parents:
343
diff
changeset
|
19 local urldecode = require "net.http".urldecode; |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
20 local datamanager = require "util.datamanager"; |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
21 local data_load, data_getpath = datamanager.load, datamanager.getpath; |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
22 local datastore = "muc_log"; |
102
a10ab09096e2
mod_muc_log_http: double check if muc_hosts is not nil, less logging, config var renamed to http_port back again
Thilo Cestonaro <thilo@cestona.ro>
parents:
101
diff
changeset
|
23 local urlBase = "muc_log"; |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
24 local config = nil; |
101
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
25 local tostring = _G.tostring; |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
26 local tonumber = _G.tonumber; |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
27 local os_date, os_time = os.date, os.time; |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
28 local str_format = string.format; |
105
cef943f0a551
mod_muc_log_http: themified ...
Thilo Cestonaro <thilo@cestona.ro>
parents:
104
diff
changeset
|
29 local io_open = io.open; |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
30 local themesParent = (module.path and module.path:gsub("[/\\][^/\\]*$", "") or (prosody.paths.plugins or "./plugins") .. "/muc_log_http") .. "/themes"; |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
31 |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
32 local lom = require "lxp.lom"; |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
33 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
34 --[[ LuaFileSystem |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
35 * URL: http://www.keplerproject.org/luafilesystem/index.html |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
36 * Install: luarocks install luafilesystem |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
37 * ]] |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
38 local lfs = require "lfs"; |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
39 |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
40 |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
41 --[[ |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
42 * Default templates for the html output. |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
43 ]]-- |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
44 local html = {}; |
183
9d4fd01443eb
mod_muc_log_http: ensure to have the default being "prosody"
Thilo Cestonaro <thilo@cestona.ro>
parents:
180
diff
changeset
|
45 local theme; |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
46 |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
47 local function checkDatastorePathExists(node, host, today, create) |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
48 create = create or false; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
49 local path = data_getpath(node, host, datastore, "dat", true); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
50 path = path:gsub("/[^/]*$", ""); |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
51 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
52 -- check existance |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
53 local attributes, err = lfs.attributes(path); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
54 if attributes == nil or attributes.mode ~= "directory" then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
55 module:log("warn", "muc_log folder isn't a folder: %s", path); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
56 return false; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
57 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
58 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
59 attributes, err = lfs.attributes(path .. "/" .. today); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
60 if attributes == nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
61 if create then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
62 return lfs.mkdir(path .. "/" .. today); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
63 else |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
64 return false; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
65 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
66 elseif attributes.mode == "directory" then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
67 return true; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
68 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
69 return false; |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
70 end |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
71 |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
72 local function htmlEscape(t) |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
73 if t then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
74 t = t:gsub("<", "<"); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
75 t = t:gsub(">", ">"); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
76 t = t:gsub("(http://[%a%d@%.:/&%?=%-_#%%~]+)", function(h) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
77 h = urlunescape(h) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
78 return "<a href='" .. h .. "'>" .. h .. "</a>"; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
79 end); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
80 t = t:gsub("\n", "<br />"); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
81 t = t:gsub("%%", "%%%%"); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
82 else |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
83 t = ""; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
84 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
85 return t; |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
86 end |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
87 |
393
20ef4a289d7d
mod_muc_log_http: Improved page titles a little.
Waqas Hussain <waqas20@gmail.com>
parents:
392
diff
changeset
|
88 function createDoc(body, title) |
20ef4a289d7d
mod_muc_log_http: Improved page titles a little.
Waqas Hussain <waqas20@gmail.com>
parents:
392
diff
changeset
|
89 assert(body, "<nil> HTTP response"); |
20ef4a289d7d
mod_muc_log_http: Improved page titles a little.
Waqas Hussain <waqas20@gmail.com>
parents:
392
diff
changeset
|
90 body = body:gsub("%%", "%%%%"); |
20ef4a289d7d
mod_muc_log_http: Improved page titles a little.
Waqas Hussain <waqas20@gmail.com>
parents:
392
diff
changeset
|
91 return html.doc:gsub("###BODY_STUFF###", body) |
20ef4a289d7d
mod_muc_log_http: Improved page titles a little.
Waqas Hussain <waqas20@gmail.com>
parents:
392
diff
changeset
|
92 :gsub("<title>muc_log</title>", "<title>"..(title and htmlEscape(title) or "Chatroom logs").."</title>"); |
20ef4a289d7d
mod_muc_log_http: Improved page titles a little.
Waqas Hussain <waqas20@gmail.com>
parents:
392
diff
changeset
|
93 end |
20ef4a289d7d
mod_muc_log_http: Improved page titles a little.
Waqas Hussain <waqas20@gmail.com>
parents:
392
diff
changeset
|
94 |
20ef4a289d7d
mod_muc_log_http: Improved page titles a little.
Waqas Hussain <waqas20@gmail.com>
parents:
392
diff
changeset
|
95 function urlunescape (escapedUrl) |
20ef4a289d7d
mod_muc_log_http: Improved page titles a little.
Waqas Hussain <waqas20@gmail.com>
parents:
392
diff
changeset
|
96 escapedUrl = escapedUrl:gsub("+", " ") |
20ef4a289d7d
mod_muc_log_http: Improved page titles a little.
Waqas Hussain <waqas20@gmail.com>
parents:
392
diff
changeset
|
97 escapedUrl = escapedUrl:gsub("%%(%x%x)", function(h) return strchar(tonumber(h,16)) end) |
20ef4a289d7d
mod_muc_log_http: Improved page titles a little.
Waqas Hussain <waqas20@gmail.com>
parents:
392
diff
changeset
|
98 escapedUrl = escapedUrl:gsub("\r\n", "\n") |
20ef4a289d7d
mod_muc_log_http: Improved page titles a little.
Waqas Hussain <waqas20@gmail.com>
parents:
392
diff
changeset
|
99 return escapedUrl |
20ef4a289d7d
mod_muc_log_http: Improved page titles a little.
Waqas Hussain <waqas20@gmail.com>
parents:
392
diff
changeset
|
100 end |
20ef4a289d7d
mod_muc_log_http: Improved page titles a little.
Waqas Hussain <waqas20@gmail.com>
parents:
392
diff
changeset
|
101 |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
102 local function generateComponentListSiteContent() |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
103 local components = ""; |
390
8090d246c268
mod_muc_log_http: Removed some more code. Module now no longer attempts to track muc_log hosts on its own.
Waqas Hussain <waqas20@gmail.com>
parents:
389
diff
changeset
|
104 for component,host in pairs(hosts) do |
8090d246c268
mod_muc_log_http: Removed some more code. Module now no longer attempts to track muc_log hosts on its own.
Waqas Hussain <waqas20@gmail.com>
parents:
389
diff
changeset
|
105 if host.modules.muc and host.modules.muc_log then |
8090d246c268
mod_muc_log_http: Removed some more code. Module now no longer attempts to track muc_log hosts on its own.
Waqas Hussain <waqas20@gmail.com>
parents:
389
diff
changeset
|
106 components = components .. html.components.bit:gsub("###COMPONENT###", component); |
8090d246c268
mod_muc_log_http: Removed some more code. Module now no longer attempts to track muc_log hosts on its own.
Waqas Hussain <waqas20@gmail.com>
parents:
389
diff
changeset
|
107 end |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
108 end |
393
20ef4a289d7d
mod_muc_log_http: Improved page titles a little.
Waqas Hussain <waqas20@gmail.com>
parents:
392
diff
changeset
|
109 return (html.components.body:gsub("###COMPONENTS_STUFF###", components)); |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
110 end |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
111 |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
112 local function generateRoomListSiteContent(component) |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
113 local rooms = ""; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
114 if prosody.hosts[component] and prosody.hosts[component].muc ~= nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
115 for jid, room in pairs(prosody.hosts[component].muc.rooms) do |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
116 local node = splitJid(jid); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
117 if not room._data.hidden and node then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
118 rooms = rooms .. html.rooms.bit:gsub("###ROOM###", node):gsub("###COMPONENT###", component); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
119 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
120 end |
393
20ef4a289d7d
mod_muc_log_http: Improved page titles a little.
Waqas Hussain <waqas20@gmail.com>
parents:
392
diff
changeset
|
121 return html.rooms.body:gsub("###ROOMS_STUFF###", rooms):gsub("###COMPONENT###", component), "Chatroom logs for "..component; |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
122 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
123 end |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
124 |
101
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
125 -- Calendar stuff |
386
d54dbbfda3bb
mod_muc_log_http: Simplified calculating day count for a month.
Waqas Hussain <waqas20@gmail.com>
parents:
385
diff
changeset
|
126 local function get_days_for_month(month, year) |
d54dbbfda3bb
mod_muc_log_http: Simplified calculating day count for a month.
Waqas Hussain <waqas20@gmail.com>
parents:
385
diff
changeset
|
127 if month == 2 then |
d54dbbfda3bb
mod_muc_log_http: Simplified calculating day count for a month.
Waqas Hussain <waqas20@gmail.com>
parents:
385
diff
changeset
|
128 local is_leap_year = (year % 4 == 0 and year % 100 ~= 0) or year % 400 == 0; |
d54dbbfda3bb
mod_muc_log_http: Simplified calculating day count for a month.
Waqas Hussain <waqas20@gmail.com>
parents:
385
diff
changeset
|
129 return is_leap_year and 29 or 28; |
d54dbbfda3bb
mod_muc_log_http: Simplified calculating day count for a month.
Waqas Hussain <waqas20@gmail.com>
parents:
385
diff
changeset
|
130 elseif (month < 8 and month%2 == 1) or (month >= 8 and month%2 == 0) then |
d54dbbfda3bb
mod_muc_log_http: Simplified calculating day count for a month.
Waqas Hussain <waqas20@gmail.com>
parents:
385
diff
changeset
|
131 return 31; |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
132 end |
386
d54dbbfda3bb
mod_muc_log_http: Simplified calculating day count for a month.
Waqas Hussain <waqas20@gmail.com>
parents:
385
diff
changeset
|
133 return 30; |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
134 end |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
135 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
136 local function createMonth(month, year, dayCallback) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
137 local htmlStr = html.month.header; |
386
d54dbbfda3bb
mod_muc_log_http: Simplified calculating day count for a month.
Waqas Hussain <waqas20@gmail.com>
parents:
385
diff
changeset
|
138 local days = get_days_for_month(month, year); |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
139 local time = os_time{year=year, month=month, day=1}; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
140 local dow = tostring(os_date("%a", time)) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
141 local title = tostring(os_date("%B", time)); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
142 local weekDays = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"}; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
143 local weekDay = 0; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
144 local weeks = 1; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
145 local logAvailableForMinimumOneDay = false; |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
146 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
147 local weekDaysHtml = ""; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
148 for _, tmp in ipairs(weekDays) do |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
149 weekDaysHtml = weekDaysHtml .. html.month.weekDay:gsub("###DAY###", tmp) .. "\n"; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
150 end |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
151 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
152 htmlStr = htmlStr:gsub("###TITLE###", title):gsub("###WEEKDAYS###", weekDaysHtml); |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
153 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
154 for i = 1, 31 do |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
155 weekDay = weekDay + 1; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
156 if weekDay == 1 then htmlStr = htmlStr .. "<tr>\n"; end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
157 if i == 1 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
158 for _, tmp in ipairs(weekDays) do |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
159 if dow ~= tmp then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
160 htmlStr = htmlStr .. html.month.emptyDay .. "\n"; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
161 weekDay = weekDay + 1; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
162 else |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
163 break; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
164 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
165 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
166 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
167 if i < days + 1 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
168 local tmp = tostring(i); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
169 if dayCallback ~= nil and dayCallback.callback ~= nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
170 tmp = dayCallback.callback(dayCallback.path, i, month, year, dayCallback.room, dayCallback.webPath); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
171 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
172 if tmp == nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
173 tmp = tostring(i); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
174 else |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
175 logAvailableForMinimumOneDay = true; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
176 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
177 htmlStr = htmlStr .. html.month.day:gsub("###DAY###", tmp) .. "\n"; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
178 end |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
179 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
180 if i >= days then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
181 break; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
182 end |
101
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
183 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
184 if weekDay == 7 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
185 weekDay = 0; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
186 weeks = weeks + 1; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
187 htmlStr = htmlStr .. "</tr>\n"; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
188 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
189 end |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
190 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
191 if weekDay + 1 < 8 or weeks < 6 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
192 weekDay = weekDay + 1; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
193 if weekDay > 7 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
194 weekDay = 1; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
195 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
196 if weekDay == 1 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
197 weeks = weeks + 1; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
198 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
199 for y = weeks, 6 do |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
200 if weekDay == 1 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
201 htmlStr = htmlStr .. "<tr>\n"; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
202 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
203 for i = weekDay, 7 do |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
204 htmlStr = htmlStr .. html.month.emptyDay .. "\n"; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
205 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
206 weekDay = 1 |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
207 htmlStr = htmlStr .. "</tr>\n"; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
208 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
209 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
210 htmlStr = htmlStr .. html.month.footer; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
211 if logAvailableForMinimumOneDay then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
212 return htmlStr; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
213 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
214 end |
101
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
215 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
216 local function createYear(year, dayCallback) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
217 local year = year; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
218 local tmp; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
219 if tonumber(year) <= 99 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
220 year = year + 2000; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
221 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
222 local htmlStr = ""; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
223 for i=1, 12 do |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
224 tmp = createMonth(i, year, dayCallback); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
225 if tmp then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
226 htmlStr = htmlStr .. "<div style='float: left; padding: 5px;'>\n" .. tmp .. "</div>\n"; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
227 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
228 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
229 if htmlStr ~= "" then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
230 return "<div name='yearDiv' style='padding: 40px; text-align: center;'>" .. html.year.title:gsub("###YEAR###", tostring(year)) .. htmlStr .. "</div><br style='clear:both;'/> \n"; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
231 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
232 return ""; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
233 end |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
234 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
235 local function perDayCallback(path, day, month, year, room, webPath) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
236 local webPath = webPath or "" |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
237 local year = year; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
238 if year > 2000 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
239 year = year - 2000; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
240 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
241 local bareDay = str_format("%.02d%.02d%.02d", year, month, day); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
242 room = urlencode(room); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
243 local attributes, err = lfs.attributes(path.."/"..bareDay.."/"..room..".dat") |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
244 if attributes ~= nil and attributes.mode == "file" then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
245 local s = html.days.bit; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
246 s = s:gsub("###BARE_DAY###", webPath .. bareDay); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
247 s = s:gsub("###DAY###", day); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
248 return s; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
249 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
250 return; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
251 end |
101
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
252 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
253 local function generateDayListSiteContentByRoom(bareRoomJid) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
254 local days = ""; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
255 local arrDays = {}; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
256 local tmp; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
257 local node, host, resource = splitJid(bareRoomJid); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
258 local path = data_getpath(node, host, datastore); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
259 local room = nil; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
260 local nextRoom = ""; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
261 local previousRoom = ""; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
262 local rooms = ""; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
263 local attributes = nil; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
264 local since = ""; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
265 local to = ""; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
266 local topic = ""; |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
267 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
268 path = path:gsub("/[^/]*$", ""); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
269 attributes = lfs.attributes(path); |
390
8090d246c268
mod_muc_log_http: Removed some more code. Module now no longer attempts to track muc_log hosts on its own.
Waqas Hussain <waqas20@gmail.com>
parents:
389
diff
changeset
|
270 do |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
271 local found = 0; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
272 for jid, room in pairs(prosody.hosts[host].muc.rooms) do |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
273 local node = splitJid(jid) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
274 if not room._data.hidden and node then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
275 if found == 0 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
276 previousRoom = node |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
277 elseif found == 1 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
278 nextRoom = node |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
279 found = -1 |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
280 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
281 if jid == bareRoomJid then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
282 found = 1 |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
283 end |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
284 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
285 rooms = rooms .. html.days.rooms.bit:gsub("###ROOM###", node); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
286 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
287 end |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
288 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
289 room = prosody.hosts[host].muc.rooms[bareRoomJid]; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
290 if room._data.hidden then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
291 room = nil |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
292 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
293 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
294 if attributes ~= nil and room ~= nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
295 local alreadyDoneYears = {}; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
296 topic = room._data.subject or "(no subject)" |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
297 if topic:len() > 135 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
298 topic = topic:sub(1, topic:find(" ", 120)) .. " ..." |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
299 end |
391
99e7ef4fc7d2
mod_muc_log_http: Properly sort calendar listing.
Waqas Hussain <waqas20@gmail.com>
parents:
390
diff
changeset
|
300 local folders = {}; |
99e7ef4fc7d2
mod_muc_log_http: Properly sort calendar listing.
Waqas Hussain <waqas20@gmail.com>
parents:
390
diff
changeset
|
301 for folder in lfs.dir(path) do table.insert(folders, folder); end |
99e7ef4fc7d2
mod_muc_log_http: Properly sort calendar listing.
Waqas Hussain <waqas20@gmail.com>
parents:
390
diff
changeset
|
302 table.sort(folders); |
99e7ef4fc7d2
mod_muc_log_http: Properly sort calendar listing.
Waqas Hussain <waqas20@gmail.com>
parents:
390
diff
changeset
|
303 for _, folder in ipairs(folders) do |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
304 local year, month, day = folder:match("^(%d%d)(%d%d)(%d%d)"); |
392
369e665ae471
mod_muc_log_http: Show proper time period in the headline.
Waqas Hussain <waqas20@gmail.com>
parents:
391
diff
changeset
|
305 if year then |
369e665ae471
mod_muc_log_http: Show proper time period in the headline.
Waqas Hussain <waqas20@gmail.com>
parents:
391
diff
changeset
|
306 to = tostring(os_date("%B %Y", os_time({ day=tonumber(day), month=tonumber(month), year=2000+tonumber(year) }))); |
369e665ae471
mod_muc_log_http: Show proper time period in the headline.
Waqas Hussain <waqas20@gmail.com>
parents:
391
diff
changeset
|
307 if since == "" then since = to; end |
369e665ae471
mod_muc_log_http: Show proper time period in the headline.
Waqas Hussain <waqas20@gmail.com>
parents:
391
diff
changeset
|
308 if not alreadyDoneYears[year] then |
369e665ae471
mod_muc_log_http: Show proper time period in the headline.
Waqas Hussain <waqas20@gmail.com>
parents:
391
diff
changeset
|
309 module:log("debug", "creating overview for: %s", to); |
369e665ae471
mod_muc_log_http: Show proper time period in the headline.
Waqas Hussain <waqas20@gmail.com>
parents:
391
diff
changeset
|
310 days = createYear(year, {callback=perDayCallback, path=path, room=node}) .. days; |
369e665ae471
mod_muc_log_http: Show proper time period in the headline.
Waqas Hussain <waqas20@gmail.com>
parents:
391
diff
changeset
|
311 alreadyDoneYears[year] = true; |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
312 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
313 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
314 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
315 end |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
316 |
388
75aea9752062
mod_muc_log_http: Generate room calendar page even when there is no log data.
Waqas Hussain <waqas20@gmail.com>
parents:
387
diff
changeset
|
317 tmp = html.days.body:gsub("###DAYS_STUFF###", days); |
75aea9752062
mod_muc_log_http: Generate room calendar page even when there is no log data.
Waqas Hussain <waqas20@gmail.com>
parents:
387
diff
changeset
|
318 tmp = tmp:gsub("###PREVIOUS_ROOM###", previousRoom == "" and node or previousRoom); |
75aea9752062
mod_muc_log_http: Generate room calendar page even when there is no log data.
Waqas Hussain <waqas20@gmail.com>
parents:
387
diff
changeset
|
319 tmp = tmp:gsub("###NEXT_ROOM###", nextRoom == "" and node or nextRoom); |
75aea9752062
mod_muc_log_http: Generate room calendar page even when there is no log data.
Waqas Hussain <waqas20@gmail.com>
parents:
387
diff
changeset
|
320 tmp = tmp:gsub("###ROOMS###", rooms); |
75aea9752062
mod_muc_log_http: Generate room calendar page even when there is no log data.
Waqas Hussain <waqas20@gmail.com>
parents:
387
diff
changeset
|
321 tmp = tmp:gsub("###ROOMTOPIC###", topic); |
75aea9752062
mod_muc_log_http: Generate room calendar page even when there is no log data.
Waqas Hussain <waqas20@gmail.com>
parents:
387
diff
changeset
|
322 tmp = tmp:gsub("###SINCE###", since); |
75aea9752062
mod_muc_log_http: Generate room calendar page even when there is no log data.
Waqas Hussain <waqas20@gmail.com>
parents:
387
diff
changeset
|
323 tmp = tmp:gsub("###TO###", to); |
393
20ef4a289d7d
mod_muc_log_http: Improved page titles a little.
Waqas Hussain <waqas20@gmail.com>
parents:
392
diff
changeset
|
324 return tmp:gsub("###JID###", bareRoomJid), "Chatroom logs for "..bareRoomJid; |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
325 end |
101
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
326 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
327 local function parseIqStanza(stanza, timeStuff, nick) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
328 local text = nil; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
329 local victim = nil; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
330 if(stanza.attr.type == "set") then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
331 for _,tag in ipairs(stanza) do |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
332 if tag.tag == "query" then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
333 for _,item in ipairs(tag) do |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
334 if item.tag == "item" and item.attr.nick ~= nil and item.attr.role == 'none' then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
335 victim = item.attr.nick; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
336 for _,reason in ipairs(item) do |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
337 if reason.tag == "reason" then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
338 text = reason[1]; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
339 break; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
340 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
341 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
342 break; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
343 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
344 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
345 break; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
346 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
347 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
348 if victim ~= nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
349 if text ~= nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
350 text = html.day.reason:gsub("###REASON###", htmlEscape(text)); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
351 else |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
352 text = ""; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
353 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
354 return html.day.kick:gsub("###TIME_STUFF###", timeStuff):gsub("###VICTIM###", victim):gsub("###REASON_STUFF###", text); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
355 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
356 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
357 return; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
358 end |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
359 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
360 local function parsePresenceStanza(stanza, timeStuff, nick) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
361 local ret = ""; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
362 local showJoin = "block" |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
363 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
364 if config and not config.showJoin then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
365 showJoin = "none"; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
366 end |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
367 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
368 if stanza.attr.type == nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
369 local showStatus = "block" |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
370 if config and not config.showStatus then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
371 showStatus = "none"; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
372 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
373 local show, status = nil, ""; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
374 local alreadyJoined = false; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
375 for _, tag in ipairs(stanza) do |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
376 if tag.tag == "alreadyJoined" then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
377 alreadyJoined = true; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
378 elseif tag.tag == "show" then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
379 show = tag[1]; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
380 elseif tag.tag == "status" and tag[1] ~= nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
381 status = tag[1]; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
382 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
383 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
384 if alreadyJoined == true then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
385 if show == nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
386 show = "online"; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
387 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
388 ret = html.day.presence.statusChange:gsub("###TIME_STUFF###", timeStuff); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
389 if status ~= "" then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
390 status = html.day.presence.statusText:gsub("###STATUS###", htmlEscape(status)); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
391 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
392 ret = ret:gsub("###SHOW###", show):gsub("###NICK###", nick):gsub("###SHOWHIDE###", showStatus):gsub("###STATUS_STUFF###", status); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
393 else |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
394 ret = html.day.presence.join:gsub("###TIME_STUFF###", timeStuff):gsub("###SHOWHIDE###", showJoin):gsub("###NICK###", nick); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
395 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
396 elseif stanza.attr.type ~= nil and stanza.attr.type == "unavailable" then |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
397 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
398 ret = html.day.presence.leave:gsub("###TIME_STUFF###", timeStuff):gsub("###SHOWHIDE###", showJoin):gsub("###NICK###", nick); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
399 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
400 return ret; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
401 end |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
402 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
403 local function parseMessageStanza(stanza, timeStuff, nick) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
404 local body, title, ret = nil, nil, ""; |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
405 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
406 for _,tag in ipairs(stanza) do |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
407 if tag.tag == "body" then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
408 body = tag[1]; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
409 if nick ~= nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
410 break; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
411 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
412 elseif tag.tag == "nick" and nick == nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
413 nick = htmlEscape(tag[1]); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
414 if body ~= nil or title ~= nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
415 break; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
416 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
417 elseif tag.tag == "subject" then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
418 title = tag[1]; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
419 if nick ~= nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
420 break; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
421 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
422 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
423 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
424 if nick ~= nil and body ~= nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
425 body = htmlEscape(body); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
426 local me = body:find("^/me"); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
427 local template = ""; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
428 if not me then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
429 template = html.day.message; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
430 else |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
431 template = html.day.messageMe; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
432 body = body:gsub("^/me ", ""); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
433 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
434 ret = template:gsub("###TIME_STUFF###", timeStuff):gsub("###NICK###", nick):gsub("###MSG###", body); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
435 elseif nick ~= nil and title ~= nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
436 title = htmlEscape(title); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
437 ret = html.day.titleChange:gsub("###TIME_STUFF###", timeStuff):gsub("###NICK###", nick):gsub("###TITLE###", title); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
438 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
439 return ret; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
440 end |
101
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
441 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
442 local function incrementDay(bare_day) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
443 local year, month, day = bare_day:match("^(%d%d)(%d%d)(%d%d)"); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
444 local leapyear = false; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
445 module:log("debug", tostring(day).."/"..tostring(month).."/"..tostring(year)) |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
446 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
447 day = tonumber(day); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
448 month = tonumber(month); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
449 year = tonumber(year); |
101
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
450 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
451 if year%4 == 0 and year%100 == 0 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
452 if year%400 == 0 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
453 leapyear = true; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
454 else |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
455 leapyear = false; -- turn of the century but not a leapyear |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
456 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
457 elseif year%4 == 0 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
458 leapyear = true; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
459 end |
101
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
460 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
461 if (month == 2 and leapyear and day + 1 > 29) or |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
462 (month == 2 and not leapyear and day + 1 > 28) or |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
463 (month < 8 and month%2 == 1 and day + 1 > 31) or |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
464 (month < 8 and month%2 == 0 and day + 1 > 30) or |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
465 (month >= 8 and month%2 == 0 and day + 1 > 31) or |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
466 (month >= 8 and month%2 == 1 and day + 1 > 30) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
467 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
468 if month + 1 > 12 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
469 year = year + 1; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
470 month = 1; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
471 day = 1; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
472 else |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
473 month = month + 1; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
474 day = 1; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
475 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
476 else |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
477 day = day + 1; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
478 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
479 return strformat("%.02d%.02d%.02d", year, month, day); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
480 end |
179
af6143756a9e
mod_muc_log_http: started new prosody theme
Thilo Cestonaro <thilo@cestona.ro>
parents:
146
diff
changeset
|
481 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
482 local function findNextDay(bareRoomJid, bare_day) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
483 local node, host, resource = splitJid(bareRoomJid); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
484 local day = incrementDay(bare_day); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
485 local max_trys = 7; |
179
af6143756a9e
mod_muc_log_http: started new prosody theme
Thilo Cestonaro <thilo@cestona.ro>
parents:
146
diff
changeset
|
486 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
487 module:log("debug", day); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
488 while(not checkDatastorePathExists(node, host, day, false)) do |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
489 max_trys = max_trys - 1; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
490 if max_trys == 0 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
491 break; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
492 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
493 day = incrementDay(day); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
494 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
495 if max_trys == 0 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
496 return nil; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
497 else |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
498 return day; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
499 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
500 end |
179
af6143756a9e
mod_muc_log_http: started new prosody theme
Thilo Cestonaro <thilo@cestona.ro>
parents:
146
diff
changeset
|
501 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
502 local function decrementDay(bare_day) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
503 local year, month, day = bare_day:match("^(%d%d)(%d%d)(%d%d)"); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
504 local leapyear = false; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
505 module:log("debug", tostring(day).."/"..tostring(month).."/"..tostring(year)) |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
506 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
507 day = tonumber(day); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
508 month = tonumber(month); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
509 year = tonumber(year); |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
510 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
511 if year%4 == 0 and year%100 == 0 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
512 if year%400 == 0 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
513 leapyear = true; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
514 else |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
515 leapyear = false; -- turn of the century but not a leapyear |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
516 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
517 elseif year%4 == 0 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
518 leapyear = true; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
519 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
520 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
521 if day - 1 == 0 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
522 if month - 1 == 0 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
523 year = year - 1; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
524 month = 12; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
525 day = 31; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
526 else |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
527 month = month - 1; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
528 if (month == 2 and leapyear) then day = 29 |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
529 elseif (month == 2 and not leapyear) then day = 28 |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
530 elseif (month < 8 and month%2 == 1) or (month >= 8 and month%2 == 0) then day = 31 |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
531 else day = 30 |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
532 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
533 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
534 else |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
535 day = day - 1; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
536 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
537 return strformat("%.02d%.02d%.02d", year, month, day); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
538 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
539 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
540 local function findPreviousDay(bareRoomJid, bare_day) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
541 local node, host, resource = splitJid(bareRoomJid); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
542 local day = decrementDay(bare_day); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
543 local max_trys = 7; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
544 module:log("debug", day); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
545 while(not checkDatastorePathExists(node, host, day, false)) do |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
546 max_trys = max_trys - 1; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
547 if max_trys == 0 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
548 break; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
549 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
550 day = decrementDay(day); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
551 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
552 if max_trys == 0 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
553 return nil; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
554 else |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
555 return day; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
556 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
557 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
558 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
559 local function parseDay(bareRoomJid, roomSubject, bare_day) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
560 local ret = ""; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
561 local year; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
562 local month; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
563 local day; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
564 local tmp; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
565 local node, host, resource = splitJid(bareRoomJid); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
566 local year, month, day = bare_day:match("^(%d%d)(%d%d)(%d%d)"); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
567 local previousDay = findPreviousDay(bareRoomJid, bare_day); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
568 local nextDay = findNextDay(bareRoomJid, bare_day); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
569 local temptime = {day=0, month=0, year=0}; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
570 local path = data_getpath(node, host, datastore); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
571 path = path:gsub("/[^/]*$", ""); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
572 local calendar = "" |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
573 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
574 if tonumber(year) <= 99 then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
575 year = year + 2000; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
576 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
577 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
578 temptime.day = tonumber(day) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
579 temptime.month = tonumber(month) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
580 temptime.year = tonumber(year) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
581 calendar = createMonth(temptime.month, temptime.year, {callback=perDayCallback, path=path, room=node, webPath="../"}) or "" |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
582 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
583 if bare_day ~= nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
584 local data = data_load(node, host, datastore .. "/" .. bare_day); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
585 if data ~= nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
586 for i=1, #data, 1 do |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
587 local stanza = lom.parse(data[i]); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
588 if stanza ~= nil and stanza.attr ~= nil and stanza.attr.time ~= nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
589 local timeStuff = html.day.time:gsub("###TIME###", stanza.attr.time):gsub("###UTC###", stanza.attr.utc or stanza.attr.time); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
590 if stanza[1] ~= nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
591 local nick; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
592 local tmp; |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
593 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
594 -- grep nick from "from" resource |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
595 if stanza[1].attr.from ~= nil then -- presence and messages |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
596 nick = htmlEscape(stanza[1].attr.from:match("/(.+)$")); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
597 elseif stanza[1].attr.to ~= nil then -- iq |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
598 nick = htmlEscape(stanza[1].attr.to:match("/(.+)$")); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
599 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
600 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
601 if stanza[1].tag == "presence" and nick ~= nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
602 tmp = parsePresenceStanza(stanza[1], timeStuff, nick); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
603 elseif stanza[1].tag == "message" then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
604 tmp = parseMessageStanza(stanza[1], timeStuff, nick); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
605 elseif stanza[1].tag == "iq" then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
606 tmp = parseIqStanza(stanza[1], timeStuff, nick); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
607 else |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
608 module:log("info", "unknown stanza subtag in log found. room: %s; day: %s", bareRoomJid, year .. "/" .. month .. "/" .. day); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
609 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
610 if tmp ~= nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
611 ret = ret .. tmp |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
612 tmp = nil; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
613 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
614 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
615 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
616 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
617 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
618 if ret ~= "" then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
619 if nextDay then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
620 nextDay = html.day.dayLink:gsub("###DAY###", nextDay):gsub("###TEXT###", ">") |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
621 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
622 if previousDay then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
623 previousDay = html.day.dayLink:gsub("###DAY###", previousDay):gsub("###TEXT###", "<"); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
624 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
625 ret = ret:gsub("%%", "%%%%"); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
626 tmp = html.day.body:gsub("###DAY_STUFF###", ret):gsub("###JID###", bareRoomJid); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
627 tmp = tmp:gsub("###CALENDAR###", calendar); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
628 tmp = tmp:gsub("###DATE###", tostring(os_date("%A, %B %d, %Y", os_time(temptime)))); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
629 tmp = tmp:gsub("###TITLE_STUFF###", html.day.title:gsub("###TITLE###", roomSubject)); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
630 tmp = tmp:gsub("###STATUS_CHECKED###", config.showStatus and "checked='checked'" or ""); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
631 tmp = tmp:gsub("###JOIN_CHECKED###", config.showJoin and "checked='checked'" or ""); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
632 tmp = tmp:gsub("###NEXT_LINK###", nextDay or ""); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
633 tmp = tmp:gsub("###PREVIOUS_LINK###", previousDay or ""); |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
634 |
393
20ef4a289d7d
mod_muc_log_http: Improved page titles a little.
Waqas Hussain <waqas20@gmail.com>
parents:
392
diff
changeset
|
635 return tmp, "Chatroom logs for "..bareRoomJid.." ("..tostring(os_date("%A, %B %d, %Y", os_time(temptime)))..")"; |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
636 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
637 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
638 end |
119
e6592d8305cb
mod_muc_log_http: support next, previous day calculations from one month/year to the next or visa versa
Thilo Cestonaro <thilo@cestona.ro>
parents:
118
diff
changeset
|
639 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
640 function handle_request(method, body, request) |
384
79983e658bb5
mod_muc_log_http: Cleaned up URL handling.
Waqas Hussain <waqas20@gmail.com>
parents:
383
diff
changeset
|
641 local host, node, day, more = request.url.path:match("^/muc_log/+([^/]*)/*([^/]*)/*([^/]*)/*(.*)$"); |
79983e658bb5
mod_muc_log_http: Cleaned up URL handling.
Waqas Hussain <waqas20@gmail.com>
parents:
383
diff
changeset
|
642 if more ~= "" then return { status = "404 Not found", body = "Unknown URL" }; end |
382
19469f3ad6d6
mod_muc_log_http: Cleaned up URL parsing.
Waqas Hussain <waqas20@gmail.com>
parents:
381
diff
changeset
|
643 if host == "" then host = nil; end |
19469f3ad6d6
mod_muc_log_http: Cleaned up URL parsing.
Waqas Hussain <waqas20@gmail.com>
parents:
381
diff
changeset
|
644 if node == "" then node = nil; end |
19469f3ad6d6
mod_muc_log_http: Cleaned up URL parsing.
Waqas Hussain <waqas20@gmail.com>
parents:
381
diff
changeset
|
645 if day == "" then day = nil; end |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
646 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
647 node = urldecode(node); |
119
e6592d8305cb
mod_muc_log_http: support next, previous day calculations from one month/year to the next or visa versa
Thilo Cestonaro <thilo@cestona.ro>
parents:
118
diff
changeset
|
648 |
390
8090d246c268
mod_muc_log_http: Removed some more code. Module now no longer attempts to track muc_log hosts on its own.
Waqas Hussain <waqas20@gmail.com>
parents:
389
diff
changeset
|
649 assert(html.doc, "MUC hosts or theme not loaded"); |
384
79983e658bb5
mod_muc_log_http: Cleaned up URL handling.
Waqas Hussain <waqas20@gmail.com>
parents:
383
diff
changeset
|
650 |
390
8090d246c268
mod_muc_log_http: Removed some more code. Module now no longer attempts to track muc_log hosts on its own.
Waqas Hussain <waqas20@gmail.com>
parents:
389
diff
changeset
|
651 if host and not(hosts[host] and hosts[host].modules.muc and hosts[host].modules.muc_log) then return { status = "404 Not found", body = "No such MUC component" }; end |
387
90d0e90c5b0e
mod_muc_log_http: Fixed a typo.
Waqas Hussain <waqas20@gmail.com>
parents:
386
diff
changeset
|
652 if host and node and not(hosts[host].modules.muc.rooms[node.."@"..host]) then return { status = "404 Not found", body = "No such MUC room" }; end |
384
79983e658bb5
mod_muc_log_http: Cleaned up URL handling.
Waqas Hussain <waqas20@gmail.com>
parents:
383
diff
changeset
|
653 |
79983e658bb5
mod_muc_log_http: Cleaned up URL handling.
Waqas Hussain <waqas20@gmail.com>
parents:
383
diff
changeset
|
654 if not host then -- main component list |
79983e658bb5
mod_muc_log_http: Cleaned up URL handling.
Waqas Hussain <waqas20@gmail.com>
parents:
383
diff
changeset
|
655 return createDoc(generateComponentListSiteContent()); |
79983e658bb5
mod_muc_log_http: Cleaned up URL handling.
Waqas Hussain <waqas20@gmail.com>
parents:
383
diff
changeset
|
656 elseif not node then -- room list for component |
79983e658bb5
mod_muc_log_http: Cleaned up URL handling.
Waqas Hussain <waqas20@gmail.com>
parents:
383
diff
changeset
|
657 return createDoc(generateRoomListSiteContent(host)); |
79983e658bb5
mod_muc_log_http: Cleaned up URL handling.
Waqas Hussain <waqas20@gmail.com>
parents:
383
diff
changeset
|
658 elseif not day then -- room's listing |
79983e658bb5
mod_muc_log_http: Cleaned up URL handling.
Waqas Hussain <waqas20@gmail.com>
parents:
383
diff
changeset
|
659 return createDoc(generateDayListSiteContentByRoom(node.."@"..host)); |
79983e658bb5
mod_muc_log_http: Cleaned up URL handling.
Waqas Hussain <waqas20@gmail.com>
parents:
383
diff
changeset
|
660 else |
389
60248c463ec3
mod_muc_log_http: Fixed a typo.
Waqas Hussain <waqas20@gmail.com>
parents:
388
diff
changeset
|
661 local room = hosts[host].modules.muc.rooms[node.."@"..host]; |
384
79983e658bb5
mod_muc_log_http: Cleaned up URL handling.
Waqas Hussain <waqas20@gmail.com>
parents:
383
diff
changeset
|
662 return createDoc(parseDay(node.."@"..host, room._data.subject or "", day:gsub("%-", ""))); |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
663 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
664 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
665 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
666 -- Compatibility: Lua-5.1 |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
667 function split(str, pat) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
668 local t = {} -- NOTE: use {n = 0} in Lua-5.0 |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
669 local fpat = "(.-)" .. pat |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
670 local last_end = 1 |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
671 local s, e, cap = str:find(fpat, 1) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
672 while s do |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
673 if s ~= 1 or cap ~= "" then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
674 table.insert(t,cap) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
675 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
676 last_end = e+1 |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
677 s, e, cap = str:find(fpat, last_end) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
678 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
679 if last_end <= #str then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
680 cap = str:sub(last_end) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
681 table.insert(t, cap) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
682 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
683 return t |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
684 end |
179
af6143756a9e
mod_muc_log_http: started new prosody theme
Thilo Cestonaro <thilo@cestona.ro>
parents:
146
diff
changeset
|
685 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
686 local function assign(arr, content) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
687 local tmp = html; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
688 local idx = nil; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
689 for _,i in ipairs(arr) do |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
690 if idx ~= nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
691 if tmp[idx] == nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
692 tmp[idx] = {}; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
693 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
694 tmp = tmp[idx]; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
695 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
696 idx = i; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
697 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
698 tmp[idx] = content; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
699 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
700 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
701 local function readFile(filepath) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
702 local f = assert(io_open(filepath, "r")); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
703 local t = f:read("*all"); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
704 f:close() |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
705 return t; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
706 end |
344
2b0f2160fc61
mod_muc_log_http: Fix room name encoding/decoding (for UTF-8 room names)
Joseph Wallace <JosephWallace@letu.edu>
parents:
343
diff
changeset
|
707 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
708 local function loadTheme(path) |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
709 for file in lfs.dir(path) do |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
710 if file ~= "." and file ~= ".." then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
711 module:log("debug", "opening theme file: " .. file); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
712 local tmp = split(file:gsub("\.html$", ""), "_"); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
713 local content = readFile(path .. "/" .. file); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
714 assign(tmp, content); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
715 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
716 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
717 return true; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
718 end |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
719 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
720 function module.load() |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
721 config = config_get("*", "core", "muc_log_http") or {}; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
722 if config.showStatus == nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
723 config.showStatus = true; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
724 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
725 if config.showJoin == nil then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
726 config.showJoin = true; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
727 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
728 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
729 theme = config.theme or "prosody"; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
730 local themePath = themesParent .. "/" .. tostring(theme); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
731 local attributes, err = lfs.attributes(themePath); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
732 if attributes == nil or attributes.mode ~= "directory" then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
733 module:log("error", "Theme folder of theme \"".. tostring(theme) .. "\" isn't existing. expected Path: " .. themePath); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
734 return false; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
735 end |
105
cef943f0a551
mod_muc_log_http: themified ...
Thilo Cestonaro <thilo@cestona.ro>
parents:
104
diff
changeset
|
736 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
737 -- module:log("debug", (require "util.serialization").serialize(html)); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
738 if(not loadTheme(themePath)) then |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
739 module:log("error", "Theme \"".. tostring(theme) .. "\" is missing something."); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
740 return false; |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
741 end |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
742 -- module:log("debug", (require "util.serialization").serialize(html)); |
105
cef943f0a551
mod_muc_log_http: themified ...
Thilo Cestonaro <thilo@cestona.ro>
parents:
104
diff
changeset
|
743 |
380
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
744 httpserver.new_from_config({ config.http_port or true }, handle_request, { base = urlBase, ssl = false, port = 5290 }); |
5ef71af77ae2
mod_muc_log_http: Spaces -> Tabs.
Waqas Hussain <waqas20@gmail.com>
parents:
348
diff
changeset
|
745 end |