Skip to content

Commit

Permalink
a few improvements from solene
Browse files Browse the repository at this point in the history
and tweaks from me
  • Loading branch information
Marc Espie committed Dec 6, 2021
1 parent ed2cee6 commit 99cb27b
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 12 deletions.
7 changes: 7 additions & 0 deletions lib/PortsReadmes.pm
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ get '/' => sub {
template 'index', $e;
};

get '/packages' => sub {
my $search;
$search->{name} = '.';
my $e = SqlPorts->full_list;
template 'packages', $e;
};

get qr{/cat/([\w\/]+)} => sub {
my ($cat) = splat;
my $e = SqlPorts->category($cat);
Expand Down
45 changes: 37 additions & 8 deletions lib/SqlPorts.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ $list_req->bind_columns(\($category));

my $list_cat_req = $db->prepare(
q{select min(_paths.fullpkgpath),
fullpkgname
fullpkgname,
comment
from _paths
join _Ports on _paths.id=_Ports.fullpkgpath
and _paths.id=_paths.canonical
Expand All @@ -42,8 +43,8 @@ my $list_cat_req = $db->prepare(
group by fullpkgname
order by fullpkgname
});
my ($fullpkgpath, $fullpkgname);
$list_cat_req->bind_columns(\($fullpkgpath, $fullpkgname));
my ($fullpkgpath, $fullpkgname, $comment);
$list_cat_req->bind_columns(\($fullpkgpath, $fullpkgname, $comment));

my $info_req = $db->prepare(
q{select
Expand All @@ -64,7 +65,7 @@ my $info_req = $db->prepare(
on _ports.permit_package=permit.keyref
join _email on _ports.maintainer=_email.keyref
where _paths.fullpkgpath=?});
my ($id, $path, $simplepath, $comment, $homepage, $descr, $permit, $maintainer);
my ($id, $path, $simplepath, $homepage, $descr, $permit, $maintainer);
$info_req->bind_columns(\($id, $path, $simplepath, $comment, $homepage, $descr, $fullpkgname, $permit, $maintainer));

my $dep_req = $db->prepare(
Expand Down Expand Up @@ -167,6 +168,18 @@ my $canonical_req = $db->prepare(
my $canonical;
$canonical_req->bind_columns(\$canonical);

my $full_list_req = $db->prepare(
q{select min(_paths.fullpkgpath),
fullpkgname,
comment
from _paths
join _Ports on _paths.id=_Ports.fullpkgpath
and _paths.id=_paths.canonical
group by fullpkgname
order by fullpkgname
});
$full_list_req->bind_columns(\($fullpkgpath, $fullpkgname, $comment));

my ($version, $creation_date);

my $meta_req = $db->prepare(
Expand Down Expand Up @@ -207,7 +220,8 @@ sub category
while ($list_cat_req->fetch) {
push(@{$e->{category}}, {
name => $fullpkgname,
url => "/path/$fullpkgpath"
url => "/path/$fullpkgpath",
comment => $comment
});
}
return $e;
Expand Down Expand Up @@ -310,6 +324,20 @@ sub canonical
}
}

sub full_list
{
$full_list_req->execute;
my $e = {};
while ($full_list_req->fetch) {
push(@{$e->{packages}}, {
name => $fullpkgname,
url => "/path/".$fullpkgpath,
comment => $comment
});
}
return $e;
}

sub search
{
my ($class, $search) = @_;
Expand Down Expand Up @@ -363,20 +391,21 @@ sub search
$s.= " where ".join(" and ", @where);
}
$s = qq{select
_paths.fullpkgpath, fullpkgname
_paths.fullpkgpath, fullpkgname, comment
from _paths
join _Ports on _paths.canonical=_Ports.fullpkgpath
$s
order by fullpkgname
};
my $req = $db->prepare($s);
$req->bind_columns(\($fullpkgpath, $fullpkgname));
$req->bind_columns(\($fullpkgpath, $fullpkgname, $comment));
$req->execute(@params);
my $e = create_hash();
while ($req->fetch) {
push(@{$e->{result}}, {
name => $fullpkgname,
url => "/path/$fullpkgpath"
url => "/path/$fullpkgpath",
comment => $comment
});
}
return $e;
Expand Down
5 changes: 5 additions & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,8 @@ white-space: pre-wrap;
#test-depends-list, #reverse-depends-list, #files-list {
display: none;
}

.package a {
min-width: 200px;
display: inline-block;
}
2 changes: 1 addition & 1 deletion views/category.tt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="three">
<ul>
<% FOREACH c IN category %>
<li><a href="<% c.url | url %>"><% c.name | html %></a>
<li><a href="<% c.url | url %>"><% c.name | html %></a> <% c.comment | html %>
<% END %>
</ul>
</div>
3 changes: 2 additions & 1 deletion views/index.tt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<h1>Index by category</h1>
<h1>Index by category</h1>
(or <a href="packages">Full package list with short description</a>)
<div class="three">
<ul>
<% FOREACH c IN categories %>
Expand Down
12 changes: 12 additions & 0 deletions views/packages.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<div id="back"><a href="/">Home</a></div>
<h1>Package list with short descriptions</h1>
<ul>
<% FOREACH p IN packages %>
<li>
<div class="package">
<a href="<% p.url | url %>"><% p.name | html %></a>
<span><% p.comment | html %></span>
</div>
</li>
<% END %>
</ul>
3 changes: 2 additions & 1 deletion views/port.tt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
</div>

<H2><% fullpkgname | html %> &ndash; <% comment | html %>
(<a href="https://cvsweb.openbsd.org/ports/<% simplepath | url %>">source</a>)</H2>
(<a href="https://cvsweb.openbsd.org/ports/<% simplepath | url %>">cvsweb</a>
<a href="https://github.com/openbsd/ports/tree/master/<% simplepath | url %>">github mirror</a>)</H2>
<H3>Description</H3>

<pre>
Expand Down
2 changes: 1 addition & 1 deletion views/searchresult.tt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="three">
<ul>
<% FOREACH c IN result %>
<li><a href="<% c.url | url %>"><% c.name | html %></a>
<li><a href="<% c.url | url %>"><% c.name | html %></a> - <% c.comment | html %>
<% END %>
</ul>
</div>

0 comments on commit 99cb27b

Please sign in to comment.