more work on rename

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@197 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2011-06-25 20:59:50 +00:00
parent 9faac3c8fe
commit 8d67bb82bb
11 changed files with 300 additions and 54 deletions

View File

@ -2,6 +2,7 @@
package require cgi
source /mod/var/mongoose/lib/ts.class
source /mod/var/mongoose/lib/pretty_size
puts "Content-Type: text/html"
puts ""
@ -19,7 +20,9 @@ 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>"
regsub -all " +" $bfile "" tbfile
puts "$bfile</a><span class=filesize id=\"$tbfile\">
</span></div>"
}
proc entry {file} {{i 0}} {
@ -34,11 +37,14 @@ proc entry {file} {{i 0}} {
set ext [file extension $file]
if {$ext in $::ignore || $ext ni $::include} { continue }
file stat $file st
set sz [pretty_size $st(size)]
set base [file rootname $file]
if {$ext eq ".ts" && [file exists "${base}.nts"]} {
set type ts
set ts [ts fetch $file]
set ts [ts fetch $file 1]
set img 741_1_10_Video_Title.png
set pad 0
} else {
@ -52,10 +58,14 @@ proc entry {file} {{i 0}} {
<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
style=\"padding:$pad\">
$bfile
</a>
"
# Size
puts "<span class=filesize> ($sz) </span>"
# Icons
set locked 0
@ -108,26 +118,65 @@ puts {
<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=renameform title="Rename media file" style="display: none">
<form id=renameform_form>
<input type=hidden name="renameorig" id="renameorig" value="">
<input type=hidden name="titleorig" id="titleorig" value="">
<table border=0>
<tr>
<th>
<label for="rename">
<b>New Filename</b>
</label>
</th>
<td>
<input type=text name="rename" id="rename"
value="" size=70 maxlength=255
class="text ui-widget-content ui-corner-all">
</td>
</tr>
<tr style="display: none" class=tstype>
<th>
<label for="renametitle" style="padding-top: 0.5em">
<b>New EPG Title</b>
</label>
</th>
<td>
<input type=text name="renametitle" id="renametitle"
value="" size=70 maxlength=255
class="text ui-widget-content ui-corner-all">
</td>
</tr>
<tr style="display: none" class=tstype>
<td colspan=2 id=synopsis style="font-style: italic"></td>
</tr>
</table>
</form>
</div>
<div id=dialogue></div>
<div id=confirm title="Confirmation Required"></div>
<script type=text/javascript src=/cgi-bin/browse/browse.js></script>
<div style="border: 1px solid grey; padding: 1em">
}
puts "<span style=\"display:none\" id=dir>$dir</span>"
# Breadcrumb path
puts "<h1>"
puts "
<fieldset style=\"margin: 1em\">
<legend style=\"font-size: 1.5em; padding: 0 0.5em 0.5em 0.5em;\">
"
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>"
puts "</legend>"
# Parent directory
set parent [join [lrange [split $dir /] 0 end-1] /]
@ -148,7 +197,7 @@ foreach file [lsort [glob -nocomplain "$dir"]] {
entry $file
}
puts "</div>"
puts "</fieldset>"
source /mod/var/mongoose/html/lib/footer.jim

View File

@ -1,4 +1,35 @@
function epginfo_callback(data, status, xhr)
{
var width = 85;
if (status != 'success')
return;
//console.log(status);
//console.dir(data);
$('#titleorig').val(data.title);
$('#renametitle').val(data.title);
if (data.synopsis.length > width)
data.synopsis = data.synopsis.substring(0, width) + '...';
$('#synopsis').html(data.synopsis);
$('tr.tstype').show('slow');
}
function insert_folder_size(folder, size)
{
folder = folder.replace(/ /g, '');
//console.log("Folder: (%s) = (%s)", folder, size);
$('#' + folder).text(' (' + size + 'iB)');
}
function folder_size_callback(data, status, xhr)
{
//console.log("Status: %s", status);
$.each(data, insert_folder_size);
}
function delete_callback(file, type, id)
{
var el = 'div.bf#' + id;
@ -24,6 +55,12 @@ function lock_callback(file, type, id)
});
}
function rename_submit()
{
var s = $('#renameform_form').serialize();
alert(s);
}
var $confirm; // Populated after DOM is loaded.
function confirm_action(action, callback, file, type, id)
@ -46,6 +83,7 @@ function preparemenu(el, menu)
{
if (el.attr('type') == 'ts')
{
$('#optmenu').enableContextMenuItems('#lock');
if (el.attr('locked') == 1)
{
$(menu).changeContextMenuItem('#lock', 'Unlock');
@ -64,15 +102,21 @@ function preparemenu(el, menu)
}
}
function menuclick(action, el, pos)
$(document).ready(function() {
var menuclick = function(action, el, pos)
{
var file = $(el).parent().prevAll('a.bf').last().attr('file');
var bfile = file.replace(/.*\/|\.[^.]*$/g, '');
bfile = bfile.replace(/[\x00-\x1f]+/g, '');
var type = $(el).attr('type');
var id = $(el).attr('did');
switch (action)
{
case 'delete':
confirm_action('delete', delete_callback, file, type, id);
confirm_action('delete', delete_callback, file,
type, id);
break;
case 'lock':
@ -80,6 +124,24 @@ function menuclick(action, el, pos)
file, type, id);
break;
case 'rename':
$('#rename').val(bfile);
$('#renameorig').val(file);
$('#titleorig').val('');
$('#renametitle').val('');
$('#synopsis').val('');
$('tr.tstype').css('display', 'none');
if (type == 'ts')
{
$.getJSON('/cgi-bin/browse/epgtitle.jim?file=' +
encodeURIComponent(file), epginfo_callback);
}
$('#renameform').dialog('open');
break;
case 'download':
window.location.href = file;
break;
@ -88,9 +150,7 @@ function menuclick(action, el, pos)
alert('Unhandled action: ' + action);
break;
}
}
$(document).ready(function() {
};
// Bind context menu to opt+ image
$('img.opt').contextMenu(
@ -103,7 +163,7 @@ $(document).ready(function() {
);
// Disable items which are not yet implemented.
$('#optmenu').disableContextMenuItems('#rename,#title');
$('#optmenu').disableContextMenuItems('#title');
// Create reusable dialogue.
var $dialog = $('#dialogue').dialog({
@ -132,6 +192,19 @@ $(document).ready(function() {
$dialog.dialog('open');
});
$('#renameform').dialog({
autoOpen: false,
height: 'auto', width: 'auto',
modal: true,
buttons: {
"Update": rename_submit,
"Close": function() {
$(this).dialog('close');
}
},
close: function() { $('#rename').val(''); }
});
// Create re-usable confirmation dialogue.
$confirm = $('#confirm').dialog({
modal: true, autoOpen: false,
@ -139,7 +212,11 @@ $(document).ready(function() {
show: 'fade', hide: 'fade',
draggable: false, resizable: false
});
var dir = $('#dir').text();
// Load folder sizes
$.getJSON('/cgi-bin/browse/sizes.jim?dir=' + encodeURIComponent(dir),
folder_size_callback);
});

View File

@ -0,0 +1,22 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/ts.class
puts "Content-Type: application/json"
puts ""
cgi_input
#cgi_dump
#set _cgi(file) "/media/My Video/Doctor Who/6.13._The_Almost_People.ts"
if {![dict exists $_cgi file]} { exit }
set file [dict get $_cgi file]
set ts [ts fetch $file]
puts "{"
puts "\"title\" : \"[$ts get title]\","
puts "\"synopsis\" : \"[$ts get synopsis]\""
puts "}"

View File

@ -0,0 +1,26 @@
#!/mod/bin/jimsh
package require cgi
puts "Content-Type: application/json"
puts ""
cgi_input
#cgi_dump
set _cgi(dir) "/media/My Video"
set dir [dict get $_cgi dir]
#9.4G /media/My Video/Archive
#1.4G /media/My Video/CSI_ Crime Scene Investigation
puts "{"
foreach line [split [exec /mod/bin/busybox/du -h "$dir/"] "\n"] {
set fields [split $line "\t"]
set size [lindex $fields 0]
set node [lindex [split [lindex $fields 1] '/'] end]
puts "\"$node\" : \"$size\","
}
puts "\"dummy\" : \"\""
puts "}"

View File

@ -32,13 +32,27 @@ catch { set scrid [dict get $_cgi scrid] }
puts "
<form method=get action=/cgi-bin/epg_search.jim>
Search EPG: <input name=term size=20 maxlength=255 value=\"$term\">
<input type=checkbox name=full"
if {[dict exists $_cgi full]} { puts " checked" }
puts ">Search descriptions as well as titles.
<fieldset>
<legend>EPG Search</legend>
<label for=term>Query</label>
<input type=text name=term id=term size=20 maxlength=255 value=\"$term\"
class=\"text ui-widget-content ui-corner-all\">
<input type=submit value=Search>
<input type=checkbox name=full id=full"
if {[dict exists $_cgi full]} { puts -nonewline " checked" }
puts ">
<label for=full>Search descriptions as well as titles.</label>
"
puts {
<style type=text/css>
.ui-button, .ui-button-text { padding: 0; font-size: 12px; }
</style>
<script type=text/javascript>
$('input:submit').button();
</script>
}
set db [sqlite3.open /var/lib/humaxtv/setup.db]
set res [$db query {
select itemBlob from TBL_USERCONFIG
@ -53,7 +67,7 @@ proc cts {type img text} {
puts {
<br>
<table>
<tr><td rowspan=2>Content Type Searches</td>
<tr><td rowspan=2 valign=top>Content Type Searches</td>
<td>
}
@ -95,6 +109,7 @@ puts "</table>"
$db close
puts "</fieldset>"
puts "</form>"
if {$ct > 0 } {

View File

@ -54,10 +54,12 @@ source /mod/var/mongoose/html/lib/header.jim
puts {<script type="text/javascript" src="/js/jquery.form.js"></script>}
puts {
<style type=text/css>
.ui-button, .ui-button-text { padding: 0; font-size: 10px; }
</style>
<script type=text/javascript>
$(document).ready(function () {
//$(":submit").button();
//$(":submit").height(20);
$(":submit").button();
$('form').each(function(i, el) {
var id = $(this).attr('id');
var output = '#' + id + '_output'
@ -75,12 +77,19 @@ puts {
}
puts "
<h1>Settings</h1>
<table class=keyval>
<fieldset style=\"display: inline\">
<legend>
General Settings
</legend>
<table>
"
puts "
<tr>
<form id=hostname method=get action=$env(REQUEST_URI)>
<th>Hostname</th>
<th class=key>Hostname</th>
<td><input name=hostname value=\"$hostname\"
class=\"text ui-widget-content ui-corner-all\"
length=20 maxlength=50>
<input id=hostname_submit value=\"change\" type=submit>
<div id=hostname_output></div>
@ -89,24 +98,12 @@ puts "
</tr>
"
puts "
<tr>
<form id=smtp_server method=get action=$env(REQUEST_URI)>
<th>SMTP Server for outbound email</th>
<td><input name=smtp_server value=\"$smtp_server\"
length=20 maxlength=50>
<input id=smtp_server_submit value=\"change\" type=submit>
<div id=smtp_server_output></div>
</td>
</form>
</tr>
"
puts "
<tr>
<form id=channel_group method=get action=$env(REQUEST_URI)>
<th>Channel Group for EPG</th>
<th class=key>Channel Group for EPG</th>
<td><select id=channel_group name=channel_group
class=\"text ui-widget-content ui-corner-all\"
value=[$settings channel_group]>
"
@ -123,7 +120,7 @@ foreach grp [$settings channel_groups] {
puts "
</select>
<input name=channel_group value=\"change\" type=submit>
<input name=channel_group value=\"set\" type=submit>
<div id=channel_group_output></div>
</td>
</form>
@ -132,11 +129,31 @@ puts "
puts "
</table>
</form>
<br>
More coming soon...
<br>
<br>
</fieldset>
<br><br>
<fieldset style=\"display: inline\">
<legend> Email Settings </legend>
<table>
"
puts "
<tr>
<form id=smtp_server method=get action=$env(REQUEST_URI)>
<th class=key>SMTP Server for outbound email</th>
<td><input name=smtp_server value=\"$smtp_server\"
class=\"text ui-widget-content ui-corner-all\"
length=20 maxlength=50>
<input id=smtp_server_submit value=\"change\" type=submit>
<div id=smtp_server_output></div>
</td>
</form>
</tr>
"
puts "
</table>
</fieldset>
"
source /mod/var/mongoose/html/lib/footer.jim

View File

@ -63,13 +63,13 @@ table.borders, table.borders td, table.borders th
empty-cells: show;
}
table tr.odd, table td.odd
table tr.odd, table td.odd, table th.odd
{
background: #ccff99;
color: black;
}
table tr.even, table td.even
table tr.even, table td.even, table th.even
{
background: #ffffcc;
color: black;
@ -86,7 +86,7 @@ table th
text-align: left;
}
table.keyval th
table.keyval th, th.key
{
background: #ccff99;
font-weight: bold;
@ -174,6 +174,12 @@ pre, .pre
background: transparent;
}
.filesize
{
color: #6a6aff;
background: transparent;
}
.footnote
{
color: #ff4000;
@ -225,3 +231,13 @@ img.progress
vertical-align: middle;
}
.block
{
display: block;
}
input.text
{
padding: .4em;
}

View File

@ -1,9 +1,27 @@
<!--#include virtual="/lib/header.shtml" -->
<style type=text/css>
.ui-button, .ui-button-text { padding: 0; font-size: 12px; }
</style>
<div style="width: 75%">
<form method=get action=/cgi-bin/epg_search.jim>
Search EPG: <input name=term size=20 maxlength=255>
<input type=checkbox name=full>Search descriptions as well as titles.
<fieldset>
<legend>EPG Search</legend>
<label for=term>Query</label>
<input type=text name=term id=term size=20 maxlength=255
class="text ui-widget-content ui-corner-all">
<input type=submit value=Search>
<input type=checkbox name=full id=full>
<label for=full>Search descriptions as well as titles.</label>
</fieldset>
</form>
</div>
<script type=text/javascript>
$('input:submit').button();
</script>
<!--#exec cmd="/mod/var/mongoose/include/epg.jim" -->
<!--#include virtual="/lib/footer.shtml" -->

View File

@ -1 +0,0 @@
ADULT PARTY.png -

View File

@ -216,7 +216,7 @@ proc {epg cleanup} {} {
proc {epg exec} {mode args} {
set raw 0
set cmd [list /mod/bin/epg -f $epgpath]
set cmd [list /mod/bin/epg -f $::epgpath]
set extra ""
foreach arg $args {
if {[string first "-" $arg] == 0} {

View File

@ -75,7 +75,14 @@ proc {ts exec} {file} {
return [exec {*}$cmd]
}
proc {ts fetch} {file} {
proc {ts fetch} {file {checked 0}} {
# Check that this is a .ts file which has at least one sidecar
# file (.nts)
if {!$checked} {
if {[file extension $file] ne ".ts"} { return 0 }
if {![file exists "[file rootname $file].nts"]} { return 0 }
}
return [ts parse $file [ts exec $file]]
}