Chairs of Academic Boards Web Page Management

John Hurst () This document defines and describes the suite of programs used to create the web page environment for the Chairs of Academic Boards organization.

1. Introduction

This document describes the files used to set up the appropriate working environment for using the bash shell. They are intensely personal, and anyone reusing this document for their own purposes will also certainly want to modify this document.

Permission is given to reuse this document, provided that the source is acknowledged, and that any changes are noted in the documentation.

The document is in the form of a literate program, and generates all files necessary to maintain the working environment, including a Makefile.

2. Literate Data

This message gets used in a number of places to ensure that all modifications are focussed through this document.

DO NOT EDIT this file! see $HOME/www/chab/chairsabs.xlp instead

3. Imported modules

3.1 Determine which host this script is running upon

server=os.environ["SERVER_NAME"]MacOSX='MacOSX' ; Solaris='Solaris' ; Linux="Linux"system=MacOSXif server=="www.csse.monash.edu.au": host='csse' ; ostype='Solaris' ; system=Solariselif server in ["njhurst.com","www.njhurst.com",\ "ajhurst.org","www.ajhurst.org",\ "chairsabs.org.au","www.chairsabs.org.au"]: host='sequoia' ; ostype='Linux' ; system=Linuxelif server in ['localhost','murtoa','murtoa.local','chairsabs']: host='murtoa'; ostype='MacOSX' ; system=MacOSXelif server=='bendigo.infotech.monash.edu.au': host='bendigo' ; ostype='MacOSX' ; system=MacOSXelif server in ['ajh.id.au','www.ajh.id.au','10.0.0.105']: host='rainbow' ; ostype='MacOSX' ; system=MacOSXelif server[0:11]=='dyn-130-194-': host='murtoa' ; ostype='MacOSX' ; system=MacOSXelse: host = ostype = server = 'unknown'

4. chabindex.py

