summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authoralekseiplusplus <alekseijeaves@protonmail.com>2024-06-30 21:57:33 +1000
committeralekseiplusplus <alekseijeaves@protonmail.com>2024-06-30 21:57:33 +1000
commita3bdaf37b72013fe581f108c4798137e1ea267cd (patch)
tree5200d85e5b923499a7c93ba5e4278613f3c053cf /modules
parentd5cc926ec6c3020d2d51cacc7d14e59c558c4167 (diff)
last commit of today; expanding on configuration and modules
Diffstat (limited to 'modules')
-rwxr-xr-xmodules/document-viewer.tcl54
1 files changed, 54 insertions, 0 deletions
diff --git a/modules/document-viewer.tcl b/modules/document-viewer.tcl
new file mode 100755
index 0000000..de8f0e7
--- /dev/null
+++ b/modules/document-viewer.tcl
@@ -0,0 +1,54 @@
+## 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 <br> "
+}
+
+append http::content [html::end]