Complated showing changes since the last build

--HG--
rename : pretty.php => index.php
This commit is contained in:
Latif Khalifa
2012-02-11 01:51:28 +01:00
parent 77ffe182aa
commit f9532c2daf
10 changed files with 178 additions and 41 deletions

View File

@@ -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);
}
}

View File

@@ -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">&copy; 2012 Singularity Viewer Project</td>
<td width="50%" style="text-align: right;">&copy; 2012 Singularity Viewer Project</td>
</tr></table>
</div>
</div><!-- everything -->

View File

@@ -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:

View File

@@ -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();

View File

@@ -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';