renamed 'sysadmin_userid' to 'sysadmin_userids' to support multiple sysadmin ids.
added svn commit history to the project home page
This commit is contained in:
parent
7af7fff45c
commit
ebeb0481ce
@ -3,7 +3,7 @@ Version: @VERSION@
|
||||
Maintainer: @PACKAGE_BUGREPORT@
|
||||
Homepage: @PACKAGE_URL@
|
||||
Depends: subversion, apache2-mpm-prefork, libapache2-svn, php5, php5-ldap, wget
|
||||
Recommends: php5-mysql, php5-svn
|
||||
Recommends: php5-mysql, php5-svn (>= 0.5.1)
|
||||
Suggests: slapd, mysql-server
|
||||
Section: web
|
||||
Priority: optional
|
||||
|
10
codepot/configure
vendored
10
codepot/configure
vendored
@ -2,7 +2,7 @@
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.64 for codepot 0.1.0.
|
||||
#
|
||||
# Report bugs to <Chung, Hyung-Hwan <hyunghwan.chung@gmail.com>>.
|
||||
# Report bugs to <Hyung-Hwan Chung <hyunghwan.chung@gmail.com>>.
|
||||
#
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
|
||||
# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software
|
||||
@ -227,7 +227,7 @@ fi
|
||||
$as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
|
||||
$as_echo "$0: be upgraded to zsh 4.3.4 or later."
|
||||
else
|
||||
$as_echo "$0: Please tell bug-autoconf@gnu.org and Chung, Hyung-Hwan
|
||||
$as_echo "$0: Please tell bug-autoconf@gnu.org and Hyung-Hwan Chung
|
||||
$0: <hyunghwan.chung@gmail.com> about your system,
|
||||
$0: including any error possibly output before this
|
||||
$0: message. Then install a modern shell, or manually run
|
||||
@ -550,7 +550,7 @@ PACKAGE_NAME='codepot'
|
||||
PACKAGE_TARNAME='codepot'
|
||||
PACKAGE_VERSION='0.1.0'
|
||||
PACKAGE_STRING='codepot 0.1.0'
|
||||
PACKAGE_BUGREPORT='Chung, Hyung-Hwan <hyunghwan.chung@gmail.com>'
|
||||
PACKAGE_BUGREPORT='Hyung-Hwan Chung <hyunghwan.chung@gmail.com>'
|
||||
PACKAGE_URL='http://www.abiyo.net/codepot'
|
||||
|
||||
ac_subst_vars='LTLIBOBJS
|
||||
@ -1270,7 +1270,7 @@ Optional Packages:
|
||||
--with-logdir directory for log files
|
||||
--with-cachedir directory for cache files
|
||||
|
||||
Report bugs to <Chung, Hyung-Hwan <hyunghwan.chung@gmail.com>>.
|
||||
Report bugs to <Hyung-Hwan Chung <hyunghwan.chung@gmail.com>>.
|
||||
codepot home page: <http://www.abiyo.net/codepot>.
|
||||
_ACEOF
|
||||
ac_status=$?
|
||||
@ -3532,7 +3532,7 @@ $config_files
|
||||
Configuration headers:
|
||||
$config_headers
|
||||
|
||||
Report bugs to <Chung, Hyung-Hwan <hyunghwan.chung@gmail.com>>.
|
||||
Report bugs to <Hyung-Hwan Chung <hyunghwan.chung@gmail.com>>.
|
||||
codepot home page: <http://www.abiyo.net/codepot>."
|
||||
|
||||
_ACEOF
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
dnl AC_PREREQ(2.59)
|
||||
|
||||
AC_INIT([codepot],[0.1.0],[Chung, Hyung-Hwan <hyunghwan.chung@gmail.com>],,[http://www.abiyo.net/codepot])
|
||||
AC_INIT([codepot],[0.1.0],[Hyung-Hwan Chung <hyunghwan.chung@gmail.com>],,[http://www.abiyo.net/codepot])
|
||||
AC_CONFIG_HEADER([./config.h])
|
||||
AC_CONFIG_AUX_DIR([ac/aux])
|
||||
AC_CONFIG_MACRO_DIR([ac/m4])
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
cfgdir=$(CFGDIR)
|
||||
cfg_DATA = codepot.ini codepot.sql codepot.a2ldap
|
||||
cfg_SCRIPTS = repo.sh start-commit post-commit
|
||||
cfg_SCRIPTS = repo.sh start-commit pre-commit post-commit
|
||||
|
||||
EXTRA_DIST = $(cfg_DATA) $(cfg_SCRIPTS)
|
||||
|
||||
|
@ -166,7 +166,7 @@ top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
wwwdir = @wwwdir@
|
||||
cfg_DATA = codepot.ini codepot.sql codepot.a2ldap
|
||||
cfg_SCRIPTS = repo.sh start-commit post-commit
|
||||
cfg_SCRIPTS = repo.sh start-commit pre-commit post-commit
|
||||
EXTRA_DIST = $(cfg_DATA) $(cfg_SCRIPTS)
|
||||
all: all-am
|
||||
|
||||
|
@ -75,9 +75,11 @@ svn_base_url = "http://${SERVER_NAME}:${SERVER_PORT}/svn"
|
||||
login_model = "LdapLoginModel"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; System administrator ID
|
||||
; Comma separated list of system administrator IDs
|
||||
;------------------------------------------------------------------------------
|
||||
sysadmin_userid =
|
||||
; sysadmin_userids = tom, dick, jane
|
||||
;------------------------------------------------------------------------------
|
||||
sysadmin_userids =
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Maximum file upload size in Kbytes
|
||||
@ -94,6 +96,10 @@ max_latest_projects = "10"
|
||||
;------------------------------------------------------------------------------
|
||||
max_svn_commits = "10"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Maximum number of svn commits to show in the project home page
|
||||
;------------------------------------------------------------------------------
|
||||
max_svn_commits_in_project = "5"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; directory to accomodate subversion repositories
|
||||
|
@ -76,7 +76,8 @@ CREATE TABLE file (
|
||||
CREATE TABLE log (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
type VARCHAR(16) NOT NULL,
|
||||
projectid VARCHAR(32) NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
createdon DATETIME NOT NULL,
|
||||
INDEX timed_type (createdon, type)
|
||||
INDEX timed_type_project (createdon, type, projectid)
|
||||
) charset=utf8 engine=InnoDB;
|
||||
|
@ -1,13 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
post_commit() {
|
||||
local repo_path="$1"
|
||||
local rev="$2"
|
||||
local repo="`basename "${repo_path}"`"
|
||||
REPOBASE="`basename "${1}"`"
|
||||
REV="${2}"
|
||||
|
||||
ans="`wget -q -O- "%API%/logSvnCommit/${repo}/${rev}" 2>/dev/null`"
|
||||
return 0
|
||||
}
|
||||
|
||||
post_commit "$1" "$2"
|
||||
exit $?
|
||||
# does not care if logging has failed.
|
||||
wget -q -O- "%API%/logSvnCommit/${REPOBASE}/${REV}" 2>/dev/null
|
||||
exit 0
|
||||
|
29
codepot/etc/pre-commit
Executable file
29
codepot/etc/pre-commit
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
REPO="$1"
|
||||
TXN="$2"
|
||||
|
||||
# TODO: need to check the policy on a commit message
|
||||
# wget ... %API%/svnPolicy/ ...
|
||||
# once done, update repo.sh to include pre-commit
|
||||
|
||||
svnlook log -t "$TXN" "$REPO" | grep "[a-zA-Z0-9]" >/dev/null || {
|
||||
echo "---------------------------------------------------------" >&2
|
||||
echo " Your commit message do not contain any meaningful text. " >&2
|
||||
echo "---------------------------------------------------------" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
#
|
||||
# Subversion problem:
|
||||
# Hard to detect the tagging patterns and update patterns on a tag.
|
||||
#
|
||||
#svnlook changed -t "$TXN" "$REPO" | grep '^tags/' >/dev/null && {
|
||||
# echo "----------------------------------------------------" >&2
|
||||
# echo " You are not allowed to change tags/* " >&2
|
||||
# echo "----------------------------------------------------" >&2
|
||||
# exit 1
|
||||
#}
|
||||
#
|
||||
|
||||
exit 0
|
@ -29,6 +29,14 @@ make_repo() {
|
||||
chmod 0755 "${repodir}/start-commit"
|
||||
#}
|
||||
|
||||
#[ -f "${repodir}/pre-commit" ] || {
|
||||
# sed "s|%API%|${api}|g" "${cfgdir}/pre-commit" > "${repodir}/pre-commit" || {
|
||||
# echo "ERROR: cannot install pre-commit to ${repodir}"
|
||||
# return 1;
|
||||
# }
|
||||
# chmod 0755 "${repodir}/pre-commit"
|
||||
#}
|
||||
|
||||
#[ -f "${repodir}/post-commit" ] || {
|
||||
sed "s|%API%|${api}|g" "${cfgdir}/post-commit" > "${repodir}/post-commit" || {
|
||||
echo "ERROR: cannot install post-commit to ${repodir}"
|
||||
|
@ -1,21 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
start_commit() {
|
||||
local repo_path="$1"
|
||||
local user="$2"
|
||||
local repo="`basename "${repo_path}"`"
|
||||
REPOBASE="`basename "${1}"`"
|
||||
USER="${2}"
|
||||
|
||||
ans="`wget -q -O- "%API%/projectHasMember/${repo}/${user}" 2>/dev/null`"
|
||||
[ "${ans}" = "YES" ] && return 0;
|
||||
ans="`wget -q -O- "%API%/projectHasMember/${REPOBASE}/${USER}" 2>/dev/null`"
|
||||
[ "${ans}" = "YES" ] && exit 0
|
||||
|
||||
[ "${ans}" = "NO" ] && {
|
||||
echo "${user} is not a member of ${repo}" >&2
|
||||
return 1
|
||||
echo "-------------------------------------------------------------" >&2
|
||||
echo " ${USER} is not a member of ${REPOBASE}" >&2
|
||||
echo "-------------------------------------------------------------" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "Critical error occurred while checking project membership of ${repo} for ${user}" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
start_commit "$1" "$2"
|
||||
exit $?
|
||||
echo "---------------------------------------------------------------------" >&2
|
||||
echo " Failed to check membership of ${REPOBASE} for ${USER}" >&2
|
||||
echo "---------------------------------------------------------------------" >&2
|
||||
exit 1
|
||||
|
@ -9,6 +9,8 @@ class API extends Controller
|
||||
|
||||
function projectHasMember ($projectid, $userid)
|
||||
{
|
||||
if (!isset($projectid) || !isset($userid)) return 'NO';
|
||||
|
||||
// TODO: access control - may allow localhost only
|
||||
$this->load->model ('ProjectModel', 'projects');
|
||||
print ($this->projects->projectHasMember ($projectid, $userid) === FALSE)? 'NO': 'YES';
|
||||
@ -16,6 +18,8 @@ class API extends Controller
|
||||
|
||||
function projectIsOwnedBy ($projectid, $userid)
|
||||
{
|
||||
if (!isset($projectid) || !isset($userid)) return 'NO';
|
||||
|
||||
// TODO: access control - may allow localhost only
|
||||
$this->load->model ('ProjectModel', 'projects');
|
||||
print ($this->projects->projectIsOwnedBy ($projectid, $userid) === FALSE)? 'NO': 'YES';
|
||||
@ -23,6 +27,8 @@ class API extends Controller
|
||||
|
||||
function logSvnCommit ($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);
|
||||
|
@ -23,6 +23,7 @@ class Project extends Controller
|
||||
function home ($projectid = "")
|
||||
{
|
||||
$this->load->model ('ProjectModel', 'projects');
|
||||
$this->load->model ('LogModel', 'logs');
|
||||
|
||||
$login = $this->login->getUser ();
|
||||
if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '')
|
||||
@ -42,11 +43,22 @@ class Project extends Controller
|
||||
$this->load->view ($this->VIEW_ERROR, $data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$svn_commits = $this->logs->getSvnCommits (
|
||||
CODEPOT_MAX_SVN_COMMITS_IN_PROJECT, $projectid);
|
||||
if ($svn_commits === FALSE)
|
||||
{
|
||||
$data['message'] = 'DATABASE ERROR';
|
||||
$this->load->view ($this->VIEW_ERROR, $data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['project'] = $project;
|
||||
$data['svn_commits'] = $svn_commits;
|
||||
$this->load->view ($this->VIEW_HOME, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _edit_project ($project, $mode, $login)
|
||||
{
|
||||
|
@ -42,11 +42,23 @@ class LoginModel extends Model
|
||||
function authenticate ($userid, $password)
|
||||
{
|
||||
$server = $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'];
|
||||
|
||||
$sysadmin = FALSE;
|
||||
$ids = explode (',', CODEPOT_SYSADMIN_USERIDS);
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
if (trim($id) == $userid)
|
||||
{
|
||||
$sysadmin = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->session->set_userdata (
|
||||
array (
|
||||
'userid' => $userid,
|
||||
'server' => $server,
|
||||
'sysadmin?' => ($userid == CODEPOT_SYSADMIN_USERID)
|
||||
'sysadmin?' => $sysadmin
|
||||
)
|
||||
);
|
||||
return TRUE;
|
||||
|
@ -8,34 +8,12 @@ class LogModel extends Model
|
||||
$this->load->database ();
|
||||
}
|
||||
|
||||
/*
|
||||
function get ($id)
|
||||
{
|
||||
$this->db->trans_start ();
|
||||
|
||||
$this->db->where ('id', (string)$id);
|
||||
$query = $this->db->get ('log');
|
||||
|
||||
$result = $query->result ();
|
||||
if (empty($result))
|
||||
{
|
||||
$this->db->trans_complete ();
|
||||
if ($this->db->trans_status() === FALSE) return FALSE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$this->db->trans_complete ();
|
||||
if ($this->db->trans_status() === FALSE) return FALSE;
|
||||
|
||||
return $result[0];
|
||||
}
|
||||
*/
|
||||
|
||||
function getSvnCommits ($limit)
|
||||
function getSvnCommits ($limit, $projectid = '')
|
||||
{
|
||||
$this->db->trans_start ();
|
||||
|
||||
$this->db->where ('type', 'svn-commit');
|
||||
if ($projectid != '') $this->db->where ('projectid', $projectid);
|
||||
$this->db->order_by ('createdon', 'desc');
|
||||
$query = $this->db->get ('log', $limit);
|
||||
|
||||
@ -49,7 +27,8 @@ class LogModel extends Model
|
||||
{
|
||||
list($repo,$rev) = split('[,]', $row->message);
|
||||
|
||||
$commits[$count]['repo'] = $repo;
|
||||
/* $row->project must be equal to $repo */
|
||||
$commits[$count]['repo'] = $row->projectid;
|
||||
$commits[$count]['rev'] = $rev;
|
||||
|
||||
$log = @svn_log (
|
||||
@ -77,6 +56,7 @@ class LogModel extends Model
|
||||
function writeSvnCommit ($repo, $rev)
|
||||
{
|
||||
$log->type = 'svn-commit';
|
||||
$log->projectid = $repo;
|
||||
$log->message = "{$repo},{$rev}";
|
||||
$this->write ($log);
|
||||
}
|
||||
@ -86,6 +66,7 @@ class LogModel extends Model
|
||||
$this->db->trans_begin ();
|
||||
|
||||
$this->db->set ('type', $log->type);
|
||||
$this->db->set ('projectid', $log->projectid);
|
||||
$this->db->set ('message', $log->message);
|
||||
$this->db->set ('createdon', date('Y-m-d H:i:s'));
|
||||
$this->db->insert ('log');
|
||||
|
@ -82,6 +82,40 @@ $this->load->view (
|
||||
<?= anchor ($this->converter->expand(CODEPOT_SVN_BASE_URL, $_SERVER) . '/' . $project->id) ?>
|
||||
</div>
|
||||
|
||||
<div class="box">
|
||||
<div class="boxtitle"><?=$this->lang->line('SVN commits')?></div>
|
||||
<table id="project_home_mainarea_sidebar_svn_commits_table">
|
||||
<?php
|
||||
$xdot = $this->converter->AsciiToHex ('.');
|
||||
foreach ($svn_commits as $commit)
|
||||
{
|
||||
print '<tr class="odd">';
|
||||
print '<td>';
|
||||
print substr($commit['time'], 0, 10);
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
print anchor (
|
||||
"/source/revision/{$commit['repo']}/{$xdot}/{$commit['rev']}",
|
||||
$commit['rev']);
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
print htmlspecialchars ($commit['author']);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr class="even">';
|
||||
print '<td colspan=4>';
|
||||
$sm = strtok (trim ($commit['message']), "\r\n");
|
||||
print htmlspecialchars ($sm);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div> <!-- project_home_sidebar -->
|
||||
|
||||
<!---------------------------------------------------------------------------->
|
||||
|
@ -5,7 +5,7 @@ function show_projectbar ($con, $site, $project, $pageid, $ctxmenuitems)
|
||||
{
|
||||
print "<div class='title'>";
|
||||
|
||||
if (isset($project)) print $project->id;
|
||||
if (isset($project)) print $project->name;
|
||||
else if (isset($site) && $site->name != '') print htmlspecialchars($site->name);
|
||||
else print htmlspecialchars(CODEPOT_DEFAULT_BANNER);
|
||||
|
||||
|
@ -26,9 +26,10 @@ function load_ini ($file)
|
||||
array ('svn_base_url', 'string', 'http://${SERVER_NAME}:${SERVER_PORT}/svn'),
|
||||
|
||||
array ('login_model', 'string', 'LdapLoginModel'),
|
||||
array ('sysadmin_userid', 'string', ''),
|
||||
array ('sysadmin_userids', 'string', ''),
|
||||
array ('max_upload_size', 'string', '10000'), // kbytes
|
||||
array ('max_svn_commits', 'integer', 10),
|
||||
array ('max_svn_commits_in_project', 'integer', 5),
|
||||
array ('max_latest_projects', 'integer', 10),
|
||||
|
||||
array ('database_username', 'string', ''),
|
||||
|
@ -113,7 +113,6 @@ body {
|
||||
|
||||
.content .mainarea {
|
||||
padding: 0.2em 0em 0.2em 0em;
|
||||
min-height: 30em;
|
||||
}
|
||||
|
||||
.content .mainarea .title {
|
||||
@ -377,6 +376,7 @@ pre.prettyprint .nocode a:hover {
|
||||
}
|
||||
|
||||
.content .footer {
|
||||
clear: both;
|
||||
padding: 0.3em 0.5em 0.3em 0.5em;
|
||||
font-size: .8em;
|
||||
font-weight: bold;
|
||||
|
@ -22,6 +22,23 @@
|
||||
background-color: inherit;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------
|
||||
* project home view
|
||||
*-----------------------------------------------*/
|
||||
#project_home_mainarea_sidebar_svn_commits_table {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#project_home_mainarea_sidebar_svn_commits_table tr.odd {
|
||||
background-color: #bbccef;
|
||||
}
|
||||
|
||||
#project_home_mainarea_sidebar_svn_commits_table tr.even {
|
||||
background-color: inherit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------
|
||||
* project file home view
|
||||
|
Loading…
Reference in New Issue
Block a user