This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new 75f7bcb4 Add maintenance banner filter
75f7bcb4 is described below
commit 75f7bcb42eb10bbcce34ece64de42c2dc3e3c657
Author: Sebb <[email protected]>
AuthorDate: Fri Jan 12 19:23:10 2024 +0000
Add maintenance banner filter
---
maintenance_banner.lua | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/maintenance_banner.lua b/maintenance_banner.lua
new file mode 100644
index 00000000..55ebe91d
--- /dev/null
+++ b/maintenance_banner.lua
@@ -0,0 +1,42 @@
+--[[
+ This is an output filter for HTML files
+ It adds a banner when maintenance mode is detected
+
+ It is invoked by the following file exists:
+ /srv/whimsy/www/maintenance.tct
+
+ The mod_lua API is described here:
+ https://httpd.apache.org/docs/current/mod/mod_lua.html#modifying_buckets
+
+ How it works:
+ For simplicity, we add the banner to the start of the page.
+
+ This is not really valid HTML, but seems to work in most cases, and avoids
having to find a better
+ place to insert it.
+
+]]--
+
+function output_filter(r)
+ -- We only filter text/html types
+ if not r.content_type:match("text/html") then return end
+
+ -- create the customised banner
+ local divstyle =
'font-size:x-large;padding:15px;color:white;background:red;z-index:99;' ;
+ -- local astyle = 'color:white;text-decoration:underline' ; -- <a>
+ local div = ([[
+ <div style='%s'>
+ The Whimsy server is undergoing maintenance. Not all functions are
available.
+ %s
+ </div>]]):format(divstyle, r.content_type)
+
+ -- add header:
+ coroutine.yield(div)
+
+ -- spit out the actual page
+ while bucket ~= nil do
+ coroutine.yield(bucket)
+ end
+
+ -- no need to add anything at the end of the content
+
+end