#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
require classdump
require clipboard.class
puts "Content-Type: text/html"
puts ""
cgi_input 1
#cgi_dump
set cb [[clipboard new {path "/tmp/webif-browse.cb"}] load]
set action [cgi_get act list]
switch $action {
list {
if {![$cb size]} {
puts "Clipboard is empty"
exit
}
puts "
"
foreach file [$cb get items] {
set img "page_white_copy"
if {[$file get action] eq "cut"} {
set img "cut"
}
set path [$file get path]
set xpath [cgi_quote_html $path]
puts "
"
puts ""
set dfile [file tail $path]
if {[string length $dfile] > 25} {
set dfile "[string range $dfile 0 22]..."
}
if {[file isdirectory $path]} {
puts ""
}
puts [cgi_quote_html $dfile]
puts "
"
puts ""
}
puts "
"
puts ""
}
add {
if {[set path [cgi_get path]] eq "0"} {
puts "No path."
exit
}
set mode [cgi_get mode copy]
foreach p [split $path ","] {
set p [cgi_unquote_input $p]
if {![$cb present $p]} {
$cb add $mode $p
puts "Added $p for $mode
"
}
}
$cb save
}
remove {
$cb remove [cgi_unquote_input [cgi_get path]]
$cb save
}
clear {
$cb clear
$cb save
}
}