enhanced the code viewer to show svn properties

This commit is contained in:
hyung-hwan 2010-04-12 12:39:08 +00:00
parent b41a102353
commit 3104736b42
19 changed files with 286 additions and 78 deletions

View File

@ -48,4 +48,4 @@ rpm: dist
mkdir -p "@abs_top_builddir@/RPM/SRPMS"
mkdir -p "@abs_top_builddir@/RPM/RPMS"
cp codepot-@VERSION@.tar.gz "@abs_top_builddir@/RPM/SOURCES"
rpmbuild --define "_topdir @abs_top_builddir@/RPM" -ba codepot.spec
rpmbuild --define "_topdir @abs_top_builddir@/RPM" -ba codepot.spec --target noarch

View File

@ -733,7 +733,7 @@ rpm: dist
mkdir -p "@abs_top_builddir@/RPM/SRPMS"
mkdir -p "@abs_top_builddir@/RPM/RPMS"
cp codepot-@VERSION@.tar.gz "@abs_top_builddir@/RPM/SOURCES"
rpmbuild --define "_topdir @abs_top_builddir@/RPM" -ba codepot.spec
rpmbuild --define "_topdir @abs_top_builddir@/RPM" -ba codepot.spec --target noarch
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.

View File

@ -11,11 +11,12 @@ default_site_name = "@PACKAGE@"
;------------------------------------------------------------------------------
; database settings
;------------------------------------------------------------------------------
database_username =
database_password =
database_name =
database_driver =
database_prefix =
database_hostname = "localhost"
database_username = ""
database_password = ""
database_name = ""
database_driver = ""
database_prefix = ""
;------------------------------------------------------------------------------
; ldap settings

View File

@ -37,7 +37,7 @@
$active_group = "default";
$active_record = TRUE;
$db['default']['hostname'] = "localhost";
$db['default']['hostname'] = CODEPOT_DATABASE_HOSTNAME;
$db['default']['username'] = CODEPOT_DATABASE_USERNAME;
$db['default']['password'] = CODEPOT_DATABASE_PASSWORD;
$db['default']['database'] = CODEPOT_DATABASE_NAME;
@ -50,5 +50,18 @@ $db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";
$db['auth-mysql']['hostname'] = CODEPOT_AUTH_MYSQL_HOSTNAME;
$db['auth-mysql']['username'] = CODEPOT_AUTH_MYSQL_USERNAME;
$db['auth-mysql']['password'] = CODEPOT_AUTH_MYSQL_PASSWORD;
$db['auth-mysql']['database'] = CODEPOT_AUTH_MYSQL_NAME;
$db['auth-mysql']['dbdriver'] = "mysql";
$db['auth-mysql']['dbprefix'] = CODEPOT_AUTH_MYSQL_PREFIX;
$db['auth-mysql']['pconnect'] = FALSE;
$db['auth-mysql']['db_debug'] = FALSE;
$db['auth-mysql']['cache_on'] = FALSE;
$db['auth-mysql']['cachedir'] = "";
$db['auth-mysql']['char_set'] = "utf8";
$db['auth-mysql']['dbcollat'] = "utf8_general_ci";
/* End of file database.php */
/* Location: ./system/application/config/database.php */

View File

@ -20,6 +20,7 @@ class Code extends Controller
$this->load->library ('Language', 'lang');
$this->lang->load ('common', CODEPOT_LANG);
$this->lang->load ('code', CODEPOT_LANG);
}
function home ($projectid = '', $subdir = '', $rev = SVN_REVISION_HEAD)

View File

@ -1,5 +1,6 @@
wwwdir=$(WWWDIR)/codepot/language/english
www_DATA = \
code_lang.php \
common_lang.php \
issue_lang.php \
index.html \

View File

@ -166,6 +166,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
wwwdir = $(WWWDIR)/codepot/language/english
www_DATA = \
code_lang.php \
common_lang.php \
issue_lang.php \
index.html \

