summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlo Landmeter <clandmeter@gmail.com>2015-03-18 16:54:58 +0000
committerCarlo Landmeter <clandmeter@gmail.com>2015-03-18 16:54:58 +0000
commitc7f0d053c8b56dff6e0abf0157b34371db910b83 (patch)
treed61597ca8e61e8bac59fd020bb8a0fe489a08b26
parent5f10cabb6efe100c9b3c07b8f29498f85a2e2b34 (diff)
downloadaports-turbo-c7f0d053c8b56dff6e0abf0157b34371db910b83.tar.bz2
aports-turbo-c7f0d053c8b56dff6e0abf0157b34371db910b83.tar.xz
add required by and subpkg to package list
-rwxr-xr-xaports.lua71
-rw-r--r--assets/style.css12
-rw-r--r--tpl/package.tpl28
3 files changed, 91 insertions, 20 deletions
diff --git a/aports.lua b/aports.lua
index c291f92..cd16817 100755
--- a/aports.lua
+++ b/aports.lua
@@ -57,22 +57,20 @@ end
local PackageRenderer = class("PackageRenderer", turbo.web.RequestHandler)
-function PackageRenderer:get(arch, pkgname)
- local fields = {}
- local table = {}
- fields.arch = arch
- fields.pkgname = pkgname
- local result = QueryPackage(fields)
- -- check for empty values and destroy them
- if result ~= nil then
- table = result
+function PackageRenderer:get(arch, name)
+ local table = QueryPackage(name, arch)
+ if table ~= nil then
table.deps = QueryDeps(table.deps)
+ table.reqbys = QueryRequiredBy(table.provides)
+ table.subpkgs = QuerySubPackages(table.origin, table.name)
table.maintainer = string.gsub(table.maintainer, '<.*>', '')
for k in pairs (table) do
if table[k] == "" then
table[k] = nil
end
end
+ else
+ table = {}
end
table.header = tpl:render("header.tpl")
table.footer = tpl:render("footer.tpl")
@@ -94,6 +92,7 @@ function QueryContents(terms)
arch = row.arch,
}
end
+ sth:close()
return r
end
@@ -116,16 +115,17 @@ function QueryPackages(terms)
bdate = row.build_time
}
end
+ sth:close()
return r
end
-function QueryPackage(fields)
+function QueryPackage(name, arch)
require('DBI')
local dbh = assert(DBI.Connect('SQLite3', 'db/apkindex.db'))
local sth = assert(dbh:prepare('select *, datetime(build_time, \'unixepoch\') as build_time from apkindex where name like ? and arch like ? limit 1'))
- sth:execute(fields.pkgname, fields.arch)
- local r = {}
- r = sth:fetch(true)
+ sth:execute(name, arch)
+ local r = sth:fetch(true)
+ sth:close()
return r
end
@@ -145,6 +145,7 @@ function QueryDeps(deps)
names[k] = k
end
end
+ sth:close()
local r = {}
for _,name in pairs (names) do
r[#r+1] = {dep=name}
@@ -154,6 +155,50 @@ function QueryDeps(deps)
end
end
+function QueryRequiredBy(provides)
+ require('DBI')
+ local names = {}
+ local dbh = assert(DBI.Connect('SQLite3', 'db/apkindex.db'))
+ local sth = assert(dbh:prepare('select name from apkindex where deps like ?'))
+ for _,d in pairs (provides:split(" ")) do
+ if d:begins('so:') then
+ d = string.gsub(d, '=.*', '')
+ sth:execute("%"..d.."%")
+ for row in sth:rows(true) do
+ if row ~= nil then
+ names[row.name] = row.name
+ end
+ end
+ end
+ end
+ sth:close()
+ local r = {}
+ for _,name in pairs (names) do
+ r[#r+1] = {reqby=name}
+ end
+ if next(r) ~= nil then
+ return r
+ end
+end
+
+function QuerySubPackages(origin, name)
+ require('DBI')
+ local names = {}
+ local dbh = assert(DBI.Connect('SQLite3', 'db/apkindex.db'))
+ local sth = assert(dbh:prepare('select name from apkindex where origin like ?'))
+ sth:execute(origin)
+ local r = {}
+ for row in sth:rows(true) do
+ if row.name ~= name then
+ r[#r+1] = {subpkg=row.name}
+ end
+ end
+ sth:close()
+ if next(r) ~= nil then
+ return r
+ end
+end
+
turbo.web.Application({
{"^/$", turbo.web.RedirectHandler, "/packages"},
{"^/contents$", ContentsRenderer, "contents.tpl"},
diff --git a/assets/style.css b/assets/style.css
index 680bc13..d72cda3 100644
--- a/assets/style.css
+++ b/assets/style.css
@@ -70,14 +70,12 @@ nav a.active {
/* icons on deps toggle */
.panel-heading .accordion-toggle:after {
- /* symbol for "opening" panels */
- font-family: 'Glyphicons Halflings'; /* essential for enabling glyphicon */
- content: "\e114"; /* adjust as needed, taken from bootstrap.css */
- float: right; /* adjust as needed */
- color: grey; /* adjust as needed */
+ font-family: 'Glyphicons Halflings';
+ content: "\e114";
+ float: right;
+ color: grey;
}
.panel-heading .accordion-toggle.collapsed:after {
- /* symbol for "collapsed" panels */
- content: "\e080"; /* adjust as needed, taken from bootstrap.css */
+ content: "\e080";
}
diff --git a/tpl/package.tpl b/tpl/package.tpl
index 145a3ab..bd9d240 100644
--- a/tpl/package.tpl
+++ b/tpl/package.tpl
@@ -69,6 +69,10 @@
<tr>
<th>Commit:</th>
<td><a href="http://git.alpinelinux.org/cgit/aports/commit/?id={{{commit}}}">{{{commit}}}</a></td>
+ </tr>
+ <tr>
+ <th>Contents:</th>
+ <td><a href="/contents?filename={{{name}}}&arch={{{arch}}}">Contents of package</a></td>
</tr>{{/name}}{{^name}}
<tr>
<td>This package does not exist!</td>
@@ -89,6 +93,30 @@
</div>
</div>
</div>
+ <div class="col-md-3 col-md-offset-1">
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <a class="accordion-toggle" data-toggle="collapse" href="#collapseReqBy" aria-expanded="false">Required by</a>
+ </div>
+ <div id="collapseReqBy" class="panel-collapse collapse">
+ <ul class="list-group">{{#reqbys}}
+ <li class="list-group-item"><a href="/package/{{{arch}}}/{{{reqby}}}">{{{reqby}}}</a></li>{{/reqbys}}{{^reqbys}}<li class="list-group-item">None</li>{{/reqbys}}
+ </ul>
+ </div>
+ </div>
+ </div>
+ <div class="col-md-3 col-md-offset-1">
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <a class="accordion-toggle" data-toggle="collapse" href="#collapseSubPkg" aria-expanded="false">Sub Packages</a>
+ </div>
+ <div id="collapseSubPkg" class="panel-collapse collapse">
+ <ul class="list-group">{{#subpkgs}}
+ <li class="list-group-item"><a href="/package/{{{arch}}}/{{{subpkg}}}">{{{subpkg}}}</a></li>{{/subpkgs}}{{^subpkgs}}<li class="list-group-item">None</li>{{/subpkgs}}
+ </ul>
+ </div>
+ </div>
+ </div>
</div>
</div>
</div>