Complated showing changes since the last build
--HG-- rename : pretty.php => index.php
This commit is contained in:
@@ -53,3 +53,31 @@ a, a:link, a:hover, a:visited, a:active {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
td, th {
|
||||
text-align: left;
|
||||
margin: 0;
|
||||
padding: 3px 20px 3px 3px;
|
||||
vertical-align: top;
|
||||
display: table-cell;
|
||||
border: none;
|
||||
}
|
||||
|
||||
th {
|
||||
border-bottom: solid 1px #404040;
|
||||
background: url(images/container-bg.gif) top repeat-x;
|
||||
}
|
||||
|
||||
.build-list {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
border-spacing: 0;
|
||||
width: 100%;
|
||||
border: solid 1px #404040;
|
||||
}
|
||||
|
||||
pre {
|
||||
font-family: monospace;
|
||||
font-size: 8pt;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
BIN
images/dl.gif
Normal file
BIN
images/dl.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 120 B |
BIN
images/favicon.ico
Normal file
BIN
images/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 318 B |
103
index.php
Normal file
103
index.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
define("SITE_ROOT", realpath(dirname(__file__)));
|
||||
require_once SITE_ROOT . "/lib/init.php";
|
||||
|
||||
function parse_email($email)
|
||||
{
|
||||
$ret = array("name" => $email, "email" => "");
|
||||
if (preg_match("|([^\<]*)<([^>]*)>|", $email, $m)) {
|
||||
$ret["name"] = trim($m[1]);
|
||||
$ret["email"] = trim($m[2]);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function print_changes($current, $next)
|
||||
{
|
||||
global $DB;
|
||||
if ($res = $DB->query(kl_str_sql("select * from revs where id<=!i and id>!i", $current->nr, $next->nr))) {
|
||||
print '<table style="width: 100%;">';
|
||||
|
||||
while ($row = $DB->fetchRow($res)) {
|
||||
$author = parse_email($row["author"]);
|
||||
$gid = md5($author["email"]);
|
||||
print '
|
||||
<tr>
|
||||
<td rowspan="2" style="text-align: center;"><img src="http://www.gravatar.com/avatar/' . $gid . '?r=x&d=mm&s=64"/><br />' .
|
||||
htmlspecialchars($author["name"]) . '</td>
|
||||
<td><a href="https://github.com/siana/SingularityViewer/commit/' . htmlspecialchars($row["hash"]) . '">' . htmlspecialchars($row["hash"]) . '</a></td>
|
||||
<td>' . htmlspecialchars($row["time"]).
|
||||
' (' . Layout::since(strtotime($row["time"])) . ' ago)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" width="99%"><pre>' . htmlspecialchars($row["message"]) . '</pre></td>
|
||||
</tr>';
|
||||
|
||||
# pre_dump($row);
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
}
|
||||
|
||||
Function print_build($current, $next)
|
||||
{
|
||||
print "
|
||||
<tr style=\"background-color: #303030;\">
|
||||
<th>" . htmlspecialchars($current->nr). "</th>
|
||||
<th>" . htmlspecialchars($current->modified). " (" . Layout::since(strtotime($current->modified)) . " ago)</th>
|
||||
<th>" . htmlspecialchars($current->chan). "</th>
|
||||
<th><a href='" . URL_ROOT . "/" . $current->file . "'>Windows Installer <img src=\"" . IMG_ROOT . "/dl.gif\" /></a>
|
||||
<a href='" . URL_ROOT . "/" . $current->file . ".log'>Build Log</a></th>
|
||||
</tr>";
|
||||
if ($next) {
|
||||
print '<tr><td colspan="4">';
|
||||
print_changes($current, $next);
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Layout::header();
|
||||
|
||||
$chan = "SingularityAlpha";
|
||||
|
||||
$pageSize = 20;
|
||||
|
||||
$builds = array();
|
||||
|
||||
if ($res = $DB->query(kl_str_sql("select * from builds where chan=!s order by nr desc limit !i", $chan, $pageSize + 1))) {
|
||||
while ($row = $DB->fetchRow($res)) {
|
||||
|
||||
$build = new stdClass;
|
||||
$DB->loadFromDbRow($build, $res, $row);
|
||||
$builds[] = $build;
|
||||
}
|
||||
}
|
||||
|
||||
$nrBuilds = count($builds);
|
||||
|
||||
if ($nrBuilds) {
|
||||
print '<table class="build-list">';
|
||||
|
||||
|
||||
for ($i = 0; $i < $pageSize; $i++) {
|
||||
if (!isset($builds[$i])) continue;
|
||||
print_build($builds[$i], $builds[$i + 1]);
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
}
|
||||
|
||||
Layout::footer();
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: noet sw=4 ts=4 fdm=marker
|
||||
* vim<600: noet sw=4 ts=4
|
||||
*/
|
||||
20
lib/DBH.php
20
lib/DBH.php
@@ -54,7 +54,7 @@ class DBH
|
||||
|
||||
if (!$res) {
|
||||
DBH::log("[error] ".$q);
|
||||
DBH::log("[error_msg] " . $error_msg);
|
||||
DBH::log("[error_msg] " . $error_msg . " " . @sqlite_error_string(@sqlite_last_error(($this->dbh))));
|
||||
$this->last_error = $error_msg;
|
||||
|
||||
$e = debug_backtrace();
|
||||
@@ -69,15 +69,6 @@ class DBH
|
||||
|
||||
return false;
|
||||
} else {
|
||||
if ($res !== TRUE) {
|
||||
$result_id = (int)$res;
|
||||
if (!isset($this->field_desc[$result_id])) {
|
||||
$nf = sqlite_num_fields($res);
|
||||
for ($i=0; $i<$nf; $i++) {
|
||||
$this->field_desc[$result_id][sqlite_field_name($res, $i)] = sqlite_field_name($res, $i);
|
||||
}
|
||||
}
|
||||
}
|
||||
DBH::log("[success] ".$q);
|
||||
return $res;
|
||||
}
|
||||
@@ -86,19 +77,14 @@ class DBH
|
||||
function loadFromDbRow(&$obj, $res, $row)
|
||||
{
|
||||
foreach ($row as $symbolicName => $nativeName){
|
||||
if ($nativeName && ($this->field_desc[(int)$res][$symbolicName] == "timestamp" ||
|
||||
$this->field_desc[(int)$res][$symbolicName] == "date")) {
|
||||
$obj->{$symbolicName} = strtotime($nativeName);
|
||||
} else {
|
||||
$obj->{$symbolicName} = $nativeName;
|
||||
}
|
||||
$obj->{$symbolicName} = $nativeName;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function fetchRow($res)
|
||||
{
|
||||
return @sqlite_fetch_array($res);
|
||||
return @sqlite_fetch_array($res, SQLITE_ASSOC);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,32 @@
|
||||
|
||||
class Layout
|
||||
{
|
||||
|
||||
function since($since)
|
||||
{
|
||||
$since = time() - $since;
|
||||
$chunks = array(
|
||||
array(60 * 60 * 24 * 365 , 'year'),
|
||||
array(60 * 60 * 24 * 30 , 'month'),
|
||||
array(60 * 60 * 24 * 7, 'week'),
|
||||
array(60 * 60 * 24 , 'day'),
|
||||
array(60 * 60 , 'hour'),
|
||||
array(60 , 'minute'),
|
||||
array(1 , 'second')
|
||||
);
|
||||
|
||||
for ($i = 0, $j = count($chunks); $i < $j; $i++) {
|
||||
$seconds = $chunks[$i][0];
|
||||
$name = $chunks[$i][1];
|
||||
if (($count = floor($since / $seconds)) != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$print = ($count == 1) ? '1 '.$name : "$count {$name}s";
|
||||
return $print;
|
||||
}
|
||||
|
||||
function header()
|
||||
{ ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
@@ -10,6 +36,7 @@ class Layout
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<link rel="stylesheet" type="text/css" href="<?php print URL_ROOT ?>/buildsite.css"/>
|
||||
<link rel="shortcut icon" href="<?php print IMG_ROOT ?>/favicon.ico" type="image/x-icon" />
|
||||
<title>Singularity Viewer Automated Build System</title>
|
||||
</head>
|
||||
<body>
|
||||
@@ -32,7 +59,7 @@ class Layout
|
||||
<td class="bottom-links"><a href="http://www.singularityviewer.org/about">About</a></td>
|
||||
<td class="bottom-links"><a href="http://code.google.com/p/singularity-viewer/issues/">Issue Tracker</a></td>
|
||||
<td class="bottom-links"><a href="https://github.com/siana/SingularityViewer">Source Tracker</a></td>
|
||||
<td width="50%" align="right">© 2012 Singularity Viewer Project</td>
|
||||
<td width="50%" style="text-align: right;">© 2012 Singularity Viewer Project</td>
|
||||
</tr></table>
|
||||
</div>
|
||||
</div><!-- everything -->
|
||||
|
||||
@@ -104,6 +104,14 @@ function kl_str_sql()
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
function pre_dump($var, $die = false)
|
||||
{
|
||||
print "<pre>";
|
||||
var_dump($var);
|
||||
print "</pre>";
|
||||
if ($die) die();
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
|
||||
@@ -98,7 +98,7 @@ function update_builds()
|
||||
|
||||
// check if table exists
|
||||
if (!($res = $DB->query("select count(*) as c from builds"))) {
|
||||
$DB->query("create table builds(nr integer, chan varchar, version varchar, file varchar, primary key(nr, chan))");
|
||||
$DB->query("create table builds(nr integer, chan varchar, version varchar, file varchar, modified timestamp, primary key(nr, chan))");
|
||||
}
|
||||
|
||||
for ($i=0; $i<count($builds); $i++) {
|
||||
@@ -109,13 +109,14 @@ function update_builds()
|
||||
$minor = $m[3];
|
||||
$maintenance = $m[4];
|
||||
$build = $m[5];
|
||||
$modified = filemtime(SITE_ROOT . "/" . $file);
|
||||
$version = "$major.$minor.$maintenance.$build";
|
||||
$res = $DB->query(kl_str_sql("select count(*) as c from builds where nr=!i and chan=!s", $build, $chan));
|
||||
$row = $DB->fetchRow($res);
|
||||
if ($row["c"] === "0") {
|
||||
$DB->query(kl_str_sql("insert into builds (nr, chan, version, file) ".
|
||||
"values (!i, !s, !s, !s)",
|
||||
$build, $chan, $version, $file));
|
||||
$DB->query(kl_str_sql("insert into builds (nr, chan, version, file, modified) ".
|
||||
"values (!i, !s, !s, !s, !t)",
|
||||
$build, $chan, $version, $file, $modified));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,8 +124,8 @@ function update_builds()
|
||||
}
|
||||
|
||||
chdir(SITE_ROOT . "/lib/source");
|
||||
update_source();
|
||||
update_revs();
|
||||
#update_source();
|
||||
#update_revs();
|
||||
|
||||
chdir(SITE_ROOT);
|
||||
update_builds();
|
||||
|
||||
@@ -4,6 +4,7 @@ if (!defined('SITE_ROOT')) {
|
||||
}
|
||||
|
||||
error_reporting(E_ALL ^ E_NOTICE);
|
||||
ini_set("display_errors", "true");
|
||||
|
||||
if (!extension_loaded('kl')) {
|
||||
require_once SITE_ROOT.'/lib/ext_kl.php';
|
||||
|
||||
17
pretty.php
17
pretty.php
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
define("SITE_ROOT", realpath(dirname(__file__)));
|
||||
require_once SITE_ROOT . "/lib/init.php";
|
||||
|
||||
Layout::header();
|
||||
|
||||
Layout::footer();
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: noet sw=4 ts=4 fdm=marker
|
||||
* vim<600: noet sw=4 ts=4
|
||||
*/
|
||||
Reference in New Issue
Block a user