[Midnightbsd-cvs] mports: www/tmpls: add category stuff, tweak port page.
ctriv at midnightbsd.org
ctriv at midnightbsd.org
Tue Mar 25 01:14:29 EDT 2008
Log Message:
-----------
add category stuff, tweak port page.
Modified Files:
--------------
mports/Tools/magus/www/data/magus:
index.cgi (r1.15 -> r1.16)
mports/Tools/magus/www/data/magus/elements:
magus.css (r1.18 -> r1.19)
mports/Tools/magus/www/tmpls:
index.tmpl (r1.9 -> r1.10)
port.tmpl (r1.8 -> r1.9)
Added Files:
-----------
mports/Tools/magus/www/tmpls:
category.tmpl (r1.1)
-------------- next part --------------
Index: index.cgi
===================================================================
RCS file: /home/cvs/mports/Tools/magus/www/data/magus/index.cgi,v
retrieving revision 1.15
retrieving revision 1.16
diff -L Tools/magus/www/data/magus/index.cgi -L Tools/magus/www/data/magus/index.cgi -u -r1.15 -r1.16
--- Tools/magus/www/data/magus/index.cgi
+++ Tools/magus/www/data/magus/index.cgi
@@ -45,17 +45,27 @@
if ($path eq '' || $path eq '/') {
summary_page($p);
} elsif ($path =~ m:/machines/(.*):) {
- machine_page($p, $1);
- } elsif ($path =~ m:runs/(.*):) {
- run_page($p, $1);
- } elsif ($path =~ m:/ports/(.*):) {
+ if ($1) {
+ machine_page($p, $1);
+ } else {
+ machine_index($p);
+ }
+ } elsif ($path =~ m:^/runs/(.*):) {
+ if ($1) {
+ run_page($p, $1);
+ } else {
+ run_index($p);
+ }
+ } elsif ($path =~ m:^/ports/(.*):) {
port_page($p, $1);
- } elsif ($path =~ m:/async/run-ports-list:) {
+ } elsif ($path =~ m:^/async/run-ports-list:) {
async_run_port_stats($p);
- } elsif ($path =~ m:/async/machine-events:) {
+ } elsif ($path =~ m:^/async/machine-events:) {
async_machine_events($p);
- } elsif ($path =~ m:/search:) {
- return search($p);
+ } elsif ($path =~ m:^/search:) {
+ search($p);
+ } elsif ($path =~m:^/browse/(.*):) {
+ browse($p, $1)
} else {
die "Unknown path: $path\n";
}
@@ -106,9 +116,14 @@
created => $_->created,
}} Magus::Run->search(status => 'active');
+ my @categories = map {{
+ category => $_->category
+ }} Magus::Category->retrieve_all;
+
$tmpl->param(
runs => \@runs,
- locks => \@locks
+ locks => \@locks,
+ cats => \@categories,
);
print $tmpl->output;
}
@@ -156,7 +171,8 @@
osversion => $port->run->osversion,
arch => $port->run->arch,
status => $port->status,
- can_reset => $port->run->status eq 'active' ? 1 : 0,
+ license => $port->license,
+ can_reset => $port->can_reset? 1 : 0,
);
my @events = map { {
@@ -195,6 +211,9 @@
$tmpl->param(depends_of => \@depends_of);
}
+ my @cats = map {{ category => $_->category }} $port->categories;
+
+ $tmpl->param(cats => \@cats);
print $p->header, $tmpl->output;
}
@@ -230,9 +249,9 @@
sub search {
- my ($p) = @_;
+ my ($p, $query, $tmpl_params) = @_;
- my $query = $p->param('q');
+ $query ||= $p->param('q');
my $origq = $query;
my %where;
while ($query =~ s/(\S+):(\S+)//) {
@@ -272,13 +291,17 @@
id => $_->id,
run => $_->run,
osversion => $_->run->osversion,
- can_reset => $_->run->status eq 'active' ? 1 : 0,
+ can_reset => $_->can_reset ? 1 : 0,
}} @ports;
my $tmpl = template($p, 'list.tmpl');
$tmpl->param(results => \@results, title => "Search Results for "$origq"", count => scalar @results);
+ if ($tmpl_params) {
+ $tmpl->param(%$tmpl_params);
+ }
+
print $p->header, $tmpl->output;
}
@@ -330,7 +353,7 @@
id => $_->id,
run => $_->run,
osversion => $_->run->osversion,
- can_reset => $_->run->status eq 'active' ? 1 : 0,
+ can_reset => $_->can_reset eq 'active' ? 1 : 0,
}} @ports;
my $tmpl = template($p, 'port-list.tmpl');
@@ -341,6 +364,31 @@
print $p->header(-type => 'text/plain'), encode_json(\%details);
}
+sub browse {
+ my ($p, $path) = @_;
+
+ if ($path =~ m:(.*?)/(.+):) {
+ return search($p,
+ "$path status:any",
+ {title => '<a href="'.$p->script_name . qq[/browse/$1">$1</a>/$2]}
+ );
+ }
+
+ # $path is a category
+ my $cat = Magus::Category->retrieve(category => $path) || die "No such category: $path\n";
+
+ my $tmpl = template($p, "category.tmpl");
+ $tmpl->param(
+ title => "Magus // Browse // $path",
+ ports => [map {{ port => $_ }} sort @{$cat->distinct_ports}],
+ category => $path,
+ );
+
+ print $p->header. $tmpl->output;
+}
+
+
+
sub template {
my ($p, $file) = @_;
@@ -363,6 +411,7 @@
run_root => $p->script_name() . '/runs',
port_root => $p->script_name() . '/ports',
machine_root => $p->script_name() . '/machines',
+ browse_root => $p->script_name() . '/browse',
);
return $tmpl;
Index: magus.css
===================================================================
RCS file: /home/cvs/mports/Tools/magus/www/data/magus/elements/magus.css,v
retrieving revision 1.18
retrieving revision 1.19
diff -L Tools/magus/www/data/magus/elements/magus.css -L Tools/magus/www/data/magus/elements/magus.css -u -r1.18 -r1.19
--- Tools/magus/www/data/magus/elements/magus.css
+++ Tools/magus/www/data/magus/elements/magus.css
@@ -104,19 +104,16 @@
color: #2e3436;
}
-.stats {
+.stats, .locks, .cats {
font-size: .8em;
}
-.locks {
- font-size: .8em;
-}
div.right {
position: absolute;
top: 60px;
- right: 0px;
- width: 20%;
+ right: 10px;
+ width: 19%;
}
div.full {
--- /dev/null
+++ Tools/magus/www/tmpls/category.tmpl
@@ -0,0 +1,12 @@
+<TMPL_INCLUDE NAME="header.tmpl">
+
+<div class="full">
+<h2><TMPL_VAR name="category"></h2>
+
+<ul class="cat-list">
+<TMPL_LOOP NAME="ports">
+ <li><a href="<TMPL_VAR NAME="browse_root">/<TMPL_VAR NAME="port">"><TMPL_VAR NAME="port"></a></li>
+</TMPL_LOOP>
+</ul>
+
+</div>
\ No newline at end of file
Index: port.tmpl
===================================================================
RCS file: /home/cvs/mports/Tools/magus/www/tmpls/port.tmpl,v
retrieving revision 1.8
retrieving revision 1.9
diff -L Tools/magus/www/tmpls/port.tmpl -L Tools/magus/www/tmpls/port.tmpl -u -r1.8 -r1.9
--- Tools/magus/www/tmpls/port.tmpl
+++ Tools/magus/www/tmpls/port.tmpl
@@ -3,7 +3,16 @@
<h2><TMPL_VAR name="port"></h2>
<div class="right">
-<a href="http://cvsweb.midnightbsd.org/mports/<TMPL_VAR NAME=port>">CVSWeb</a>
+<h3>Links</h3>
+<ul class="depends">
+<li><a href="http://cvsweb.midnightbsd.org/mports/<TMPL_VAR NAME=port>" target="_blank">CVSWeb</a></li>
+<TMPL_IF NAME="www">
+<li><a title="<TMPL_VAR NAME="www">" href="<TMPL_VAR NAME="www">" target="_blank">Homepage</a></li>
+<TMPL_ELSE>
+<li>Website: <em>None</em></li>
+</TMPL_IF>
+<li><a href="<TMPL_VAR NAME="browse_root">/<TMPL_VAR NAME="port">">All <TMPL_VAR NAME="port"> results</a></li>
+</ul>
<h3>Depends On</h3>
@@ -29,18 +38,25 @@
<i>Nothing</i>
</TMPL_IF>
+<h3>Categories</h3>
+
+<ul class="depends">
+ <TMPL_LOOP NAME="cats">
+ <li><a href="<TMPL_VAR NAME=browse_root>/<TMPL_VAR NAME=category>"><TMPL_VAR NAME="category"></a></li>
+ </TMPL_LOOP>
+</ul>
+
</div>
<div class="left">
-<p><TMPL_VAR NAME="desc"></p>
-<p>Website: <a target="_blank" href="<TMPL_VAR NAME="www">"><TMPL_VAR NAME="www"></a></p>
-<hr />
+<p style="margin-bottom: 2em"><TMPL_VAR NAME="desc"></p>
<table class="port-results">
<tr>
<th>Version</th>
<th>Run</th>
<th>OSVersion</th>
<th>Arch</th>
+ <th>License</th>
<th>Status</th>
<th></th>
</tr>
@@ -49,6 +65,7 @@
<td><a href="<TMPL_VAR NAME="run_root">/<TMPL_VAR NAME="run">"><TMPL_VAR NAME="run"></a></td>
<td><TMPL_VAR NAME="osversion"></td>
<td><TMPL_VAR NAME="arch"></td>
+ <td><TMPL_IF NAME="license"><TMPL_VAR NAME="license"><TMPL_ELSE><em>No License</em></TMPL_IF></td>
<td><TMPL_VAR NAME="status"></td>
<td>
<TMPL_IF NAME="can_reset">
Index: index.tmpl
===================================================================
RCS file: /home/cvs/mports/Tools/magus/www/tmpls/index.tmpl,v
retrieving revision 1.9
retrieving revision 1.10
diff -L Tools/magus/www/tmpls/index.tmpl -L Tools/magus/www/tmpls/index.tmpl -u -r1.9 -r1.10
--- Tools/magus/www/tmpls/index.tmpl
+++ Tools/magus/www/tmpls/index.tmpl
@@ -53,6 +53,17 @@
</table>
</TMPL_IF>
+<TMPL_IF name="cats">
+<h3>Browse</h3>
+
+<p class="cats">
+<TMPL_LOOP NAME="cats">
+ <a href="<TMPL_VAR NAME="browse_root">/<TMPL_VAR NAME="category">"><TMPL_VAR NAME="category"></a>
+ <TMPL_UNLESS NAME="__last__">ยท</TMPL_UNLESS>
+</TMPL_LOOP>
+</p>
+</TMPL_IF>
+
</div>
More information about the Midnightbsd-cvs
mailing list