From b691be415a7fe5f5810618ebb1573eafbfc80bb7 Mon Sep 17 00:00:00 2001 From: hummypkg Date: Mon, 15 Oct 2012 21:32:25 +0000 Subject: [PATCH] quick edit, cli status, db.jim git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1164 2a923420-c742-0410-a762-8d5b09965624 --- CONTROL/control | 2 +- bin/status | 1 + var/mongoose/cgi-bin/browse/browse.js | 10 ++- var/mongoose/cgi-bin/db.jim | 89 +++++---------------------- var/mongoose/cgi-bin/status.jim | 62 ++++++++++++++----- var/mongoose/html/edit/edit.jim | 10 +++ var/mongoose/html/edit/script.js | 4 ++ 7 files changed, 86 insertions(+), 92 deletions(-) create mode 120000 bin/status diff --git a/CONTROL/control b/CONTROL/control index f82241d..18fb855 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -1,7 +1,7 @@ Package: webif Priority: optional Section: web -Version: 0.9.14 +Version: 0.9.14-1 Architecture: mipsel Maintainer: af123@hummypkg.org.uk Depends: webif-channelicons(>=1.0.3),mongoose(>=3.0-7),jim(>=0.73-1),jim-oo,jim-sqlite3(>=0.73),jim-cgi(>=0.5),service-control(>=1.2),busybox(>=1.19.3-1),lsof,epg(>=1.0.9),hmt(>=1.1.6),ssmtp,anacron,trm,openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2),stripts(>=1.1.2) diff --git a/bin/status b/bin/status new file mode 120000 index 0000000..3d4433a --- /dev/null +++ b/bin/status @@ -0,0 +1 @@ +../webif/cgi-bin/status.jim \ No newline at end of file diff --git a/var/mongoose/cgi-bin/browse/browse.js b/var/mongoose/cgi-bin/browse/browse.js index fecf4e2..8884d63 100755 --- a/var/mongoose/cgi-bin/browse/browse.js +++ b/var/mongoose/cgi-bin/browse/browse.js @@ -95,10 +95,14 @@ function insert_folder_size(folder, size) folder = folder.replace(/ /g, ''); folder = folder.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1'); //console.log("Folder: (%s) = (%s)", folder, size); - if (folder == "") - $('#dirsize').text(' (' + size + 'iB)'); + if (size.search(/\d$/) == -1) + size += 'iB'; else - $('#' + folder).text(' (' + size + 'iB)'); + size += ' bytes'; + if (folder == "") + $('#dirsize').text(' (' + size + ')'); + else + $('#' + folder).text(' (' + size + ')'); } function folder_size_callback(data, status, xhr) diff --git a/var/mongoose/cgi-bin/db.jim b/var/mongoose/cgi-bin/db.jim index e64909a..4a112ad 100755 --- a/var/mongoose/cgi-bin/db.jim +++ b/var/mongoose/cgi-bin/db.jim @@ -1,80 +1,23 @@ -#!/mod/bin/jimsh +#!/bin/sh -package require cgi -package require sqlite3 -source /mod/webif/lib/setup -require altrow +PATH=$PATH:/mod/bin export PATH + +echo "Content-Type: text/plain" +echo "" -puts "Content-Type: text/html" -puts "" +[ -n "$QUERY_STRING" ] && data="${QUERY_STRING##*=}" || data=epg -set databases [glob /var/lib/humaxtv/*.db] -lappend databases "/mnt/hd2/dms_cds.db" +case $data in + channels) + sqlite3 -header -batch -separator ' ' \ + /var/lib/humaxtv/channel.db ' + select * from TBL_SVC; + ' + ;; -header -cgi_input -#cgi_dump + *) /mod/bin/epg -p dump ;; +esac -set ftab [cgi_get tab] -set fdb [cgi_get db] - -if {$fdb != 0} { - puts "

Remove filters

" -} - -proc db_info {db_file} { - global _cgi fdb ftab - - if {$fdb != 0 && [file tail $db_file] ne $fdb} { return } - if {![file exists $db_file]} { return } - - set db [sqlite3.open $db_file] - set tables [$db query { - select name from sqlite_master - where type='table' order by name - }] - - puts "

