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 ( CREATE TABLE log (
id BIGINT PRIMARY KEY AUTO_INCREMENT, id BIGINT PRIMARY KEY AUTO_INCREMENT,
type VARCHAR(16) NOT NULL,
projectid VARCHAR(32) 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, message TEXT NOT NULL,
createdon DATETIME 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; ) charset=utf8 engine=InnoDB;

View File

@ -4,5 +4,5 @@ REPOBASE="`basename "${1}"`"
REV="${2}" REV="${2}"
# does not care if logging has failed. # 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 exit 0

View File

@ -25,13 +25,13 @@ class API extends Controller
print ($this->projects->projectIsOwnedBy ($projectid, $userid) === FALSE)? 'NO': 'YES'; print ($this->projects->projectIsOwnedBy ($projectid, $userid) === FALSE)? 'NO': 'YES';
} }
function logSvnCommit ($repo, $rev) function logCodeCommit ($type, $repo, $rev)
{ {
if (!isset($repo) || !isset($rev)) return; if (!isset($repo) || !isset($rev)) return;
// TODO: access control - may allow localhost only // TODO: access control - may allow localhost only
$this->load->model ('LogModel', 'logs'); $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 else
{ {
$svn_commits = $this->logs->getSvnCommits ( $log_entries = $this->logs->getEntries (
0, CODEPOT_MAX_SVN_COMMITS_IN_PROJECT, $projectid); 0, CODEPOT_MAX_SVN_COMMITS_IN_PROJECT, $projectid);
if ($svn_commits === FALSE) if ($log_entries === FALSE)
{ {
$data['message'] = 'DATABASE ERROR'; $data['message'] = 'DATABASE ERROR';
$this->load->view ($this->VIEW_ERROR, $data); $this->load->view ($this->VIEW_ERROR, $data);
@ -54,7 +54,7 @@ class Project extends Controller
else else
{ {
$data['project'] = $project; $data['project'] = $project;
$data['svn_commits'] = $svn_commits; $data['log_entries'] = $log_entries;
$this->load->view ($this->VIEW_HOME, $data); $this->load->view ($this->VIEW_HOME, $data);
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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