2012-10-31 23:50:27 +00:00
#!/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]
2012-11-05 21:57:29 +00:00
puts "<li class=\"pkg_$name\"><h3>$name</h3>"
2012-10-31 23:50:27 +00:00
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
}
2012-11-05 21:57:29 +00:00
puts "
2012-10-31 23:50:27 +00:00
<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>
2012-11-05 21:57:29 +00:00
"
2012-10-31 23:50:27 +00:00
puts "</li>"
}
proc pkglist {type} {
set pkgs [pkg $type]
2012-11-05 21:57:29 +00:00
puts "<ul data-role=listview>"
2012-10-31 23:50:27 +00:00
if {[llength $pkgs] <= 0} {
2012-11-05 21:57:29 +00:00
puts "<li><i>No packages "
2012-10-31 23:50:27 +00:00
switch $type {
inst { puts "are installed." }
2012-11-05 21:57:29 +00:00
upgr { puts "are available for upgrade; try updating the package list from the Internet using the button above." }
2012-10-31 23:50:27 +00:00
avail { puts "are available for installation." }
}
2012-11-05 21:57:29 +00:00
puts "</i></li></ul>"
2012-10-31 23:50:27 +00:00
return
}
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
2012-11-05 21:57:29 +00:00
puts {
<ul data-role=listview>
<li>
<button data-theme=e class=opkg_update>
Update package list from Internet
</button>
}
if {$pageid eq "pkgu_b"} {
puts {
<button data-theme=e class=opkg_upgrade>
Upgrade all packages
</button>
}
}
puts {
</li>
</ul>
}
2012-10-31 23:50:27 +00:00
pkglist $qtype
2012-11-05 21:57:29 +00:00
puts {
<div data-role=popup class="opkg_popup ui-corner-all" data-theme=e>
<div data-role=header data-theme=a class=ui-corner-top>
<h1>Results</h1>
</div>
<div data-role=content data-theme=d class="ui-corner-bottom ui-content">
<p class="pre opkg_popup_text" data-theme=d></p>
</div>
<center><div class="hidden opkg_op_complete">
<img border=0 src=/images/167_2_00_Check_W2_SUB.png>
Operation complete.
<a href=# data-role=button data-inline=true data-rel=back
data-mini=true data-theme=b>Close</a>
</div></center>
</div>
}
2012-10-31 23:50:27 +00:00
mfooter