- $db_file

" - - foreach table $tables { - set table [lindex $table 1] - if {$ftab != 0 && $ftab ne $table} { continue } - set columns [$db query "pragma table_info($table)"] - set datas [$db query "SELECT * FROM $table order by 1"] - - puts "

$table

" - puts "" - puts " " - foreach column $columns { - puts " " - } - puts " " - foreach data $datas { - altrow - - for {set i 1} {$i < [llength $data]} {incr i 2} { - puts " " - } - puts " " - } - puts "
[lindex $column 3]
[lindex $data $i]
" - } - - $db close -} - -if {$fdb == 0} { - puts "Please choose database to view:" -} else { - foreach db $databases { db_info $db } -} - -footer +exit 0 diff --git a/var/mongoose/cgi-bin/status.jim b/var/mongoose/cgi-bin/status.jim index 6056441..5c08be1 100755 --- a/var/mongoose/cgi-bin/status.jim +++ b/var/mongoose/cgi-bin/status.jim @@ -1,12 +1,22 @@ #!/mod/bin/jimsh +package require cgi source /mod/webif/lib/setup require system.class findhsvc epg.class -puts "Content-Type: text/html" -puts "Pragma: no-cache" -puts "Expires: Thu, 01 Jan 1970 00:00:00 GMT" -puts "" +set runmode cli +if {[string match {*jim} $argv0]} { set runmode cgi } + +cgi_input + +set type [cgi_get type "full"] + +if {$runmode eq "cgi"} { + puts "Content-Type: text/html" + puts "Pragma: no-cache" + puts "Expires: Thu, 01 Jan 1970 00:00:00 GMT" + puts "" +} if {[catch {set pid [exec pgrep humaxtv]}]} { puts "Cannot find humaxtv process." @@ -40,7 +50,12 @@ set rec 0 set seen {} set output {} -set data [get_data] +if {$type eq "full"} { + set data [get_data] +} else { + set data {} +} + if {[llength $data]} { sleep 3 set ndata [get_data] @@ -64,8 +79,12 @@ if {[llength $data]} { incr seen($name) - lappend output " - $mode $name" + if {$runmode eq "cgi"} { + lappend output " + $mode $name" + } else { + lappend output "$mode $name" + } } } @@ -94,20 +113,33 @@ if {![system instandby] && $play < 1} { append prog "[clock format $([$epg get start] + [$epg get duration]) -format %H:%M]" append prog ") \[[$epg percent]%\]" } - - lappend output "[epg channelicon $name 30 \ - {vertical-align: middle; padding: 0 4px 0 2px}] - Watching $lcn: $name $prog" + + if {$runmode eq "cgi"} { + lappend output "[epg channelicon $name 30 \ + {vertical-align: middle; padding: 0 4px 0 2px}] + + Watching $lcn: $name $prog" + } else { + lappend output "Watching $lcn: $name $prog" + } } } if {[system instandby]} { - lappend output " - System is in standby." + if {$runmode eq "cgi"} { + lappend output " + System is in standby." + } else { + lappend output "System is in standby." + } } if {[llength $output]} { - puts [join $output "
"] + if {$runmode eq "cgi"} { + puts [join $output "
"] + } else { + puts [join $output "\n"] + } } diff --git a/var/mongoose/html/edit/edit.jim b/var/mongoose/html/edit/edit.jim index ba4c553..2f99f6e 100755 --- a/var/mongoose/html/edit/edit.jim +++ b/var/mongoose/html/edit/edit.jim @@ -43,6 +43,16 @@ Use the Open button below to begin. +
+
+ Commonly edited files + +
+
+
Humax Filesystem
diff --git a/var/mongoose/html/edit/script.js b/var/mongoose/html/edit/script.js index d7d148b..14a1a84 100644 --- a/var/mongoose/html/edit/script.js +++ b/var/mongoose/html/edit/script.js @@ -144,4 +144,8 @@ $('#create').click(function() { $('#createf').dialog('open'); }); +$('a.qfile').on('click', function() { + loadfile($(this).text()); +}); + });