% ns_adp_include [ns_info pageroot]/include/Base.adp set baseurl "/misc/videos" set videoTypes { *.mov *.MOV *.mpg *.MPG *.mpeg *.MPEG *.avi *.AVI *.wmv *.WMV *.asf *.ASF *.rm *.RM *.swf *.SWF } set action [ns_queryget action index] namespace eval Videos { } #{{{ Videos::Information proc Videos::Information { gallery { video "GALLERY-ONLY" } } { global baseurl videoTypes set info [ns_info pageroot]$baseurl/galleries/$gallery/info.txt if ![file exists $info] { return "" } set fh [open $info] set infoD [read $fh] close $fh if ![string length [string trim $infoD]] { return "" } set title [lindex [split $infoD \n] 0] if { $video == "GALLERY-ONLY" } { set count 0; set total 0; foreach f [glob -nocomplain [ns_info pageroot]$baseurl/galleries/$gallery/{[join $videoTypes ,]}] { incr count incr total [file size $f] } #ns_log Notice Info $gallery returning $title $count $total return [list $title $count $total] } set fHeight ""; set fWidth ""; set fShort ""; set fLong "" set size [file size [ns_info pageroot]$baseurl/galleries/$gallery/$video] foreach line [lrange [split $infoD \n] 1 end] { unlist [split $line |] fName width height short long if { $video == $fName } { set fHeight $height; set fWidth $width; set fShort $short; set fLong $long; break } } return [list $fWidth $fHeight $fShort $fLong $size] } #}}} #{{{ Videos::Index proc Videos::Index { } { global baseurl Base::OutputHeader videos "Videos" "" /misc/videos # Fetch information about photo albums foreach gallery [glob -nocomplain [ns_info pageroot]$baseurl/galleries/*] { set gallery [file tail $gallery] unlist [Videos::Information $gallery] title if { [string length $title] } { lappend albums [list $title $gallery] } } set albums [join [lsort -dictionary -index 0 $albums]] ns_adp_puts "
"
foreach v $videos {
set tVideo [file tail $v]
set title ""
unlist [Videos::Information $gallery $tVideo] tWidth tHeight tShort tLong
if { $tShort == "" } {
set str $tVideo
} else {
set str $tShort
}
ns_adp_puts "$str" } ns_adp_puts " | "
foreach t $thumbs {
set thumb [file tail $t]
ns_adp_puts " |
"
set videos [lsort -dictionary [glob -nocomplain -type f [ns_info pageroot]$baseurl/galleries/$gallery/{[join $videoTypes ,]}]]
foreach v $videos {
set tVideo [file tail $v]
unlist [Videos::Information $gallery $tVideo] tWidth tHeight tShort tLong
if { $tShort== "" } {
set str $tVideo
} else {
set str $tShort
}
ns_adp_puts "$str" } ns_adp_puts " | "
ns_adp_puts " "
if ![string length $short] {
ns_adp_puts " "
ns_adp_puts "$video" } elseif ![string length $long] { ns_adp_puts "$short" } else { ns_adp_puts "$short$long" } #// video ns_adp_puts "[Videos::Embed $gallery $video]" #// info in info.txt file if it exists ns_adp_puts "" ns_adp_puts " |