## Note that this code is leftover from the beginning of this project, ## which was originally a CGI document viewer that grew into a HTTP ## server instead, but I plan to implement this as a module. ## This is not at all supposed to be used right now. variable directories {articles test-one} ### Content proc run {request_target} { } append http::content [html::start Lame!] ## If directory is not queried, if { ([lsearch -exact [dict keys $query] "directory"] eq -1) || ([lsearch -exact $directories [dict get $query directory]] eq -1 )} { append http::content "Utter failure." append http::content [html::end] http::respond exit } set directory [dict get $query directory] ## If document is not queried, or does not exist in our directory, set documents [exec ls -Q $directory] if { ([lsearch -exact [dict keys $query] "document"] eq -1) || ([lsearch -exact $documents [dict get $query document]] eq -1 ) } { foreach a $documents { append http::content [html::link $a "?directory=$directory&document=$a"] } append http::content [html::end] http::respond exit } ## Open file set file [open "$directory/[dict get $query document]" r] ## Output lines while {[gets $file line] != -1} { append http::content "$line
" } append http::content [html::end]