checkpoint pkg

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1195 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2012-10-31 23:50:27 +00:00
parent 0a2c7966b5
commit e15b82fe2d
6 changed files with 160 additions and 10 deletions

View File

@ -41,7 +41,7 @@ puts "</li>"
tb "/images/323_1_10_Menu_Video.png" "Browse" "browse.jim"
tb "/images/321_1_00_Menu_CHList.png" "Schedule" "schedule.jim"
tb "/img/spanner.png" "Services" "#"
tb "/img/packages.png" "Packages" "#"
tb "/img/packages.png" "Packages" "pkgi_b.jim"
tb "/images/326_1_00_Menu_Settings.png" "Settings" \
"/cgi-bin/settings.jim\" rel=\"external"
tb "/img/diagnostics.png" "Diag" "#"

View File

@ -45,18 +45,20 @@ if {[string range $pageid end-1 end] eq "_d"} {
set _dialog 1
}
set _bare 0
if {[string range $pageid end-1 end] eq "_b"} {
set _bare 1
}
puts "<body>"
if {$_dialog} {
puts "<div data-role=page id=${pageid}page>\n"
} else {
puts "
<div data-role=page data-add-back-btn=true id=${pageid}page>
proc _header {{title ""}} {
<div class=\"hidden status\"></div>
<div data-role=header data-theme=b>
if {$title eq ""} {
set title "[system model] ([system hostname])"
}
return "
<div class=ui-btn-right style=\"top: -5px\">
<div style=\"display: inline-block; margin-right: 10px;\">
<a data-theme=b data-icon=home data-iconpos=notext data-role=button
@ -67,8 +69,22 @@ if {$_dialog} {
class=refresh data-direction=reverse href=#></a>
</div>
</div>
<h1>$title</h1>
"
}
<h1>[system model] ([system hostname])</h1>
if {$_bare} {
puts ""
} elseif {$_dialog} {
puts "<div data-role=page id=${pageid}page>\n"
} else {
puts "
<div data-role=page data-add-back-btn=true id=${pageid}page>
<div class=\"hidden status\"></div>
<div data-role=header data-theme=b>
[_header]
</div>
<div data-role=content>
}

View File

@ -0,0 +1 @@
pkgi_b.jim

127
var/mongoose/html/m/pkgi_b.jim Executable file
View File

@ -0,0 +1,127 @@
#!/mod/bin/jimsh
package require cgi
source /mod/webif/lib/setup
require settings.class pkg.class
if {[[settings] pkgdev]} { set filter 0 } else { set filter 1 }
pkg loadmeta
proc nav {active} {
set q "<div data-role=navbar data-id=pkg_navbar>\n <ul>\n"
foreach f {installed available upgrades} {
append q " <li><a"
if {$f eq $active} {
append q { class="ui-btn-active ui-state-persist"}
}
append q " href=pkg[string range $f 0 0]_b.jim>"
append q "[string totitle $f]</a></li>\n"
}
append q " </ul>\n</div>\n"
return $q
}
proc pkgtop {type} {
puts "
<div data-role=page id=pkga>
<div data-role=header data-theme=b>
[_header]
[nav $type]
</div>
<div data-role=content>
"
}
proc pkgrow {type pkg} {
set name [$pkg get name]
puts "<li><h3>$name</h3>"
if {$type eq "avail"} {
puts "<p class=ui-li-aside>[$pkg get latest]</p>"
} else {
puts "<p class=ui-li-aside>[$pkg get installed]</p>"
}
if {$type eq "upgr"} {
puts "<p>Latest: [$pkg get latest]</p>"
}
if {[dict exists $::pkgmeta $name]} {
puts "<p class=wsn>$::pkgmeta($name)</p>"
} else {
puts "<p class=wsn>[$pkg get descr]</p>"
}
if {![$pkg is installed]} {
set btype Install
} elseif {$type eq "upgr" && [$pkg is upgradable]} {
set btype Upgrade
} else {
set btype Remove
}
# puts "<td align=center><small><button id=\"$name\"
# action=[string tolower $type]
# class=\"va [string tolower $type]\">$type</button></small></td>"
# <div data-role=controlgroup data-type=horizontal data-mini=true>
puts "
<p>
<a data-inline=true data-role=button data-mini=true data-theme=e
href=#
action=[string tolower $btype] pkg=\"$name\"
class=[string tolower $btype]>$btype</a>
</p>
"
puts "</li>"
}
proc pkglist {type} {
set pkgs [pkg $type]
if {[llength $pkgs] <= 0} {
puts "<i>No packages "
switch $type {
inst { puts "are installed." }
upgr { puts "are available for upgrade; try updating the package list from the Internet using the button below." }
avail { puts "are available for installation." }
}
puts "</i>"
return
}
puts "<ul data-role=listview>"
foreach pkg $pkgs {
if {$type ne "upgr" && $::filter && \
![dict exists $::pkgmeta $pkg]} { continue }
pkgrow $type [pkg load $pkg]
}
if {$::filter} {
puts "<li data-role=list-divider>This is a filtered package list. To show all packages, enable the <i>Show development and advanced packages</i> in the settings screen.</li>"
}
puts "</ul>"
}
mheader
switch $pageid {
pkgi_b {
set type installed
set qtype inst
}
pkga_b {
set type available
set qtype avail
}
default {
set type upgrades
set qtype upgr
}
}
pkgtop $type
pkglist $qtype
mfooter

View File

@ -0,0 +1 @@
pkgi_b.jim

View File

@ -94,3 +94,8 @@ table.keyval td
text-decoration: none;
}
p.wsn
{
white-space: normal;
}