Author: henkp Date: Wed Apr 11 06:18:31 2018 New Revision: 1828863 URL: http://svn.apache.org/viewvc?rev=1828863&view=rev Log: init add-banner.lua
Added: attic/site/docs/scripts/ attic/site/docs/scripts/add-banner.lua (with props) Added: attic/site/docs/scripts/add-banner.lua URL: http://svn.apache.org/viewvc/attic/site/docs/scripts/add-banner.lua?rev=1828863&view=auto ============================================================================== --- attic/site/docs/scripts/add-banner.lua (added) +++ attic/site/docs/scripts/add-banner.lua Wed Apr 11 06:18:31 2018 @@ -0,0 +1,142 @@ +local posix = require 'posix' +local TEMPL = [=[ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" +"http://www.w3.org/TR/html4/loose.dtd"> +<html> +<head> +<title>Project !PROJ! is retired.</title> +<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8"> +<style type="text/css"> +<!--/* <![CDATA[ */ +div.top + { font-size : xx-large ; + padding : 15px ; + color : white ; + background-color : red ; + } +div.top a:link { color : white ; } +div.top a:visited { color : white ; } +span.urly { color : blue ; text-decoration : underline } +/* ]]> */--> +</style> +<script>//<![CDATA[ +function initialize () + { console.log ( 'initialize' ) ; + resize() ; + if ( window.self != window.top ) + { var win1 = window.top.document.getElementById("f2").contentWindow + var win2 = window.self.document.getElementById("f2").contentWindow + win1.location.href = win2.location.href + console.log ( 'window.self != window.top' ) + console.log ( 'promote to : ' + win1.location.href ) + } + else + { console.log ( 'window.self == window.top' ) ; } + } + +function resize () + { console.log ( 'resize' ) ; + console.log ( 'innerHeight[%s]', window.innerHeight ) ; + var f1h = document.getElementById("f1").clientHeight ; + var w_w = window.innerWidth ; + var w_h = window.innerHeight ; + var f_w = 0.99 * w_w ; + var f_h = w_h - f1h - 50 ; + document.getElementById("f2").width = f_w ; + document.getElementById("f2").height = f_h ; + console.log ( 'f2.height[%s]', document.getElementById("f2").height ) ; + } + +function change_loc() + { console.log ( 'change_loc' ) ; + var top = document.getElementById("top") ; + var loc = document.getElementById("loc") ; + var f2 = document.getElementById('f2') ; + try { f2.contentWindow.location.href ; } + catch ( exception ) + { console.log ( 'exception ' + exception ) ; + top.innerHTML = "Left <i>!HOST!</i> ..." + loc.innerHTML = '<p><span style="color:red">' + + '<b>[to leave frame]</b></span> ' + + 'Use the <i><b>show only this frame</b></i> function ' + + 'of your browser.' + return ; + } + var url = '<a href="http://attic.apache.org/projects/!PROJ!.html">' + + 'attic page</a>' + top.innerHTML = "Project <i>!PROJ!</i> is retired ; " + + "for details, see !PROJ!'s " + url + '.' + loc.innerHTML = '<p>location: ' + + f2.contentWindow.location.pathname + } +//]]></script> +</head> + +<body onload="initialize()" onresize="resize()"> + <div id="f1"> + <div id="top" class="top"></div> + <span id='loc'></span> + </div> + <iframe id="f2" onload="change_loc()" src="/try2/FRAME/!PATH!"></iframe> +</body> +</html> +]=] + +local PROG = 'add-banner.lua' ; +local ATTIC_DIR = '/var/www/attic.apache.org/' +local ATTIC_PRJS = ATTIC_DIR .. 'flagged/' + +function exists(f) return posix.stat(f) ~= nil end +function in_attic(p) return exists ( ATTIC_PRJS .. p ) end + +function handle(r) + local get = r:parseargs() + local err = nil + local PROJ + local PATH + local TEST = true + + r.content_type = "text/html" + + -- r:puts ( r.unparsed_uri .. "<br>\n" ) + -- for k, v in pairs ( get ) do + -- r:puts( string.format("arg [%s] [%s]<br>\n", k, v) ) + -- end + + if get.PROJ then + if get.PROJ == '' then + err = "PROJ is empty" + else + PROJ = r.subprocess_env['REQUEST_URI'] + end + else + -- |try2| == 1 + 3 + local uri = r.unparsed_uri:sub(3+string.len(PROG)) + local idx = uri:find('/') + if idx then + PROJ = uri:sub(1,idx-1) ; PATH = uri:sub(idx+1) + else + PROJ = uri ; PATH = '' + end + end + + if err ~= nil then r:puts(err) return apache2.OK end + + if not TEST and not get.test and not in_attic(PROJ) then + err = "project is not in attic [" .. PROJ .. "]" + end + + if err ~= nil then + r:puts(err) + else + local text = TEMPL + local subs = + { ['!PROJ!'] = PROJ + , ['!HOST!'] = PROJ .. '.apache.org' + , ['!PATH!'] = PATH + } + for k, v in pairs ( subs ) do text, _ = string.gsub ( text, k, v ) end + r:puts(text) + end + return apache2.OK +end Propchange: attic/site/docs/scripts/add-banner.lua ------------------------------------------------------------------------------ svn:executable = *