Author: buildbot Date: Sat Dec 16 15:47:55 2023 New Revision: 1914717 URL: http://svn.apache.org/viewvc?rev=1914717&view=rev Log: Automatic Site Publish by Buildbot
Modified: attic/site/docs/scripts/attic_filter.lua Modified: attic/site/docs/scripts/attic_filter.lua URL: http://svn.apache.org/viewvc/attic/site/docs/scripts/attic_filter.lua?rev=1914717&r1=1914716&r2=1914717&view=diff ============================================================================== --- attic/site/docs/scripts/attic_filter.lua (original) +++ attic/site/docs/scripts/attic_filter.lua Sat Dec 16 15:47:55 2023 @@ -6,7 +6,26 @@ /var/www/attic.apache.org/flagged/%{HTTP_HOST} See the tlp vhost definitions in https://github.com/apache/infrastructure-p6/blob/production/data/roles/tlpserver.yaml - + + 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. It does not work for some hosts, especially those that have a static menu bar + with scrolling content. In such cases, the code looks for a specific tag (which should only occur once + in any of the site pages, otherwise two banners may be added) and adds the banner either before or after it. + + The best location for this is found by trial and error: + - download a copy of a page + - move the banner from the start of the page (where it is added by default) and try it in various + other parts of the page. + - try the same in some other pages that have a different layout. + - repeat until a suitable location is found and find a tag or other string that uniquely identifies it + - add the host-specific processing to the filter along the lines of the existing host exceptions + Note: This filter was introduced in April 2018, so not all projects in the Attic use this filter. Previously the project websites themselves were changed. ]]-- @@ -15,11 +34,11 @@ function output_filter(r) -- We only filter text/html types if not r.content_type:match("text/html") then return end - -- add header: -- get TLP part of hostname local host = r.hostname:match("^([^.]+)") - local divstyle = 'font-size:x-large;padding:15px;color:white;background:red;z-index: 99;' ; + -- 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' ; local div = ([[ <div style='%s'> @@ -28,6 +47,7 @@ function output_filter(r) Attic page</a>. </div>]]):format(divstyle, astyle, host) + -- add header: -- special processing needed for some hosts if host == 'predictionio' or host == 'eagle' or host == 'metamodel' or host == 'mxnet' then @@ -35,8 +55,9 @@ function output_filter(r) else coroutine.yield(div) end + -- spit out the actual page - while bucket do + while bucket ~= nil do -- special processing needed for hosts as above if host == 'predictionio' then @@ -59,4 +80,6 @@ function output_filter(r) end end + -- no need to add anything at the end of the content + end