This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/attic.git
The following commit(s) were added to refs/heads/main by this push:
new 43129e8 Simplify special processing
43129e8 is described below
commit 43129e88e2632ece3e417a4f656feb081ce51dc1
Author: Sebb <[email protected]>
AuthorDate: Thu Oct 9 18:37:21 2025 +0100
Simplify special processing
---
DOCKER.md | 5 +++--
scripts/attic_filter.lua | 49 +++++++++++++++++++++++++++++++-----------------
2 files changed, 35 insertions(+), 19 deletions(-)
diff --git a/DOCKER.md b/DOCKER.md
index c72734d..2a35539 100644
--- a/DOCKER.md
+++ b/DOCKER.md
@@ -20,7 +20,8 @@ To enable/disable the Attic banner, create/delete the
directory (not a file!):
Alternatively, define the variable VAR_ATTIC=yes
If the banner does not display correctly (e.g. it may be partially hidden
under the menu bar),
-you can try to see if any of the existing filter overrides work. Just use the
relevant sitename
+you can try to see if any of the existing filter overrides work.
+Use one of the shorthand style names (currently _a, _b ..._e) as the VAR_NAME
value
in the docker command below instead of the target sitename.
You can quickly check all the existing overrides using this method.
@@ -31,7 +32,7 @@ If not available, such pages will fail to load, but the site
should otherwise wo
Start:
`[VAR_DYN=/path/to/closer_cgi/files] VAR_HTML=/path/to/website
VAR_NAME=sitename [VAR_ATTIC=yes] docker compose up`
-browse to localhost:8000
+Browse to localhost:8000
Start shell (container must be running):
`docker compose exec attic_lua_csp /bin/bash`
diff --git a/scripts/attic_filter.lua b/scripts/attic_filter.lua
index 8c54c05..6ea53eb 100644
--- a/scripts/attic_filter.lua
+++ b/scripts/attic_filter.lua
@@ -30,6 +30,22 @@
Previously the project websites themselves were changed.
]]--
+-- hostnames that need special processing
+-- keys are the host names, values are the style of edit needed
+local OVERRIDES = {
+ predictionio = 'a',
+ mxnet = 'b',
+ twill = 'c',
+ eagle = 'd',
+ metamodel = 'e',
+ -- Shorthand names for testing using VAR_NAME override
+ _a = 'a',
+ _b = 'b',
+ _c = 'c',
+ _d = 'd',
+ _e = 'e'
+}
+
function output_filter(r)
-- We only filter text/html types
if not r.content_type:match("text/html") then return end
@@ -57,7 +73,9 @@ function output_filter(r)
-- add header:
-- special processing needed for some hosts
- if host == 'predictionio' or host == 'eagle' or host == 'metamodel' or
host == 'mxnet' or host == 'twill'
+ local style = OVERRIDES[host]
+ -- if host == 'predictionio' or host == 'eagle' or host == 'metamodel' or
host == 'mxnet' or host == 'twill'
+ if style
then
coroutine.yield('')
else
@@ -66,32 +84,29 @@ function output_filter(r)
-- spit out the actual page
while bucket ~= nil do
+ local output
-- special processing needed for hosts as above
- if host == 'predictionio'
+ if style == 'a'
then
- local output = bucket:gsub('<header>', '<header>'..div, 1)
- coroutine.yield(output)
- elseif host == 'mxnet'
+ output = bucket:gsub('<header>', '<header>'..div, 1)
+ elseif style == 'b'
then
- local output = bucket:gsub('</header>', div..'</header>', 1)
- coroutine.yield(output)
- elseif host == 'twill'
+ output = bucket:gsub('</header>', div..'</header>', 1)
+ elseif style == 'c'
then
-- Fix for Javadocs: </header> does not appear in them, and
-- topNav only appears in the Javadoc pages that can take the div
without failing
- local output = bucket:gsub('</header>', div..'</header>',
1):gsub('<div class="topNav">', divnew..'<div class="topNav">', 1)
- coroutine.yield(output)
- elseif host == 'eagle'
+ output = bucket:gsub('</header>', div..'</header>', 1):gsub('<div
class="topNav">', divnew..'<div class="topNav">', 1)
+ elseif style == 'd'
then
- local output = bucket:gsub('</nav>', '</nav>'..div, 1)
- coroutine.yield(output)
- elseif host == 'metamodel'
+ output = bucket:gsub('</nav>', '</nav>'..div, 1)
+ elseif style == 'e'
then
- local output = bucket:gsub('</nav>', div..'</nav>', 1):gsub('<div
class="topNav">', divnew..'<div class="topNav">', 1)
- coroutine.yield(output)
+ output = bucket:gsub('</nav>', div..'</nav>', 1):gsub('<div
class="topNav">', divnew..'<div class="topNav">', 1)
else
- coroutine.yield(bucket)
+ output = bucket
end
+ coroutine.yield(output)
end
-- no need to add anything at the end of the content