From b2c7be03a46f38cb9027e8782fd5bf5a77b58bd1 Mon Sep 17 00:00:00 2001 From: hummypkg Date: Mon, 11 Mar 2013 23:00:41 +0000 Subject: [PATCH] add thumbnail generation git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1445 2a923420-c742-0410-a762-8d5b09965624 --- CONTROL/control | 6 +- var/mongoose/html/browse/assets.jim | 4 + var/mongoose/html/browse/file.jim | 7 +- var/mongoose/html/browse/script.js | 26 +++-- var/mongoose/html/browse/thumbnail/_mk.jim | 19 ++++ var/mongoose/html/browse/thumbnail/fetch.jim | 17 +++ var/mongoose/html/browse/thumbnail/index.jim | 98 ++++++++++++++++++ .../html/browse/thumbnail/mkrange.jim | 21 ++++ var/mongoose/html/browse/thumbnail/script.js | 58 +++++++++++ .../{thumbnail.jim => thumbnail/set.jim} | 4 +- var/mongoose/html/css/style.css | 15 +++ var/mongoose/html/img/generating.png | Bin 0 -> 1282 bytes var/mongoose/lib/ts.class | 55 +++++++--- 13 files changed, 307 insertions(+), 23 deletions(-) create mode 100755 var/mongoose/html/browse/thumbnail/_mk.jim create mode 100755 var/mongoose/html/browse/thumbnail/fetch.jim create mode 100755 var/mongoose/html/browse/thumbnail/index.jim create mode 100755 var/mongoose/html/browse/thumbnail/mkrange.jim create mode 100755 var/mongoose/html/browse/thumbnail/script.js rename var/mongoose/html/browse/{thumbnail.jim => thumbnail/set.jim} (80%) create mode 100644 var/mongoose/html/img/generating.png diff --git a/CONTROL/control b/CONTROL/control index 193bc9cd..b1398b12 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -1,9 +1,9 @@ Package: webif Priority: optional Section: web -Version: 0.13.3-2 +Version: 0.13.3-3 Architecture: mipsel Maintainer: af123@hummypkg.org.uk -Depends: webif-channelicons(>=1.0.4-1),mongoose(>=3.0-7),jim(>=0.73-1),jim-oo,jim-sqlite3(>=0.73-1),jim-cgi(>=0.7),jim-binary,service-control(>=1.2),busybox(>=1.20.2-1),lsof,epg(>=1.0.10),hmt(>=1.1.13),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2),stripts(>=1.1.2),smartmontools,tmenu(>=1.05) -Suggests: ffmpeg +Depends: webif-channelicons(>=1.0.4-1),mongoose(>=3.0-7),jim(>=0.73-1),jim-oo,jim-sqlite3(>=0.73-1),jim-cgi(>=0.7),jim-binary,service-control(>=1.2),busybox(>=1.20.2-1),lsof,epg(>=1.0.10),hmt(>=1.1.13),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2),stripts(>=1.1.2),smartmontools,tmenu(>=1.05),ffmpeg,id3v2 +Suggests: Description: An evolving web interface for the Humax. diff --git a/var/mongoose/html/browse/assets.jim b/var/mongoose/html/browse/assets.jim index f1ad784c..9831c901 100755 --- a/var/mongoose/html/browse/assets.jim +++ b/var/mongoose/html/browse/assets.jim @@ -291,5 +291,9 @@ Please wait... + + } diff --git a/var/mongoose/html/browse/file.jim b/var/mongoose/html/browse/file.jim index 0c952b80..c4990b98 100755 --- a/var/mongoose/html/browse/file.jim +++ b/var/mongoose/html/browse/file.jim @@ -23,7 +23,12 @@ if {$type eq "ts"} { - + diff --git a/var/mongoose/html/browse/script.js b/var/mongoose/html/browse/script.js index f2e33350..c05fd24d 100755 --- a/var/mongoose/html/browse/script.js +++ b/var/mongoose/html/browse/script.js @@ -271,7 +271,7 @@ function preparemenu(el, menu) else $(menu).disableContextMenuItems('#crop'); - if (el.attr('bx') > 0 && el.attr('odencd') == 0) + if (el.attr('odencd') == 0) $(menu).enableContextMenuItems('#thm'); else $(menu).disableContextMenuItems('#thm'); @@ -449,14 +449,16 @@ var menuclick = function(action, el, pos) break; case 'thm': - confirm_action('re-generate the thumbnail for', - thumbnail_callback, file, dir, id); + window.location.href = '/browse/thumbnail/index.jim?file=' + + file; break; case 'vthm': - window.open('/browse/bmp.jim?file=' + file, 'hxwebifbmp', - 'height=78,width=140,toolbar=no,' + - 'scrollbars=no,menubar=no,location=no,titlebar=no'); +// window.open('/browse/bmpw.jim?file=' + file, 'hxwebifbmp', +// 'height=156,width=280,toolbar=no,' + +// 'scrollbars=no,menubar=no,location=no,titlebar=no'); + $('#thmbmp').attr('src', 'bmp.jim?file=' + file); + $('#bmpdialogue').dialog('open'); break; case 'download': @@ -783,6 +785,18 @@ var dmenuclick = function(action, el, pos) close: function() { $('#savestream_name').val(''); } }); + $('#bmpdialogue').dialog({ + autoOpen: false, + height: 'auto', width: 'auto', + modal: true, + buttons: { + "Close": function() { + $(this).dialog('close'); + } + }, + close: function() { $('#thmbmp').attr('src', 'about:blank'); } + }); + // Create re-usable confirmation dialogue. $confirm = $('#confirm').dialog({ modal: true, autoOpen: false, diff --git a/var/mongoose/html/browse/thumbnail/_mk.jim b/var/mongoose/html/browse/thumbnail/_mk.jim new file mode 100755 index 00000000..da888c4e --- /dev/null +++ b/var/mongoose/html/browse/thumbnail/_mk.jim @@ -0,0 +1,19 @@ +#!/mod/bin/jimsh + +package require cgi +source /mod/webif/lib/setup +require ts.class cat + +httpheader "image/bmp" + +set rfile [cgi_get file] +set pos [cgi_get pos 0] + +if {![catch {set ts [ts fetch $rfile]}]} { + $ts mkbmp $pos ".pos$pos" + + set f "[file rootname $rfile].pos$pos.bmp" + cat $f + file delete $f +} + diff --git a/var/mongoose/html/browse/thumbnail/fetch.jim b/var/mongoose/html/browse/thumbnail/fetch.jim new file mode 100755 index 00000000..37be02bc --- /dev/null +++ b/var/mongoose/html/browse/thumbnail/fetch.jim @@ -0,0 +1,17 @@ +#!/mod/bin/jimsh + +package require cgi +source /mod/webif/lib/setup +require cat + +httpheader "image/bmp" + +set rfile [cgi_get file] +set pos [cgi_get pos 0] + +set f "[file rootname $rfile].pos$pos.bmp" +if {[file exists $f]} { + cat $f + file delete $f +} + diff --git a/var/mongoose/html/browse/thumbnail/index.jim b/var/mongoose/html/browse/thumbnail/index.jim new file mode 100755 index 00000000..720eb6c8 --- /dev/null +++ b/var/mongoose/html/browse/thumbnail/index.jim @@ -0,0 +1,98 @@ +#!/mod/bin/jimsh + +package require cgi +source /mod/webif/lib/setup +require ts.class pretty_size + +header + +set rfile [cgi_get file] +set ts [ts fetch $rfile] +set dir [file dirname $rfile] + +set len [$ts duration 1] + +lassign [$ts bookmarks] book +if {$book eq ""} { set book 0 } + +set pos [cgi_get pos $book] +set pos $($pos + 0) +if {$pos < 0} { set pos 0 } + +puts " + + + +
+Replace Thumbnail + +
Title[$ts get title] + " + if {[file exists "[file rootname $file].thm"]} { + puts "" + } + puts "[$ts get title]
Synopsis [$ts get synopsis]
+ + + + + +
File: + + $rfile +
Length:[clock format $len -format %T]
Size:[pretty_size [$ts size]] ([$ts get definition])
Bookmarks:[$ts get bookmarks] ($book second(s))
Thumbnail: + +
+" + +if {[$ts get definition] eq "HD"} { + set start $($pos - 0.5) + set incr 1.0 +} else { + set start $($pos - 1) + set incr 2.0 +} +if {$start < 0} { set start 0 } +set limit $($start + $incr) + +puts "
+ +

+
+ + Thumbnails from around + + second(s) into recording. +
+ + + + + +
+ + + + +" + +for {set i [expr $start + 0.0]} {$i <= $limit} {set i [expr $i + 0.5]} { + lappend times $i + puts "" +} +puts "" + +foreach i $times { + puts "" +} + +puts "" + +foreach i $times { + puts "" +} + +puts "" + +puts "
+ @ $is
+ +
+ +
" + diff --git a/var/mongoose/html/browse/thumbnail/mkrange.jim b/var/mongoose/html/browse/thumbnail/mkrange.jim new file mode 100755 index 00000000..dc4acb3b --- /dev/null +++ b/var/mongoose/html/browse/thumbnail/mkrange.jim @@ -0,0 +1,21 @@ +#!/mod/bin/jimsh + +package require cgi +source /mod/webif/lib/setup +require ts.class + +httpheader + +set rfile [cgi_get file] +set s [cgi_get s 0] +set e [cgi_get e $($s + 2)] +set i [expr [cgi_get i 0.5] + 0.0] + +if {![catch {set ts [ts fetch $rfile]}]} { + $ts cleanbmp + for {set n [expr $s + 0.0]} {$n <= $e} {set n [expr $n + $i]} { + puts "Generating thumbnail for pos $n" + $ts mkbmp $n ".pos$n" + } +} + diff --git a/var/mongoose/html/browse/thumbnail/script.js b/var/mongoose/html/browse/thumbnail/script.js new file mode 100755 index 00000000..e15117fb --- /dev/null +++ b/var/mongoose/html/browse/thumbnail/script.js @@ -0,0 +1,58 @@ + +$(document).ready(function() { + +var dir = $('#dir').text(); +var file = $('#file').text(); + +$('button').button(); + +function go(pos) +{ + window.location.href = 'index.jim?file=' + + encodeURIComponent(file) + '&pos=' + pos; +} + +$('button.mvpos').disable().on('click', function(e) { + e.preventDefault(); + var pos = $(this).attr('pos'); + go(pos); +}); + +$('#repos').disable().on('click', function(e) { + e.preventDefault(); + var pos = $('#pos').val(); + go(pos); +}); + +$('#back').on('click', function(e) { + e.preventDefault(); + window.location.href = '/browse/index.jim?dir=' + + encodeURIComponent(dir); +}); + +$('button.usethm').disable().on('click', function(e) { + e.preventDefault(); + var pos = $(this).attr('pos'); + $('button,input').disable(); + $.get('set.jim?file=' + encodeURIComponent(file) + '&pos=' + pos, + function() { + window.location.href = '/browse/index.jim?dir=' + + encodeURIComponent(dir); + });; +}); + +var start = $('#start').text(); +var end = $('#end').text(); +$.get('mkrange.jim?file=' + encodeURIComponent(file) + + '&s=' + start + '&e=' + end, function() { + $('img.bmp').each(function(i) { + var pos = $(this).attr('pos'); + $(this).attr('src', + 'fetch.jim?file=' + encodeURIComponent(file) + + '&pos=' + pos); + }); + $('button').enable(); +}); + +}); + diff --git a/var/mongoose/html/browse/thumbnail.jim b/var/mongoose/html/browse/thumbnail/set.jim similarity index 80% rename from var/mongoose/html/browse/thumbnail.jim rename to var/mongoose/html/browse/thumbnail/set.jim index a5f16455..eeb7814b 100755 --- a/var/mongoose/html/browse/thumbnail.jim +++ b/var/mongoose/html/browse/thumbnail/set.jim @@ -7,7 +7,9 @@ require ts.class httpheader set file [cgi_get file] +set pos [cgi_get pos 0] + if {![catch {set ts [ts fetch $file]}]} { - $ts mkthm + $ts mkthm $pos } diff --git a/var/mongoose/html/css/style.css b/var/mongoose/html/css/style.css index 6349f6e9..3f8d42fc 100644 --- a/var/mongoose/html/css/style.css +++ b/var/mongoose/html/css/style.css @@ -410,3 +410,18 @@ div#restart_block z-index: 31; } +img.bmp, img.doublebmp +{ + transform: scaleY(-1); + -webkit-transform: scaleY(-1); + -o-transform: scaleY(-1); + height: 78px; + width: 140px; +} + +img.doublebmp +{ + height: 156px; + width: 280px; +} + diff --git a/var/mongoose/html/img/generating.png b/var/mongoose/html/img/generating.png new file mode 100644 index 0000000000000000000000000000000000000000..b4832cfbb5bd64d2c5c735f906debda5cf48b054 GIT binary patch literal 1282 zcmeAS@N?(olHy`uVBq!ia0vp^JwWWo!3HEhJ^0rMq}Y|gW!U_%O?XxI14-? ziy0WWg+Z8+Vb&Z8pdfpRr>`sfU1n}k36@;H)M%iPY-UJAiF1B#Zfaf$kjuc}T$Gwv zlA5AWo>`Ki;O^-gkfN8$&cMKu=IP=XQgQ3;t>}yxSDE7<^DpIWWXo|M}tO>6D8)(3ah_@nZ- ziVOE%yya#XEB~!LLE>48`Rv?DvGwv1QR(M@R{tyhm!5Vm=inKFAZ=0PyQW>c!nqsD z9$0)>zxzm#7^6PJVF$w>H4G&?s&&4t<$4nOAn1Wfg5(By3$~aidYdkU9_Tvq>0y=V zCAIR2p}Us-WWRBj8ljFyq?J};QkSjd;4n&kIQpihB}6SEZ3OI8T}dS zS8t9kz0>gMNLSz)ug4R2Obgha^qwK?^|OAB?LVxxt$dsNpzs0Xf(bjG?U4zpoWoQj z=wrWqwLL$>efPp!4I5WX(9WH`EwO0&qzcIy(zW}2=EnNmS>mg;qx9imwg|d~`&1N>;T)l1Eiyc2LS&M_VUa`1$ z_Sff!g+i6u7qSt63iU;@Udl)Z>3g zIyg4uSzR;Ox-FRV%<4yXT%$bXSmappnCFG>DeXLWZ_U;dw;qU=SBiezG-Ezv{L5oD zymRDogn2R_?hb6dyxJnVNqVo=45hG_#mO_9P8LPj`^gn=;SFGkyZGhCV%w$pul6Qb zO+BC+I?q1d@LOi$&glHmhtk)*Umdtvwbf=>ZI`uhe%jO{r_C;%yR1#K7mUl{>SjX?=EpGXtyxC#}>`U**x0$eh&AwP>`g8Yz-W8GjXS4OVjq!lZ bnV;p$xAb> $bfile.thm~ + file rename -force $bfile.thm~ $bfile.thm tdelete $bfile.bmp - puts "Done." + return 1 } proc {ts renamegroup} {from to} {