#!/usr/bin/python## This script processes all my web page XML files# It requires apache to be configured:# a) to allow python files (this file) to run as cgi in user directories# b) to add a handler for XML files that calls this program# c) to pass as cgi parm the XSLT file that translates the XML file# These are done in a .htaccess file for each directory (and its# subdirectories) that require XML processing with a particular# XSLT stylesheet.## The script relies upon picking up the required file and its XSLT file# from a) the REDIRECT environment variables, and b) the script parameter,# respectively.#import cgiimport osimport reimport sysimport datetimesys.stderr.write("Running new chairsabs index.py\n")# some globalsdebug=FalsereturnXML=Falsexslfile=""# BASE is the path to the web base directory - with no trailing slash!if system==MacOSX: BASE="/home/ajh/www" PRIVATE="/home/ajh/local/"+hostelif system==Solaris: BASE="/u/web/homes/ajh/chab" PRIVATE=BASEelif system==Linux: BASE="/home/ajh/www/chab" PRIVATE="/home/ajh/local/"+hostWEBDIR="file://"+BASE# define the XSLTPROCif system==MacOSX: XSLTPROC="/usr/bin/xsltproc"elif system==Solaris: XSLTPROC="/usr/monash/bin/xsltproc"elif system==Linux: XSLTPROC="/usr/X11R6/bin/xsltproc"# start processing. Get timestamp for recording key events in the lognow=datetime.datetime.now()tsstring=now.strftime("%Y%m%d:%H%M")today=now.strftime("%d %b %Y")# start the html outputprint "Content-type: text/html\n\n"file=""# Create string patterns# - to extract directory and filename from requestfilepat=re.compile('/~ajh/?(.*)/([^/]*)$')filename='index'# - to detect stylesheet request (optional)stylesheet=re.compile('<\?xml-stylesheet.*href="(.*)"')# - to terminate file scanningdoctype=re.compile('<!DOCTYPE')# to check for missing htmlshtmlpat=re.compile('(.*)\.html$')# to check for xslspecification in htaccessxslspec=re.compile('.*?xslfile=(.*)&')# collect the original parameters from the redirect (if there is one!)if os.environ.has_key('REDIRECT_QUERY_STRING'): query_string=os.environ['REDIRECT_QUERY_STRING'] form=cgi.parse_qs(query_string) if form.has_key('debug') and form['debug'][0]=='true': sys.stderr.write("%s: %s\n" % (tsstring,repr(form))) debug=True print "<p>%s: os.environ=%s</p>\n" % (tsstring,repr(os.environ)) print "<p>%s: form=%s</p>\n" % (tsstring,repr(form)) sys.stderr.write("%s: redirect_query string=%s\n" % (tsstring,query_string)) if form.has_key('xml') and form['xml'][0]=='true': sys.stderr.write("%s: %s\n" % (tsstring,repr(form))) returnXML=True if debug: print "<p>%s: os.environ=%s</p>\n" % (tsstring,repr(os.environ)) print "<p>%s: form=%s</p>\n" % (tsstring,repr(form)) sys.stderr.write("%s: redirect_query string=%s\n" % (tsstring,query_string))else: form={}if debug: print "<p>%s: (BASE,PRIVATE)=(%s,%s)</p>\n" % (tsstring,BASE,PRIVATE) print "<p>%s: (server,host,system)=(%s,%s,%s)</p>\n" % (tsstring,server,host,system) remoteAdr=''if os.environ.has_key('REMOTE_ADDR'): remoteAdr=os.environ['REMOTE_ADDR'] # get the file name from the redirect environmentif system==MacOSX: scriptURL='REDIRECT_URL'elif system==Solaris: scriptURL='REDIRECT_URL'elif system==Linux: scriptURL='REDIRECT_URL'if os.environ.has_key(scriptURL): file=os.environ[scriptURL] sys.stderr.write("%s: [client %s] requesting %s\n" % (tsstring,remoteAdr,file))orgfile=file# analyse file request. If a bare directory, add 'index.xml'if os.environ.has_key('REDIRECT_STATUS') and \ os.environ['REDIRECT_STATUS']=='404': res=htmlpat.match(file) if res: filename=res.group(1) file=filename+'.xml'dir=relcwd=""res=filepat.match(file)if res: dir=res.group(1) relcwd='/'+dir if dir!="": file=dir+'/'+res.group(2) else: file=res.group(2) filename=res.group(2)if file=='' or file[-1]=='/': file+='index.xml' filename='index'file=BASE+'/'+filedir=BASE+'/'+dirif debug: print "<p>%s: file to process = %s</p>" % (tsstring,file) print "<p>%s: os.environ=%s</p>\n" % (tsstring,repr(os.environ))# collect the XSLT file name from the .htaccess referentquery_string=os.environ['QUERY_STRING']if debug: sys.stderr.write("%s: query string=%s\n" % (tsstring,query_string))form2=cgi.parse_qs(query_string)if debug: print("<p>%s: form2=%s</p>\n" % (tsstring,repr(form)))if form2.has_key('xslfile'): xslfile=form2['xslfile'][0] if debug: print "<p>%s: got xslfile=%s</p>\n" % (tsstring,xslfile)# Check the requested file for a local stylesheet. We also scan the# entire file, replacing any symbolic references to $WEBDIR with the# full path for the current machine. Note that the DOCTYPE statement# must start a line by itself.try: filed=open(file) while 1: # keep scanning file until we find DOCTYPE line=filed.readline() if line=='': # this is EOF, so quit break line=line.strip() # remove NL #print "read line='%s'" % (line) # check if stylesheet specification start res=re.match('(<\?xml-stylesheet)(.*?)(\?>)?$',line) if res: if debug: print "%s~%s~%s" % (res.group(1),res.group(2),res.group(3)) # if group 3 is None, we haven't got the end of the stylesheet spec while res and res.group(3)==None: next=filed.readline() if next=='': break line+=' '+next.strip() #print "add line (group 3 was %s)='%s'" % (res.group(3),line) # check for full stylesheet again res=re.match('(<\?xml-stylesheet)(.*?)(\?>)?$',line) line=re.sub('(\$WEBDIR)',WEBDIR,line) #newfiled.write(line) # here we have a full stylesheet line - if it is stylesheet res=re.match('<\?xml-stylesheet.*href="(.*?)".*?>',line) if res: # it IS stylesheet, extract filename xslfile=res.group(1) if debug: print "<p>%s: found xslfile=%s</p>" % (tsstring,xslfile) break # not a stylesheet, check for DOCTYPE - stop scanning if so res=doctype.match(line) if res: break #while line!='': # scan to EOF #line=filed.readline() #if line=='': # this is EOF, so quit #break #line=re.sub('(\$WEBDIR)',WEBDIR,line) #newfiled.write(line) filed.close()except: print """ <h1>Sorry!! (Error 404)</h1> <p>In trying to process dynamically your request for file %s,<br/> it was found that the corresponding XML file %s does not exist</p> <p>Please check that the URL is correct</p> Exception values: (%s,%s,%s) """ % (orgfile,file,sys.exc_type,sys.exc_value,sys.exc_traceback) sys.exit(0)#newfiled.close()# have we got an xslfile yet?htacc=Noneif xslfile=="": # no, so check all .htaccess # first grab directory while len(dir)>=len(BASE): if debug: print "<p>directory=%s</p>\n" % (dir) if os.path.isfile(dir+"/.htaccess"): htacc=open(dir+"/.htaccess") if debug: print "<p>found .htaccess in directory %s</p>" % (dir) break else: dir=os.path.dirname(dir)if htacc: for line in htacc.readlines(): res=xslspec.match(line) if res: xslfile=BASE+'/'+res.group(1) if debug: print "<p>found xslfile %s in .htaccess</p>" % (xslfile) break if debug: print "<p>found xslfile %s in .htaccess</p>" % (xslfile)if system==Solaris: xslfile=re.sub('/home/ajh'+'/www','/u/web/homes/ajh',xslfile) if xslfile[0]!='/' and not (xslfile[0:5]=='file:'): xslfile='/u/web/homes/ajh/'+xslfile # define the parameters to the translationfilestat=os.stat(file)filemod=filestat.st_mtimedtfilemod=datetime.datetime.fromtimestamp(filemod)dtstring=dtfilemod.strftime("%Y%m%d:%H%M")parms="--param xmltime \"'%s'\" " % (dtstring)parms+="--param htmltime \"'%s'\" " % (tsstring)parms+="--param filename \"'%s'\" " % (filename)parms+="--param relcwd \"'%s'\" " % (relcwd)parms+="--param today \"'%s'\" " % (today)parms+="--param host \"'%s'\" " % (host)for key in form: value=form[key][0] parms+="--param "+key+" \"'%s'\" " % (value)if debug: sys.stderr.write("%s: xml file modified at %s\n" % (tsstring,dtstring))if returnXML: rawxmlf=open(file,'r') print "<PRE>\n" for line in rawxmlf.readlines(): line=line.rstrip() print cgi.escape(line) print "</PRE>\n"else: # start a pipe to process the XSLT translation cmd=XSLTPROC+" "+parms+"%s %s " % (xslfile,file) (pipein,pipeout,pipeerr)=os.popen3(cmd) if debug: cwd=os.getcwd() print "<p>%s: (cwd:%s) %s</p>" % (tsstring,cwd,cmd) sys.stderr.write("(cwd:%s) %s: %s\n" % (cwd,tsstring,cmd)) # report the fact, and the context (debugging purposes) if debug: print "%s: converting %s with %s\n" % (tsstring,file,xslfile) # process the converted HTML for line in pipeout.readlines(): line=line.strip() print line errs=[] for line in pipeerr.readlines(): errs.append(line) logfile=PRIVATE+'/xmlerror.log' logfiled=open(logfile,'a') if errs: logfiled.write("%s: ERROR IN REQUEST: %s\n" % (tsstring,file)) for errline in errs: logfiled.write("%s: %s" % (tsstring,errline)) else: logfiled.write("%s: NO ERRORS IN %s\n" % (tsstring,file)) logfiled.close() pipein.close(); pipeout.close(); pipeerr.close()now=datetime.datetime.now()tsstring=now.strftime("%Y%m%d:%H%M")sys.stderr.write("%s: [client %s] request satisfied\n" % (tsstring,remoteAdr))

