enhanced the log view

This commit is contained in:
hyung-hwan 2010-02-28 13:36:29 +00:00
parent 72c8419f5d
commit 95d6be9445
12 changed files with 147 additions and 122 deletions

View File

@ -75,9 +75,11 @@ CREATE TABLE file (
CREATE TABLE log (
id BIGINT PRIMARY KEY AUTO_INCREMENT,
type VARCHAR(16) NOT NULL,
projectid VARCHAR(32) NOT NULL,
type VARCHAR(16) NOT NULL,
action VARCHAR(16) NOT NULL,
userid VARCHAR(32) NOT NULL,
message TEXT NOT NULL,
createdon DATETIME NOT NULL,
INDEX timed_type_project (createdon, type, projectid)
INDEX timed_project_type_action (createdon, projectid, type, action)
) charset=utf8 engine=InnoDB;

View File

@ -4,5 +4,5 @@ REPOBASE="`basename "${1}"`"
REV="${2}"
# does not care if logging has failed.
wget -q -O- "%API%/logSvnCommit/${REPOBASE}/${REV}" 2>/dev/null
wget -q -O- "%API%/logCodeCommit/svn/${REPOBASE}/${REV}" 2>/dev/null
exit 0

View File

@ -25,13 +25,13 @@ class API extends Controller
print ($this->projects->projectIsOwnedBy ($projectid, $userid) === FALSE)? 'NO': 'YES';
}
function logSvnCommit ($repo, $rev)
function logCodeCommit ($type, $repo, $rev)
{
if (!isset($repo) || !isset($rev)) return;
// TODO: access control - may allow localhost only
$this->load->model ('LogModel', 'logs');
$this->logs->writeSvnCommit ($repo, $rev);
$this->logs->writeCodeCommit ($type, $repo, $rev, '');
}
}

View File

