Mercurial > prosody-modules
annotate mod_muc_log_http/muc_log_http/mod_muc_log_http.lua @ 376:8f5726adc61e
mod_auth_phpbb3: Comment logging of user password.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Fri, 01 Jul 2011 07:53:13 +0500 |
parents | 03e1dc036a28 |
children | 5ef71af77ae2 |
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 muc_hosts = {}; |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
25 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
|
26 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
|
27 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
|
28 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
|
29 local str_format = string.format; |
105
cef943f0a551
mod_muc_log_http: themified ...
Thilo Cestonaro <thilo@cestona.ro>
parents:
104
diff
changeset
|
30 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
|
31 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
|
32 |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
33 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
|
34 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
35 --[[ LuaFileSystem |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
36 * 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
|
37 * 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
|
38 * ]] |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
39 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
|
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 --[[ |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
43 * 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
|
44 ]]-- |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
45 local html = {}; |
183
9d4fd01443eb
mod_muc_log_http: ensure to have the default being "prosody"
Thilo Cestonaro <thilo@cestona.ro>
parents:
180
diff
changeset
|
46 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
|
47 |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
48 local function checkDatastorePathExists(node, host, today, create) |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
49 create = create or false; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
50 local path = data_getpath(node, host, datastore, "dat", true); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
51 path = path:gsub("/[^/]*$", ""); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
52 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
53 -- check existance |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
54 local attributes, err = lfs.attributes(path); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
55 if attributes == nil or attributes.mode ~= "directory" then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
56 module:log("warn", "muc_log folder isn't a folder: %s", path); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
57 return false; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
58 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
59 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
60 attributes, err = lfs.attributes(path .. "/" .. today); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
61 if attributes == nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
62 if create then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
63 return lfs.mkdir(path .. "/" .. today); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
64 else |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
65 return false; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
66 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
67 elseif attributes.mode == "directory" then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
68 return true; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
69 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
70 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
|
71 end |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
72 |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
73 function createDoc(body) |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
74 if body then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
75 body = body:gsub("%%", "%%%%"); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
76 return html.doc:gsub("###BODY_STUFF###", body); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
77 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
78 end |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
79 |
116
f68a781efe81
mod_muc_log_http: support escaped urls
Thilo Cestonaro <thilo@cestona.ro>
parents:
115
diff
changeset
|
80 function urlunescape (escapedUrl) |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
81 escapedUrl = escapedUrl:gsub("+", " ") |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
82 escapedUrl = escapedUrl:gsub("%%(%x%x)", function(h) return strchar(tonumber(h,16)) end) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
83 escapedUrl = escapedUrl:gsub("\r\n", "\n") |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
84 return escapedUrl |
116
f68a781efe81
mod_muc_log_http: support escaped urls
Thilo Cestonaro <thilo@cestona.ro>
parents:
115
diff
changeset
|
85 end |
f68a781efe81
mod_muc_log_http: support escaped urls
Thilo Cestonaro <thilo@cestona.ro>
parents:
115
diff
changeset
|
86 |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
87 local function htmlEscape(t) |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
88 if t then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
89 t = t:gsub("<", "<"); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
90 t = t:gsub(">", ">"); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
91 t = t:gsub("(http://[%a%d@%.:/&%?=%-_#%%~]+)", function(h) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
92 h = urlunescape(h) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
93 return "<a href='" .. h .. "'>" .. h .. "</a>"; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
94 end); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
95 t = t:gsub("\n", "<br />"); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
96 t = t:gsub("%%", "%%%%"); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
97 else |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
98 t = ""; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
99 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
100 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
|
101 end |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
102 |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
103 function splitUrl(url) |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
104 local tmp = url:sub(string.len("/muc_log/") + 1); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
105 local day = nil; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
106 local room = nil; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
107 local component = nil; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
108 local at = nil; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
109 local slash = nil; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
110 local slash2 = nil; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
111 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
112 slash = tmp:find("/"); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
113 if slash then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
114 component = tmp:sub(1, slash - 1); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
115 if tmp:len() > slash then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
116 room = tmp:sub(slash + 1); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
117 slash = room:find("/"); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
118 if slash then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
119 tmp = room; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
120 room = tmp:sub(1, slash - 1); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
121 if tmp:len() > slash then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
122 day = tmp:sub(slash + 1); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
123 slash = day:find("/"); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
124 if slash then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
125 day = day:sub(1, slash - 1); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
126 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
127 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
128 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
129 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
130 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
131 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
132 return room, component, day; |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
133 end |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
134 |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
135 local function generateComponentListSiteContent() |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
136 local components = ""; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
137 for component,muc_host in pairs(muc_hosts or {}) do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
138 components = components .. html.components.bit:gsub("###COMPONENT###", component); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
139 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
140 if components ~= "" then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
141 return html.components.body:gsub("###COMPONENTS_STUFF###", components); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
142 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
143 end |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
144 |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
145 local function generateRoomListSiteContent(component) |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
146 local rooms = ""; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
147 if prosody.hosts[component] and prosody.hosts[component].muc ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
148 for jid, room in pairs(prosody.hosts[component].muc.rooms) do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
149 local node = splitJid(jid); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
150 if not room._data.hidden and node then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
151 rooms = rooms .. html.rooms.bit:gsub("###ROOM###", node):gsub("###COMPONENT###", component); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
152 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
153 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
154 if rooms ~= "" then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
155 return html.rooms.body:gsub("###ROOMS_STUFF###", rooms):gsub("###COMPONENT###", component); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
156 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
157 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
158 end |
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
159 |
101
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
160 -- Calendar stuff |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
161 local function getDaysForMonth(month, year) |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
162 local daysCount = 30; |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
163 local leapyear = false; |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
164 |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
165 if year%4 == 0 and year%100 == 0 then |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
166 if year%400 == 0 then |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
167 leapyear = true; |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
168 else |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
169 leapyear = false; -- turn of the century but not a leapyear |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
170 end |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
171 elseif year%4 == 0 then |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
172 leapyear = true; |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
173 end |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
174 |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
175 if month == 2 and leapyear then |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
176 daysCount = 29; |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
177 elseif month == 2 and not leapyear then |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
178 daysCount = 28; |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
179 elseif month < 8 and month%2 == 1 or |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
180 month >= 8 and month%2 == 0 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
181 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
182 daysCount = 31; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
183 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
184 return daysCount; |
101
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
185 end |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
186 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
187 local function createMonth(month, year, dayCallback) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
188 local htmlStr = html.month.header; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
189 local days = getDaysForMonth(month, year); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
190 local time = os_time{year=year, month=month, day=1}; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
191 local dow = tostring(os_date("%a", time)) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
192 local title = tostring(os_date("%B", time)); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
193 local weekDays = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"}; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
194 local weekDay = 0; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
195 local weeks = 1; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
196 local logAvailableForMinimumOneDay = false; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
197 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
198 local weekDaysHtml = ""; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
199 for _, tmp in ipairs(weekDays) do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
200 weekDaysHtml = weekDaysHtml .. html.month.weekDay:gsub("###DAY###", tmp) .. "\n"; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
201 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
202 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
203 htmlStr = htmlStr:gsub("###TITLE###", title):gsub("###WEEKDAYS###", weekDaysHtml); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
204 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
205 for i = 1, 31 do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
206 weekDay = weekDay + 1; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
207 if weekDay == 1 then htmlStr = htmlStr .. "<tr>\n"; end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
208 if i == 1 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
209 for _, tmp in ipairs(weekDays) do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
210 if dow ~= tmp then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
211 htmlStr = htmlStr .. html.month.emptyDay .. "\n"; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
212 weekDay = weekDay + 1; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
213 else |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
214 break; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
215 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
216 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
217 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
218 if i < days + 1 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
219 local tmp = tostring(i); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
220 if dayCallback ~= nil and dayCallback.callback ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
221 tmp = dayCallback.callback(dayCallback.path, i, month, year, dayCallback.room, dayCallback.webPath); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
222 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
223 if tmp == nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
224 tmp = tostring(i); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
225 else |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
226 logAvailableForMinimumOneDay = true; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
227 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
228 htmlStr = htmlStr .. html.month.day:gsub("###DAY###", tmp) .. "\n"; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
229 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
230 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
231 if i >= days then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
232 break; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
233 end |
101
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
234 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
235 if weekDay == 7 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
236 weekDay = 0; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
237 weeks = weeks + 1; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
238 htmlStr = htmlStr .. "</tr>\n"; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
239 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
240 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
241 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
242 if weekDay + 1 < 8 or weeks < 6 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
243 weekDay = weekDay + 1; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
244 if weekDay > 7 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
245 weekDay = 1; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
246 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
247 if weekDay == 1 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
248 weeks = weeks + 1; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
249 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
250 for y = weeks, 6 do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
251 if weekDay == 1 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
252 htmlStr = htmlStr .. "<tr>\n"; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
253 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
254 for i = weekDay, 7 do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
255 htmlStr = htmlStr .. html.month.emptyDay .. "\n"; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
256 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
257 weekDay = 1 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
258 htmlStr = htmlStr .. "</tr>\n"; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
259 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
260 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
261 htmlStr = htmlStr .. html.month.footer; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
262 if logAvailableForMinimumOneDay then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
263 return htmlStr; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
264 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
265 end |
101
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
266 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
267 local function createYear(year, dayCallback) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
268 local year = year; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
269 local tmp; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
270 if tonumber(year) <= 99 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
271 year = year + 2000; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
272 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
273 local htmlStr = ""; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
274 for i=1, 12 do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
275 tmp = createMonth(i, year, dayCallback); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
276 if tmp then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
277 htmlStr = htmlStr .. "<div style='float: left; padding: 5px;'>\n" .. tmp .. "</div>\n"; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
278 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
279 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
280 if htmlStr ~= "" then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
281 return "<div name='yearDiv' style='padding: 40px; text-align: center;'>" .. html.year.title:gsub("###YEAR###", tostring(year)) .. htmlStr .. "</div><br style='clear:both;'/> \n"; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
282 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
283 return ""; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
284 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
285 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
286 local function perDayCallback(path, day, month, year, room, webPath) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
287 local webPath = webPath or "" |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
288 local year = year; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
289 if year > 2000 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
290 year = year - 2000; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
291 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
292 local bareDay = str_format("%.02d%.02d%.02d", year, month, day); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
293 room = urlencode(room); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
294 local attributes, err = lfs.attributes(path.."/"..bareDay.."/"..room..".dat") |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
295 if attributes ~= nil and attributes.mode == "file" then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
296 local s = html.days.bit; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
297 s = s:gsub("###BARE_DAY###", webPath .. bareDay); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
298 s = s:gsub("###DAY###", day); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
299 return s; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
300 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
301 return; |
101
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
302 end |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
303 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
304 local function generateDayListSiteContentByRoom(bareRoomJid) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
305 local days = ""; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
306 local arrDays = {}; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
307 local tmp; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
308 local node, host, resource = splitJid(bareRoomJid); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
309 local path = data_getpath(node, host, datastore); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
310 local room = nil; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
311 local nextRoom = ""; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
312 local previousRoom = ""; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
313 local rooms = ""; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
314 local attributes = nil; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
315 local since = ""; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
316 local to = ""; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
317 local topic = ""; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
318 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
319 path = path:gsub("/[^/]*$", ""); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
320 attributes = lfs.attributes(path); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
321 if muc_hosts ~= nil and muc_hosts[host] and prosody.hosts[host] ~= nil and prosody.hosts[host].muc ~= nil and prosody.hosts[host].muc.rooms[bareRoomJid] ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
322 local found = 0; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
323 for jid, room in pairs(prosody.hosts[host].muc.rooms) do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
324 local node = splitJid(jid) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
325 if not room._data.hidden and node then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
326 if found == 0 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
327 previousRoom = node |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
328 elseif found == 1 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
329 nextRoom = node |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
330 found = -1 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
331 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
332 if jid == bareRoomJid then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
333 found = 1 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
334 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
335 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
336 rooms = rooms .. html.days.rooms.bit:gsub("###ROOM###", node); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
337 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
338 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
339 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
340 room = prosody.hosts[host].muc.rooms[bareRoomJid]; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
341 if room._data.hidden then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
342 room = nil |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
343 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
344 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
345 if attributes ~= nil and room ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
346 local first = 1; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
347 local alreadyDoneYears = {}; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
348 local temptime = {day=0, month=0, year=0}; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
349 topic = room._data.subject or "(no subject)" |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
350 if topic:len() > 135 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
351 topic = topic:sub(1, topic:find(" ", 120)) .. " ..." |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
352 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
353 for folder in lfs.dir(path) do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
354 local year, month, day = folder:match("^(%d%d)(%d%d)(%d%d)"); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
355 if year ~= nil and alreadyDoneYears[year] == nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
356 temptime.day = tonumber(day) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
357 temptime.month = tonumber(month) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
358 temptime.year = 2000 + tonumber(year) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
359 if first == 1 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
360 to = tostring(os_date("%B %Y", os_time(temptime))) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
361 first = 0 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
362 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
363 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
364 since = tostring(os_date("%B %Y", os_time(temptime))) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
365 module:log("debug", "creating overview for: " .. tostring(since)) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
366 days = createYear(year, {callback=perDayCallback, path=path, room=node}) .. days; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
367 alreadyDoneYears[year] = true; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
368 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
369 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
370 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
371 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
372 if days ~= "" then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
373 tmp = html.days.body:gsub("###DAYS_STUFF###", days); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
374 tmp = tmp:gsub("###PREVIOUS_ROOM###", previousRoom == "" and node or previousRoom); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
375 tmp = tmp:gsub("###NEXT_ROOM###", nextRoom == "" and node or nextRoom); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
376 tmp = tmp:gsub("###ROOMS###", rooms); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
377 tmp = tmp:gsub("###ROOMTOPIC###", topic); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
378 tmp = tmp:gsub("###SINCE###", since); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
379 tmp = tmp:gsub("###TO###", to); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
380 return tmp:gsub("###JID###", bareRoomJid); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
381 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
382 end |
101
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
383 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
384 local function parseIqStanza(stanza, timeStuff, nick) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
385 local text = nil; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
386 local victim = nil; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
387 if(stanza.attr.type == "set") then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
388 for _,tag in ipairs(stanza) do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
389 if tag.tag == "query" then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
390 for _,item in ipairs(tag) do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
391 if item.tag == "item" and item.attr.nick ~= nil and item.attr.role == 'none' then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
392 victim = item.attr.nick; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
393 for _,reason in ipairs(item) do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
394 if reason.tag == "reason" then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
395 text = reason[1]; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
396 break; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
397 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
398 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
399 break; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
400 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
401 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
402 break; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
403 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
404 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
405 if victim ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
406 if text ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
407 text = html.day.reason:gsub("###REASON###", htmlEscape(text)); |
101
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
408 else |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
409 text = ""; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
410 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
411 return html.day.kick:gsub("###TIME_STUFF###", timeStuff):gsub("###VICTIM###", victim):gsub("###REASON_STUFF###", text); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
412 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
413 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
414 return; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
415 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
416 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
417 local function parsePresenceStanza(stanza, timeStuff, nick) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
418 local ret = ""; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
419 local showJoin = "block" |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
420 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
421 if config and not config.showJoin then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
422 showJoin = "none"; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
423 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
424 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
425 if stanza.attr.type == nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
426 local showStatus = "block" |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
427 if config and not config.showStatus then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
428 showStatus = "none"; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
429 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
430 local show, status = nil, ""; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
431 local alreadyJoined = false; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
432 for _, tag in ipairs(stanza) do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
433 if tag.tag == "alreadyJoined" then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
434 alreadyJoined = true; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
435 elseif tag.tag == "show" then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
436 show = tag[1]; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
437 elseif tag.tag == "status" and tag[1] ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
438 status = tag[1]; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
439 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
440 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
441 if alreadyJoined == true then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
442 if show == nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
443 show = "online"; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
444 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
445 ret = html.day.presence.statusChange:gsub("###TIME_STUFF###", timeStuff); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
446 if status ~= "" then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
447 status = html.day.presence.statusText:gsub("###STATUS###", htmlEscape(status)); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
448 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
449 ret = ret:gsub("###SHOW###", show):gsub("###NICK###", nick):gsub("###SHOWHIDE###", showStatus):gsub("###STATUS_STUFF###", status); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
450 else |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
451 ret = html.day.presence.join:gsub("###TIME_STUFF###", timeStuff):gsub("###SHOWHIDE###", showJoin):gsub("###NICK###", nick); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
452 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
453 elseif stanza.attr.type ~= nil and stanza.attr.type == "unavailable" then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
454 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
455 ret = html.day.presence.leave:gsub("###TIME_STUFF###", timeStuff):gsub("###SHOWHIDE###", showJoin):gsub("###NICK###", nick); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
456 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
457 return ret; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
458 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
459 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
460 local function parseMessageStanza(stanza, timeStuff, nick) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
461 local body, title, ret = nil, nil, ""; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
462 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
463 for _,tag in ipairs(stanza) do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
464 if tag.tag == "body" then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
465 body = tag[1]; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
466 if nick ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
467 break; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
468 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
469 elseif tag.tag == "nick" and nick == nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
470 nick = htmlEscape(tag[1]); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
471 if body ~= nil or title ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
472 break; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
473 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
474 elseif tag.tag == "subject" then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
475 title = tag[1]; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
476 if nick ~= nil then |
101
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
477 break; |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
478 end |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
479 end |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
480 end |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
481 if nick ~= nil and body ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
482 body = htmlEscape(body); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
483 local me = body:find("^/me"); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
484 local template = ""; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
485 if not me then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
486 template = html.day.message; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
487 else |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
488 template = html.day.messageMe; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
489 body = body:gsub("^/me ", ""); |
101
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
490 end |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
491 ret = template:gsub("###TIME_STUFF###", timeStuff):gsub("###NICK###", nick):gsub("###MSG###", body); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
492 elseif nick ~= nil and title ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
493 title = htmlEscape(title); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
494 ret = html.day.titleChange:gsub("###TIME_STUFF###", timeStuff):gsub("###NICK###", nick):gsub("###TITLE###", title); |
101
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
495 end |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
496 return ret; |
101
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
497 end |
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
498 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
499 local function incrementDay(bare_day) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
500 local year, month, day = bare_day:match("^(%d%d)(%d%d)(%d%d)"); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
501 local leapyear = false; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
502 module:log("debug", tostring(day).."/"..tostring(month).."/"..tostring(year)) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
503 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
504 day = tonumber(day); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
505 month = tonumber(month); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
506 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
|
507 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
508 if year%4 == 0 and year%100 == 0 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
509 if year%400 == 0 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
510 leapyear = true; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
511 else |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
512 leapyear = false; -- turn of the century but not a leapyear |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
513 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
514 elseif year%4 == 0 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
515 leapyear = true; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
516 end |
101
e3c09996cf7b
mod_muc_log_http: display available days in a calendar view
Thilo Cestonaro <thilo@cestona.ro>
parents:
94
diff
changeset
|
517 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
518 if (month == 2 and leapyear and day + 1 > 29) or |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
519 (month == 2 and not leapyear and day + 1 > 28) or |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
520 (month < 8 and month%2 == 1 and day + 1 > 31) or |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
521 (month < 8 and month%2 == 0 and day + 1 > 30) or |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
522 (month >= 8 and month%2 == 0 and day + 1 > 31) or |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
523 (month >= 8 and month%2 == 1 and day + 1 > 30) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
524 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
525 if month + 1 > 12 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
526 year = year + 1; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
527 month = 1; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
528 day = 1; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
529 else |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
530 month = month + 1; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
531 day = 1; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
532 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
533 else |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
534 day = day + 1; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
535 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
536 return strformat("%.02d%.02d%.02d", year, month, day); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
537 end |
179
af6143756a9e
mod_muc_log_http: started new prosody theme
Thilo Cestonaro <thilo@cestona.ro>
parents:
146
diff
changeset
|
538 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
539 local function findNextDay(bareRoomJid, bare_day) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
540 local node, host, resource = splitJid(bareRoomJid); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
541 local day = incrementDay(bare_day); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
542 local max_trys = 7; |
179
af6143756a9e
mod_muc_log_http: started new prosody theme
Thilo Cestonaro <thilo@cestona.ro>
parents:
146
diff
changeset
|
543 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
544 module:log("debug", day); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
545 while(not checkDatastorePathExists(node, host, day, false)) do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
546 max_trys = max_trys - 1; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
547 if max_trys == 0 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
548 break; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
549 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
550 day = incrementDay(day); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
551 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
552 if max_trys == 0 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
553 return nil; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
554 else |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
555 return day; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
556 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
557 end |
179
af6143756a9e
mod_muc_log_http: started new prosody theme
Thilo Cestonaro <thilo@cestona.ro>
parents:
146
diff
changeset
|
558 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
559 local function decrementDay(bare_day) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
560 local year, month, day = bare_day:match("^(%d%d)(%d%d)(%d%d)"); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
561 local leapyear = false; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
562 module:log("debug", tostring(day).."/"..tostring(month).."/"..tostring(year)) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
563 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
564 day = tonumber(day); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
565 month = tonumber(month); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
566 year = tonumber(year); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
567 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
568 if year%4 == 0 and year%100 == 0 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
569 if year%400 == 0 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
570 leapyear = true; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
571 else |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
572 leapyear = false; -- turn of the century but not a leapyear |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
573 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
574 elseif year%4 == 0 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
575 leapyear = true; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
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 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
578 if day - 1 == 0 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
579 if month - 1 == 0 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
580 year = year - 1; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
581 month = 12; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
582 day = 31; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
583 else |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
584 month = month - 1; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
585 if (month == 2 and leapyear) then day = 29 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
586 elseif (month == 2 and not leapyear) then day = 28 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
587 elseif (month < 8 and month%2 == 1) or (month >= 8 and month%2 == 0) then day = 31 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
588 else day = 30 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
589 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
590 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
591 else |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
592 day = day - 1; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
593 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
594 return strformat("%.02d%.02d%.02d", year, month, day); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
595 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
596 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
597 local function findPreviousDay(bareRoomJid, bare_day) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
598 local node, host, resource = splitJid(bareRoomJid); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
599 local day = decrementDay(bare_day); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
600 local max_trys = 7; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
601 module:log("debug", day); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
602 while(not checkDatastorePathExists(node, host, day, false)) do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
603 max_trys = max_trys - 1; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
604 if max_trys == 0 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
605 break; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
606 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
607 day = decrementDay(day); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
608 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
609 if max_trys == 0 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
610 return nil; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
611 else |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
612 return day; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
613 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
614 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
615 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
616 local function parseDay(bareRoomJid, roomSubject, bare_day) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
617 local ret = ""; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
618 local year; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
619 local month; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
620 local day; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
621 local tmp; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
622 local node, host, resource = splitJid(bareRoomJid); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
623 local year, month, day = bare_day:match("^(%d%d)(%d%d)(%d%d)"); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
624 local previousDay = findPreviousDay(bareRoomJid, bare_day); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
625 local nextDay = findNextDay(bareRoomJid, bare_day); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
626 local temptime = {day=0, month=0, year=0}; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
627 local path = data_getpath(node, host, datastore); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
628 path = path:gsub("/[^/]*$", ""); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
629 local calendar = "" |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
630 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
631 if tonumber(year) <= 99 then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
632 year = year + 2000; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
633 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
634 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
635 temptime.day = tonumber(day) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
636 temptime.month = tonumber(month) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
637 temptime.year = tonumber(year) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
638 calendar = createMonth(temptime.month, temptime.year, {callback=perDayCallback, path=path, room=node, webPath="../"}) or "" |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
639 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
640 if bare_day ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
641 local data = data_load(node, host, datastore .. "/" .. bare_day); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
642 if data ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
643 for i=1, #data, 1 do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
644 local stanza = lom.parse(data[i]); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
645 if stanza ~= nil and stanza.attr ~= nil and stanza.attr.time ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
646 local timeStuff = html.day.time:gsub("###TIME###", stanza.attr.time):gsub("###UTC###", stanza.attr.utc or stanza.attr.time); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
647 if stanza[1] ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
648 local nick; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
649 local tmp; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
650 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
651 -- grep nick from "from" resource |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
652 if stanza[1].attr.from ~= nil then -- presence and messages |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
653 nick = htmlEscape(stanza[1].attr.from:match("/(.+)$")); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
654 elseif stanza[1].attr.to ~= nil then -- iq |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
655 nick = htmlEscape(stanza[1].attr.to:match("/(.+)$")); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
656 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
657 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
658 if stanza[1].tag == "presence" and nick ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
659 tmp = parsePresenceStanza(stanza[1], timeStuff, nick); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
660 elseif stanza[1].tag == "message" then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
661 tmp = parseMessageStanza(stanza[1], timeStuff, nick); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
662 elseif stanza[1].tag == "iq" then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
663 tmp = parseIqStanza(stanza[1], timeStuff, nick); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
664 else |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
665 module:log("info", "unknown stanza subtag in log found. room: %s; day: %s", bareRoomJid, year .. "/" .. month .. "/" .. day); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
666 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
667 if tmp ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
668 ret = ret .. tmp |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
669 tmp = nil; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
670 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
671 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
672 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
673 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
674 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
675 if ret ~= "" then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
676 if nextDay then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
677 nextDay = html.day.dayLink:gsub("###DAY###", nextDay):gsub("###TEXT###", ">") |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
678 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
679 if previousDay then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
680 previousDay = html.day.dayLink:gsub("###DAY###", previousDay):gsub("###TEXT###", "<"); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
681 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
682 ret = ret:gsub("%%", "%%%%"); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
683 tmp = html.day.body:gsub("###DAY_STUFF###", ret):gsub("###JID###", bareRoomJid); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
684 tmp = tmp:gsub("###CALENDAR###", calendar); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
685 tmp = tmp:gsub("###DATE###", tostring(os_date("%A, %B %d, %Y", os_time(temptime)))); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
686 tmp = tmp:gsub("###TITLE_STUFF###", html.day.title:gsub("###TITLE###", roomSubject)); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
687 tmp = tmp:gsub("###STATUS_CHECKED###", config.showStatus and "checked='checked'" or ""); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
688 tmp = tmp:gsub("###JOIN_CHECKED###", config.showJoin and "checked='checked'" or ""); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
689 tmp = tmp:gsub("###NEXT_LINK###", nextDay or ""); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
690 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
|
691 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
692 return tmp; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
693 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
694 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
695 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
|
696 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
697 function handle_request(method, body, request) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
698 local node, host, day = splitUrl(request.url.path); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
699 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
700 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
|
701 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
702 if muc_hosts ~= nil and html.doc ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
703 if node ~= nil and host ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
704 local bare = node .. "@" .. host; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
705 if prosody.hosts[host] ~= nil and prosody.hosts[host].muc ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
706 if prosody.hosts[host].muc.rooms[bare] ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
707 local room = prosody.hosts[host].muc.rooms[bare]; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
708 if day == nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
709 return createDoc(generateDayListSiteContentByRoom(bare)); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
710 else |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
711 local subject = "" |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
712 if room._data ~= nil and room._data.subject ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
713 subject = room._data.subject; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
714 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
715 return createDoc(parseDay(bare, subject, day)); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
716 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
717 else |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
718 return createDoc(generateRoomListSiteContent(host)); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
719 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
720 else |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
721 return createDoc(generateComponentListSiteContent()); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
722 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
723 elseif host ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
724 return createDoc(generateRoomListSiteContent(host)); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
725 else |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
726 return createDoc(generateComponentListSiteContent()); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
727 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
728 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
729 return; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
730 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
731 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
732 -- Compatibility: Lua-5.1 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
733 function split(str, pat) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
734 local t = {} -- NOTE: use {n = 0} in Lua-5.0 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
735 local fpat = "(.-)" .. pat |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
736 local last_end = 1 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
737 local s, e, cap = str:find(fpat, 1) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
738 while s do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
739 if s ~= 1 or cap ~= "" then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
740 table.insert(t,cap) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
741 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
742 last_end = e+1 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
743 s, e, cap = str:find(fpat, last_end) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
744 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
745 if last_end <= #str then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
746 cap = str:sub(last_end) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
747 table.insert(t, cap) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
748 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
749 return t |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
750 end |
179
af6143756a9e
mod_muc_log_http: started new prosody theme
Thilo Cestonaro <thilo@cestona.ro>
parents:
146
diff
changeset
|
751 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
752 local function assign(arr, content) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
753 local tmp = html; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
754 local idx = nil; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
755 for _,i in ipairs(arr) do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
756 if idx ~= nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
757 if tmp[idx] == nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
758 tmp[idx] = {}; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
759 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
760 tmp = tmp[idx]; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
761 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
762 idx = i; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
763 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
764 tmp[idx] = content; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
765 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
766 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
767 local function readFile(filepath) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
768 local f = assert(io_open(filepath, "r")); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
769 local t = f:read("*all"); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
770 f:close() |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
771 return t; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
772 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
|
773 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
774 local function loadTheme(path) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
775 for file in lfs.dir(path) do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
776 if file ~= "." and file ~= ".." then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
777 module:log("debug", "opening theme file: " .. file); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
778 local tmp = split(file:gsub("\.html$", ""), "_"); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
779 local content = readFile(path .. "/" .. file); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
780 assign(tmp, content); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
781 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
782 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
783 return true; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
784 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
785 |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
786 function module.load() |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
787 config = config_get("*", "core", "muc_log_http") or {}; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
788 if config.showStatus == nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
789 config.showStatus = true; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
790 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
791 if config.showJoin == nil then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
792 config.showJoin = true; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
793 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
794 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
795 theme = config.theme or "prosody"; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
796 local themePath = themesParent .. "/" .. tostring(theme); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
797 local attributes, err = lfs.attributes(themePath); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
798 if attributes == nil or attributes.mode ~= "directory" then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
799 module:log("error", "Theme folder of theme \"".. tostring(theme) .. "\" isn't existing. expected Path: " .. themePath); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
800 return false; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
801 end |
105
cef943f0a551
mod_muc_log_http: themified ...
Thilo Cestonaro <thilo@cestona.ro>
parents:
104
diff
changeset
|
802 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
803 -- module:log("debug", (require "util.serialization").serialize(html)); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
804 if(not loadTheme(themePath)) then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
805 module:log("error", "Theme \"".. tostring(theme) .. "\" is missing something."); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
806 return false; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
807 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
808 -- module:log("debug", (require "util.serialization").serialize(html)); |
105
cef943f0a551
mod_muc_log_http: themified ...
Thilo Cestonaro <thilo@cestona.ro>
parents:
104
diff
changeset
|
809 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
810 httpserver.new_from_config({ config.http_port or true }, handle_request, { base = urlBase, ssl = false, port = 5290 }); |
105
cef943f0a551
mod_muc_log_http: themified ...
Thilo Cestonaro <thilo@cestona.ro>
parents:
104
diff
changeset
|
811 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
812 for jid, host in pairs(prosody.hosts) do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
813 if host.muc then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
814 local enabledModules = config_get(jid, "core", "modules_enabled"); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
815 if enabledModules then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
816 for _,mod in ipairs(enabledModules) do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
817 if(mod == "muc_log") then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
818 module:log("debug", "component: %s", tostring(jid)); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
819 muc_hosts[jid] = true; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
820 break; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
821 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
822 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
823 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
824 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
825 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
826 module:log("debug", "loaded mod_muc_log_http"); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
827 end |
105
cef943f0a551
mod_muc_log_http: themified ...
Thilo Cestonaro <thilo@cestona.ro>
parents:
104
diff
changeset
|
828 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
829 function module.unload() |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
830 muc_hosts = nil; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
831 module:log("debug", "unloaded mod_muc_log_http"); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
832 end |
94
941fd7d8b9b2
mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff
changeset
|
833 |
348
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
834 module:hook("component-activated", function(component, config) |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
835 if config.core and config.core.modules_enabled then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
836 for _,mod in ipairs(config.core.modules_enabled) do |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
837 if(mod == "muc_log") then |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
838 module:log("debug", "component: %s", tostring(component)); |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
839 muc_hosts[component] = true; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
840 break; |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
841 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
842 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
843 end |
03e1dc036a28
mod_muc_log_http: HTML overhaul. Replacing deprecated elements and style-attributes.
Florian Zeitz <florob@babelmonkeys.de>
parents:
344
diff
changeset
|
844 end); |