Mercurial > prosody-modules
comparison mod_http_muc_log/mod_http_muc_log.lua @ 1582:8e282eb0c70c
mod_http_muc_log: Split out template into a configurable file.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 03 Dec 2014 15:35:38 +0100 |
parents | 9f6cd252d233 |
children | c8a51d1bc96d |
comparison
equal
deleted
inserted
replaced
1581:9f6cd252d233 | 1582:8e282eb0c70c |
---|---|
61 return block:sub(e+1, -2); | 61 return block:sub(e+1, -2); |
62 end | 62 end |
63 end)); | 63 end)); |
64 end | 64 end |
65 | 65 |
66 -- TODO Move template into a file | 66 local template = "Could not load template" |
67 local template = [=[ | 67 do |
68 <!DOCTYPE html> | 68 local template_file = module:get_option_string(module.name .. "_template", module.name .. ".html"); |
69 <html> | 69 template_file = assert(module:load_resource(template_file)); |
70 <head> | 70 template = template_file:read("*a"); |
71 <meta charset="utf-8"> | 71 template_file:close(); |
72 <meta name="viewport" content="width=device-width, initial-scale=1"> | 72 end |
73 <title>{title}</title> | |
74 <style> | |
75 :link,:visited{text-decoration:none;color:#2e3436;text-decoration:none;} | |
76 :link:hover,:visited:hover{color:#3465a4;} | |
77 body{background-color:#eeeeec;margin:1ex 0;padding-bottom:3em;font-family:Arial,Helvetica,sans-serif;} | |
78 ul,ol{padding:0;} | |
79 li{list-style:none;} | |
80 hr{visibility:hidden;clear:both;} | |
81 br{clear:both;} | |
82 header,footer{margin:1ex 1em;} | |
83 footer{font-size:smaller;color:#babdb6;} | |
84 nav{font-size:large;margin:1ex 1ex;clear:both;line-height:1.5em;} | |
85 footer nav .up{display:none;} | |
86 @media screen and (min-width: 460px) { | |
87 nav {font-size:x-large;margin:1ex 1em;} | |
88 } | |
89 nav a{padding: 1ex;} | |
90 nav .up{font-size:smaller;display:block;clear:both;} | |
91 nav .prev{float:left;} | |
92 nav .next{float:right;} | |
93 nav .next::after{content:" →";} | |
94 nav .prev::before{content:"← ";} | |
95 nav :empty::after,nav :empty::before{content:""} | |
96 .content{background-color:white;padding:1em;list-style-position:inside;} | |
97 .time{float:right;font-size:small;opacity:0.2;} | |
98 li:hover .time{opacity:1;} | |
99 .description{font-size:smaller;} | |
100 .body{white-space:pre-line;} | |
101 .body::before,.body::after{content:"";} | |
102 .presence .verb{font-style:normal;color:#30c030;} | |
103 .unavailable .verb{color:#c03030;} | |
104 </style> | |
105 </head> | |
106 <body> | |
107 <header> | |
108 <h1 title="xmpp:{jid?}">{title}</h1> | |
109 <nav>{links# | |
110 <a class="{rel?}" href="{href}" rel="{rel?}">{text}</a>} | |
111 </nav> | |
112 </header> | |
113 <hr> | |
114 <div class="content"> | |
115 <nav> | |
116 <dl class="room-list"> | |
117 {rooms# | |
118 <dt class="name"><a href="{href}">{name}</a></dt> | |
119 <dd class="description">{description?}</dd>} | |
120 </dl> | |
121 <ul class="dates">{dates# | |
122 <li><a href="{date}">{date}</a></li>} | |
123 </ul> | |
124 </nav> | |
125 <ol class="chat-logs">{lines# | |
126 <li class="{st_name} {st_type?}" id="{key}"> | |
127 <a class="time" href="#{key}"><time datetime="{datetime}">{time}</time></a> | |
128 <b class="nick">{nick}</b> | |
129 <em class="verb">{verb?}</em> | |
130 <q class="body">{body?}</q> | |
131 </li>} | |
132 </ol> | |
133 </div> | |
134 <hr> | |
135 <footer> | |
136 <nav>{links# | |
137 <a class="{rel?}" href="{href}" rel="{rel?}">{text}</a>} | |
138 </nav> | |
139 <br> | |
140 <div class="powered-by">Prosody</div> | |
141 </footer> | |
142 <script> | |
143 /* | |
144 * Local timestamps | |
145 */ | |
146 (function () { | |
147 var timeTags = document.getElementsByTagName("time"); | |
148 var i = 0, tag, date; | |
149 while(timeTags[i]) { | |
150 tag = timeTags[i++]; | |
151 if(date = tag.getAttribute("datetime")) { | |
152 date = new Date(date); | |
153 tag.textContent = date.toLocaleTimeString(); | |
154 tag.setAttribute("title", date.toString()); | |
155 } | |
156 } | |
157 })(); | |
158 </script> | |
159 </body> | |
160 </html> | |
161 ]=]; | |
162 | 73 |
163 local base_url = module:http_url() .. '/'; | 74 local base_url = module:http_url() .. '/'; |
164 local get_link do | 75 local get_link do |
165 local link, path = { path = '/' }, { "", "", is_directory = true }; | 76 local link, path = { path = '/' }, { "", "", is_directory = true }; |
166 function get_link(room, date) | 77 function get_link(room, date) |