From 8d67bb82bb56f878d29213bf78254690bce0d83c Mon Sep 17 00:00:00 2001 From: hummypkg Date: Sat, 25 Jun 2011 20:59:50 +0000 Subject: [PATCH] more work on rename git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@197 2a923420-c742-0410-a762-8d5b09965624 --- var/mongoose/cgi-bin/browse.jim | 65 +++++++++++-- var/mongoose/cgi-bin/browse/browse.js | 93 +++++++++++++++++-- var/mongoose/cgi-bin/browse/epgtitle.jim | 22 +++++ var/mongoose/cgi-bin/browse/sizes.jim | 26 ++++++ var/mongoose/cgi-bin/epg_search.jim | 25 ++++- var/mongoose/cgi-bin/settings.jim | 67 ++++++++----- var/mongoose/html/css/style.css | 22 ++++- var/mongoose/html/epg.shtml | 22 ++++- .../html/img/channels/ADULT PARTY.png | 1 - var/mongoose/lib/epg.class | 2 +- var/mongoose/lib/ts.class | 9 +- 11 files changed, 300 insertions(+), 54 deletions(-) create mode 100755 var/mongoose/cgi-bin/browse/epgtitle.jim create mode 100755 var/mongoose/cgi-bin/browse/sizes.jim delete mode 100644 var/mongoose/html/img/channels/ADULT PARTY.png diff --git a/var/mongoose/cgi-bin/browse.jim b/var/mongoose/cgi-bin/browse.jim index 6ae5e2a..9253a43 100755 --- a/var/mongoose/cgi-bin/browse.jim +++ b/var/mongoose/cgi-bin/browse.jim @@ -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 "
" puts "" puts "" - puts "$bfile
" + regsub -all " +" $bfile "" tbfile + puts "$bfile + " } 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}} {
$bfile + style=\"padding:$pad\"> + $bfile " + # Size + puts " ($sz) " + # Icons set locked 0 @@ -108,26 +118,65 @@ puts {
  • Delete
  • Toggle Lock
  • Rename
  • -
  • Change Title
  • Download
  • + +
    -
    } +puts "$dir" + # Breadcrumb path -puts "

    " +puts " +
    + +" set stub "" foreach part [split $dir /] { if {$stub eq "/"} { set name $part } else { set name "/$part" } append stub $name puts "$name } -puts "

    " +puts "" # Parent directory set parent [join [lrange [split $dir /] 0 end-1] /] @@ -148,7 +197,7 @@ foreach file [lsort [glob -nocomplain "$dir"]] { entry $file } -puts "
    " +puts "" source /mod/var/mongoose/html/lib/footer.jim diff --git a/var/mongoose/cgi-bin/browse/browse.js b/var/mongoose/cgi-bin/browse/browse.js index d21f8a0..a1d4b34 100755 --- a/var/mongoose/cgi-bin/browse/browse.js +++ b/var/mongoose/cgi-bin/browse/browse.js @@ -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); }); - - diff --git a/var/mongoose/cgi-bin/browse/epgtitle.jim b/var/mongoose/cgi-bin/browse/epgtitle.jim new file mode 100755 index 0000000..7aae0a0 --- /dev/null +++ b/var/mongoose/cgi-bin/browse/epgtitle.jim @@ -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 "}" + diff --git a/var/mongoose/cgi-bin/browse/sizes.jim b/var/mongoose/cgi-bin/browse/sizes.jim new file mode 100755 index 0000000..0313ec7 --- /dev/null +++ b/var/mongoose/cgi-bin/browse/sizes.jim @@ -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 "}" + diff --git a/var/mongoose/cgi-bin/epg_search.jim b/var/mongoose/cgi-bin/epg_search.jim index d7e66bc..cecec39 100755 --- a/var/mongoose/cgi-bin/epg_search.jim +++ b/var/mongoose/cgi-bin/epg_search.jim @@ -32,13 +32,27 @@ catch { set scrid [dict get $_cgi scrid] } puts "
    -Search EPG: -Search descriptions as well as titles. +
    +EPG Search + + + + " +puts { + + +} + 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 {
    - +
    Content Type Searches
    Content Type Searches } @@ -95,6 +109,7 @@ puts "
    " $db close +puts "
    " puts "
    " if {$ct > 0 } { diff --git a/var/mongoose/cgi-bin/settings.jim b/var/mongoose/cgi-bin/settings.jim index 4a148f6..d12b330 100755 --- a/var/mongoose/cgi-bin/settings.jim +++ b/var/mongoose/cgi-bin/settings.jim @@ -54,10 +54,12 @@ source /mod/var/mongoose/html/lib/header.jim puts {} puts { + + diff --git a/var/mongoose/html/img/channels/ADULT PARTY.png b/var/mongoose/html/img/channels/ADULT PARTY.png deleted file mode 100644 index 31caa28..0000000 --- a/var/mongoose/html/img/channels/ADULT PARTY.png +++ /dev/null @@ -1 +0,0 @@ -ADULT PARTY.png - diff --git a/var/mongoose/lib/epg.class b/var/mongoose/lib/epg.class index 1e1333d..f2c3f1a 100644 --- a/var/mongoose/lib/epg.class +++ b/var/mongoose/lib/epg.class @@ -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} { diff --git a/var/mongoose/lib/ts.class b/var/mongoose/lib/ts.class index a208703..fae134e 100644 --- a/var/mongoose/lib/ts.class +++ b/var/mongoose/lib/ts.class @@ -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]] }