5. chabwebdoc.xsl

<?xml version="1.0"?><!--********************************************************************* ** C H A B W E B D O C . X S L ** ** This XSL stylesheet converts XML documents with document type ** chabwebdoc to HTML. It relies upon several external components, the ** principal ones being header.xsl and footer.xsl, which define the ** header and footer material respectively. The header has some limited ** parameterization. ** **********************************************************************--><!DOCTYPE xsl:stylesheet PUBLIC "-//MONASH-CSSE//DTD stylesheet 1.0//EN" "file:///u/web/homes/ajh/lib/dtd/stylesheet.dtd"><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:func="http://exslt.org/functions" xmlns:date="http://exslt.org/dates-and-times" extension-element-prefixes="date func" > <xsl:output method="html" encoding="ASCII"/> <!-- These should be supplied from the make script, or dynamic parameters --> <xsl:param name="xmltime">(Not available)</xsl:param> <xsl:param name="htmltime">(Not available)</xsl:param> <xsl:param name="filename">(Not available)</xsl:param> <xsl:param name="relcwd">file:///home/ajh/web</xsl:param> <xsl:param name="today"></xsl:param> <xsl:param name="host">sequoia</xsl:param> <!-- define where all the server related information is kept --> <xsl:param name="serverdir"> <xsl:text>file:///home/ajh/local/</xsl:text> <xsl:value-of select="$host"/> </xsl:param> <xsl:param name="local"></xsl:param> <!-- define where the web pages are --> <xsl:param name="webdir"> <xsl:text>file:///u/web/homes/ajh</xsl:text> </xsl:param> <!-- envfile defines the path to the environment document --> <xsl:variable name="envfile"> <xsl:value-of select="$serverdir"/> <xsl:text>/environment</xsl:text> </xsl:variable> <!-- thisserver defines the current server. It does this by reading the local file 'environment', which contains a definition of the server qualified domain name --> <xsl:param name="thisserver"> <xsl:text>http://</xsl:text> <xsl:value-of select="document($envfile)/environment/chairsabs"/> <xsl:text>/</xsl:text> </xsl:param> <!-- base defines the directory from which documents are served by this script. <xsl:text>http://</xsl:text> --> <xsl:param name="base"> <xsl:value-of select="$thisserver"/> <xsl:if test="$host!='sequoia'"> <xsl:text>~ajh/chab/</xsl:text> </xsl:if> </xsl:param> <!-- some of these overridden, see below --> <xsl:include href="file:///u/web/homes/ajh/lib/xsl/basic2html.xsl"/> <xsl:include href="file:///u/web/homes/ajh/lib/xsl/numbered2html.xsl"/> <xsl:include href="file:///u/web/homes/ajh/lib/xsl/tables2html.xsl"/> <!-- D E F I N E H E A D E R A N D F O O T E R --> <!-- There are three parameters to header.xsl, and one to footer.xsl, described below --> <xsl:variable name="subpath"> <xsl:variable name="subdir"> <xsl:value-of select="chabwebdoc/@subdirectory"/> </xsl:variable> <xsl:if test="$subdir!=''"> <xsl:choose> <xsl:when test="substring($subdir,1,1)='/'"> <xsl:message> <xsl:text>@subdirectory=</xsl:text> <xsl:value-of select="$subdir"/> <xsl:text> starts with '/' - it shouldn't</xsl:text> </xsl:message> <xsl:value-of select="substring($subdir,2)"/> </xsl:when> <xsl:when test="substring($subdir,string-length($subdir),1)='/'"> <xsl:message> <xsl:text>@subdirectory=</xsl:text> <xsl:value-of select="$subdir"/> <xsl:text> ends with '/' - it shouldn't</xsl:text> </xsl:message> <xsl:value-of select="substring($subdir,1,string-length($subdir)-1)"/> </xsl:when> <xsl:otherwise><xsl:value-of select="$subdir"/></xsl:otherwise> </xsl:choose> <xsl:text>/</xsl:text> </xsl:if> <xsl:choose> <xsl:when test="chabwebdoc/@page"> <xsl:value-of select="chabwebdoc/@page"/> </xsl:when> <xsl:otherwise>index</xsl:otherwise> </xsl:choose> </xsl:variable> <!-- GlobalNavBar defines additional content to insert into the global navigation bar. It is usually empty. --> <xsl:variable name="GlobalNavBar"></xsl:variable> <!-- GlobalImage generates an image to insert in the banner line. --> <xsl:variable name="GlobalImage"> <img id="banner-image" SRC="images/banner/520-6.jpg" height="79" alt="steam loco" /> </xsl:variable> <!-- GlobalCounter inserts a counter into the footer material. --> <xsl:variable name="GlobalCounter"> <xsl:variable name="countername"> <xsl:value-of select="$serverdir"/> <xsl:text>/counters/</xsl:text> <xsl:if test="$host!='sequoia'">chab-</xsl:if> <xsl:call-template name="do-replace"> <xsl:with-param name="text"> <xsl:value-of select="$subpath"/> </xsl:with-param> <xsl:with-param name="replace">/</xsl:with-param> <xsl:with-param name="by">-</xsl:with-param> </xsl:call-template> <xsl:if test="not(chabwebdoc/@subdirectory) and not(chabwebhome)"> <xsl:text>-bad</xsl:text> </xsl:if> </xsl:variable> <xsl:variable name="counter"> <xsl:variable name="test"> <xsl:value-of select="document($countername)/counter/value+1"/> </xsl:variable> <xsl:choose> <xsl:when test="string($test)='NaN'">0</xsl:when> <xsl:otherwise><xsl:value-of select="$test"/></xsl:otherwise> </xsl:choose> </xsl:variable> <!-- <xsl:message> <xsl:text>got countername=</xsl:text> <xsl:value-of select="$countername"/> <xsl:text>&#x0a;got counter=</xsl:text> <xsl:value-of select="$counter"/> </xsl:message> --> <xsl:variable name="date"> <xsl:variable name="test"> <xsl:value-of select="document($countername)/counter/date"/> </xsl:variable> <xsl:choose> <xsl:when test="string-length($test)>0"> <xsl:value-of select="$test"/> </xsl:when> <xsl:otherwise><xsl:value-of select="$today"/></xsl:otherwise> </xsl:choose> </xsl:variable> <TABLE> <TR><TD> <xsl:value-of select="$counter"/> <SPAN STYLE="font-size:80%"> accesses since<BR/> <xsl:value-of select="$date"/> </SPAN> </TD></TR> </TABLE> <xsl:document href="{$countername}" method="xml"> <xsl:element name="counter"> <xsl:element name="value"> <xsl:value-of select="$counter"/> </xsl:element> <xsl:element name="date"> <xsl:value-of select="$date"/> </xsl:element> </xsl:element> </xsl:document> </xsl:variable> <!-- SubDirectory defines which directory is searched by the search engine box on this page. --> <xsl:variable name="SubDirectory"> <xsl:if test="/chabwebdoc/@search"> <xsl:value-of select="/chabwebdoc/@search"/> </xsl:if> </xsl:variable> <!-- SearchButton defines the label used by the search button on this page. --> <xsl:variable name="SearchButton"> <xsl:if test="/chabwebdoc/@searchbutton"> <xsl:value-of select="/chabwebdoc/@searchbutton"/> </xsl:if> </xsl:variable> <!-- Now include the header and footer material definitions. These each define a variable $header and $footer respectively, which is the built header and footer material. <xsl:include href="file:///u/web/homes/ajh/header.xsl"/> <xsl:include href="file:///u/web/homes/ajh/footer.xsl"/> --> <xsl:variable name="chabsitemap"> <xsl:text>chab-site-map.py</xsl:text> </xsl:variable> <xsl:variable name="bgcolour">#383</xsl:variable> <xsl:variable name="header"> <!-- A C C E S S I B I L I T Y S E C T I O N <div id="accessibility"> <a href="#content">Skip to content</a> | <a href="http://assets.monash.edu.au/style/change/textsize/"> Change text size</a> </div> <div class="spacer"></div> --> <!-- S I T E I D E N T I F I C A T I O N --> <div id="global-header"> <div id="global-images"> <table width="100%" bgcolor="white"> <xsl:if test="not(chabwebdoc/@subdirectory) and not(chabwebhome)"> <tr><td height="10">WARNING: no subdirectory attribute: counter is wrong</td></tr> </xsl:if> <tr width="100%"> <td align="left"> <img src="images/chairsAB.jpg" height="90"/> </td> <td align="left"> <table> <tr> <td align="left"> <a href="http://www.chairsabs.org.au"> <span style="font-family : sans-serif; font-size : +160%; font-weight : bold; background-color : #ffffff; color : black"> Chairs of Academic Boards/Senates </span> </a> </td> </tr> <tr> <td align="left"> <span style="font-family:sans-serif;font-size:+140%;font-weight:bold;background-color:#ffffff;color:black"> Australian Universities</span> </td> </tr> </table> </td> </tr> </table> </div> <div class="spacer"></div> <!-- U T I L I T Y N A V I G A T I O N --> <table style="background-color:{$bgcolour};color:#fff;vertical-align:middle;text-align: right" width="100%" id="global-utils" summary="Layout for utility navigation"> <tr> <td align="left" style="background-color:{$bgcolour}"> <a HREF="index.xml" style="background-color:{$bgcolour}">Home</a> | <a HREF="about.xml" style="background-color:{$bgcolour}">About Us</a> | <a HREF="news.xml" style="background-color:{$bgcolour}">News</a> | <a HREF="resources.xml" style="background-color:{$bgcolour}">Resources</a> | <a HREF="/~ajh/cgi-bin/{$chabsitemap}" style="background-color:{$bgcolour}">Site map</a> </td> </tr> </table> </div> <div class="spacer"></div> <!-- B R E A D C R U M B S D Y N A M I C A L L Y I N C L U D E D (and commented out for now) <div id="breadcrumbs"><a HREF="index.xml">John Hurst home</a></div> --> </xsl:variable> <!-- F O O T E R V A R I A B L E D E F I N I T I O N --> <xsl:variable name="localfile"> <xsl:text>http://www.csse.monash.edu.au/~ajh/</xsl:text> <xsl:value-of select="$subpath"/> <xsl:text>.xml</xsl:text> </xsl:variable> <xsl:variable name="homefile"> <xsl:text>http://www.ajhurst.org/~ajh/</xsl:text> <xsl:value-of select="$subpath"/> <xsl:text>.xml</xsl:text> </xsl:variable> <xsl:variable name="workfile"> <xsl:text>http://bendigo.csse.monash.edu.au/~ajh/</xsl:text> <xsl:value-of select="$subpath"/> <xsl:text>.xml</xsl:text> </xsl:variable> <xsl:variable name="cssefile"> <xsl:text>http://www.csse.monash.edu.au/~ajh/</xsl:text> <xsl:value-of select="$subpath"/> <xsl:text>.xml</xsl:text> </xsl:variable> <xsl:variable name="footer"> <HR SIZE="4" NOSHADE="on" COLOR="#339"/> <TABLE width="100%" align="center" border="0" cellspacing="0" cellpadding="0"> <TR><TD height="10"></TD></TR> <xsl:if test="not(chabwebdoc/@subdirectory) and not(chabwebhome)"> <TR><TD height="10">WARNING: no subdirectory attribute: counter is wrong</TD></TR> </xsl:if> <TR> <TD>Any changes to these web pages, please contact the <A HREF="mailto:ajh@csse.monash.edu.au">webmaster</A>. <BR/> This page and those under its hierarchy are Copyright </TD> <TD> <xsl:copy-of select="$GlobalCounter"/> </TD> <TD ALIGN="right" ROWSPAN="2"> <xsl:element name="IMG"> <xsl:attribute name="VALIGN">bottom</xsl:attribute> <xsl:attribute name="SRC"> <xsl:text>images/MadeOnMac.gif</xsl:text> </xsl:attribute> </xsl:element> </TD> </TR> <TR> <TD ALIGN="left" valign="bottom" COLSPAN="3"> <SPAN STYLE="font-size:80%"> <P> Dynamically generated at <xsl:value-of select="$htmltime"/> from an XML file modified on <xsl:value-of select="$xmltime"/> </P> </SPAN> </TD> </TR> </TABLE> </xsl:variable> <!-- T H E R O O T N O D E --> <xsl:template match="/"> <!-- <xsl:message>invoking chabwebdoc.xsl</xsl:message> <xsl:message> <xsl:text>serverdir=</xsl:text> <xsl:value-of select="$serverdir"/> <xsl:text>&#x0a;thisserver=</xsl:text> <xsl:value-of select="$thisserver"/> <xsl:text>&#x0a;envfile=</xsl:text> <xsl:value-of select="$envfile"/> </xsl:message> --> <html> <head> <title> <xsl:value-of select="chabwebdoc/@titlebar"/> <xsl:value-of select="chabwebdoc/border"/> </title> <base href="{$base}"/> <!-- <xsl:message> <xsl:text>thisserver=</xsl:text> <xsl:value-of select="$thisserver"/> <xsl:text>&#x0a;envfile=</xsl:text> <xsl:value-of select="$envfile"/> </xsl:message> --> <link rel="stylesheet" HREF="../styles/monash.css" type="text/css" /> </head> <body> <!-- H E A D E R --> <xsl:copy-of select="$header"/> <!-- C O N T E N T B E G I N S --> <xsl:apply-templates/> <!-- F O O T E R --> <xsl:copy-of select="$footer"/> </body> </html> </xsl:template> <!-- E N D R O O T N O D E --> <!-- P R O C E D U R E S --> <xsl:template name="do-replace"> <xsl:param name="text"/> <xsl:param name="replace"/> <xsl:param name="by"/> <xsl:choose> <xsl:when test="contains($text,$replace)"> <xsl:value-of select="substring-before($text,$replace)"/> <xsl:value-of select="$by"/> <xsl:call-template name="do-replace"> <xsl:with-param name="text" select="substring-after($text,$replace)"/> <xsl:with-param name="replace" select="$replace"/> <xsl:with-param name="by" select="$by"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$text"/> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- ******** The nested nodes ******** --> <xsl:template match="chabwebdoc"><xsl:apply-templates/></xsl:template> <xsl:template match="chabwebdoc/border"></xsl:template> <xsl:template match="code"> <PRE> <xsl:apply-templates/> </PRE> </xsl:template> <xsl:template match="date">(<xsl:apply-templates/>)</xsl:template> <xsl:template match="ajhlink"> <A HREF="{@href}"><xsl:apply-templates/></A> </xsl:template> <xsl:template match="DocumentHistory"> <HR SIZE="4" NOSHADE="yes"/><TABLE BORDER="0"> <H4>Document History</H4> <xsl:apply-templates/> </TABLE> </xsl:template> <xsl:template match="DocumentHistory/Modified"> <TR> <xsl:apply-templates/> </TR> </xsl:template> <xsl:template match="Modified/TimeStamp"> <TD VALIGN="top"> <xsl:apply-templates/> </TD> </xsl:template> <xsl:template match="Modified/version"> <TD VALIGN="top"> <xsl:apply-templates/> </TD> </xsl:template> <xsl:template match="Modified/author"> <TD VALIGN="top"> <xsl:apply-templates/> </TD> </xsl:template> <xsl:template match="Modified/comment"> <TD VALIGN="top"> <xsl:apply-templates/> </TD> </xsl:template> <xsl:template match="omit"></xsl:template> <xsl:template match="subtitle"> <H3 ALIGN="center"><xsl:apply-templates/> </H3> </xsl:template> <xsl:template match="chabwebdoc/title"> <div align="center" style="font-size:+200%;color:#339;margin-top:1em;margin-bottom:0.5em"> <xsl:apply-templates/> </div> <div class="spacer"></div> </xsl:template> <xsl:template match="GCHEdTrailer"> <HR/> <xsl:if test="@prev"> <xsl:element name="A"> <xsl:attribute name="HREF"> <xsl:value-of select="$relcwdweb"/> <xsl:value-of select="@prev"/> </xsl:attribute> <xsl:text>Previous activity: </xsl:text> <xsl:value-of select="@prev"/> </xsl:element> <xsl:element name="BR"/> </xsl:if> <xsl:if test="@next"> <xsl:element name="A"> <xsl:attribute name="HREF"> <xsl:value-of select="$relcwdweb"/> <xsl:value-of select="@next"/> </xsl:attribute> <xsl:text>Next activity: </xsl:text> <xsl:value-of select="@next"/> </xsl:element> <xsl:element name="BR"/> </xsl:if> <A HREF="{$relcwdweb}activities.html">List of all Activities</A><BR/> <A HREF="http://www.celts.monash.edu.au/hedu/hed5003.html">HED5003 Home Page</A> </xsl:template> <xsl:template match="include"> <P>Including file "<xsl:value-of select="@file"/>"</P> <xsl:message>Including file <xsl:value-of select="@file"/></xsl:message> <xi:include href="@file"/> </xsl:template> <xsl:template match="input"> <input type="{@type}" name="{@name}" value="{@value}"> <xsl:apply-templates/> </input> </xsl:template> <xsl:template match="form"> <xsl:element name="form"> <xsl:attribute name="action"> <xsl:value-of select="@action"/> </xsl:attribute> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:template match="uri"> <xsl:variable name="href"> <xsl:value-of select="@href"/> <xsl:choose> <xsl:when test="contains(@href,'.')"></xsl:when> <xsl:when test="$thisserver='www.csse.monash.edu.au'">.html</xsl:when> <xsl:otherwise>.xml</xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:element name="A"> <xsl:attribute name="HREF"> <xsl:value-of select="$href"/> </xsl:attribute> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:template match="*"> <xsl:message terminate="no">No template for <xsl:value-of select="name()"/></xsl:message> <xsl:text disable-output-escaping="yes">&lt;</xsl:text> <xsl:value-of select="name()"/> <xsl:text disable-output-escaping="yes">&gt;</xsl:text> <xsl:apply-templates/> <xsl:text disable-output-escaping="yes">&lt;/</xsl:text> <xsl:value-of select="name()"/> <xsl:text disable-output-escaping="yes">&gt;</xsl:text> </xsl:template></xsl:stylesheet>

