/* SUBJECT_TO_HTML.CMD -- Generate HTML directory listings with descriptions taken from the extended attributes */ /* * This is a REXX script that reads the .SUBJECT extended attributes of files * and directories in the current directory and from them generates an HTML * directory listing, that includes the descriptions, to its standard output, * suitable for inclusion in a web page. * * (c) Copyright 2004,2007 Jonathan de Boyne Pollard. "Moral" rights asserted. * * Permission is hereby granted to copy, modify, and redistribute this script * as long as the author is not held responsible for any consequences of its * possession or use, and as long as you agree that it comes with no guarantee. * * NOTE: This script requires Object REXX. */ call RxFuncAdd 'SysFileTree','RexxUtil','SysFileTree' call RxFuncAdd 'SysGetEA','RexxUtil','SysGetEA' call RxFuncAdd 'SysGetMessage','RexxUtil','SysGetMessage' error = SysFileTree('*', 'names', 'BT') if error \= 0 then do say ''||escape(SysGetMessage(error,,'*'))||' "*"' exit end say '
' do i = 1 to names.0 attr = names.i~subword(3,1) name = names.i~subword(4) isdir = attr~substr(2,1) basename = filespec("Name",name) if isdir == 'D' then image = 'internal-gopher-menu' else image = 'internal-gopher-unknown' say '
'||basename||'
' error = SysGetEA(name, ".SUBJECT", "subject") select when error \= 0 then say '
'||escape(SysGetMessage(error,,name))||'
' when subject \= '' then do len = subject~substr(3,2)~reverse()~c2d() description = subject~substr(5,len) say '
'||escape(description)||'
' end otherwise nop end end say '
' exit escape: procedure parse arg s r = '' do while s \= '' c = left(s,1) s = substr(s,2) select when c = '<' then r = r||'<' when c = '>' then r = r||'>' when c = '&' then r = r||'&' otherwise r = r||c end end return r