[Midnightbsd-cvs] mports: www/tmpls: start of work for mk II database.
ctriv at midnightbsd.org
ctriv at midnightbsd.org
Thu Mar 13 23:29:49 EDT 2008
Log Message:
-----------
start of work for mk II database. Not complete, but usable.
Modified Files:
--------------
mports/Tools/magus/www/data/magus:
index.cgi (r1.5 -> r1.6)
mports/Tools/magus/www/data/magus/elements:
magus.css (r1.14 -> r1.15)
mports/Tools/magus/www/tmpls:
index.tmpl (r1.7 -> r1.8)
port.tmpl (r1.4 -> r1.5)
result-list.tmpl (r1.4 -> r1.5)
-------------- next part --------------
Index: index.cgi
===================================================================
RCS file: /home/cvs/mports/Tools/magus/www/data/magus/index.cgi,v
retrieving revision 1.5
retrieving revision 1.6
diff -L Tools/magus/www/data/magus/index.cgi -L Tools/magus/www/data/magus/index.cgi -u -r1.5 -r1.6
--- Tools/magus/www/data/magus/index.cgi
+++ Tools/magus/www/data/magus/index.cgi
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use lib qw(/usr/mports/Tools/lib);
+use lib qw(/home/mbsd/magus/mports/Tools/lib);
use Magus;
use CGI;
@@ -11,9 +11,21 @@
eval {
main();
+ exit 0;
};
-error($@) if $@;
+if ($@) {
+ print "Content-Type: text/html\n\n";
+ print <<END_OF_ERROR;
+ <html>
+ <head><title>Error</title></head>
+ <body>
+ <h1>Error</h1>
+ <p>The following error occured:</p>
+ <pre>$@</pre>
+END_OF_ERROR
+ exit 0;
+}
sub main {
my $p = CGI->new;
@@ -38,19 +50,20 @@
sub summary_page {
my ($p) = @_;
- Magus::Result->set_sql(last_twenty => qq{
+ Magus::Port->set_sql(last_twenty => qq{
SELECT __ESSENTIAL__
FROM __TABLE__
- ORDER BY id DESC LIMIT 20
+ ORDER BY updated DESC LIMIT 20
});
my @results = map {{
- summary => $_->summary,
- port => $_->port,
- version => $_->version,
- machine => $_->machine->name,
- arch => $_->arch
- }} Magus::Result->search_last_twenty;
+ summary => $_->status,
+ port => $_->name,
+ port_id => $_->id,
+ version => $_->version,
+ osversion => $_->run->osversion,
+ arch => $_->run->arch,
+ }} Magus::Port->search_last_twenty;
print $p->header;
@@ -62,9 +75,12 @@
);
my @locks = map {{
- port => $_->port->name,
- machine => $_->machine->name,
- arch => $_->arch
+ port => $_->port->name,
+ port_id => $_->port->id,
+ machine => $_->machine->name,
+ arch => $_->port->run->arch,
+ run => $_->port->run->id,
+ osversion => $_->port->run->osversion,
}} Magus::Lock->retrieve_all;
$tmpl->param(
@@ -82,27 +98,31 @@
$tmpl->param(
port => $port->name,
+ id => $port->id,
title => "Magus // $port",
desc => $port->description,
+ www => $port->www,
+ version => $port->version,
+ run => $port->run->id,
+ osversion => $port->run->osversion,
+ arch => $port->run->arch,
+ status => $port->status,
);
- my @results = map { {
- id => $_->id,
- version => $_->version,
- machine => $_->machine->name,
- arch => $_->arch,
- summary => $_->summary,
- has_details => ($_->summary eq 'pass') ? 0 : 1,
- }} sort { $b->id <=> $a->id } $port->results;
+ my @events = map { {
+ machine_id => $_->machine->id,
+ machine => $_->machine->name,
+ type => $_->type,
+ msg => $_->msg
+ } } $port->events;
- if (@results) {
- $tmpl->param(
- results => \@results,
- );
+ if (@events) {
+ $tmpl->param(events => \@events);
}
-
+
my @depends = map { {
- port => $_->name
+ port => $_->name,
+ id => $_->id
} } $port->depends;
if (@depends) {
@@ -110,8 +130,13 @@
}
my @depends_of = map { {
- port => $_->port
- } } Magus::Depend->search(dependency => $port);
+ port => $_->name,
+ id => $_->id
+ } } map { Magus::Port->retrieve($_->port) } Magus::Depend->search(dependency => $port);
+
+ if ($port->log) {
+ $tmpl->param(log => $port->log);
+ }
if (@depends_of) {
$tmpl->param(depends_of => \@depends_of);
@@ -186,19 +211,20 @@
my @ports = Magus::Port->retrieve_from_sql("name LIKE ?", "%$query%");
if (@ports == 1) {
- print $p->redirect("http://cs.emich.edu/magus/index.cgi/ports/$ports[0]");
+ my $id = $ports[0]->id;
+ print $p->redirect("http://www.midnightbsd.org/magus/ports/$id");
return;
}
my @results = map {{
- summary => $_->summary,
- port => $_->port,
- version => $_->version,
- machine => $_->machine->name,
- arch => $_->arch,
- id => $_->id,
- has_details => ($_->summary eq 'pass') ? 0 : 1,
- }} map { $_->current_result } @ports;
+ summary => $_->status,
+ port => $_->name,
+ version => $_->version,
+ arch => $_->run->arch,
+ id => $_->id,
+ run => $_->run,
+ osversion => $_->run->osversion,
+ }} @ports;
my $tmpl = template($p, 'list.tmpl');
@@ -209,59 +235,27 @@
-sub error {
- my ($msg) = @_;
-
- my $tmpl = template(CGI->new, 'error.tmpl');
-
- $tmpl->param(error => $msg, title => 'Error');
-
- print "Content-Type: text/html\n\n", $tmpl->output;
-}
-
-
-
sub template {
my ($p, $file) = @_;
my $tmpl = HTML::Template->new(
cache => 1,
global_vars => 1,
- filename => "/usr/local/www/apache22/tmpls/$file",
+ filename => "/home/mbsd/magus/mports/Tools/magus/www/tmpls/$file",
loop_context_vars => 1,
die_on_bad_params => 0
);
- my $dbh = Magus::Result->db_Main();
- my $sth = $dbh->prepare("SELECT summary,COUNT(*) as count FROM results JOIN ports ON results.port=ports.name AND results.version=ports.version GROUP BY summary ORDER BY count DESC");
- $sth->execute;
- my $stats = $sth->fetchall_arrayref({});
- $sth->finish;
-
- $sth = $dbh->prepare("SELECT COUNT(DISTINCT port) FROM results");
- $sth->execute;
- my ($count) = $sth->fetchrow_array;
- $sth->finish;
-
- $sth = $dbh->prepare("SELECT COUNT(*) FROM ports WHERE name NOT IN (SELECT port FROM results)");
- $sth->execute;
- my ($untested) = $sth->fetchrow_array;
- $sth->finish;
-
my $query = $p->param('q');
$query ||= '';
$tmpl->param(
query => $query,
- ports_tested => $count,
- ports_untested => $untested,
- stats => $stats,
title => 'Magus',
-# breadcrumbs => breadcrumbs(path => $p->path_info or '/'),
root => $p->script_name(),
- list_root => $p->script_name() . '/list',
+ run_root => $p->script_name() . '/runs',
port_root => $p->script_name() . '/ports',
- result_root => $p->script_name() . '/results',
+ machine_root => $p->script_name() . '/machines',
);
return $tmpl;
Index: magus.css
===================================================================
RCS file: /home/cvs/mports/Tools/magus/www/data/magus/elements/magus.css,v
retrieving revision 1.14
retrieving revision 1.15
diff -L Tools/magus/www/data/magus/elements/magus.css -L Tools/magus/www/data/magus/elements/magus.css -u -r1.14 -r1.15
--- Tools/magus/www/data/magus/elements/magus.css
+++ Tools/magus/www/data/magus/elements/magus.css
@@ -33,6 +33,12 @@
color: #555;
}
+h3 {
+ font-size 1.1em;
+ letter-spacing: .1em;
+ color: #555;
+}
+
a {
color: #405491;
}
@@ -115,7 +121,7 @@
max-width: 75%;
}
-table.result-list, table.port-results {
+table.result-list, table.port-results, table.event-list {
max-width: 100%;
width: 100%;
}
Index: result-list.tmpl
===================================================================
RCS file: /home/cvs/mports/Tools/magus/www/tmpls/result-list.tmpl,v
retrieving revision 1.4
retrieving revision 1.5
diff -L Tools/magus/www/tmpls/result-list.tmpl -L Tools/magus/www/tmpls/result-list.tmpl -u -r1.4 -r1.5
--- Tools/magus/www/tmpls/result-list.tmpl
+++ Tools/magus/www/tmpls/result-list.tmpl
@@ -1,17 +1,24 @@
<table class="result-list">
- <tr><th>Port</th><th>Version</th><th>Summary</th><th>Machine</th><th>Arch</th><th></th></tr>
+ <tr>
+ <th>Port</th>
+ <th>Version</th>
+ <th>Status</th>
+ <th>Run</th>
+ <th>OSVersion</th>
+ <th>Arch</th>
+ <th></th>
+ </tr>
<TMPL_LOOP NAME=results>
<tr class="<TMPL_VAR NAME=summary><TMPL_UNLESS NAME=__odd__> even</TMPL_UNLESS>">
- <td><a href="<TMPL_VAR name=port_root>/<TMPL_VAR NAME=port>"><TMPL_VAR NAME="port"></a></td>
+ <td><a href="<TMPL_VAR name=port_root>/<TMPL_VAR NAME=id>"><TMPL_VAR NAME="port"></a></td>
<td><TMPL_VAR NAME=version></td>
<td><TMPL_VAR NAME=summary></td>
- <td><TMPL_VAR NAME=machine></td>
+ <td><a href="<TMPL_VAR NAME="run_root">/<TMPL_VAR NAME="root">"><TMPL_VAR NAME=run></a></td>
+ <td><TMPL_VAR NAME=osversion></td>
<td><TMPL_VAR NAME=arch></td>
<td>
- <TMPL_IF NAME="has_details">
- (<a href="#" id="result_<TMPL_VAR NAME=id>_link" onclick="return details_link(<TMPL_VAR NAME=id>);">Show Details</a>)
- </TMPL_IF>
- (<a onclick="return confirm_delete()" href="/magus/auth/delete-result?id=<TMPL_VAR NAME=id>">Delete</a>)
+ (<a href="<TMPL_VAR NAME="port_root">/<TMPL_VAR NAME="id">">Show Details</a>) ·
+ (<a onclick="return confirm_reset()" href="/magus/auth/reset_port.cgi?id=<TMPL_VAR NAME=id>">Reset Port</a>)
</td>
</tr>
<tr class="details<TMPL_UNLESS NAME=__odd__> even</TMPL_UNLESS>" id="result_<TMPL_VAR NAME=id>_row">
Index: port.tmpl
===================================================================
RCS file: /home/cvs/mports/Tools/magus/www/tmpls/port.tmpl,v
retrieving revision 1.4
retrieving revision 1.5
diff -L Tools/magus/www/tmpls/port.tmpl -L Tools/magus/www/tmpls/port.tmpl -u -r1.4 -r1.5
--- Tools/magus/www/tmpls/port.tmpl
+++ Tools/magus/www/tmpls/port.tmpl
@@ -10,7 +10,7 @@
<TMPL_IF NAME="depends">
<ul class="depends">
<TMPL_LOOP NAME="depends">
- <li><a href="<TMPL_VAR NAME=port_root>/<TMPL_VAR NAME=port>"><TMPL_VAR NAME="port"></a></li>
+ <li><a href="<TMPL_VAR NAME=port_root>/<TMPL_VAR NAME=id>"><TMPL_VAR NAME="port"></a></li>
</TMPL_LOOP>
</ul>
<TMPL_ELSE>
@@ -22,7 +22,7 @@
<TMPL_IF NAME="depends_of">
<ul class="depends">
<TMPL_LOOP NAME="depends_of">
- <li><a href="<TMPL_VAR NAME=port_root>/<TMPL_VAR NAME=port>"><TMPL_VAR NAME="port"></a></li>
+ <li><a href="<TMPL_VAR NAME=port_root>/<TMPL_VAR NAME=id>"><TMPL_VAR NAME="port"></a></li>
</TMPL_LOOP>
</ul>
<TMPL_ELSE>
@@ -33,39 +33,58 @@
<div class="left">
<p><TMPL_VAR NAME="desc"></p>
-
-<TMPL_IF name="results">
-
+<p>Website: <a target="_blank" href="<TMPL_VAR NAME="www">"><TMPL_VAR NAME="www"></a></p>
+<hr />
<table class="port-results">
<tr>
<th>Version</th>
- <th>Machine</th>
+ <th>Run</th>
+ <th>OSVersion</th>
<th>Arch</th>
- <th>Summary</th>
+ <th>Status</th>
<th></th>
</tr>
-<TMPL_LOOP name="results">
-<tr class="<TMPL_VAR NAME=summary><TMPL_UNLESS NAME=__odd__> even</TMPL_UNLESS>">
+<tr class="<TMPL_VAR NAME=status>">
<td><TMPL_VAR NAME="version"></td>
- <td><TMPL_VAR NAME="machine"></td>
+ <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_VAR NAME="summary"></td>
+ <td><TMPL_VAR NAME="status"></td>
<td>
<TMPL_IF NAME="has_details">
(<a href="#" id="result_<TMPL_VAR NAME=id>_link" onclick="return details_link(<TMPL_VAR NAME=id>);">Show Details</a>)
</TMPL_IF>
- (<a onclick="return confirm_delete()" href="/magus/auth/delete-result.cgi?id=<TMPL_VAR NAME=id>">Delete</a>)
+ (<a onclick="return confirm_reset()" href="/magus/auth/reset_port.cgi?id=<TMPL_VAR NAME=id>">Reset Port</a>)
</td>
</tr>
-<tr class="details<TMPL_UNLESS NAME=__odd__> even</TMPL_UNLESS>" id="result_<TMPL_VAR NAME=id>_row">
- <td colspan="5" id="result_<TMPL_VAR NAME=id>_details"></td>
+</table>
+
+
+<TMPL_IF name="events">
+<h3>Events</h3>
+<table class="event-list">
+<tr>
+ <th>Machine</th>
+ <th>Type</th>
+ <th>Message</th>
+</tr>
+
+<TMPL_LOOP name="events">
+<tr class="<TMPL_VAR NAME=type><TMPL_UNLESS NAME=__odd__> even</TMPL_UNLESS>">
+ <td><a href="<TMPL_VAR NAME="machine_root">/<TMPL_VAR NAME="machine_id">"><TMPL_VAR NAME="machine"></a></td>
+ <td><TMPL_VAR NAME="type"></td>
+ <td><TMPL_VAR NAME="msg"></td>
</tr>
</TMPL_LOOP>
</table>
-<TMPL_ELSE>
-<p><TMPL_VAR name=port> has not been tested.</p>
</TMPL_IF>
+<TMPL_IF NAME="log">
+<h3>Log</h3>
+<pre class="log"><TMPL_VAR NAME="log"></pre>
+</TMPL_IF>
+
+
</div>
<TMPL_INCLUDE NAME="footer.tmpl">
Index: index.tmpl
===================================================================
RCS file: /home/cvs/mports/Tools/magus/www/tmpls/index.tmpl,v
retrieving revision 1.7
retrieving revision 1.8
diff -L Tools/magus/www/tmpls/index.tmpl -L Tools/magus/www/tmpls/index.tmpl -u -r1.7 -r1.8
--- Tools/magus/www/tmpls/index.tmpl
+++ Tools/magus/www/tmpls/index.tmpl
@@ -9,15 +9,19 @@
<th>Port</th>
<th>Machine</th>
<th>Arch</th>
+ <th>OSVersion</th>
+ <th>Run</th>
</tr>
</thead>
<tbody>
<TMPL_LOOP NAME="locks">
<tr<TMPL_UNLESS name="__odd__">class="even"</TMPL_UNLESS>>
- <td><a href="<TMPL_VAR name=port_root>/<TMPL_VAR NAME=port>"><TMPL_VAR NAME="port"></a></td>
+ <td><a href="<TMPL_VAR name=port_root>/<TMPL_VAR NAME=port_id>"><TMPL_VAR NAME="port"></a></td>
<td><TMPL_VAR name="machine"></td>
<td><TMPL_VAR name="arch"></td>
+ <td><TMPL_VAR NAME="osversion"></td>
+ <td><a href="<TMPL_VAR name=run_root>/<TMPL_VAR NAME=run>"><TMPL_VAR NAME="run"></a></td>
</tr>
</TMPL_LOOP>
</tbody>
@@ -35,17 +39,17 @@
<th>Port</th>
<th>Version</th>
<th>Summary</th>
- <th>Machine</th>
+ <th>OSVersion</th>
<th>Arch</th>
</tr>
</thead>
<tbody>
<TMPL_LOOP NAME=results>
<tr class="<TMPL_VAR NAME=summary><TMPL_UNLESS NAME="__odd__"> even</TMPL_UNLESS>">
- <td><a href="<TMPL_VAR name=port_root>/<TMPL_VAR NAME=port>"><TMPL_VAR NAME="port"></a></td>
+ <td><a href="<TMPL_VAR name=port_root>/<TMPL_VAR NAME=port_id>"><TMPL_VAR NAME="port"></a></td>
<td><TMPL_VAR NAME=version></td>
<td><TMPL_VAR NAME=summary></td>
- <td><TMPL_VAR NAME=machine></td>
+ <td><TMPL_VAR NAME=osversion></td>
<td><TMPL_VAR NAME=arch></td>
</tr>
</TMPL_LOOP>
More information about the Midnightbsd-cvs
mailing list