Comparison

plugins/mod_http_errors.lua @ 11403:747e8245f180

mod_http_errors: Add some silly variations for the '/' page > "You can do anything in XMPP!" > as a reminiscence of zombo.com -- jonas’ > A study in simplicity. Prosody tagline
author Kim Alvefur <zash@zash.se>
date Thu, 25 Feb 2021 12:59:28 +0100
parent 11395:d336b28b4002
child 11404:f7704f987439
comparison
equal deleted inserted replaced
11402:a3be7b3cf1e1 11403:747e8245f180
13 [403] = { "You're not allowed to do that." }; 13 [403] = { "You're not allowed to do that." };
14 [404] = { "Whatever you were looking for is not here. %"; 14 [404] = { "Whatever you were looking for is not here. %";
15 "Where did you put it?", "It's behind you.", "Keep looking." }; 15 "Where did you put it?", "It's behind you.", "Keep looking." };
16 [500] = { "% Check your error log for more info."; 16 [500] = { "% Check your error log for more info.";
17 "Gremlins.", "It broke.", "Don't look at me." }; 17 "Gremlins.", "It broke.", "Don't look at me." };
18 ["/"] = {
19 "A study in simplicity.";
20 "Better catch it!";
21 "Don't just stand there, go after it!";
22 "Well, say something, before it runs too far!";
23 "Welcome to the world of XMPP!";
24 "You can do anything in XMPP!"; -- "The only limit is XML.";
25 "You can do anything with Prosody!"; -- the only limit is memory?
26 };
18 }; 27 };
19 28
20 local messages = setmetatable(module:get_option("http_errors_messages", {}), { __index = default_messages }); 29 local messages = setmetatable(module:get_option("http_errors_messages", {}), { __index = default_messages });
21 30
22 local html = [[ 31 local html = [[
76 85
77 module:hook_object_event(server, "http-error", function (event) 86 module:hook_object_event(server, "http-error", function (event)
78 local request, response = event.request, event.response; 87 local request, response = event.request, event.response;
79 if request and response and request.path == "/" and response.status_code == 404 then 88 if request and response and request.path == "/" and response.status_code == 404 then
80 response.headers.content_type = "text/html; charset=utf-8"; 89 response.headers.content_type = "text/html; charset=utf-8";
90 local message = messages["/"];
81 return render(html, { 91 return render(html, {
82 title = "Prosody is running!"; 92 title = "Prosody is running!";
83 message = "Welcome to the XMPP world!"; 93 message = message[math.random(#message)];
84 }); 94 });
85 end 95 end
86 end, 1); 96 end, 1);
87 97