Software /
code /
prosody
Comparison
plugins/mod_http_errors.lua @ 11663:04fa947784bc
mod_http_errors: Add a Prosody logo to root page
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 09 Jul 2021 21:55:14 +0200 |
parent | 11662:a8798e04b5c8 |
child | 11664:d83f8f44caea |
comparison
equal
deleted
inserted
replaced
11662:a8798e04b5c8 | 11663:04fa947784bc |
---|---|
83 event.response.headers.content_type = "text/html; charset=utf-8"; | 83 event.response.headers.content_type = "text/html; charset=utf-8"; |
84 end | 84 end |
85 return render(html, event); | 85 return render(html, event); |
86 end); | 86 end); |
87 | 87 |
88 local icon = [[ | |
89 <svg xmlns="http://www.w3.org/2000/svg" height="0.7em" viewBox="0 0 480 480" width="0.7em"> | |
90 <rect fill="#6197df" height="220" rx="60" ry="60" width="220" x="10" y="10"></rect> | |
91 <rect fill="#f29b00" height="220" rx="60" ry="60" width="220" x="10" y="240"></rect> | |
92 <rect fill="#f29b00" height="220" rx="60" ry="60" width="220" x="240" y="10"></rect> | |
93 <rect fill="#6197df" height="220" rx="60" ry="60" width="220" x="240" y="240"></rect> | |
94 </svg> | |
95 ]]; | |
96 | |
88 -- Something nicer shown instead of 404 at the root path, if nothing else handles this path | 97 -- Something nicer shown instead of 404 at the root path, if nothing else handles this path |
89 module:hook_object_event(server, "http-error", function (event) | 98 module:hook_object_event(server, "http-error", function (event) |
90 local request, response = event.request, event.response; | 99 local request, response = event.request, event.response; |
91 if request and response and request.path == "/" and response.status_code == 404 then | 100 if request and response and request.path == "/" and response.status_code == 404 then |
92 response.headers.content_type = "text/html; charset=utf-8"; | 101 response.headers.content_type = "text/html; charset=utf-8"; |
93 local message = messages["/"]; | 102 local message = messages["/"]; |
94 return render(html, { | 103 return render(html, { |
104 icon_raw = icon, | |
95 title = "Prosody is running!"; | 105 title = "Prosody is running!"; |
96 message = message[math.random(#message)]; | 106 message = message[math.random(#message)]; |
97 }); | 107 }); |
98 end | 108 end |
99 end, 1); | 109 end, 1); |