implement the new site log view.

- it shows code commits only.
 - it needs to be improved to show other types of log message
This commit is contained in:
hyung-hwan 2010-02-28 01:22:17 +00:00
parent ebeb0481ce
commit 72c8419f5d
16 changed files with 304 additions and 43 deletions

View File

@ -91,6 +91,11 @@ max_upload_size = "10000"
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
max_latest_projects = "10" max_latest_projects = "10"
;------------------------------------------------------------------------------
; Maximum number of site log entries to show per page
;------------------------------------------------------------------------------
max_site_logs_per_page = "50"
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; Maximum number of svn commits to show in the front page ; Maximum number of svn commits to show in the front page
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------

View File

@ -45,7 +45,7 @@ class Project extends Controller
else else
{ {
$svn_commits = $this->logs->getSvnCommits ( $svn_commits = $this->logs->getSvnCommits (
CODEPOT_MAX_SVN_COMMITS_IN_PROJECT, $projectid); 0, CODEPOT_MAX_SVN_COMMITS_IN_PROJECT, $projectid);
if ($svn_commits === FALSE) if ($svn_commits === FALSE)
{ {
$data['message'] = 'DATABASE ERROR'; $data['message'] = 'DATABASE ERROR';

View File

@ -5,6 +5,7 @@ class User extends Controller
var $VIEW_ERROR = 'error'; var $VIEW_ERROR = 'error';
var $VIEW_HOME = 'user_home'; var $VIEW_HOME = 'user_home';
var $VIEW_PROJECT_LIST = 'project_list'; var $VIEW_PROJECT_LIST = 'project_list';
var $VIEW_SITELOG = 'user_sitelog';
function User () function User ()
{ {
@ -53,7 +54,7 @@ class User extends Controller
return; return;
} }
$svn_commits = $this->logs->getSvnCommits (CODEPOT_MAX_SVN_COMMITS); $svn_commits = $this->logs->getSvnCommits (0, CODEPOT_MAX_SVN_COMMITS);
if ($svn_commits === FALSE) if ($svn_commits === FALSE)
{ {
$data['login'] = $login; $data['login'] = $login;
@ -71,6 +72,45 @@ class User extends Controller
$this->load->view ($this->VIEW_HOME, $data); $this->load->view ($this->VIEW_HOME, $data);
} }
function sitelog ($offset = 0)
{
$login = $this->login->getUser ();
$this->load->library ('pagination');
$this->load->model ('LogModel', 'logs');
$num_svn_commits = $this->logs->getNumSvnCommits ();
if ($num_svn_commits === FALSE)
{
$data['login'] = $login;
$data['message'] = 'DATABASE ERROR';
$this->load->view ($this->VIEW_ERROR, $data);
return;
}
$pagecfg['base_url'] = site_url() . '/user/sitelog/';
$pagecfg['total_rows'] = $num_svn_commits;
$pagecfg['per_page'] = CODEPOT_MAX_SITE_LOGS_PER_PAGE;
$svn_commits = $this->logs->getSvnCommits ($offset, $pagecfg['per_page']);
if ($svn_commits === FALSE)
{
$data['login'] = $login;
$data['message'] = 'DATABASE ERROR';
$this->load->view ($this->VIEW_ERROR, $data);
return;
}
$this->pagination->initialize ($pagecfg);
$data['login'] = $login;
$data['sitelogs'] = $svn_commits;
$data['page_links'] = $this->pagination->create_links ();
$this->load->view ($this->VIEW_SITELOG, $data);
}
function projectlist () function projectlist ()
{ {
$login = $this->login->getUser (); $login = $this->login->getUser ();

View File

@ -1,6 +1,9 @@
<?php <?php
$lang['Author'] = 'Author'; $lang['Author'] = 'Author';
$lang['Blame'] = 'Blame'; $lang['Blame'] = 'Blame';
$lang['Change log'] = 'Change log';
$lang['Code'] = 'Code';
$lang['Code changes'] = 'Code changes';
$lang['Create'] = 'Create'; $lang['Create'] = 'Create';
$lang['Created by'] = 'Created by'; $lang['Created by'] = 'Created by';
$lang['Created on'] = 'Created on'; $lang['Created on'] = 'Created on';
@ -43,7 +46,6 @@ $lang['Size'] = 'Size';
$lang['Source'] = 'Source'; $lang['Source'] = 'Source';
$lang['Summary'] = 'Summary'; $lang['Summary'] = 'Summary';
$lang['System'] = 'System'; $lang['System'] = 'System';
$lang['SVN commits'] = 'SVN commits';
$lang['Tag'] = 'Tag'; $lang['Tag'] = 'Tag';
$lang['Text'] = 'Text'; $lang['Text'] = 'Text';
$lang['Time'] = 'Time'; $lang['Time'] = 'Time';

View File

@ -1,6 +1,9 @@
<?php <?php
$lang['Author'] = 'Pengarang '; $lang['Author'] = 'Pengarang ';
$lang['Blame'] = 'Menyalahkan'; $lang['Blame'] = 'Menyalahkan';
$lang['Change log'] = 'Change log';
$lang['Code'] = 'Kode';
$lang['Code changes'] = 'Kode changes'
$lang['Create'] = 'Dibuat'; $lang['Create'] = 'Dibuat';
$lang['Created by'] = 'Dibuat oleh'; $lang['Created by'] = 'Dibuat oleh';
$lang['Created on'] = 'Waktu dibuat'; $lang['Created on'] = 'Waktu dibuat';
@ -12,7 +15,7 @@ $lang['Difference'] = 'Beda';
$lang['Directory'] = 'Direktori'; $lang['Directory'] = 'Direktori';
$lang['Download'] = 'Download'; $lang['Download'] = 'Download';
$lang['Edit'] = 'Rubah'; $lang['Edit'] = 'Rubah';
$lang['Head revision'] = 'Kepala Revisi'; $lang['Head revision'] = 'Kepala revisi';
$lang['History'] = 'Sejarah'; $lang['History'] = 'Sejarah';
$lang['Home'] = 'Beranda'; $lang['Home'] = 'Beranda';
$lang['File'] = 'File'; $lang['File'] = 'File';
@ -43,7 +46,6 @@ $lang['Size'] = 'Ukuran';
$lang['Source'] = 'Sumber'; $lang['Source'] = 'Sumber';
$lang['Summary'] = 'Rangkuman'; $lang['Summary'] = 'Rangkuman';
$lang['System'] = 'Sistem'; $lang['System'] = 'Sistem';
$lang['SVN commits'] = 'SVN commits';
$lang['Tag'] = 'Label'; $lang['Tag'] = 'Label';
$lang['Text'] = 'Teks'; $lang['Text'] = 'Teks';
$lang['Time'] = 'Waktu'; $lang['Time'] = 'Waktu';

View File

@ -1,6 +1,9 @@
<?php <?php
$lang['Author'] = '저자'; $lang['Author'] = '저자';
$lang['Blame'] = '책임전가'; $lang['Blame'] = '책임전가';
$lang['Change log'] = '변경내역';
$lang['Code'] = '코드';
$lang['Code changes'] = '코드변경';
$lang['Create'] = '생성'; $lang['Create'] = '생성';
$lang['Created by'] = '최초생성인'; $lang['Created by'] = '최초생성인';
$lang['Created on'] = '최초생성시간'; $lang['Created on'] = '최초생성시간';
@ -43,7 +46,6 @@ $lang['Size'] = '크기';
$lang['Source'] = '소스'; $lang['Source'] = '소스';
$lang['Summary'] = '요약'; $lang['Summary'] = '요약';
$lang['System'] = '시스템'; $lang['System'] = '시스템';
$lang['SVN commits'] = 'SVN 커밋';
$lang['Tag'] = '태그'; $lang['Tag'] = '태그';
$lang['Text'] = '본문'; $lang['Text'] = '본문';
$lang['Time'] = '시간'; $lang['Time'] = '시간';

View File

@ -8,14 +8,28 @@ class LogModel extends Model
$this->load->database (); $this->load->database ();
} }
function getSvnCommits ($limit, $projectid = '') function getNumSvnCommits ($projectid = '')
{
$this->db->trans_start ();
$this->db->where ('type', 'svn-commit');
if ($projectid != '') $this->db->where ('projectid', $projectid);
$num = $this->db->count_all ('log');
$this->db->trans_complete ();
if ($this->db->trans_status() === FALSE) return FALSE;
return $num;
}
function getSvnCommits ($offset, $limit, $projectid = '')
{ {
$this->db->trans_start (); $this->db->trans_start ();
$this->db->where ('type', 'svn-commit'); $this->db->where ('type', 'svn-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); $query = $this->db->get ('log', $limit, $offset);
$result = $query->result (); $result = $query->result ();
$this->db->trans_complete (); $this->db->trans_complete ();
@ -28,23 +42,27 @@ class LogModel extends Model
list($repo,$rev) = split('[,]', $row->message); list($repo,$rev) = split('[,]', $row->message);
/* $row->project must be equal to $repo */ /* $row->project must be equal to $repo */
$commits[$count]['repo'] = $row->projectid; $commits[$count]['time'] = $row->createdon;
$commits[$count]['rev'] = $rev; $commits[$count]['type'] = $row->type;
$commits[$count]['projectid'] = $row->projectid;
$commits[$count]['svn_repo'] = $repo;
$commits[$count]['svn_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]['author'] = ''; $commits[$count]['svn_author'] = '';
$commits[$count]['message'] = ''; $commits[$count]['svn_message'] = '';
$commits[$count]['time'] = ''; $commits[$count]['svn_time'] = '';
} }
else else
{ {
$commits[$count]['author'] = $log[0]['author']; $commits[$count]['svn_author'] = $log[0]['author'];
$commits[$count]['message'] = $log[0]['msg']; $commits[$count]['svn_message'] = $log[0]['msg'];
$commits[$count]['time'] = $log[0]['date']; $commits[$count]['svn_time'] = $log[0]['date'];
} }
$count++; $count++;

View File

@ -23,6 +23,7 @@ www_DATA = \
source_revision.php \ source_revision.php \
taskbar.php \ taskbar.php \
user_home.php \ user_home.php \
user_sitelog.php \
wiki_delete.php \ wiki_delete.php \
wiki_edit.php \ wiki_edit.php \
wiki_home.php \ wiki_home.php \

View File

@ -186,6 +186,7 @@ www_DATA = \
source_revision.php \ source_revision.php \
taskbar.php \ taskbar.php \
user_home.php \ user_home.php \
user_sitelog.php \
wiki_delete.php \ wiki_delete.php \
wiki_edit.php \ wiki_edit.php \
wiki_home.php \ wiki_home.php \

View File

@ -83,7 +83,9 @@ $this->load->view (
</div> </div>
<div class="box"> <div class="box">
<div class="boxtitle"><?=$this->lang->line('SVN commits')?></div> <div class="boxtitle">
<?= anchor ("source/history/{$project->id}", $this->lang->line('Code changes')) ?>
</div>
<table id="project_home_mainarea_sidebar_svn_commits_table"> <table id="project_home_mainarea_sidebar_svn_commits_table">
<?php <?php
$xdot = $this->converter->AsciiToHex ('.'); $xdot = $this->converter->AsciiToHex ('.');
@ -91,23 +93,23 @@ $this->load->view (
{ {
print '<tr class="odd">'; print '<tr class="odd">';
print '<td>'; print '<td>';
print substr($commit['time'], 0, 10); print substr($commit['svn_time'], 0, 10);
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print anchor ( print anchor (
"/source/revision/{$commit['repo']}/{$xdot}/{$commit['rev']}", "/source/revision/{$commit['svn_repo']}/{$xdot}/{$commit['svn_rev']}",
$commit['rev']); $commit['svn_rev']);
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print htmlspecialchars ($commit['author']); print htmlspecialchars ($commit['svn_author']);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '<tr class="even">'; print '<tr class="even">';
print '<td colspan=4>'; print '<td colspan=3>';
$sm = strtok (trim ($commit['message']), "\r\n"); $sm = strtok (trim ($commit['svn_message']), "\r\n");
print htmlspecialchars ($sm); print htmlspecialchars ($sm);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';

View File

@ -29,7 +29,7 @@ function show_projectbar ($con, $site, $project, $pageid, $ctxmenuitems)
$menuitems = array ( $menuitems = array (
array ("project/home/{$project->id}", $con->lang->line('Overview')), array ("project/home/{$project->id}", $con->lang->line('Overview')),
array ("wiki/home/{$project->id}", $con->lang->line('Wiki')), array ("wiki/home/{$project->id}", $con->lang->line('Wiki')),
array ("source/home/{$project->id}", $con->lang->line('Source')), array ("source/home/{$project->id}", $con->lang->line('Code')),
array ("file/home/{$project->id}", $con->lang->line('Files')) array ("file/home/{$project->id}", $con->lang->line('Files'))
); );

View File

@ -80,7 +80,9 @@ foreach ($latest_projects as $project)
</div> </div>
<div class="box"> <div class="box">
<div class="boxtitle"><?=$this->lang->line('SVN commits')?></div> <div class="boxtitle">
<?= anchor ("/user/sitelog", $this->lang->line('Code changes')) ?>
</div>
<table id="user_home_mainarea_sidebar_svn_commits_table"> <table id="user_home_mainarea_sidebar_svn_commits_table">
<?php <?php
$xdot = $this->converter->AsciiToHex ('.'); $xdot = $this->converter->AsciiToHex ('.');
@ -88,26 +90,26 @@ foreach ($latest_projects as $project)
{ {
print '<tr class="odd">'; print '<tr class="odd">';
print '<td>'; print '<td>';
print substr($commit['time'], 0, 10); print substr($commit['svn_time'], 0, 10);
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print anchor ( print anchor (
"/source/file/{$commit['repo']}/{$xdot}/{$commit['rev']}", "/source/file/{$commit['svn_repo']}/{$xdot}/{$commit['svn_rev']}",
$commit['repo']); $commit['svn_repo']);
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print anchor ( print anchor (
"/source/revision/{$commit['repo']}/{$xdot}/{$commit['rev']}", "/source/revision/{$commit['svn_repo']}/{$xdot}/{$commit['svn_rev']}",
$commit['rev']); $commit['svn_rev']);
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print htmlspecialchars ($commit['author']); print htmlspecialchars ($commit['svn_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['message']), "\r\n"); $sm = strtok (trim ($commit['svn_message']), "\r\n");
print htmlspecialchars ($sm); print htmlspecialchars ($sm);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';

View File

@ -0,0 +1,121 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link type="text/css" rel="stylesheet" href="<?=base_url()?>/css/common.css" />
<link type="text/css" rel="stylesheet" href="<?=base_url()?>/css/project.css" />
</script>
<?php
$caption = $this->lang->line('Home');
if ($login['id'] != '') $caption .= "({$login['id']})";
?>
<title><?=htmlspecialchars($caption)?></title>
</head>
<body>
<div class="content" id="user_sitelog_content">
<!---------------------------------------------------------------------------->
<?php $this->load->view ('taskbar'); ?>
<!---------------------------------------------------------------------------->
<?php
$this->load->view (
'projectbar',
array (
'project' => NULL,
'site' => NULL,
'pageid' => 'sitelog',
'ctxmenuitems' => array ()
)
);
?>
<!---------------------------------------------------------------------------->
<div class="mainarea" id="user_sitelog_mainarea">
<div class="title" id="user_sitelog_mainarea_title">
<?= $this->lang->line ('Change log') ?>
</div>
<div id="user_sitelog_mainarea_result">
<table id="user_sitelog_mainarea_result_table">
<?php
$curdate = '';
$xdot = $this->converter->AsciiToHex ('.');
$rowclasses = array ('odd', 'even');
$rowcount = 0;
foreach ($sitelogs as $sitelog)
{
// 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 ($curdate != $date)
{
print "<tr class='break'><td colspan=3 class='break'>&nbsp;</td></tr>";
print "<tr class='head'><td colspan=3 class='date'>$date</td></tr>";
$curdate = $date;
$rowcount = 0;
}
print "<tr class='{$rowclasses[$rowcount%2]}'>";
$rowcount++;
print '<td class="time">' . $time . '</td>';
print '<td class="projectid">';
print anchor (
"/source/file/{$sitelog['projectid']}/{$xdot}/{$sitelog['svn_rev']}",
$sitelog['projectid']);
print '</td>';
print '<td class="details">';
if ($sitelog['type'] == 'svn-commit')
{
print '<span class="description">';
print anchor (
"/source/revision/{$sitelog['projectid']}/{$xdot}/{$sitelog['svn_rev']}",
"r{$sitelog['svn_rev']}");
print ' committed by ';
print htmlspecialchars ($sitelog['svn_author']);
print '</span>';
print '<pre class="message">';
print htmlspecialchars ($sitelog['svn_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>';
print '</tr>';
}
?>
<tr class='foot'>
<td colspan=3 class='pages'><?= $page_links ?></td>
</table>
</div> <!-- user_sitelog_mainarea_result -->
</div> <!-- user_sitelog_mainarea -->
<?php $this->load->view ('footer'); ?>
</div> <!-- user_sitelog_content -->
</body>
</html>

View File

@ -28,9 +28,11 @@ function load_ini ($file)
array ('login_model', 'string', 'LdapLoginModel'), array ('login_model', 'string', 'LdapLoginModel'),
array ('sysadmin_userids', 'string', ''), array ('sysadmin_userids', 'string', ''),
array ('max_upload_size', 'string', '10000'), // kbytes array ('max_upload_size', 'string', '10000'), // kbytes
array ('max_latest_projects', 'integer', 10),
array ('max_site_logs_per_page', 'integer', 50),
array ('max_svn_commits', 'integer', 10), array ('max_svn_commits', 'integer', 10),
array ('max_svn_commits_in_project', 'integer', 5), array ('max_svn_commits_in_project', 'integer', 5),
array ('max_latest_projects', 'integer', 10),
array ('database_username', 'string', ''), array ('database_username', 'string', ''),
array ('database_password', 'string', ''), array ('database_password', 'string', ''),

View File

@ -316,9 +316,7 @@ pre.prettyprint .nocode a:hover {
.content .sidebar { .content .sidebar {
font-size: 0.9em; font-size: 0.9em;
float: right; float: right;
width: 20em; width: 22em;
//padding: 5px;
//margin-right: 2px;
} }
.content .sidebar .box { .content .sidebar .box {

View File

@ -10,35 +10,100 @@
} }
#user_home_mainarea_sidebar_svn_commits_table { #user_home_mainarea_sidebar_svn_commits_table {
margin: 0; border-collapse: collapse;
padding: 0;
} }
#user_home_mainarea_sidebar_svn_commits_table tr.odd { #user_home_mainarea_sidebar_svn_commits_table tr.odd {
background-color: #bbccef; background-color: #bbccef;
} }
#user_home_mainarea_sidebar_svn_commits_table tr.odd td {
width: 1px;
white-space: nowrap;
}
#user_home_mainarea_sidebar_svn_commits_table tr.even { #user_home_mainarea_sidebar_svn_commits_table tr.even {
background-color: inherit; background-color: inherit;
font-size: 0.9em;
font-style: italic;
}
/*-----------------------------------------------
* user sidelog view
*-----------------------------------------------*/
#user_sitelog_mainarea_result {
overflow: auto;
}
#user_sitelog_mainarea_result_table {
border-collapse: collapse;
}
#user_sitelog_mainarea_result_table a {
text-decoration: none;
}
#user_sitelog_mainarea_result_table td {
vertical-align: top;
white-space: nowrap;
}
#user_sitelog_mainarea_result_table td.break {
font-size: 0.5em;
}
#user_sitelog_mainarea_result_table td.date {
font-weight: bold;
background-color: #bbccef;
}
#user_sitelog_mainarea_result_table td.time {
width: 1px;
color: #777777;
}
#user_sitelog_mainarea_result_table td.details {
white-space: normal;
}
#user_sitelog_mainarea_result_table td.details .description {
font-style: italic;
}
#user_sitelog_mainarea_result_table td.details pre.message {
border: 0;
margin: 1px;
background-color: inherit;
white-space: pre-wrap;
}
#user_sitelog_mainarea_result_table td.pages {
padding-top: 1em;
text-align: center;
font-weight: bold;
} }
/*----------------------------------------------- /*-----------------------------------------------
* project home view * project home view
*-----------------------------------------------*/ *-----------------------------------------------*/
#project_home_mainarea_sidebar_svn_commits_table { #project_home_mainarea_sidebar_svn_commits_table {
margin: 0; border-collapse: collapse;
padding: 0;
} }
#project_home_mainarea_sidebar_svn_commits_table tr.odd { #project_home_mainarea_sidebar_svn_commits_table tr.odd {
background-color: #bbccef; background-color: #bbccef;
} }
#project_home_mainarea_sidebar_svn_commits_table tr.even { #project_home_mainarea_sidebar_svn_commits_table tr.odd td {
background-color: inherit; width: 1px;
white-space: nowrap;
} }
#project_home_mainarea_sidebar_svn_commits_table tr.even {
background-color: inherit;
//font-size: 0.9em;
font-style: italic;
}
/*----------------------------------------------- /*-----------------------------------------------
* project file home view * project file home view