6. chab-site-map.py

#!/usr/bin/python# web cgi script to build a page of links to all html pages## currently in development: hard coded directory name and link page#import cgi,string,re,osimport time,sys(year, month, day, hour, minute, second, weekday, yday, DST) = time.localtime(time.time())tm = time.asctime(time.localtime(time.time())) + ["", "(Daylight savings)"][DST]import cgitop="/home/ajh/www/chab"print "Content-Type: text/html\n\n";htmlmatch = re.compile('^.*\.(ht|x)ml$')ignoredirs = re.compile('(tmp)|(units)')print """ <html> <head> <title>John Hurst Web Page Site Map</title> <base href="http://www.csse.monash.edu.au/~ajh/"/> <link rel="stylesheet" href="styles/monash.css" type="text/css" /> </head> <!-- S I T E I D E N T I F I C A T I O N --> <div id="global-header"> <div id="global-images"> <table width="100%" bgcolor="white"> <tr width="100%"> <td align="left"> <img src="images/chairsAB.jpg" height="90"/> </td> <td align="left"> <table> <tr> <td align="left"> <a href="http://www.monash.edu.au"> <span style="font-family:sans-serif;font-size:+160%;font-weight:bold;background-color:#ffffff;color:black"> Chairs of Academic Boards/Senates </span> </a> </td> </tr> <tr> <td align="left"> <span style="font-family:sans-serif;font-size:+140%;font-weight:bold;background-color:#ffffff;color:black"> Australian Universities</span> </td> </tr> </table> </td> </tr> </table> </div> <div class="spacer"></div> <!-- U T I L I T Y N A V I G A T I O N --> <table style="background-color:#383;color:#fff;vertical-align:middle;text-align: right" width="100%" id="global-utils" summary="Layout for utility navigation"> <tr> <td align="left" style="background-color:#383"> <a HREF="chab/index.xml" style="background-color:#383">Home</a> | <a HREF="chab/about.xml" style="background-color:#383">About Us</a> | <a HREF="chab/news.xml" style="background-color:#383">News</a> | <a HREF="chab/resources.xml" style="background-color:#383">Resources</a> | <a HREF="cgi-bin/{$chabsitemap}" style="background-color:#383">Site map</a> </td> </tr> </table>"""print "Dynamically generated new site map at " + tm + "<P>\n";print "<table>\n"ignores=['tmp','.tmpcsse','units']for root,dirs,files in os.walk(top): for i in ignores: if i in dirs: dirs.remove(i) for name in files: res = htmlmatch.match(name) if res: fullpath = "%s/%s" % (root,name) localname = fullpath[len(top)+1:] try: countfilename=re.sub('/home/ajh/www/','',fullpath) countfilename=re.sub('/','-',countfilename) #print "<p>got countfilename=%s</p>\n" % (countfilename) countfilename=re.sub('.(ht|x)ml','',countfilename) countfilename="/home/ajh/local/%s/counters/%s" % (host,countfilename) #print "<p>got countfilename=%s</p>\n" % (countfilename) countfiled=open(countfilename,'r') countfile='' for line in countfiled.readlines(): countfile+=line.strip() #print "<p>got countfile=%s</p>\n" % (countfile) res=re.match('.*<value>(\d+)</value>',countfile) if res: count=int(res.group(1)) #print "<p>got count=%s</p>\n" % (count) counter="%10d" % (count) else: counter="%10s" % ('dud') except: #print "<p>Cannot open counter file</p>\n" counter="%10s" % ('-') url = "<A href=\"http://www.csse.monash.edu.au/~ajh/chab" + fullpath[len(top):] + "\">" + localname + "</A>" print " <tr><td align='right'>%s</td><td>%s</td></tr>\n" % (counter,url)print "</table>\n"print """ <HR SIZE="4" NOSHADE="on" COLOR="#339"/> <TABLE width="100%" align="center" border="0" cellspacing="0" cellpadding="0"> <TR><TD height="10"></TD></TR> <TR> <TD>Any changes to these web pages, please contact the <A HREF="mailto:ajh@csse.monash.edu.au">webmaster</A>. <BR/> This page and those under its hierarchy are Copyright </TD> <TD> <xsl:copy-of select="$GlobalCounter"/> </TD> <TD ALIGN="right" ROWSPAN="2"> <IMG VALIGN="bottom" SRC="images/MadeOnMac.gif"/> </TD> </TR> <TR> <TD ALIGN="left" valign="bottom" COLSPAN="3"> <SPAN STYLE="font-size:80%"> <P> Dynamically generated at <xsl:value-of select="$htmltime"/> from an XML file modified on <xsl:value-of select="$xmltime"/> <BR/> Maintainer use only; not generally accessible: <!-- **** NB! The "href"s in the following MUST be in lower case to avoid being converted for other server contexts --> <A href="{$localfile}">Local Server</A> <xsl:text>&#x0a;</xsl:text> <A href="{$homefile}">Home Server</A> <xsl:text>&#x0a;</xsl:text> <A href="{$workfile}">Work Server</A> <xsl:text>&#x0a;</xsl:text> <A href="{$cssefile}">CSSE Server</A> <xsl:text>&#x0a;</xsl:text> </P> </SPAN> </TD> </TR> </TABLE> </body></html>"""

7. Indices

7.1 Files

7.2 Chunks

7.3 Identifiers


Document History

(20061213:135125)
ajh1.0.0 first version to get a version number!
1.0.0 20061213:135059

WARNING: no subdirectory attribute: counter is wrong
Any changes to these web pages, please contact the webmaster.
This page and those under its hierarchy are Copyright
348 accesses since
16 Jun 2007

Dynamically generated at 20090707:2139 from an XML file modified on 20090419:1128

434 accesses since 16 Aug 2008, HTML cache rendered at 20110330:0935