2011-06-14 11:48:55 +00:00
|
|
|
#!/mod/bin/jimsh
|
|
|
|
|
|
|
|
package require cgi
|
2011-06-16 03:10:41 +00:00
|
|
|
source /mod/var/mongoose/lib/ts.class
|
2011-06-14 11:48:55 +00:00
|
|
|
|
|
|
|
puts "Content-Type: text/html"
|
|
|
|
puts ""
|
|
|
|
|
2011-06-16 23:49:48 +00:00
|
|
|
set ignore {.nts .thm .hmt .hmi}
|
2011-06-22 23:36:30 +00:00
|
|
|
set include {.ts .avi .mpg .wmv .mkv}
|
2011-06-16 03:10:41 +00:00
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
cgi_input
|
|
|
|
#cgi_dump
|
|
|
|
|
2011-06-16 03:10:41 +00:00
|
|
|
#set env(REQUEST_URI) ''
|
2011-06-22 23:36:30 +00:00
|
|
|
#set _cgi(dir) "/media/My Video/Chuggington"
|
2011-06-16 03:10:41 +00:00
|
|
|
|
|
|
|
proc directory {file bfile} {
|
|
|
|
puts "<div class=va>"
|
|
|
|
puts "<a href=$::env(REQUEST_URI)?dir=[cgi_quote_url $file]>"
|
|
|
|
puts "<img border=0 class=va src=/images/711_1_09_Media_Folder.png>"
|
|
|
|
puts "$bfile</a></div>"
|
|
|
|
}
|
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
proc entry {file} {{i 0}} {
|
|
|
|
set bfile [file tail $file]
|
2011-06-16 03:10:41 +00:00
|
|
|
if {[string index $bfile 0] == "\025"} {
|
|
|
|
set bfile [string range $bfile 1 end]
|
|
|
|
}
|
|
|
|
if [file isdirectory "$file"] {
|
|
|
|
directory $file $bfile
|
|
|
|
continue
|
|
|
|
}
|
2011-06-16 23:49:48 +00:00
|
|
|
set ext [file extension $file]
|
2011-06-22 23:36:30 +00:00
|
|
|
if {$ext in $::ignore || $ext ni $::include} { continue }
|
|
|
|
|
|
|
|
set base [file rootname $file]
|
|
|
|
|
|
|
|
if {$ext eq ".ts" && [file exists "${base}.nts"]} {
|
|
|
|
set type ts
|
|
|
|
set ts [ts fetch $file]
|
|
|
|
set img 741_1_10_Video_Title.png
|
|
|
|
set pad 0
|
|
|
|
} else {
|
|
|
|
set type gen
|
|
|
|
set ts 0
|
|
|
|
set img 743_4_10_Video_Xvid_File.png
|
|
|
|
set pad "2 2 2 2"
|
2011-06-16 03:10:41 +00:00
|
|
|
}
|
2011-06-14 11:48:55 +00:00
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
puts "
|
|
|
|
<div class=\"va bf\" id=[incr i]>
|
|
|
|
<a class=bf file=\"$file\" type=$type href=#>
|
|
|
|
<img class=va border=0 width=45 src=/images/$img
|
|
|
|
style=\"padding:$pad\">$bfile
|
|
|
|
</a>
|
|
|
|
"
|
|
|
|
|
|
|
|
# Icons
|
|
|
|
|
|
|
|
set locked 0
|
|
|
|
if {$type eq "ts"} {
|
|
|
|
# HD / SD
|
|
|
|
if {[$ts get definition] eq "HD"} {
|
|
|
|
set img "172_1_00_HD"
|
|
|
|
} else {
|
|
|
|
set img "172_1_26_SD"
|
|
|
|
}
|
|
|
|
puts "<img class=va src=/images/$img.png height=21>"
|
2011-06-14 11:48:55 +00:00
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
# Locked
|
|
|
|
if {[$ts flag "Locked"] > 0} {
|
|
|
|
set locked 1
|
|
|
|
puts "<img class=va src=/images/178_1_00_Icon_Lock.png
|
|
|
|
height=21>"
|
2011-06-16 03:10:41 +00:00
|
|
|
}
|
2011-06-14 11:48:55 +00:00
|
|
|
}
|
2011-06-16 03:10:41 +00:00
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
# Opt+ button
|
2011-06-16 03:10:41 +00:00
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
puts "
|
2011-06-22 23:36:30 +00:00
|
|
|
<a href=#>
|
|
|
|
<img class=\"opt va\" border=0 width=45 type=$type did=$i
|
|
|
|
locked=$locked
|
|
|
|
src=/images/181_1_00_Help5_OPT_Plus.png>
|
|
|
|
</a>
|
|
|
|
<div class=\"results blood\" style=\"margin: 0 0 0 5em\"></div>
|
2011-06-14 11:48:55 +00:00
|
|
|
"
|
2011-06-22 23:36:30 +00:00
|
|
|
puts "</div>"
|
2011-06-14 11:48:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if {[dict exists $_cgi dir]} {
|
|
|
|
set dir [dict get $_cgi dir]
|
|
|
|
} else {
|
|
|
|
set dir "/media/My Video"
|
|
|
|
}
|
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
######################################################################
|
|
|
|
# Render web page
|
2011-06-16 23:49:48 +00:00
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
source /mod/var/mongoose/html/lib/header.jim
|
2011-06-16 03:10:41 +00:00
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
puts {
|
|
|
|
<link href=/css/jquery.contextMenu.css rel=stylesheet type=text/css />
|
|
|
|
<script type="text/javascript" src="/js/jquery.contextMenu.js"></script>
|
2011-06-14 11:48:55 +00:00
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
<ul id=optmenu class=contextMenu>
|
|
|
|
<li><a href=#delete>Delete</a></li>
|
|
|
|
<li><a href=#lock>Toggle Lock</a></li>
|
|
|
|
<li><a href=#rename>Rename</a></li>
|
|
|
|
<li><a href=#title>Change Title</a></li>
|
|
|
|
<li><a href=#download>Download</a></li>
|
|
|
|
</ul>
|
2011-06-16 23:49:48 +00:00
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
<div id=dialogue></div>
|
|
|
|
<div id=confirm title="Confirmation Required"></div>
|
2011-06-14 11:48:55 +00:00
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
<script type=text/javascript src=/cgi-bin/browse/browse.js></script>
|
|
|
|
<div style="border: 1px solid grey; padding: 1em">
|
2011-06-14 11:48:55 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 03:10:41 +00:00
|
|
|
# Breadcrumb path
|
2011-06-14 11:48:55 +00:00
|
|
|
puts "<h1>"
|
|
|
|
set stub ""
|
|
|
|
foreach part [split $dir /] {
|
|
|
|
if {$stub eq "/"} { set name $part } else { set name "/$part" }
|
|
|
|
append stub $name
|
|
|
|
puts "<a href=$env(REQUEST_URI)?dir=[cgi_quote_url $stub]>$name</a>
|
|
|
|
}
|
|
|
|
puts "</h1>"
|
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
# Parent directory
|
2011-06-14 11:48:55 +00:00
|
|
|
set parent [join [lrange [split $dir /] 0 end-1] /]
|
|
|
|
if {$parent ne ""} {
|
|
|
|
puts "
|
2011-06-16 03:10:41 +00:00
|
|
|
<div class=va>
|
2011-06-14 11:48:55 +00:00
|
|
|
<a href=$env(REQUEST_URI)?dir=[cgi_quote_url $parent]>
|
2011-06-16 03:10:41 +00:00
|
|
|
<img src=/images/711_3_09_Media_Folder_UP.png class=va>
|
2011-06-14 11:48:55 +00:00
|
|
|
\[parent directory\]</a>
|
|
|
|
</div>
|
|
|
|
"
|
|
|
|
}
|
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
# Strip double slashes
|
2011-06-14 11:48:55 +00:00
|
|
|
regsub -all -- {\/+} "$dir/*" "/" dir
|
|
|
|
|
|
|
|
foreach file [lsort [glob -nocomplain "$dir"]] {
|
2011-06-16 03:10:41 +00:00
|
|
|
entry $file
|
2011-06-14 11:48:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
puts "</div>"
|
|
|
|
|
|
|
|
source /mod/var/mongoose/html/lib/footer.jim
|
|
|
|
|