home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / ckscripts / webindex < prev    next >
Text File  |  2020-01-01  |  6KB  |  136 lines

  1. #!/p/kd/fdc/solaris9/wermit +
  2. #
  3. # Script to build a clickable HTTP index of the Kermit FTP archive.
  4. # F. da Cruz, Columbia University, December 2006
  5.  
  6. # set flag on # debugging
  7.  
  8. if flag echo \%0 | \v(timestamp) | Debugging...
  9.  
  10. .title = Kermit FTP archive Web access        # Title for index page
  11. .index = ~kermit/index.html.tmp               # Working copy of index
  12. .final = ~kermit/index.html                   # Final name for index
  13. if flag .final = ~kermit/testing123.html      # Different name for testing
  14. .tmp = ~/tmp/index.txt                        # Directory listing file
  15. .skip = 0                                     # Flag to skip a directory
  16.  
  17. cd ~kermit                                    # CD to Kermit tree
  18. if fail exit 1 "CD ~kermit failed"            # Check
  19. directory /nobackup /recursive /output:\m(tmp) # Get directory tree listing
  20. if fail exit 1                                # Check
  21. if flag echo Directory OK...
  22.  
  23. fopen /read \%c \m(tmp)                       # Open the listing
  24. if fail exit 1                                # Check
  25. fopen /write \%o \m(index)                    # Start the index file
  26. if fail exit 1                                # Check
  27.  
  28. # Write the HTML header
  29.  
  30. fwrite /line \%o <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  31. fwrite /line \%o <html lang="en">
  32. fwrite /line \%o <head>
  33. fwrite /line \%o <title>\m(title)</title>
  34. fwrite /line \%o -
  35.  <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  36. fwrite /line \%o <META http-equiv="Content-Style-Type" content="text/css">
  37. fwrite /line \%o </head>
  38.  
  39. # Write the beginning of the contents
  40.  
  41. fwrite /line \%o <body>
  42. fwrite /line \%o <h2>\m(title)</h2>
  43. fwrite /line \%o <blockquote>
  44. fwrite /line \%o <i>This page created \v(timestamp) by</i> -
  45.  <a href="scripts/ckermit/index"><tt>index.ksc</tt></a>
  46. fwrite /line \%o </blockquote>
  47. fwrite /line \%o <p>
  48.  
  49. fwrite /line \%o Click on any link to download a file with HTTP.
  50. fwrite /line \%o You might need to right-click and choose "save link as" or
  51. fwrite /line \%o "save target as" to prevent your browser from feeding the
  52. fwrite /line \%o file to some random helper application.  The "daily" 
  53. fwrite /line \%o <a href="http://www.columbia.edu/kermit/ckdaily.html">
  54. fwrite /line \%o C-Kermit development build</a> tarball is
  55. fwrite /line \%o <a href="test/tar/x.tar.gz">HERE</a>.  For other files,
  56. fwrite /line \%o scroll down the long list or use the links just below for
  57. fwrite /line \%o quick access to the main areas.
  58. fwrite /line \%o <p>
  59.  
  60. # Write a quick index to the main sections
  61.  
  62. fwrite /line \%o [ <a href="#a">a</a> ]  
  63. fwrite /line \%o [ <a href="#b">b</a> ]  
  64. fwrite /line \%o [ <a href="#c">c</a> ]  
  65. fwrite /line \%o [ <a href="#d">d</a> ]  
  66. fwrite /line \%o [ <a href="#e">e</a> ]  
  67. fwrite /line \%o [ <a href="#c-kermit">c-kermit</a> ]  
  68. fwrite /line \%o [ <a href="#archives">archives</a> ]  
  69. fwrite /line \%o [ <a href="#bin">binaries</a> ]  
  70. fwrite /line \%o [ <a href="#scripts">scripts</a> ]  
  71. fwrite /line \%o [ <a href="#test">test</a> ]  
  72. fwrite /line \%o [ <a href="#charsets">charsets</a> ]  
  73. fwrite /line \%o [ <a href="#newsgroups">newsgroups</a> ]
  74.  
  75. # Write the file listing
  76.  
  77. fwrite /line \%o <pre>
  78. .prev = xxx
  79.  
  80. while 1 {
  81.     fread /line \%c line                # Read a directory listing line
  82.     if fail break                       # Check for end of file
  83.     .s2 := \s(line[44])                 # Get the filename
  84.     if eq "\s(line[1:1])" "d" {         # If it's a directory....
  85.         if flag {
  86.             echo \m(line)
  87.             echo line[8] = '\s(line[8:1])'
  88.         }
  89.         # Don't list the contents of directories that lack read access
  90.         if \m(skip) if == 1 \findex(\m(root),\m(s2)) continue
  91.         .skip = 0
  92.         if eq "-" "\s(line[8:1])" {     # If no world-read permission
  93.             .skip = 1                   # don't show this directory
  94.         } else {
  95.             # Also skip these specific directories...
  96.             if equ \m(s2) public_html .skip = 1
  97.             if equ \m(s2) old .skip = 1
  98.             if equ \m(s2) cu .skip = 1
  99.         }
  100.         # If we're skipping this directory also skip all its subdirectories
  101.         undef root
  102.         if skip .root := \m(s2)
  103.         if flag sho mac skip root
  104.         continue                        # Don't list directories themselves
  105.     } else {                            # Just popped out of a closed subdir
  106.         if \m(skip) if != 1 \findex(\m(root),\m(s2)) .skip = 0
  107.     }
  108.     # If we're skipping this directory don't list this file
  109.     if \m(skip) continue
  110.     if not \findex(->,\m(line)) {       # Don't make links to symlinks
  111.         .s1 := \s(line[1:43])           # 1st part of line
  112.         .s3 := \fword(\m(s2),1,/,-)     # Top-level subdirectory
  113.         if not eq "\m(s3)" "\m(prev)" {
  114.             # If entering a new directory put a line and an anchor
  115.             fwrite /line \%o <a name="\m(s3)"><p><hr></a>
  116.         }
  117.         .prev := \m(s3)                 # Remember for next time
  118.         .line := \m(s1)<a href="\m(s2)">\m(s2)</a> # Construct line with link
  119.     }
  120.     fwrite /line \%o \m(line)           # Write the line to the index
  121. }
  122. # Done - Finish the page, close the files, install the index.
  123.  
  124. fwrite /line \%o </pre>
  125. fwrite /line \%o <hr>
  126. fwrite /line \%o [ <a href="index.html">Top</a> ]   -
  127.  <tt>index.ksc / \v(timestamp)
  128. fwrite /line \%o </body>
  129. fwrite /line \%o </html>
  130. fclose \%c
  131. fclose \%o
  132. chmod 644 \m(index)
  133. rename \m(index) \m(final)
  134. if flag directory \m(final)
  135. exit 0
  136.