<% 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 { title gallery } $albums { unlist [Videos::Information $gallery] title fileCount totalSize ns_adp_puts "

$title  ($fileCount files, [expr $totalSize/1024]KB)

" } ns_adp_puts "
" } #}}} #{{{ Videos::ShowGallery proc Videos::ShowGallery { gallery } { global baseurl videoTypes unlist [Videos::Information $gallery] title imageCount totalSize set thumbs [lsort -dictionary [glob -nocomplain -type f [ns_info pageroot]$baseurl/galleries/$gallery/*.thumb.jpg]] set videos [lsort -dictionary [glob -nocomplain -type f [ns_info pageroot]$baseurl/galleries/$gallery/{[join $videoTypes ,]}]] Base::OutputHeader videos "Videos - $title" "$title" /misc/videos ns_adp_puts "" 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 "" } ns_adp_puts "
" } #}}} #{{{ Videos::Embed proc Videos::Embed { gallery video } { global baseurl unlist [Videos::Information $gallery $video] width height short long switch -exact -- [file extension $video] { .mov { if ![string length $height] { set height 254 } if ![string length $width] { set width 320 } return " " } .swf { if ![string length $height] { set height 480 } if ![string length $width] { set width 640 } return " " } default { return "Videos::Embed: movie type not supported" } } } #}}} #{{{ Videos::ShowVideo proc Videos::ShowVideo { gallery video } { global baseurl videoTypes unlist [Videos::Information $gallery] title unlist [Videos::Information $gallery $video] width height short long if [string length $short] { Base::OutputHeader videos "Videos - $title" "$title: $short" /misc/videos } else { Base::OutputHeader videos "Videos - $title" "$title: $video" /misc/videos } ns_adp_puts "" 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 "

$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 "
" ns_adp_puts "
" } #}}} switch -- $action { show-video { Videos::ShowVideo [ns_queryget gallery] [ns_queryget video] } show-gallery { Videos::ShowGallery [ns_queryget gallery] } index { Videos::Index } } %>