#!/hmt/sirius1/prv0/kd/fdc/bin.linux/wermit + # # Kermit script to make pages that are like the file lists you # get when you follow an FTP link to a directory, where you can click # on individual files to see or download them. FTP was "deprecated" # by Google (in Chrome) and Mozilla (in Firefox) in March-April 2021, # this is my response. A similar program was needed on the Panix end # to install the file-list pages there and link to them from the Panix # Kermit archive page. # # Frank da Cruz, 1 May 2021 .destdir = ~/p/archives/ # Macro to write HTML header for a file-list page def MAKEHEADER { fwrite /line \%1 {} fwrite /line \%1 {} fwrite /line \%1 {
} fwrite /line \%1 {} fwrite /line \%1 {} fwrite /line \%1 {}
}
# Macro to convert a plain-text directory listing into a Web page with links
def MAKEHTML {
local line
fopen /read \%f \m(destdir)\m(name).txt # Open directory listing file
if fail exit 1 "FAILED: fopen /read \m(name).txt"
fopen /write \%o \m(destdir)\m(name).html # Create HTML version of it
if fail exit 1 "FAILED: fopen /write \m(name).html"
makeheader \%o # Put the html header
while true { # Loop through the files
fread /line \%f line # Read a line from the listing
if fail break
if not def line continue # (shouldn't happen)
if \findex(\32->\32,\m(line)) continue # Skip symlinks
undef fn
.fn := \fword(\m(line),5,\32,ALL) # Get filename
if not def fn exit 1 "No filename found in line: \m(line)"
# Convert the filename into a link
.link :=
.link := \m(link)\m(fn)
.line := \freplace(\m(line),\m(fn),\m(link))
fwrite /line \%o \m(line)
}
fwrite /line \%o "" # Finish the HTML page
fwrite /line \%o "