#!/usr/pkg/bin/rexx /*-----------------------------------------------------------------------------+ | Program name: | | | | Subject: home pages maker | | | | File name: 0_make_html_page.rexx | | | | Note: Checked with Regina Rexx and Open Object Rexx | | | | Category: Freeware, BSD Licenced | | | | Copyright (C) by Przemysław Pawełczyk Cracow, April 2007 | | E-Mail: pp_o2@o2.pl | | P2O2 WWW: http://pp.kv.net.pl | +-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------+ | VARIABLES | +-----------------------------------------------------------------------------*/ /* File2Read1 = 'index.tmpl' File2Read2 = '00_html_page.templ' File2Write = 'index.html' */ parse arg ArgFile /*---------------------------------------------------------+ | If no argument show Helper and exit | +---------------------------------------------------------*/ if ArgFile = "" then call Helper parse var ArgFile ArgFileName"."ArgFileExt ArgFileName = strip(ArgFileName) File2Read2 = '00_html_page.templ' File2Read1 = ArgFileName'.tmpl' File2Write = ArgFileName'.html' /*---------------------------------------------------------+ | Defining date | +---------------------------------------------------------*/ dateStr = date('N') parse var dateStr dayStr monStr yearStr /*---------------------------------------------------------+ | End of line character | +---------------------------------------------------------*/ _LF = x2c('0a') /*---------------------------------------------------------+ | Defining number of variables and lists | | TypeNo Stem keeps indexes for List Stems | +---------------------------------------------------------*/ ok = stream(File2Read2, 'c','open read') /* Opening File2Read */ File2Read2_Size = stream(File2Read2, "c", "query size") File2Read2_Tmp = charin(File2Read2, 1, File2Read2_Size) File2Read2_VarNo = countstr("Qvar_" , File2Read2_Tmp) File2Read2_ListNo = countstr("Qlist_", File2Read2_Tmp) File2Read2_TypeNo = countstr("Qltype", File2Read2_Tmp) ok = stream(File2Read2, 'c','close') /* Closing File2Read */ /*---------------------------------------------------------+ | We will read variables from file.tmpl file | | to following compound variables (stems): | +---------------------------------------------------------*/ VarStem. = "" /* Variable Stem */ i_var = 1 TypeStem. = "" /* List Type Stem */ i_type = 1 do i = 1 to File2Read2_ListNo ListStem.i. = "" /* List Stems */ i_list.i = 1 end /*-----------------------------------------------------------------------------+ | >>>>>>>>>>>>>>>>>>>>>>>>> Main program body <<<<<<<<<<<<<<<<<<<<<<<<<<<<< | +-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------+ | File to FileStem - linein way | +-----------------------------------------------------------------------------*/ FileStem. = "" ok = stream(File2Read1, 'c','open read') /* Opening File2Read */ i = 1 do while lines(File2Read1) > 0 /* If File2Read contains lines */ FileStem.i = linein(File2Read1) /* then read them in FileStem */ FileStem.i = strip(FileStem.i) First1Char = substr(FileStem.i, 1, 1) /* selecting comment lines */ First5Chars = substr(FileStem.i, 1, 5) /* "$var_" and "$list" */ First6Chars = substr(FileStem.i, 1, 6) /* "$ltype" */ /*---------------------------------------------------------+ | if empty line or comments go to the next line | +---------------------------------------------------------*/ if First1Char = "#" then do iterate end if First1Char = "" then do iterate end /*---------------------------------------------------------+ | reading variables: Qvar_xQ (from file.tmpl) | +---------------------------------------------------------*/ if First5Chars = "$var_" then do parse var FileStem.i FirstItem "$var_" VarNumber "$" SecItem VarNumber = strip(VarNumber) SecItem = strip(SecItem) if pos("Created", SecItem) = 1 then do parse var SecItem PrevItem "Modified" NextItem PrevItem = strip(PrevItem) NextItem = " - "monStr" "dayStr", "yearStr VarStem.i_var = PrevItem"Modified:"NextItem end else do VarStem.i_var = SecItem end i_var = i_var + 1 iterate end /*---------------------------------------------------------+ | reading variables: QltypeQ (from file.tmpl) | +---------------------------------------------------------*/ if First6Chars = "$ltype" then do parse var FileStem.i FirstItem "$ltype" VarNumber "$" SecItem VarNumber = strip(VarNumber) SecItem = strip(SecItem) TypeStem.VarNumber = SecItem i_type = i_type + 1 iterate end /*---------------------------------------------------------+ | reading variables: Qlist_xQ (from file.tmpl) | +---------------------------------------------------------*/ if First5Chars = "$list" then do parse var FileStem.i FirstItem "$list_"k"$" SecItem SecItem = strip(SecItem) parse var SecItem AddrItem "×" NameItem "×" CommentItem AddrItem = strip(AddrItem) NameItem = strip(NameItem) CommentItem = strip(CommentItem) /* html lists = ol, ul ================================================== */ if TypeStem.k = "list-ul" | TypeStem.k = "list-ol" then do if AddrItem = "section" then /* Section item */ do _AddrItem = "" _NameItem = ""NameItem"" _CommentItem = CommentItem _tmpHtmlStr = '
'_LF ||, ''_LF ||,
''_LF ||,
_NameItem""_LF ||,
''_LF ||,
'
'
end
else if AddrItem = "chapter" then /* Chapter beginning */
do
_AddrItem = ""
_NameItem = ""NameItem""
_CommentItem = CommentItem
/* font color = lm or rm*/
if TypeStem.k = "list-lm" then
do
font_col = '#006600'
end
else
do
font_col = '#000066'
end
_tmpHtmlStr = "
"_LF ||, ''_LF ||, _NameItem""_LF ||, ''_LF ||, '
'_LF end /* else if */ else /* List item */ do _AddrItem = '' _NameItem = NameItem'' _CommentItem = ' 'CommentItem _tmpHtmlStr = _AddrItem || _NameItem || _CommentItem''_AddrItem || _NameItem || '
' _LF || ''_LF end /* if TypeStem.k = "images" */ /* e-mail lists ========================================================= */ if TypeStem.k = "emails" then do _AddrItem = '' _NameItem = NameItem'' _CommentItem = ' 'CommentItem _tmpHtmlStr = '', _AddrItem || _NameItem || _CommentItem || '' _LF end /* if TypeStem.k = "emails" */ /* hpage lists ========================================================== */ if TypeStem.k = "hpage" then do if countstr("×", SecItem) = 4 then do parse var SecItem Addr1"×"Name1"×"Addr2"×"Name2"×"CommentItem Addr1 = strip(Addr1) Name1 = strip(Name1) Addr2 = strip(Addr2) Name2 = strip(Name2) CommentItem = strip(CommentItem) _Addr1 = '' _Name1 = Name1'' _Addr2 = '' _Name2 = Name2'' _CommentItem = ' 'CommentItem _tmpHtmlStr = '
'_LF ||, ' '_Addr1''_Name1' -> '_Addr2''_Name2 ||, _CommentItem || _LF ||, '
' end /* if countstr("×", SecItem) = 4 */ else do _AddrItem = '' _NameItem = NameItem'' _CommentItem = ' 'CommentItem _tmpHtmlStr = ''_LF ||, ' '_AddrItem || _NameItem || _CommentItem || _LF ||, '
' end /* else countstr("×", SecItem) = 4 */ end /* if TypeStem.k = "hpage" */ /* definition lists ===================================================== */ if TypeStem.k = "list-dl" then do _AddrItem = '