View File

@ -0,0 +1,9 @@
<?php
$lang['CODE_COMMIT'] = 'Commit';
$lang['CODE_HIDE_DETAILS'] = 'Hide details';
$lang['CODE_PROPERTIES'] = 'Properties';
$lang['CODE_PROPERTY'] = 'Property';
$lang['CODE_SHOW_DETAILS'] = 'Show details';
$lang['CODE_MSG_COMMITTED_BY_ON'] = 'Committed by %s on %s';
?>

View File

@ -1,5 +1,6 @@
wwwdir=$(WWWDIR)/codepot/language/korean
www_DATA = \
code_lang.php \
common_lang.php \
issue_lang.php \
index.html \

View File

@ -166,6 +166,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
wwwdir = $(WWWDIR)/codepot/language/korean
www_DATA = \
code_lang.php \
common_lang.php \
issue_lang.php \
index.html \

View File

@ -0,0 +1,9 @@
<?php
$lang['CODE_COMMIT'] = '커밋';
$lang['CODE_HIDE_DETAILS'] = '상세내역숨김';
$lang['CODE_PROPERTIES'] = '속성';
$lang['CODE_PROPERTY'] = '속성';
$lang['CODE_SHOW_DETAILS'] = '상세내역보기';
$lang['CODE_MSG_COMMITTED_BY_ON'] = '%s가 %s에 커밋함';
?>

View File

@ -6,6 +6,7 @@ www_DATA = \
ldaploginmodel.php \
loginmodel.php \
logmodel.php \
mysqlloginmodel.php \
projectmodel.php \
sitemodel.php \
subversionmodel.php \

View File

@ -172,6 +172,7 @@ www_DATA = \
ldaploginmodel.php \
loginmodel.php \
logmodel.php \
mysqlloginmodel.php \
projectmodel.php \
sitemodel.php \
subversionmodel.php \

View File

@ -0,0 +1,37 @@
<?php
require_once 'loginmodel.php';
class MysqlLoginModel extends LoginModel
{
function LdapLoginModel ()
{
parent::LoginModel ();
$this->load->database ('auth-mysql');
}
function authenticate ($userid, $password)
{
$this->db->trans_start ();
/*
TODO:
$this->db->select ('username');
$this->db->where ('username', $userid);
$this->db->where ('passwd', $userid);
*/
$this->db->trans_complete ();
if ($this->db->trans_status() === FALSE) return FALSE;
return parent::authenticate ($userid, $password, $email);
}
function queryUserInfo ($userid)
{
$user['id'] = '';
$user['email'] = '';
return $user;
}
}
?>

View File