@ -44,9 +44,9 @@ class Project extends Controller
}
else
{
$svn_commits = $this->logs->getSvnCommits (
$log_entries = $this->logs->getEntries (
0, CODEPOT_MAX_SVN_COMMITS_IN_PROJECT, $projectid);
if ($svn_commits === FALSE)
if ($log_entries === FALSE)
{
$data['message'] = 'DATABASE ERROR';
$this->load->view ($this->VIEW_ERROR, $data);
@ -54,7 +54,7 @@ class Project extends Controller
else
{
$data['project'] = $project;
$data['svn_commits'] = $svn_commits;
$data['log_entries'] = $log_entries;
$this->load->view ($this->VIEW_HOME, $data);
}
}

View File

@ -54,8 +54,8 @@ class User extends Controller
return;
}
$svn_commits = $this->logs->getSvnCommits (0, CODEPOT_MAX_SVN_COMMITS);
if ($svn_commits === FALSE)
$log_entries = $this->logs->getEntries (0, CODEPOT_MAX_SVN_COMMITS);
if ($log_entries === FALSE)
{
$data['login'] = $login;
$data['message'] = 'DATABASE ERROR';
@ -65,7 +65,7 @@ class User extends Controller
$data['login'] = $login;
$data['latest_projects'] = $latest_projects;
$data['svn_commits'] = $svn_commits;
$data['log_entries'] = $log_entries;
$data['site'] = $site;
//$data['user_name'] = '';
//$data['user_pass'] = '';
@ -79,8 +79,8 @@ class User extends Controller
$this->load->library ('pagination');
$this->load->model ('LogModel', 'logs');
$num_svn_commits = $this->logs->getNumSvnCommits ();
if ($num_svn_commits === FALSE)
$num_log_entries = $this->logs->getNumEntries ();
if ($num_log_entries === FALSE)
{
$data['login'] = $login;
$data['message'] = 'DATABASE ERROR';
@ -89,11 +89,11 @@ class User extends Controller
}
$pagecfg['base_url'] = site_url() . '/user/sitelog/';
$pagecfg['total_rows'] = $num_svn_commits;
$pagecfg['total_rows'] = $num_log_entries;
$pagecfg['per_page'] = CODEPOT_MAX_SITE_LOGS_PER_PAGE;
$svn_commits = $this->logs->getSvnCommits ($offset, $pagecfg['per_page']);
if ($svn_commits === FALSE)
$log_entries = $this->logs->getEntries ($offset, $pagecfg['per_page']);
if ($log_entries === FALSE)
{
$data['login'] = $login;
$data['message'] = 'DATABASE ERROR';
@ -105,7 +105,7 @@ class User extends Controller
$this->pagination->initialize ($pagecfg);
$data['login'] = $login;
$data['sitelogs'] = $svn_commits;
$data['log_entries'] = $log_entries;
$data['page_links'] = $this->pagination->create_links ();
$this->load->view ($this->VIEW_SITELOG, $data);

View File

@ -8,11 +8,12 @@ class LogModel extends Model
$this->load->database ();
}
function getNumSvnCommits ($projectid = '')
function getNumEntries ($projectid = '')
{
$this->db->trans_start ();
$this->db->where ('type', 'svn-commit');
//$this->db->where ('type', 'code');
//$this->db->where ('action', 'commit');
if ($projectid != '') $this->db->where ('projectid', $projectid);
$num = $this->db->count_all ('log');
@ -22,11 +23,12 @@ class LogModel extends Model
return $num;
}
function getSvnCommits ($offset, $limit, $projectid = '')
function getEntries ($offset, $limit, $projectid = '')
{
$this->db->trans_start ();
$this->db->where ('type', 'svn-commit');
//$this->db->where ('type', 'code');
//$this->db->where ('action', 'commit');
if ($projectid != '') $this->db->where ('projectid', $projectid);
$this->db->order_by ('createdon', 'desc');
$query = $this->db->get ('log', $limit, $offset);
@ -39,43 +41,49 @@ class LogModel extends Model
$commits = array ();
foreach ($result as $row)
{
list($repo,$rev) = split('[,]', $row->message);
list($type,$repo,$rev) = split('[,]', $row->message);
/* $row->project must be equal to $repo */
$commits[$count]['time'] = $row->createdon;
$commits[$count]['createdon'] = $row->createdon;
$commits[$count]['type'] = $row->type;
$commits[$count]['action'] = $row->action;
$commits[$count]['projectid'] = $row->projectid;
$commits[$count]['userid'] = $row->userid;
$commits[$count]['svn_repo'] = $repo;
$commits[$count]['svn_rev'] = $rev;
$tmp['type'] = $type;
$tmp['repo'] = $repo;
$tmp['rev'] = $rev;
$log = @svn_log (
'file:///'.CODEPOT_SVNREPO_DIR."/{$repo}",
$rev, $rev, 1,SVN_DISCOVER_CHANGED_PATHS);
if ($log === FALSE || count($log) < 1)
{
$commits[$count]['svn_author'] = '';
$commits[$count]['svn_message'] = '';
$commits[$count]['svn_time'] = '';
$tmp['time'] = '';
$tmp['author'] = '';
$tmp['message'] = '';
}
else
{
$commits[$count]['svn_author'] = $log[0]['author'];
$commits[$count]['svn_message'] = $log[0]['msg'];
$commits[$count]['svn_time'] = $log[0]['date'];
$tmp['time'] = $log[0]['date'];
$tmp['author'] = $log[0]['author'];
$tmp['message'] = $log[0]['msg'];
}
$commits[$count][$row->type.'-'.$row->action] = $tmp;
$count++;
}
return $commits;
}
function writeSvnCommit ($repo, $rev)
function writeCodecommit ($type, $repo, $rev, $userid)
{
$log->type = 'svn-commit';
$log->type = 'code';
$log->action = 'commit';
$log->projectid = $repo;
$log->message = "{$repo},{$rev}";
$log->userid = $userid;
$log->message = "{$type},{$repo},{$rev}";
$this->write ($log);
}
@ -84,6 +92,7 @@ class LogModel extends Model
$this->db->trans_begin ();
$this->db->set ('type', $log->type);
$this->db->set ('action', $log->action);
$this->db->set ('projectid', $log->projectid);
$this->db->set ('message', $log->message);
$this->db->set ('createdon', date('Y-m-d H:i:s'));

View File

@ -43,8 +43,8 @@ class SubversionModel extends Model
if ($list === FALSE) return FALSE;
$log = @svn_log ($url,
$fileinfo['created_rev'],
$fileinfo['created_rev'],
$info[0]['revision'],
$info[0]['revision'],
1, SVN_DISCOVER_CHANGED_PATHS);
if ($log === FALSE) return FALSE;

View File

@ -84,36 +84,40 @@ $this->load->view (
<div class="box">
<div class="boxtitle">
<?= anchor ("source/history/{$project->id}", $this->lang->line('Code changes')) ?>
<?= anchor ("source/history/{$project->id}", $this->lang->line('Change log')) ?>
</div>
<table id="project_home_mainarea_sidebar_svn_commits_table">
<table id="project_home_mainarea_sidebar_log_table">
<?php
$xdot = $this->converter->AsciiToHex ('.');
foreach ($svn_commits as $commit)
foreach ($log_entries as $log)
{
if ($log['type'] == 'code' && $log['action'] == 'commit')
{
$x = $log['code-commit'];
print '<tr class="odd">';
print '<td>';
print substr($commit['svn_time'], 0, 10);
print substr($x['time'], 0, 10);
print '</td>';
print '<td>';
print anchor (
"/source/revision/{$commit['svn_repo']}/{$xdot}/{$commit['svn_rev']}",
$commit['svn_rev']);
"/source/revision/{$x['repo']}/{$xdot}/{$x['rev']}",
$x['rev']);
print '</td>';
print '<td>';
print htmlspecialchars ($commit['svn_author']);
print htmlspecialchars ($x['author']);
print '</td>';
print '</tr>';
print '<tr class="even">';
print '<td colspan=3>';
$sm = strtok (trim ($commit['svn_message']), "\r\n");
$sm = strtok (trim ($x['message']), "\r\n");
print htmlspecialchars ($sm);
print '</td>';
print '</tr>';
}
}
?>
</table>
</div>

View File

@ -30,15 +30,13 @@ $this->load->view (
<!---------------------------------------------------------------------------->
<?php if ($revision >= 0): ?>
<div class="sidebar" id="project_source_folder_sidebar">
<div class="box">
<ul>
<li><?=$this->lang->line('Revision')?>: <?=$revision?></li>
</ul>
<div class="sidebar" id="project_source_folder_sidebar">
<div class="box" id="project_source_folder_sidebar_info">
<div class="boxtitle"><?=$this->lang->line('Revision')?>: <?=$file['created_rev']?></div>
<pre><?=$file['logmsg']?></pre>
</div>
</div> <!-- project_source_folder_sidebar -->
<?php endif; ?>
</div> <!-- project_source_folder_sidebar -->
<!---------------------------------------------------------------------------->

View File

@ -81,39 +81,44 @@ foreach ($latest_projects as $project)
<div class="box">
<div class="boxtitle">
<?= anchor ("/user/sitelog", $this->lang->line('Code changes')) ?>
<?= anchor ("/user/sitelog", $this->lang->line('Change log')) ?>
</div>
<table id="user_home_mainarea_sidebar_svn_commits_table">
<table id="user_home_mainarea_sidebar_log_table">
<?php
$xdot = $this->converter->AsciiToHex ('.');
foreach ($svn_commits as $commit)
foreach ($log_entries as $log)
{
if ($log['type'] == 'code' && $log['action'] == 'commit')
{
$x = $log['code-commit'];
print '<tr class="odd">';
print '<td>';
print substr($commit['svn_time'], 0, 10);
print substr($x['time'], 0, 10);
print '</td>';
print '<td>';
print anchor (
"/source/file/{$commit['svn_repo']}/{$xdot}/{$commit['svn_rev']}",
$commit['svn_repo']);
"/source/file/{$x['repo']}/{$xdot}/{$x['rev']}",
$x['repo']);
print '</td>';
print '<td>';
print anchor (
"/source/revision/{$commit['svn_repo']}/{$xdot}/{$commit['svn_rev']}",
$commit['svn_rev']);
"/source/revision/{$x['repo']}/{$xdot}/{$x['rev']}",
$x['rev']);
print '</td>';
print '<td>';
print htmlspecialchars ($commit['svn_author']);
print htmlspecialchars ($x['author']);
print '</td>';
print '</tr>';
print '<tr class="even">';
print '<td colspan=4>';
$sm = strtok (trim ($commit['svn_message']), "\r\n");
$sm = strtok (trim ($x['message']), "\r\n");
print htmlspecialchars ($sm);
print '</td>';
print '</tr>';
}
}
?>
</table>
</div>

View File

@ -54,11 +54,21 @@ $this->load->view (
$rowclasses = array ('odd', 'even');
$rowcount = 0;
foreach ($sitelogs as $sitelog)
foreach ($log_entries as $log)
{
// TODO: use time... and inspect type then may use svn_time.
$date = substr($sitelog['svn_time'], 0, 10);
$time = substr($sitelog['svn_time'], 11, 5);
if ($log['type'] == 'code' && $log['action'] == 'commit')
{
$code_commit = $log['code-commit'];
$date = substr($code_commit['time'], 0, 10);
$time = substr($code_commit['time'], 11, 5);
}
else
{
$date = date ('Y-m-d', strtotime($log['createdon']));
$time = date ('h:i', strtotime($log['createdon']));
}
if ($curdate != $date)
{
print "<tr class='break'><td colspan=3 class='break'>&nbsp;</td></tr>";
@ -73,32 +83,25 @@ $this->load->view (
print '<td class="projectid">';
print anchor (
"/source/file/{$sitelog['projectid']}/{$xdot}/{$sitelog['svn_rev']}",
$sitelog['projectid']);
"/project/home/{$log['projectid']}",
$log['projectid']);
print '</td>';
print '<td class="details">';
if ($sitelog['type'] == 'svn-commit')
if ($log['type'] == 'code' && $log['action'] == 'commit')
{
print '<span class="description">';
print anchor (
"/source/revision/{$sitelog['projectid']}/{$xdot}/{$sitelog['svn_rev']}",
"r{$sitelog['svn_rev']}");
"/source/revision/{$log['projectid']}/{$xdot}/{$code_commit['rev']}",
"r{$code_commit['rev']}");
print ' committed by ';
print htmlspecialchars ($sitelog['svn_author']);
print htmlspecialchars ($code_commit['author']);
print '</span>';
print '<pre class="message">';
print htmlspecialchars ($sitelog['svn_message']);
print htmlspecialchars ($code_commit['message']);
print '</pre>';
/*
print '<br />';
print '<span class="message">';
$sm = htmlspecialchars ($sitelog['svn_message']);
print str_replace (array ("\r\n", "\n", "\r"), '<br />', $sm);
print '</span>';
*/
}
print '</td>';

View File

@ -9,22 +9,21 @@
width: 25em;
}
#user_home_mainarea_sidebar_svn_commits_table {
#user_home_mainarea_sidebar_log_table {
border-collapse: collapse;
}
#user_home_mainarea_sidebar_svn_commits_table tr.odd {
#user_home_mainarea_sidebar_log_table tr.odd {
background-color: #bbccef;
}
#user_home_mainarea_sidebar_svn_commits_table tr.odd td {
#user_home_mainarea_sidebar_log_table tr.odd td {
width: 1px;
white-space: nowrap;
}
#user_home_mainarea_sidebar_svn_commits_table tr.even {
#user_home_mainarea_sidebar_log_table tr.even {
background-color: inherit;
font-size: 0.9em;
font-style: italic;
}
@ -86,20 +85,20 @@
/*-----------------------------------------------
* project home view
*-----------------------------------------------*/
#project_home_mainarea_sidebar_svn_commits_table {
#project_home_mainarea_sidebar_log_table {
border-collapse: collapse;
}
#project_home_mainarea_sidebar_svn_commits_table tr.odd {
#project_home_mainarea_sidebar_log_table tr.odd {
background-color: #bbccef;
}
#project_home_mainarea_sidebar_svn_commits_table tr.odd td {
#project_home_mainarea_sidebar_log_table tr.odd td {
width: 1px;
white-space: nowrap;
}
#project_home_mainarea_sidebar_svn_commits_table tr.even {
#project_home_mainarea_sidebar_log_table tr.even {
background-color: inherit;
//font-size: 0.9em;
font-style: italic;
@ -120,6 +119,10 @@
/*-----------------------------------------------
* project source folder view
*-----------------------------------------------*/
#project_source_folder_sidebar_info pre {
white-space: pre-wrap;
}
#project_source_folder_mainarea_result {
overflow: auto;
}
@ -145,7 +148,7 @@
position: absolute;
top: 0;
right: 0;
width: 20em;
width: 22em;
}
#project_source_file_mainarea_result_info pre {
@ -189,7 +192,7 @@
position: absolute;
top: 0;
right: 0;
width: 20em;
width: 22em;
}
#project_source_blame_mainarea_result_info pre {
@ -266,6 +269,7 @@
background-color: inherit;
margin: 0;
margin-bottom: 1em;
white-space: pre-wrap;
}
#project_source_revision_mainarea_result_table td.M {