summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xaports.lua41
-rw-r--r--assets/style.css54
-rw-r--r--tpl/package.tpl157
3 files changed, 153 insertions, 99 deletions
diff --git a/aports.lua b/aports.lua
index b80bf4d..c291f92 100755
--- a/aports.lua
+++ b/aports.lua
@@ -3,6 +3,11 @@
-- lua turbo application
local turbo = require "turbo"
+local inspect = require "inspect"
+
+function string.begins(str, prefix)
+ return str:sub(1,#prefix)==prefix
+end
local tpl = turbo.web.Mustache.TemplateHelper("./tpl")
@@ -57,9 +62,12 @@ function PackageRenderer:get(arch, pkgname)
local table = {}
fields.arch = arch
fields.pkgname = pkgname
- result = QueryPackage(fields)
+ local result = QueryPackage(fields)
+ -- check for empty values and destroy them
if result ~= nil then
table = result
+ table.deps = QueryDeps(table.deps)
+ table.maintainer = string.gsub(table.maintainer, '<.*>', '')
for k in pairs (table) do
if table[k] == "" then
table[k] = nil
@@ -69,7 +77,7 @@ function PackageRenderer:get(arch, pkgname)
table.header = tpl:render("header.tpl")
table.footer = tpl:render("footer.tpl")
local page = tpl:render(self.options, table)
- self:write(page)
+ self:write(page)
end
function QueryContents(terms)
@@ -80,8 +88,8 @@ function QueryContents(terms)
local r = {}
for row in sth:rows(true) do
r[#r + 1] = {
- file = "/" .. row.path .. "/" .. row.file,
- pkgname = row.pkgname,
+ file = "/" .. row.path .. "/" .. row.file,
+ pkgname = row.pkgname,
repo = row.repo,
arch = row.arch,
}
@@ -121,6 +129,31 @@ function QueryPackage(fields)
return r
end
+function QueryDeps(deps)
+ require('DBI')
+ local names = {}
+ local dbh = assert(DBI.Connect('SQLite3', 'db/apkindex.db'))
+ local sth = assert(dbh:prepare('select name from apkindex where provides like ?'))
+ for _,k in pairs (deps:split(" ")) do
+ if k:begins('so:') then
+ sth:execute("%"..k.."%")
+ local l = sth:fetch(true)
+ if l ~= nil then
+ names[l.name] = l.name
+ end
+ else
+ names[k] = k
+ end
+ end
+ local r = {}
+ for _,name in pairs (names) do
+ r[#r+1] = {dep=name}
+ end
+ 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 f525dba..680bc13 100644
--- a/assets/style.css
+++ b/assets/style.css
@@ -1,49 +1,47 @@
html {
- height: 100%;
+ height: 100%;
}
html, body {
- overflow-x: hidden;
- margin: 0;
- padding: 0;
+ overflow-x: hidden;
+ margin: 0;
+ padding: 0;
}
body {
- position: relative;
- min-height: 100%;
+ position: relative;
+ min-height: 100%;
background: #eee;
margin:auto;
width:80%;
}
-
-
header {
- border-bottom: 2px solid #17a;
+ border-bottom: 2px solid #17a;
display: inline-block;
width: 100%;
/* fix inline-block auto margin */
- margin-bottom: -4px;
+ margin-bottom: -4px;
}
#main {
- background: #fff;
+ background: #fff;
padding: 10px;
margin:0px;
}
form#search {
- margin: 10px;
+ margin: 10px;
}
footer {
- margin: 10px;
- text-align: center;
- font-size: 0.8em
+ margin: 10px;
+ text-align: center;
+ font-size: 0.8em
}
img#logo {
- width:300px;
+ width:300px;
float: left;
margin: 1em;
margin-right: 2em;
@@ -65,17 +63,21 @@ nav a {
}
nav a.active {
- background-color: #17a;
- color: white;
+ background-color: #17a;
+ color: white;
}
-table {
- font-size: 90%;
- white-space: nowrap;
-}
+/* icons on deps toggle */
-/* package */
+.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 */
+}
+.panel-heading .accordion-toggle.collapsed:after {
+ /* symbol for "collapsed" panels */
+ content: "\e080"; /* adjust as needed, taken from bootstrap.css */
+}
-table#package {
- width: 60%;
- } \ No newline at end of file
diff --git a/tpl/package.tpl b/tpl/package.tpl
index 56aae33..145a3ab 100644
--- a/tpl/package.tpl
+++ b/tpl/package.tpl
@@ -3,76 +3,95 @@
<div class="panel panel-default">
<div class="panel-heading">Package details</div>
<div class="panel-body">
+ <div class="container-fluid">
+ <div class="row">
+ <div class="col-md-8">
+ <div class="panel panel-default">
+ <div class="panel-heading">General</div>
+ <div class="panel-body">
+ <table class="table table-striped table-bordered table-condensed">{{#name}}
+ <tr>
+ <th>Name:</th>
+ <td title="{{{desc}}}"><a href="/package/{{{name}}}">{{{name}}}</a></td>
+ </tr>
+ <tr>
+ <th>Version:</th>
+ <td>{{{version}}}</td>
+ </tr>
+ <tr>
+ <th>Description:</th>
+ <td>{{{desc}}}</td>
+ </tr>
+ <tr>
+ <th>Project:</th>
+ <td><a href="{{{url}}}">URL</a></td>
+ </tr>
+ <tr>
+ <th>Licence:</th>
+ <td>{{{lic}}}</td>
+ </tr>
+ <tr>
+ <th>Architecture:</th>
+ <td>{{{arch}}}</td>
+ </tr>
+ <tr>
+ <th>Checksum:</th>
+ <td>{{{csum}}}</td>
+ </tr>
+ <tr>
+ <th>Size:</th>
+ <td>{{{size}}} Bytes</td>
+ </tr>{{#install_size}}
+ <tr>
+ <th>Installed size:</th>
+ <td>{{{install_size}}} Bytes</td>
+ </tr>{{/install_size}}{{#provides}}
+ <tr>
+ <th>Provides:</th>
+ <td>{{{provides}}}</td>
+ </tr>{{/provides}}{{#install_if}}
+ <tr>
+ <th>Install if:</th>
+ <td>{{{install_if}}}</td>
+ </tr>{{/install_if}}{{#name}}
+ <tr>
+ <th>Origin:</th>
+ <td><a href="/package/{{{arch}}}/{{{origin}}}">{{{origin}}}</a></td>
+ </tr>
+ <tr>
+ <th>Maintainer:</th>
+ <td>{{{maintainer}}}</td>
+ </tr>
+ <tr>
+ <th>Build time:</th>
+ <td>{{{build_time}}}</td>
+ </tr>
+ <tr>
+ <th>Commit:</th>
+ <td><a href="http://git.alpinelinux.org/cgit/aports/commit/?id={{{commit}}}">{{{commit}}}</a></td>
+ </tr>{{/name}}{{^name}}
+ <tr>
+ <td>This package does not exist!</td>
+ </tr>{{/name}}
+ </table>
+ </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="#collapseDeps" aria-expanded="false">Dependecies</a>
+ </div>
+ <div id="collapseDeps" class="panel-collapse collapse">
+ <ul class="list-group">{{#deps}}
+ <li class="list-group-item"><a href="/package/{{{arch}}}/{{{dep}}}">{{{dep}}}</a></li>{{/deps}}{{^deps}}<li class="list-group-item">None</li>{{/deps}}
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
</div>
- <table class="table table-striped table-bordered table-condensed" id="package">{{#name}}
- <tr>
- <th>Name:</th>
- <td title="{{{desc}}}"><a href="/package/{{{name}}}">{{{name}}}</a></td>
- </tr>
- <tr>
- <th>Version:</th>
- <td>{{{version}}}</td>
- </tr>
- <tr>
- <th>Description:</th>
- <td>{{{desc}}}</td>
- </tr>
- <tr>
- <th>Project:</th>
- <td><a href="{{{url}}}">URL</a></td>
- </tr>
- <tr>
- <th>Licence:</th>
- <td>{{{lic}}}</td>
- </tr>
- <tr>
- <th>Architecture:</th>
- <td>{{{arch}}}</td>
- </tr>{{#deps}}
- <tr>
- <th>Dependecies:</th>
- <td>{{{deps}}}</td>
- </tr>{{/deps}}
- <tr>
- <th>Checksum:</th>
- <td>{{{csum}}}</td>
- </tr>
- <tr>
- <th>Size:</th>
- <td>{{{size}}}</td>
- </tr>{{#install_size}}
- <tr>
- <th>Installed size:</th>
- <td>{{{install_size}}}</td>
- </tr>{{/install_size}}{{#provides}}
- <tr>
- <th>Provides:</th>
- <td>{{{provides}}}</td>
- </tr>{{/provides}}{{#install_if}}
- <tr>
- <th>Install if:</th>
- <td>{{{install_if}}}</td>
- </tr>{{/install_if}}
- <tr>
- <th>Origin:</th>
- <td>{{{origin}}}</td>
- </tr>
- <tr>
- <th>Maintainer:</th>
- <td>{{{maintainer}}}</td>
- </tr>
- <tr>
- <th>Build time:</th>
- <td>{{{build_time}}}</td>
- </tr>
- <tr>
- <th>Commit:</th>
- <td>{{{commit}}}</td>
- </tr>{{/name}}{{^name}}
- <tr>
- <td>This package does not exist!</td>
- </tr>{{/name}}
- </table>
</div>
</div>
{{{footer}}}