@ -7,9 +7,21 @@ class SubversionModel extends Model
parent::Model ();
}
function _canonical_path($path)
{
$canonical = preg_replace('|/\.?(?=/)|','',$path);
while (($collapsed = preg_replace('|/[^/]+/\.\./|','/',$canonical,1)) !== $canonical)
{
$canonical = $collapsed;
}
$canonical = preg_replace('|^/\.\./|','/',$canonical);
return $canonical;
}
function getFile ($projectid, $path, $rev = SVN_REVISION_HEAD)
{
$url = 'file:///'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
//$url = 'file://'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
$url = 'file://'.$this->_canonical_path(CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}");
$info = @svn_info ($url, FALSE, $rev);
if ($info === FALSE || count($info) != 1) return FALSE;
@ -31,10 +43,20 @@ class SubversionModel extends Model
1, SVN_DISCOVER_CHANGED_PATHS);
if ($log === FALSE) return FALSE;
$prop = @svn_proplist ($url, FALSE, $rev);
if ($prop === FALSE) return FALSE;
if (array_key_exists ($url, $prop))
{
$fileinfo['properties'] = $prop[$url];
}
else $fileinfo['properties'] = NULL;
$fileinfo['fullpath'] = substr (
$info[0]['url'], strlen($info[0]['repos']));
$fileinfo['content'] = $str;
$fileinfo['logmsg'] = (count($log) > 0)? $log[0]['msg']: '';
return $fileinfo;
}
else if ($info[0]['kind'] == SVN_NODE_DIR)
@ -52,6 +74,13 @@ class SubversionModel extends Model
if ($log === FALSE) return FALSE;
}
$prop = @svn_proplist ($url, FALSE, $rev);
if ($prop === FALSE) return FALSE;
if (array_key_exists ($url, $prop))
$fileinfo['properties'] = $prop[$url];
else $fileinfo['properties'] = NULL;
$fileinfo['fullpath'] = substr (
$info[0]['url'], strlen($info[0]['repos']));
$fileinfo['name'] = $info[0]['path'];
@ -69,7 +98,8 @@ class SubversionModel extends Model
function getBlame ($projectid, $path, $rev = SVN_REVISION_HEAD)
{
$url = 'file:///'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
//$url = 'file:///'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
$url = 'file://'.$this->_canonical_path(CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}");
$info = @svn_info ($url, FALSE, $rev);
if ($info === FALSE || count($info) != 1) return FALSE;
@ -100,7 +130,8 @@ class SubversionModel extends Model
function getHistory ($projectid, $path, $rev = SVN_REVISION_HEAD)
{
$url = 'file:///'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
//$url = 'file:///'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
$url = 'file://'.$this->_canonical_path(CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}");
$info = @svn_info ($url, FALSE, $rev);
if ($info === FALSE || count($info) != 1) return FALSE;
@ -134,7 +165,8 @@ class SubversionModel extends Model
function getRevHistory ($projectid, $path, $rev)
{
$url = 'file:///'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
//$url = 'file:///'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
$url = 'file://'.$this->_canonical_path(CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}");
$info = @svn_info ($url, FALSE, $rev);
if ($info === FALSE || count($info) != 1) return FALSE;
@ -420,7 +452,8 @@ class SubversionModel extends Model
//
function getDiff ($projectid, $path, $rev1, $rev2)
{
$url = 'file:///'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
//$url = 'file:///'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
$url = 'file://'.$this->_canonical_path(CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}");
$lsinfo1 = @svn_ls ($url, $rev1, FALSE, TRUE);
if ($lsinfo1 === FALSE || count($lsinfo1) != 1) return FALSE;
@ -504,7 +537,8 @@ class SubversionModel extends Model
function getPrevRev ($projectid, $path, $rev)
{
$url = 'file:///'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
//$url = 'file:///'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
$url = 'file://'.$this->_canonical_path(CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}");
$log = @svn_log (
$url, $rev, SVN_REVISION_INITIAL, 2,
@ -520,7 +554,8 @@ class SubversionModel extends Model
function getNextRev ($projectid, $path, $rev)
{
$url = 'file:///'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
//$url = 'file:///'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
$url = 'file://'.$this->_canonical_path(CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}");
$log = @svn_log (
$url, SVN_REVISION_HEAD, $rev, 0,
@ -557,7 +592,8 @@ class SubversionModel extends Model
function getHeadRev ($projectid, $path)
{
$url = 'file:///'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
//$url = 'file:///'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
$url = 'file://'.$this->_canonical_path(CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}");
$log = @svn_log (
$url, SVN_REVISION_HEAD, SVN_REVISION_INITIAL, 1,

View File

@ -10,6 +10,36 @@
<script type="text/javascript" src="<?=base_url()?>/js/prettify/lang-lua.js"></script>
<script type="text/javascript" src="<?=base_url()?>/js/prettify/lang-sql.js"></script>
<script type="text/javascript" src="<?=base_url()?>/js/prettify/lang-vb.js"></script>
<script type="text/javascript" src="<?=base_url()?>/js/jquery.min.js"></script>
<script type="text/javascript" src="<?=base_url()?>/js/jquery-ui.min.js"></script>
<link type="text/css" rel="stylesheet" href="<?=base_url()?>/css/jquery-ui.css" />
<script type="text/javascript">
$(function () {
if ($("#code_blame_mainarea_result_info").is(":visible"))
btn_label = "<?=$this->lang->line('CODE_HIDE_DETAILS')?>";
else
btn_label = "<?=$this->lang->line('CODE_SHOW_DETAILS')?>";
btn = $("#code_blame_mainarea_details_button").button({"label": btn_label}).click (function () {
if ($("#code_blame_mainarea_result_info").is(":visible"))
{
$("#code_blame_mainarea_result_info").hide();
$("#code_blame_mainarea_details_button").button(
"option", "label", "<?=$this->lang->line('CODE_SHOW_DETAILS')?>");
}
else
{
$("#code_blame_mainarea_result_info").show();
$("#code_blame_mainarea_details_button").button(
"option", "label", "<?=$this->lang->line('CODE_HIDE_DETAILS')?>");
}
});
});
</script>
<title><?=htmlspecialchars($project->name)?></title>
</head>
@ -112,12 +142,11 @@ print anchor ("code/history/{$project->id}/{$xpar}", $this->lang->line('History'
</div> <!-- code_blame_mainarea_menu -->
<div class="infostrip" id="code_blame_mainarea_infostrip">
<?=anchor ("code/file/{$project->id}/${xpar}/{$file['prev_rev']}", '<<')?>
<?=anchor ("code/blame/{$project->id}/${xpar}/{$file['prev_rev']}", '<<')?>
<?=$this->lang->line('Revision')?>: <?=$file['created_rev']?>
<?=anchor ("code/file/{$project->id}/${xpar}/{$file['next_rev']}", '>>')?> |
<?=$this->lang->line('Author')?>: <?=htmlspecialchars($file['last_author'])?> |
<?=anchor ("code/blame/{$project->id}/${xpar}/{$file['next_rev']}", '>>')?> |
<?=$this->lang->line('Size')?>: <?=$file['size']?> |
<?=$this->lang->line('Last updated on')?>: <?=$file['time']?>
<a id="code_blame_mainarea_details_button" href='#'><?=$this->lang->line('Details')?></a>
</div>
<div id="code_blame_mainarea_result">
@ -174,21 +203,34 @@ print anchor ("code/history/{$project->id}/{$xpar}", $this->lang->line('History'
</pre>
<div id="code_blame_mainarea_result_info">
<script language='javascript'>
function toggle_logmsg()
{
var x = document.getElementById ('code_blame_mainarea_result_info_logmsg');
if (x) x.style.visibility = (x.style.visibility == 'visible')? 'hidden': 'visible';
return false;
}
</script>
<div class="title"><?= $this->lang->line('CODE_COMMIT') ?></div>
<?php printf ($this->lang->line('CODE_MSG_COMMITTED_BY_ON'), $file['last_author'], $file['time']); ?>
<div class="title">
<a href='#' onClick='toggle_logmsg()'><?= $this->lang->line('Message') ?></a>
</div>
<pre id="code_blame_mainarea_result_info_logmsg" style="visibility: visible">
<div class="title"><?= $this->lang->line('Message') ?></div>
<pre id="code_blame_mainarea_result_info_logmsg">
<?= $file['logmsg'] ?>
</pre>
<?php
if (array_key_exists('properties', $file) && count($file['properties']) > 0)
{
print '<div class="title">';
print $this->lang->line('CODE_PROPERTIES');
print '</div>';
print '<ul id="code_blame_mainarea_result_info_property_list">';
foreach ($file['properties'] as $pn => $pv)
{
print '<li>';
print htmlspecialchars($pn);
print ' - ';
print htmlspecialchars($pv);
print '</li>';
}
print '</ul>';
}
?>
</pre>
</div> <!-- code_blame_mainarea_result_info -->
</div> <!-- code_blame_mainarea_result -->

View File

@ -10,6 +10,36 @@
<script type="text/javascript" src="<?=base_url()?>/js/prettify/lang-lua.js"></script>
<script type="text/javascript" src="<?=base_url()?>/js/prettify/lang-sql.js"></script>
<script type="text/javascript" src="<?=base_url()?>/js/prettify/lang-vb.js"></script>
<script type="text/javascript" src="<?=base_url()?>/js/jquery.min.js"></script>
<script type="text/javascript" src="<?=base_url()?>/js/jquery-ui.min.js"></script>
<link type="text/css" rel="stylesheet" href="<?=base_url()?>/css/jquery-ui.css" />
<script type="text/javascript">
$(function () {
if ($("#code_file_mainarea_result_info").is(":visible"))
btn_label = "<?=$this->lang->line('CODE_HIDE_DETAILS')?>";
else
btn_label = "<?=$this->lang->line('CODE_SHOW_DETAILS')?>";
btn = $("#code_file_mainarea_details_button").button({"label": btn_label}).click (function () {
if ($("#code_file_mainarea_result_info").is(":visible"))
{
$("#code_file_mainarea_result_info").hide();
$("#code_file_mainarea_details_button").button(
"option", "label", "<?=$this->lang->line('CODE_SHOW_DETAILS')?>");
}
else
{
$("#code_file_mainarea_result_info").show();
$("#code_file_mainarea_details_button").button(
"option", "label", "<?=$this->lang->line('CODE_HIDE_DETAILS')?>");
}
});
});
</script>
<title><?=htmlspecialchars($project->name)?></title>
</head>
@ -113,9 +143,8 @@ $this->load->view (
<?=anchor ("code/file/{$project->id}/${xpar}/{$file['prev_rev']}", '<<')?>
<?=$this->lang->line('Revision')?>: <?=$file['created_rev']?>
<?=anchor ("code/file/{$project->id}/${xpar}/{$file['next_rev']}", '>>')?> |
<?=$this->lang->line('Author')?>: <?=htmlspecialchars($file['last_author'])?> |
<?=$this->lang->line('Size')?>: <?=$file['size']?> |
<?=$this->lang->line('Last updated on')?>: <?=$file['time']?>
<a id="code_file_mainarea_details_button" href='#'><?=$this->lang->line('Details')?></a>
</div>
<div id="code_file_mainarea_result">
@ -153,21 +182,34 @@ if ($fileext == '') $fileext = "html"
<div id="code_file_mainarea_result_info">
<script language='javascript'>
function toggle_logmsg()
{
var x = document.getElementById ('code_file_mainarea_result_info_logmsg');
if (x) x.style.visibility = (x.style.visibility == 'visible')? 'hidden': 'visible';
return false;
}
</script>
<div class="title"><?= $this->lang->line('CODE_COMMIT') ?></div>
<?php printf ($this->lang->line('CODE_MSG_COMMITTED_BY_ON'), $file['last_author'], $file['time']); ?>
<div class="title">
<a href='#' onClick='toggle_logmsg()'><?= $this->lang->line('Message') ?></a>
</div>
<pre id="code_file_mainarea_result_info_logmsg" style="visibility: visible">
<div class="title"><?= $this->lang->line('Message') ?></div>
<pre id="code_file_mainarea_result_info_logmsg">
<?= $file['logmsg'] ?>
</pre>
<?php
if (array_key_exists('properties', $file) && count($file['properties']) > 0)
{
print '<div class="title">';
print $this->lang->line('CODE_PROPERTIES');
print '</div>';
print '<ul id="code_file_mainarea_result_info_property_list">';
foreach ($file['properties'] as $pn => $pv)
{
print '<li>';
print htmlspecialchars($pn);
print ' - ';
print htmlspecialchars($pv);
print '</li>';
}
print '</ul>';
}
?>
</pre>
</div> <!-- code_file_mainarea_result_info -->
</div> <!-- code_file_mainarea_result -->

View File

@ -35,12 +35,19 @@ function load_ini ($file)
array ('max_logs_in_site_home', 'integer', 10),
array ('max_logs_in_project_home', 'integer', 5),
array ('database_hostname', 'string', 'localhost'),
array ('database_username', 'string', ''),
array ('database_password', 'string', ''),
array ('database_name', 'string', ''),
array ('database_driver', 'string', ''),
array ('database_prefix', 'string', ''),
array ('auth_mysql_hostname', 'string', 'localhost'),
array ('auth_mysql_username', 'string', ''),
array ('auth_mysql_password', 'string', ''),
array ('auth_mysql_name', 'string', ''),
array ('auth_mysql_prefix', 'string', ''),
array ('ldap_server_host', 'string', '127.0.0.1'),
array ('ldap_server_port', 'integer', 389),
array ('ldap_server_protocol_version', 'integer', 3),

View File

@ -28,9 +28,14 @@
#code_file_mainarea_result_info {
position: absolute;
top: 0;
right: 0;
top: 5;
right: 5;
width: 22em;
background: #E5ECF9 none repeat scroll 0 0;
border: #D4DBE8 1px solid;
overflow: auto;
padding: 0.2em 0.4em 0.2em 0.4em;
font-size: 0.9em;
}
#code_file_mainarea_result_info pre {
@ -38,24 +43,20 @@
border: 0;
margin: 0;
padding: 0;
background-color: inherit;
white-space: -moz-pre-wrap;
white-space: -o-pre-wrap;
white-space: pre-wrap;
}
#code_file_mainarea_result_info .title {
background-color: #7777FF;
border: 0;
margin: 0;
font-size: 0.8em;
text-align: right;
}
#code_file_mainarea_result_info .title a {
color: white;
background-color: #8888FF;
color: #FFFFFF;
border: #D4DBE8 1px solid;
margin: 0.3em 0 0.3em 0;
padding: 0.1em 0.1em 0.1em 0.1em;
font-size: inherit;
background-color: inherit;
}
#code_file_mainarea_result_info .title a:hover {
background-color: inherit;
text-transform: uppercase;
}
/*-----------------------------------------------
@ -72,9 +73,14 @@
#code_blame_mainarea_result_info {
position: absolute;
top: 0;
right: 0;
top: 5;
right: 5;
width: 22em;
background: #E5ECF9 none repeat scroll 0 0;
border: #D4DBE8 1px solid;
overflow: auto;
padding: 0.2em 0.4em 0.2em 0.4em;
font-size: 0.9em;
}
#code_blame_mainarea_result_info pre {
@ -82,24 +88,20 @@
border: 0;
margin: 0;
padding: 0;
background-color: inherit;
white-space: -moz-pre-wrap;
white-space: -o-pre-wrap;
white-space: pre-wrap;
}
#code_blame_mainarea_result_info .title {
background-color: #7777FF;
border: 0;
margin: 0;
font-size: 0.8em;
text-align: right;
}
#code_blame_mainarea_result_info .title a {
color: white;
background-color: #8888FF;
color: #FFFFFF;
border: #D4DBE8 1px solid;
margin: 0.3em 0 0.3em 0;
padding: 0.1em 0.1em 0.1em 0.1em;
font-size: inherit;
background-color: inherit;
}
#code_blame_mainarea_result_info .title a:hover {
background-color: inherit;
text-transform: uppercase;
}
/*-----------------------------------------------
@ -127,6 +129,9 @@
background-color: inherit;
padding: 0;
margin: 0;
white-space: -moz-pre-wrap;
white-space: -o-pre-wrap;
white-space: pre-wrap;
}
#code_history_mainarea_result_table .title {