home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / gohttp.zip / BUILDDIR.CMD next >
OS/2 REXX Batch file  |  1995-07-05  |  4KB  |  105 lines

  1. /*ALC--   Albert Crosby's Directory Indexing code.    */
  2.  
  3. /* ----------------------------------------------------------------------- */
  4. /* BUILDDIR: Builds a directory map on the fly.                            */
  5. /* ----------------------------------------------------------------------- */
  6. /*builddir: procedure expose Dir. tempfile sel    */
  7.   parse arg dir, sel, Dir.Describe, Dir.Info, Dir.Exclude
  8.  
  9. /*say 'Attempting to build directory for 'dir    */
  10.  
  11.   fulldir=translate(dir,'\','/')
  12.   message = ''
  13. /*say 'fulldir = ['fulldir']'    */
  14.  
  15.   description.=""
  16.   if Dir.Describe\="" then
  17.     do while lines(fulldir||Dir.Describe)
  18.       line=linein(fulldir||Dir.Describe)
  19.       if left(line,1)='"' then parse var line '"'name'"' desc
  20.       else parse var line name desc
  21.       name=translate(translate(name,'_',' '))
  22.       description.name=desc
  23.     end
  24.  
  25.   crlf = '0a0d'x
  26.   message =     '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'crlf,
  27.           "<html><head><title>Contents of "sel"</title></head>"crlf,
  28.           "<body><h2>Contents of "sel"</h2>"crlf,
  29.           "<hr>"crlf
  30.  
  31.   if stream(fulldir||Dir.Info, 'c', 'query exists')\='' then do
  32.     msg = charin(fulldir||Dir.Info,,chars(fulldir||Dir.Info))
  33.     message = message || msg || "<hr>" || crlf
  34. /*    address cmd 'type 'fulldir||Dir.Info'>>'tempfile 
  35.     call lineout tempfile, "<hr>"*/
  36.     end
  37.   call SysFileTree fulldir||'*.*','files.','D','*+-*-'
  38.   message = message || '<pre><img src="/icons/dblank.gif" alt="      " width=24 height=24>' left("Name",20) left("Last Modified",17) right("Size",10) '</pre>'crlf
  39.   parent=translate(filespec('path',left(fulldir,length(dir)-1)),'/','\')
  40.   if (length(sel) > 0) then _sel = left(sel, length(sel) -1)
  41.   else _sel = sel
  42.   if dir\=sel then parent='/'||translate( filespec('path', _sel),'/','\')
  43.   message = message || '<hr><dt><pre><img src="/icons/back.gif" alt="[back]" width=24 height=24> <a href="'parent'">Parent directory</a></pre>'crlf
  44.   do i=1 to files.0
  45.     parse var files.i date time size attribs fullname
  46.     name=filespec('name',fullname)
  47.     dname=name||"/"
  48.     message = message || '<dt><pre><img src="/icons/menu.gif" alt="[dir] " width=24 height=24> <a href="'dname'">'dname'</a></pre>'crlf
  49.     name=translate(translate(name,'_',' '))
  50.     if description.name\='' then
  51.       message = message || '<dd><i>'description.name'</i>'crlf
  52.   end
  53.   call SysFileTree fulldir||'*.*','files.','F','**-*-'
  54.   do i=1 to files.0
  55.     parse var files.i date time size attribs name
  56.     name=filespec('name',name)
  57.     /* Don't display excluded files */
  58.     if (wordpos(translate(name),translate(Dir.Exclude)) \= 0) then iterate
  59.     message = message || '<dt><pre>'imagetype(name),
  60.         '<a href="'name'">'strip(left(name,20))'</a>'copies(' ',max(0,20-length(name))),
  61.         right(date,8) right(time,8) right(size,10)'</pre>'crlf
  62.     name=translate(translate(name,'_',' '))
  63.     if description.name\='' then
  64.       message = message || '<dd><i>'description.name'</i>'crlf
  65.   end
  66.  
  67.   return message || "</dl>"crlf
  68.  
  69. /*******/
  70. /* IMAGETYPE: Return the name of the image file to use based on file type */
  71. /*******/
  72.  
  73. imagetype: procedure
  74.   size='width=24 height=24'
  75.  
  76.   e=extension(arg(1))
  77.  
  78.   select
  79.     when e='TXT' | e='CMD' | e='DOC' | e='FAQ' | e='SAS'
  80.       then return '<img src="/icons/text.gif"' size 'alt="[text]">'
  81.     when e='HTM' | e='HTML'
  82.       then return '<img src="/icons/text.gif"' size 'alt="[html]">'
  83.     when e='PS'
  84.       then return '<img src="/icons/text.gif"' size 'alt="[ps]  ">'
  85.     when e='EXE' | e='ZIP' | e='ARC' | e='ARJ'
  86.       then return '<img src="/icons/binary.gif"' size 'alt="[bin] ">'
  87.     when e="AU" | e="WAV" | e="MID"  | e="SND"
  88.       then return '<img src="/icons/sound.gif"' size 'alt="[snd] ">'
  89.     when e="GIF" | e="JPG" | e="JPEG" | e="TIF" | e="TIFF" | e="BMP"
  90.       then return '<img src="/icons/image.gif"' size 'alt="[img] ">'
  91.     when e="MPG" | e="MPEG" | e="AVI"
  92.       then return '<img src="/icons/movie.gif"' size 'alt="[mov] ">'
  93.     otherwise
  94.       return '<img src="/icons/unknown.gif"' size 'alt="[file]">'
  95.   end
  96.  
  97.  
  98. extension: procedure
  99. arg filename
  100. /* If no period or only period is first char, then return "" */
  101. if lastpos(".",filename)<2 then return ""
  102. return translate(substr(filename, lastpos('.',filename)+1))
  103.  
  104. /*ALC--   Albert Crosby's Directory Indexing code.   --End   */
  105.