restructure browser
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@194 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
parent
1cd0f96bf4
commit
0c858b3410
@ -1,10 +1,11 @@
|
||||
Package: webif
|
||||
Priority: optional
|
||||
Section: web
|
||||
Version: 0.5.3
|
||||
Version: 0.5.4
|
||||
Architecture: mipsel
|
||||
Maintainer: af123@hummypkg.org.uk
|
||||
Depends: mongoose(>=2.11-5),jim,jim-sqlite3,jim-cgi,jim-oo,service-control,busybox(>=1.18.3-1),lsof,epg(>=1.0.2),hmt(>=1.0.4),ssmtp
|
||||
Depends: mongoose(>=2.11-5),jim(>=0.71-1),jim-sqlite3(>=0.71-1),jim-cgi(>=0.2),jim-oo,service-control,busybox(>=1.18.3-1),lsof,epg(>=1.0.2),hmt(>=1.0.4),ssmtp
|
||||
Replaces: af123-webif
|
||||
Conflicts: af123-webif
|
||||
Suggests: ffmpeg
|
||||
Description: A web interface for the Humax. In development.
|
||||
|
@ -7,58 +7,13 @@ puts "Content-Type: text/html"
|
||||
puts ""
|
||||
|
||||
set ignore {.nts .thm .hmt .hmi}
|
||||
set standard {.avi .mpg .wmv .mkv}
|
||||
set include {.ts .avi .mpg .wmv .mkv}
|
||||
|
||||
cgi_input
|
||||
#cgi_dump
|
||||
|
||||
#set _cgi(tsfile) "/media/My Video/Family Guy/2.19._Excellence_in_Broadcasting.ts"
|
||||
#set _cgi(action) "delete"
|
||||
#set env(REQUEST_URI) ''
|
||||
|
||||
proc tsfile {file bfile {ajax 0}} {{i 0}} {
|
||||
set ts [ts fetch $file]
|
||||
if {$ajax == 0} { puts "<div class=\"va tsfile\" id=[incr i]>" }
|
||||
puts "
|
||||
<a class=ts file=\"$file\" href=#>
|
||||
<img class=va border=0 width=45
|
||||
src=/images/741_1_10_Video_Title.png>
|
||||
$bfile
|
||||
</a>
|
||||
"
|
||||
if {[$ts get definition] eq "HD"} {
|
||||
puts "<img class=va src=/images/172_1_00_HD.png height=21>"
|
||||
} else {
|
||||
puts "<img class=va src=/images/172_1_26_SD.png height=21>"
|
||||
}
|
||||
set locked 0
|
||||
if {[$ts flag "Locked"] > 0} {
|
||||
set locked 1
|
||||
puts "<img class=va src=/images/178_1_00_Icon_Lock.png
|
||||
height=21>"
|
||||
}
|
||||
|
||||
puts "
|
||||
<a class=tsopt file=\"$file\" href=#>
|
||||
<img class=\"opt va\" border=0 width=45 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>
|
||||
"
|
||||
if {$ajax == 0} { puts "</div>" }
|
||||
}
|
||||
|
||||
proc genfile {file bfile} {
|
||||
puts "
|
||||
<div class=va>
|
||||
<a href=#>
|
||||
<img class=va border=0 width=45 style=\"padding: 0.3em 0\"
|
||||
src=/images/743_4_10_Video_Xvid_File.png>
|
||||
$bfile
|
||||
</a>
|
||||
</div>
|
||||
"
|
||||
}
|
||||
#set _cgi(dir) "/media/My Video/Chuggington"
|
||||
|
||||
proc directory {file bfile} {
|
||||
puts "<div class=va>"
|
||||
@ -67,8 +22,8 @@ proc directory {file bfile} {
|
||||
puts "$bfile</a></div>"
|
||||
}
|
||||
|
||||
proc entry {file {ajax 0}} {
|
||||
set bfile [lindex [split $file /] end]
|
||||
proc entry {file} {{i 0}} {
|
||||
set bfile [file tail $file]
|
||||
if {[string index $bfile 0] == "\025"} {
|
||||
set bfile [string range $bfile 1 end]
|
||||
}
|
||||
@ -77,94 +32,61 @@ proc entry {file {ajax 0}} {
|
||||
continue
|
||||
}
|
||||
set ext [file extension $file]
|
||||
if {$ext eq ".ts"} {
|
||||
tsfile $file $bfile $ajax
|
||||
continue
|
||||
}
|
||||
if {$ext in $::ignore} { continue }
|
||||
if {$ext in $::standard} {
|
||||
genfile $file $bfile
|
||||
continue
|
||||
}
|
||||
}
|
||||
if {$ext in $::ignore || $ext ni $::include} { continue }
|
||||
|
||||
if {[dict exists $_cgi tsfile]} {
|
||||
set file [dict get $_cgi tsfile]
|
||||
set ts [ts fetch $file]
|
||||
set base [file rootname $file]
|
||||
|
||||
if {[dict exists $_cgi action]} {
|
||||
switch [dict get $_cgi action] {
|
||||
entry {
|
||||
entry $file 1
|
||||
}
|
||||
delete {
|
||||
if {[$ts delete]} {
|
||||
puts "Successfully deleted $file."
|
||||
} else {
|
||||
puts "Problem deleting $file, [$ts get error]"
|
||||
}
|
||||
}
|
||||
lock {
|
||||
set action lock
|
||||
if {[$ts flag "Locked"]} { set action unlock }
|
||||
if {[$ts $action]} {
|
||||
puts "Successfully [set action]ed $file."
|
||||
} else {
|
||||
puts "Problem [set action]ing $file,
|
||||
[$ts get error]"
|
||||
}
|
||||
}
|
||||
}
|
||||
exit
|
||||
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"
|
||||
}
|
||||
|
||||
source /mod/var/mongoose/lib/epg.class
|
||||
|
||||
puts "
|
||||
<table class=keyval>
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<td>[$ts get title]</td>
|
||||
</tr><tr>
|
||||
<th>Synopsis</th>
|
||||
<td>[$ts get synopsis]</td>
|
||||
</tr><tr>
|
||||
<th>Definition</th>
|
||||
<td>
|
||||
<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>
|
||||
"
|
||||
if {[$ts get definition] eq "HD"} {
|
||||
puts "<img class=va src=/images/172_1_00_HD.png height=21>"
|
||||
} else {
|
||||
puts "<img class=va src=/images/172_1_26_SD.png height=21>"
|
||||
|
||||
# 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>"
|
||||
|
||||
# Locked
|
||||
if {[$ts flag "Locked"] > 0} {
|
||||
set locked 1
|
||||
puts "<img class=va src=/images/178_1_00_Icon_Lock.png
|
||||
height=21>"
|
||||
}
|
||||
}
|
||||
puts "</td>
|
||||
</tr><tr>
|
||||
<th>Channel</th>
|
||||
<td>[epg channelicon [$ts get channel_name] 50 "vertical-align: middle"]
|
||||
[$ts get channel_num] - [$ts get channel_name]</td>
|
||||
</tr><tr>
|
||||
<th>Start Time</th>
|
||||
<td>"
|
||||
puts [clock format [$ts get start] -format "%c %Z"]
|
||||
puts "</td>
|
||||
</tr><tr>
|
||||
<th>End Time</th>
|
||||
<td>"
|
||||
puts [clock format [$ts get end] -format "%c %Z"]
|
||||
puts "</td>
|
||||
</tr><tr>
|
||||
<th>Duration</th>
|
||||
<td>[$ts duration] minute(s).</td>
|
||||
</tr><tr>
|
||||
<th>Size</th>
|
||||
<td>[$ts size] MiB</td>
|
||||
</tr><tr>
|
||||
<th>Flags</th>
|
||||
<td>[$ts get flags]</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
# Opt+ button
|
||||
|
||||
puts "
|
||||
<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>
|
||||
"
|
||||
exit
|
||||
puts "</div>"
|
||||
}
|
||||
|
||||
if {[dict exists $_cgi dir]} {
|
||||
@ -173,158 +95,29 @@ if {[dict exists $_cgi dir]} {
|
||||
set dir "/media/My Video"
|
||||
}
|
||||
|
||||
######################################################################
|
||||
# Render web page
|
||||
|
||||
source /mod/var/mongoose/html/lib/header.jim
|
||||
|
||||
puts {
|
||||
puts {
|
||||
<link href=/css/jquery.contextMenu.css rel=stylesheet type=text/css />
|
||||
<script type="text/javascript" src="/js/jquery.contextMenu.js"></script>
|
||||
|
||||
<link href=/css/jquery.contextMenu.css rel=stylesheet type=text/css />
|
||||
<script type="text/javascript" src="/js/jquery.contextMenu.js"></script>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<div id=dialogue></div>
|
||||
<div id=confirm title="Confirmation Required"></div>
|
||||
|
||||
<div id=dialogue></div>
|
||||
<div id=confirm title="Confirmation Required"></div>
|
||||
|
||||
<script type=text/javascript>
|
||||
function bindmenu(selector)
|
||||
{
|
||||
$(selector).contextMenu(
|
||||
{
|
||||
menu: 'optmenu',
|
||||
leftButton: true,
|
||||
beforeShow:
|
||||
function(el, menu)
|
||||
{
|
||||
if (el.attr('locked') == 1)
|
||||
{
|
||||
$(menu).changeContextMenuItem('#lock', 'Unlock');
|
||||
$('#optmenu').disableContextMenuItems('#delete');
|
||||
}
|
||||
else
|
||||
{
|
||||
$(menu).changeContextMenuItem('#lock', 'Lock');
|
||||
$('#optmenu').enableContextMenuItems('#delete');
|
||||
}
|
||||
<script type=text/javascript src=/cgi-bin/browse/browse.js></script>
|
||||
<div style="border: 1px solid grey; padding: 1em">
|
||||
}
|
||||
},
|
||||
function (action, el, pos)
|
||||
{
|
||||
var ts = $(el).parent().prevAll('a.ts').last().attr('file');
|
||||
var did = $(el).attr('did');
|
||||
switch (action)
|
||||
{
|
||||
case 'delete':
|
||||
confirm_action('delete', delete_callback, ts, did);
|
||||
break;
|
||||
|
||||
case 'lock':
|
||||
confirm_action('change the lock on', lock_callback, ts, did);
|
||||
break;
|
||||
|
||||
case 'download':
|
||||
window.location.href = ts;
|
||||
break;
|
||||
|
||||
default:
|
||||
alert('Unhandled action: ' + action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
var $confirm = $('#confirm').dialog({
|
||||
modal: true, autoOpen: false,
|
||||
height: 160, width: 500,
|
||||
show: 'fade', hide: 'fade',
|
||||
draggable: false, resizable: false
|
||||
});
|
||||
|
||||
var confirm_action = function(action, callback, ts, id) {
|
||||
var bts = ts.replace(/.*\/|\.[^.]*$/g, '');
|
||||
$confirm.dialog('option', 'buttons', {
|
||||
'Yes': function() { $(this).dialog('close');
|
||||
callback(ts, id); },
|
||||
'No': function() {$(this).dialog('close');}
|
||||
|
||||
});
|
||||
$('#confirm').empty().html(
|
||||
'Are you sure you wish to ' + action + '<br>' +
|
||||
'<i>' + bts + '</i> ?'
|
||||
);
|
||||
$confirm.dialog('open');
|
||||
}
|
||||
|
||||
var delete_callback = function(ts, id) {
|
||||
var el = 'div.tsfile#' + id;
|
||||
var results = el + ' .results';
|
||||
var url = window.location.pathname + '?tsfile=' +
|
||||
encodeURIComponent(ts) + '&action=delete';
|
||||
$(results).load(url, function() {
|
||||
$(el).delay(3000).slideUp(300, function() {
|
||||
$(el).remove();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var lock_callback = function(ts, id) {
|
||||
var el = 'div.tsfile#' + id;
|
||||
var results = el + ' .results';
|
||||
var url = window.location.pathname + '?tsfile=' +
|
||||
encodeURIComponent(ts) + '&action=';
|
||||
|
||||
$(results).load(url + 'lock', function() {
|
||||
$(results).delay(3000).slideUp(150,
|
||||
function() {
|
||||
$(el).load(url + 'entry', function() {
|
||||
bindmenu(el + ' img.opt');
|
||||
});;
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Dialogue init
|
||||
var $dialog = $('#dialogue').dialog({
|
||||
title: "Recording Details",
|
||||
modal: false, autoOpen: false,
|
||||
height: 600, width: 700,
|
||||
show: 'scale', hide: 'fade',
|
||||
draggable: true, resizable: true,
|
||||
buttons: {
|
||||
"Close": function() {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
},
|
||||
close: function(e,u) { $('#dialogue').empty().html(
|
||||
'<img src="/img/loading.gif" alt="loading">'); }
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#optmenu').disableContextMenuItems('#rename,#title');
|
||||
bindmenu('img.opt');
|
||||
|
||||
$('a.ts').click(function(e) {
|
||||
e.preventDefault();
|
||||
var file = $(this).attr('file');
|
||||
var url = window.location.pathname + '?tsfile=' +
|
||||
encodeURIComponent(file);
|
||||
$('#dialogue').load(url);
|
||||
$dialog.dialog('open');
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
}
|
||||
|
||||
puts { <div style="border: 1px solid grey; padding: 1em"> }
|
||||
|
||||
# Breadcrumb path
|
||||
puts "<h1>"
|
||||
@ -336,6 +129,7 @@ foreach part [split $dir /] {
|
||||
}
|
||||
puts "</h1>"
|
||||
|
||||
# Parent directory
|
||||
set parent [join [lrange [split $dir /] 0 end-1] /]
|
||||
if {$parent ne ""} {
|
||||
puts "
|
||||
@ -347,6 +141,7 @@ if {$parent ne ""} {
|
||||
"
|
||||
}
|
||||
|
||||
# Strip double slashes
|
||||
regsub -all -- {\/+} "$dir/*" "/" dir
|
||||
|
||||
foreach file [lsort [glob -nocomplain "$dir"]] {
|
||||
|
145
var/mongoose/cgi-bin/browse/browse.js
Executable file
145
var/mongoose/cgi-bin/browse/browse.js
Executable file
@ -0,0 +1,145 @@
|
||||
|
||||
function delete_callback(file, type, id)
|
||||
{
|
||||
var el = 'div.bf#' + id;
|
||||
var results = el + ' .results';
|
||||
var url = '/cgi-bin/browse/delete.jim?file=' +
|
||||
encodeURIComponent(file) + '&type=' + type;
|
||||
$(results).load(url, function() {
|
||||
$(el).delay(3000).slideUp(300, function() {
|
||||
$(el).remove();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function lock_callback(file, type, id)
|
||||
{
|
||||
var el = 'div.bf#' + id;
|
||||
var results = el + ' .results';
|
||||
var url = '/cgi-bin/browse/lock.jim?file=' +
|
||||
encodeURIComponent(file);
|
||||
|
||||
$(results).load(url, function() {
|
||||
$(results).delay(3000).slideUp(150);
|
||||
});
|
||||
}
|
||||
|
||||
var $confirm; // Populated after DOM is loaded.
|
||||
|
||||
function confirm_action(action, callback, file, type, id)
|
||||
{
|
||||
var bfile = file.replace(/.*\/|\.[^.]*$/g, '');
|
||||
$confirm.dialog('option', 'buttons', {
|
||||
'Yes': function() { $(this).dialog('close');
|
||||
callback(file, type, id); },
|
||||
'No': function() {$(this).dialog('close');}
|
||||
|
||||
});
|
||||
$('#confirm').empty().html(
|
||||
'Are you sure you wish to ' + action + '<br>' +
|
||||
'<i>' + bfile + '</i> ?'
|
||||
);
|
||||
$confirm.dialog('open');
|
||||
}
|
||||
|
||||
function preparemenu(el, menu)
|
||||
{
|
||||
if (el.attr('type') == 'ts')
|
||||
{
|
||||
if (el.attr('locked') == 1)
|
||||
{
|
||||
$(menu).changeContextMenuItem('#lock', 'Unlock');
|
||||
$('#optmenu').disableContextMenuItems('#delete');
|
||||
}
|
||||
else
|
||||
{
|
||||
$(menu).changeContextMenuItem('#lock', 'Lock');
|
||||
$('#optmenu').enableContextMenuItems('#delete');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#optmenu').enableContextMenuItems('#delete');
|
||||
$('#optmenu').disableContextMenuItems('#lock');
|
||||
}
|
||||
}
|
||||
|
||||
function menuclick(action, el, pos)
|
||||
{
|
||||
var file = $(el).parent().prevAll('a.bf').last().attr('file');
|
||||
var type = $(el).attr('type');
|
||||
var id = $(el).attr('did');
|
||||
switch (action)
|
||||
{
|
||||
case 'delete':
|
||||
confirm_action('delete', delete_callback, file, type, id);
|
||||
break;
|
||||
|
||||
case 'lock':
|
||||
confirm_action('change the lock on', lock_callback,
|
||||
file, type, id);
|
||||
break;
|
||||
|
||||
case 'download':
|
||||
window.location.href = file;
|
||||
break;
|
||||
|
||||
default:
|
||||
alert('Unhandled action: ' + action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
// Bind context menu to opt+ image
|
||||
$('img.opt').contextMenu(
|
||||
{
|
||||
menu: 'optmenu',
|
||||
leftButton: true,
|
||||
beforeShow: preparemenu
|
||||
},
|
||||
menuclick
|
||||
);
|
||||
|
||||
// Disable items which are not yet implemented.
|
||||
$('#optmenu').disableContextMenuItems('#rename,#title');
|
||||
|
||||
// Create reusable dialogue.
|
||||
var $dialog = $('#dialogue').dialog({
|
||||
title: "Media Details",
|
||||
modal: false, autoOpen: false,
|
||||
height: 600, width: 700,
|
||||
show: 'scale', hide: 'fade',
|
||||
draggable: true, resizable: true,
|
||||
buttons: {
|
||||
"Close": function() {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
},
|
||||
close: function(e,u) { $('#dialogue').empty().html(
|
||||
'<img src="/img/loading.gif" alt="loading">'); }
|
||||
});
|
||||
|
||||
// Bind dialogue open to filenames.
|
||||
$('a.bf').click(function(e) {
|
||||
e.preventDefault();
|
||||
var file = $(this).attr('file');
|
||||
var type = $(this).attr('type');
|
||||
var url = '/cgi-bin/browse/file.jim?file=' +
|
||||
encodeURIComponent(file) + '&type=' + type;
|
||||
$('#dialogue').load(url);
|
||||
$dialog.dialog('open');
|
||||
});
|
||||
|
||||
// Create re-usable confirmation dialogue.
|
||||
$confirm = $('#confirm').dialog({
|
||||
modal: true, autoOpen: false,
|
||||
height: 160, width: 500,
|
||||
show: 'fade', hide: 'fade',
|
||||
draggable: false, resizable: false
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
27
var/mongoose/cgi-bin/browse/delete.jim
Executable file
27
var/mongoose/cgi-bin/browse/delete.jim
Executable file
@ -0,0 +1,27 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
package require cgi
|
||||
source /mod/var/mongoose/lib/ts.class
|
||||
|
||||
puts "Content-Type: text/html"
|
||||
puts ""
|
||||
|
||||
cgi_input
|
||||
#cgi_dump
|
||||
|
||||
set file [dict get $_cgi file]
|
||||
set type [dict get $_cgi type]
|
||||
|
||||
if {$type eq "ts"} {
|
||||
set ts [ts fetch $file]
|
||||
if {[$ts delete]} {
|
||||
puts "Successfully deleted $file."
|
||||
} else {
|
||||
puts "Problem deleting $file, [$ts get error]"
|
||||
}
|
||||
exit
|
||||
}
|
||||
|
||||
file delete $file
|
||||
puts "Successfully deleted $file."
|
||||
|
17
var/mongoose/cgi-bin/browse/ffmpeg.jim
Executable file
17
var/mongoose/cgi-bin/browse/ffmpeg.jim
Executable file
@ -0,0 +1,17 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
package require cgi
|
||||
|
||||
puts "Content-Type: text/html"
|
||||
puts ""
|
||||
|
||||
cgi_input
|
||||
#cgi_dump
|
||||
|
||||
if [file exists /mod/bin/ffmpeg] {
|
||||
set file [dict get $_cgi file]
|
||||
puts [exec /mod/var/mongoose/lib/ffmpeg -i $file]
|
||||
} else {
|
||||
puts "Install ffmpeg package for more information..."
|
||||
}
|
||||
|
101
var/mongoose/cgi-bin/browse/file.jim
Executable file
101
var/mongoose/cgi-bin/browse/file.jim
Executable file
@ -0,0 +1,101 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
package require cgi
|
||||
source /mod/var/mongoose/lib/pretty_size
|
||||
|
||||
puts "Content-Type: text/html"
|
||||
puts ""
|
||||
|
||||
cgi_input
|
||||
#cgi_dump
|
||||
|
||||
#set _cgi(file) "/media/My Video/Dangermouse/Series 1/01_rogue_robots.avi"
|
||||
|
||||
if {![dict exists $_cgi file]} { exit }
|
||||
|
||||
set file [dict get $_cgi file]
|
||||
set type [dict get $_cgi type]
|
||||
|
||||
file stat $file st
|
||||
set sz [pretty_size $st(size)]
|
||||
|
||||
if {$type eq "ts"} {
|
||||
source /mod/var/mongoose/lib/epg.class
|
||||
source /mod/var/mongoose/lib/ts.class
|
||||
|
||||
set ts [ts fetch $file]
|
||||
|
||||
puts "
|
||||
<table class=keyval>
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<td>[$ts get title]</td>
|
||||
</tr><tr>
|
||||
<th>Synopsis</th>
|
||||
<td>[$ts get synopsis]</td>
|
||||
</tr><tr>
|
||||
<th>Definition</th>
|
||||
<td>
|
||||
"
|
||||
if {[$ts get definition] eq "HD"} {
|
||||
puts "<img class=va src=/images/172_1_00_HD.png height=21>"
|
||||
} else {
|
||||
puts "<img class=va src=/images/172_1_26_SD.png height=21>"
|
||||
}
|
||||
puts "</td>
|
||||
</tr><tr>
|
||||
<th>Channel</th>
|
||||
<td>[epg channelicon [$ts get channel_name] 50 "vertical-align: middle"]
|
||||
[$ts get channel_num] - [$ts get channel_name]</td>
|
||||
</tr><tr>
|
||||
<th>Start Time</th>
|
||||
<td>"
|
||||
puts [clock format [$ts get start] -format "%c %Z"]
|
||||
puts "</td>
|
||||
</tr><tr>
|
||||
<th>End Time</th>
|
||||
<td>"
|
||||
puts [clock format [$ts get end] -format "%c %Z"]
|
||||
puts "</td>
|
||||
</tr><tr>
|
||||
<th>Duration</th>
|
||||
<td>[$ts duration] minute(s).</td>
|
||||
</tr><tr>
|
||||
<th>Size</th>
|
||||
<td>$sz</td>
|
||||
</tr><tr>
|
||||
<th>Flags</th>
|
||||
<td>[$ts get flags]</td>
|
||||
</tr>
|
||||
</table>
|
||||
"
|
||||
exit
|
||||
}
|
||||
|
||||
# Otherwise, for a general file.
|
||||
|
||||
puts "
|
||||
<table class=keyval>
|
||||
<tr>
|
||||
<th>File</th>
|
||||
<td>$file</td>
|
||||
</tr><tr>
|
||||
<th>Size</th>
|
||||
<td>$sz</td>
|
||||
</tr><tr>
|
||||
<th>Info</th>
|
||||
<td class=pre id=ffmpeg>
|
||||
<img src=/img/loading.gif><i>Loading...</i>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
"
|
||||
|
||||
set url "/cgi-bin/browse/ffmpeg.jim?file=[cgi_quote_url $file]"
|
||||
puts { <script type="text/javascript"> }
|
||||
puts "var url = \"$url\";"
|
||||
puts {
|
||||
$('#ffmpeg').load(url);
|
||||
</script>
|
||||
}
|
||||
|
24
var/mongoose/cgi-bin/browse/lock.jim
Executable file
24
var/mongoose/cgi-bin/browse/lock.jim
Executable file
@ -0,0 +1,24 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
package require cgi
|
||||
source /mod/var/mongoose/lib/ts.class
|
||||
|
||||
puts "Content-Type: text/html"
|
||||
puts ""
|
||||
|
||||
cgi_input
|
||||
#cgi_dump
|
||||
|
||||
set file [dict get $_cgi file]
|
||||
set ts [ts fetch $file]
|
||||
|
||||
set action lock
|
||||
if {[$ts flag "Locked"]} { set action unlock }
|
||||
|
||||
if {[$ts $action]} {
|
||||
puts "Successfully [set action]ed $file."
|
||||
} else {
|
||||
puts "Problem [set action]ing $file,
|
||||
[$ts get error]"
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ table.keyval td
|
||||
color: black;
|
||||
}
|
||||
|
||||
pre
|
||||
pre, .pre
|
||||
{
|
||||
font-family: Consolas, 'Courier New', Courier, monospace;
|
||||
color: black;
|
||||
|
8
var/mongoose/lib/ffmpeg
Executable file
8
var/mongoose/lib/ffmpeg
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
/mod/bin/ffmpeg "$@" 2>&1 | sed '
|
||||
1,8d
|
||||
$d
|
||||
'
|
||||
exit 0
|
||||
|
15
var/mongoose/lib/pretty_size
Normal file
15
var/mongoose/lib/pretty_size
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
if {[expr ! [exists -proc pretty_size ]]} {
|
||||
proc pretty_size {size} {
|
||||
set units {bytes KiB MiB GiB TiB}
|
||||
|
||||
for {set i 0} {$size > 1023} {incr i} {
|
||||
set size $($size / 1024.0)
|
||||
}
|
||||
|
||||
set size [format "%.2f" $size]
|
||||
|
||||
return "$size [lindex $units $i]"
|
||||
}
|
||||
}
|
||||
|
@ -20,12 +20,8 @@ ts method duration {} {
|
||||
}
|
||||
|
||||
ts method size {} {
|
||||
set sz "??"
|
||||
catch {
|
||||
file stat $file st
|
||||
set sz [expr $st(size) / 1048576]
|
||||
}
|
||||
return $sz
|
||||
file stat $file st
|
||||
return $st(size)
|
||||
}
|
||||
|
||||
ts method _parse {line} {
|
||||
|
Loading…
x
Reference in New Issue
Block a user