/* : Define www.rexxtags.org pages */ /* */ /* Parameters: */ /* title="page title" Mandatory (not checked) */ /* type="page type" Optional; default: "" (ommited): standard page */ /* Other values: "Tutorial" : tutorial page */ /* */ /* Version: 1.1 */ /* */ /* Author: (c) Jose Maria Blasco */ /* */ /* This software is subject to the terms of the Common Public License. You */ /* must accept the terms of this license to use this software. Refer to */ /* the license at the following URL for more information: */ /* http://oss.software.ibm.com/developerworks/opensource/CPLv1.0.htm */ /* */ /* This is the tag used in http://www.rexxtags.org to describe pages. It is */ /* provided AS A SAMPLE so that others can start writing page tags. */ /* */ /* Modifications: */ /* */ /* Date Author Description */ /* ---------- ----------- --------------------------------------------------- */ /* 2002/12/13 J.M.Blasco v1.0 Initial release */ /* 2011/12/29 J.M.Blasco v1.1 Q&D Adapt to REXXHTTP */ Use arg request,response, output, verb, parms Parse version objrexx . objrexx = 0 -- v1.1 If verb == 'START' Then Signal StartTag /* Handle start tag */ If verb == 'END' Then Signal EndTag /* Handle end tag */ Return 0 /* Standard rexx tag exit */ /*----------------------------------------------------------------------------*/ /* Common 'get parameters' routine. Used by both 'StartTag' and 'EndTag' */ /*----------------------------------------------------------------------------*/ GetParms: Parse value ' 'parms with ' title="'title'"' Parse value ' 'parms with ' type="'type'"' /* Store a boolean indicating whether this is a tutorial page */ tutorial = Translate(type) = 'TUTORIAL' /* If this is a tutorial page, store the page number and alter the title. */ If tutorial Then Do Parse value request~script_name with 'tutorial/page'page'.html' page = page + 0 title = 'Tutorial -' page':' title End /* This will allow for future support of different header and title */ header = title title = 'REXXTAGS - 'title Return /*----------------------------------------------------------------------------*/ /* Start tag handling */ /*----------------------------------------------------------------------------*/ StartTag: /* 1: Get the parameters */ Call GetParms /* 3: Special handling of tutorial pages. */ /* If this is a tutorial page, we build a small navigation bar with.. */ /* ..'home', 'prev' and 'next' links. The later are only displayed.. */ /* ..when needed (i.e., no 'next' link for the last page, etc) */ nl = '00'x /* new line indicator */ extra = '' /* This will get the extra 'tutorial page' html code */ If tutorial Then Do prevnext = ' ' p = LastPos('/',wwwFileName) nextfile = Left(wwwFileName,p)'page'Right(page+1,2,0)'.html' nextfile = Stream(nextFile,'C','QUERY EXISTS') anext = 'Next >>' aprev = '<< Prev' If page = 1 Then prevnext = anext Else If nextfile = '' Then prevnext = aprev Else prevnext = aprev '|' anext extra = nl'
' , nl'Home Tutorial' , nl'' , nl prevnext , nl '
' End /* 4: Return html for the startting part of the page */ Return '', nl'', nl'' , nl'' , nl''title'' , nl'', nl'' , nl'' , nl'' , nl' ', nl' ', nl' ' , nl'
REXXTAGS.org :: 'header'
' , extra /*----------------------------------------------------------------------------*/ /* End tag handling */ /*----------------------------------------------------------------------------*/ EndTag: /* 1: Get the parameters */ Call GetParms /* 2: Evaluate the URI for stats collection */ /* We discard the path info part, if any, and normalize indexes */ uri = request~script_name If uri = "/index.html" Then uri = "/" Else If right(uri,11) = '/index.html' then uri = left(uri,length(uri)-11) Parse value stream(request~filename,'C','QUERY DATETIME') with mm'-'dd'-'aa' 'h':'m':'s /* 6: Special handling of tutorial pages */ /* We parse the next page, look for its title, and display it in the..*/ /* ..current page as a link after 'Next section:' */ nl = '00'x extra = '' If tutorial Then Do p = LastPos('/',request~filename) nextfile = Left(request~filename,p)'page'Right(page+1,2,0)'.html' nextfile = Stream(nextFile,'C','QUERY EXISTS') If nextFile <> '' Then Do Do While lines(nextFile) > 0 l = LineIn(nextFile) Parse var l ' '' Then Leave End Call Stream nextFile,'C','CLOSE' If nextChapter <> '' Then nextSection = 'Next section: 'nextChapter'' Else nextSection = 'Next section' End Else nextSection = ' ' extra = '' nl, '
'nextsection'View the XML code for this page
' End /* 7: Return the footer */ Return extra '
' , ||'00'x||'' , ||'00'x||' ' , ||'00'x||' ' , ||'00'x||' ' , ||'00'x||' ' , ||'00'x||' ' , ||'00'x||'
'uri'
' , ||'00'x||' Last update: 'dd'/'mm'/'aa' at 'h':'m , ||'00'x||'
' , ||'00'x||' ' , ||'00'x||' ' , ||'00'x||'
Valid XHTML 1.0! ' , ||'00'x||' Valid CSS!
' , ||'00'x||'
' , ||'00'x||'' , ||'00'x||'' MonthName: Select When arg(1) = 1 Then Return "jan" When arg(1) = 2 Then Return "feb" When arg(1) = 3 Then Return "mar" When arg(1) = 4 Then Return "apr" When arg(1) = 5 Then Return "may" When arg(1) = 6 Then Return "jun" When arg(1) = 7 Then Return "jul" When arg(1) = 8 Then Return "aug" When arg(1) = 9 Then Return "sep" When arg(1) = 10 Then Return "oct" When arg(1) = 11 Then Return "nov" When arg(1) = 12 Then Return "dec" Otherwise Return "" End Syntax: Return "Syntax error at line" sigl /* From rspcomp.rex */ add_quotes: procedure quote = arg(1) line = arg(2) x = pos(quote, line) do while x > 0 line = substr(line, 1, x) || quote || substr(line, x + 1) x = pos(quote, line, x + 2) end return line