webif/var/mongoose/lib/browse.class

105 lines
2.4 KiB
Plaintext
Raw Normal View History

require system.class
#if {![exists -proc class]} { package require oo }
#class browse {}
set _flatten [system pkginst flatten]
proc _addicon {img {hover ""} {class va}} {
set icon "<img src=$img class=\"$class\" height=21"
if {$hover ne ""} {
append icon " alt=\"$hover\" title=\"$hover\""
}
append icon ">"
return $icon
}
proc {dir expiry} {dir} {
if {[catch {
set fd [open "$dir/.autoexpire"]
set days $([read $fd] + 0)
$fd close
}]} { set days 0 }
if {!$days} { set days 7 }
return $days
}
proc {dir iconset} {dir} {
set icons {}
set attrs {}
set noflat 0
if $::_flatten {
if {[string match {\[*\]} [file tail $dir]]} { set noflat 1 }
if {[file exists "$dir/.noflatten"]} { set noflat 1 }
if $noflat { lappend icons \
[_addicon "/img/flat-tyre.png" "No-flatten" }
lappend attrs "noflat=$noflat"
}
set autoshrinkr 0
if {[file exists "$dir/.autoshrinkr"]} {
set autoshrinkr 1
lappend icons [_addicon "/img/compressr.png" \
"Recursive Auto-shrink"]
lappend attrs "autoshrinkr=1"
}
set autoshrink 0
if {!$autoshrinkr && [file exists "$dir/.autoshrink"]} {
set autoshrink 1
lappend icons [_addicon "/img/compress.png" "Auto-shrink"]
lappend attrs "autoshrink=1"
}
set autodedup 0
if {[file exists "$dir/.autodedup"]} {
set autodedup 1
lappend icons [_addicon "/img/dedup.png" "Auto-dedup"]
lappend attrs "autodedup=1"
}
set autodecryptr 0
if {[file exists "$dir/.autodecryptr"]} {
set autodecryptr 1
lappend icons [_addicon "/img/decryptr.png" \
"Recursive Auto-decrypt"]
lappend attrs "autodecryptr=1"
}
set autodecrypt 0
if {!$autodecryptr && [file exists "$dir/.autodecrypt"]} {
set autodecrypt 1
lappend icons [_addicon "/img/decrypt.png" "Auto-decrypt"]
lappend attrs "autodecrypt=1"
}
set autompg 0
if {[file exists "$dir/.autompg"]} {
set autompg 1
lappend icons [_addicon "/img/mpg.png" "Auto-MPG Extract"]
lappend attrs "autompg=1"
}
set automp3 0
if {[file exists "$dir/.automp3"]} {
set automp3 1
lappend icons [_addicon "/img/mp3.png" "Auto-Audio Extract"]
lappend attrs "automp3=1"
}
set autoexpire 0
if {[file exists "$dir/.autoexpire"]} {
set days [{dir expiry} $dir]
set autoexpire 1
lappend icons [_addicon "/img/clock.png" \
"Auto-Expire ($days day$($days == 1 ? "" : "s"))"]
lappend attrs "autoexpire=1" "autoexpiredays=$days"
}
return [list $icons $attrs]
}