Wapp

filelist.tcl at [c0bf5ea896]
Login

File examples/filelist.tcl artifact 595aa0dfe2 part of check-in c0bf5ea896


#!/usr/bin/w3tclsh
#
# Show all files in the same directory as the script.
#
package require w3
proc w3-page-env {} {
  w3-allow-xorigin-params
  w3-trim {
    <h1>W3 Environment</h1>
    <pre>%html([w3-debug-env])</pre>
  }
}
proc w3-default {} {
  cd [file dir [w3-param SCRIPT_FILENAME {}]]
  regsub {/[^/]+$} [w3-param BASE_URL] {} base
  w3-trim {
     <html>
     <body>
     <ol>
  }
  foreach file [lsort [glob -nocomplain *]] {
    if {[file isdir $file]} continue
    if {![file readable $file]} continue
    w3-trim {
       <li><a href="%html($base/$file)">%html($file)</a></li>
    }
  }
  w3-trim {</ol>\n}
}
w3-start $argv