diff --git a/codepot/etc/codepot.ini.in b/codepot/etc/codepot.ini.in index a53fe69c..78599f7c 100644 --- a/codepot/etc/codepot.ini.in +++ b/codepot/etc/codepot.ini.in @@ -37,16 +37,24 @@ ldap_password_format = "${password}" ;------------------------------------------------------------------------------ language = "auto" -;------------------------------------------------------------------------------ -; When set to yes, viewing pages require a user to sign in. -;------------------------------------------------------------------------------ -always_require_signin = "no" - ;------------------------------------------------------------------------------ ; Use websvn as a repository browser. ;------------------------------------------------------------------------------ enable_websvn = "no" +;------------------------------------------------------------------------------ +; When set to yes, viewing pages require a user to sign in. +;------------------------------------------------------------------------------ +singin_compulsory = "no" + +;------------------------------------------------------------------------------ +; When set to yes, non-http access is diverted to https using +; the base URL specified in https_base_url. api calls are not affected. +; change api_base_url to force https api calls instead. +;------------------------------------------------------------------------------ +https_compulsory = "no" +https_url = "https://${SERVER_NAME}${REQUEST_URI}" + ;------------------------------------------------------------------------------ ; API base URL ;------------------------------------------------------------------------------ diff --git a/codepot/src/codepot/controllers/file.php b/codepot/src/codepot/controllers/file.php index 70395d2c..fa53121d 100644 --- a/codepot/src/codepot/controllers/file.php +++ b/codepot/src/codepot/controllers/file.php @@ -26,7 +26,7 @@ class File extends Controller $this->load->model ('FileModel', 'files'); $login = $this->login->getUser (); - if (CODEPOT_ALWAYS_REQUIRE_SIGNIN && $login['id'] == '') + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') redirect ('main/signin'); $data['login'] = $login; @@ -64,7 +64,7 @@ class File extends Controller $this->load->model ('FileModel', 'files'); $login = $this->login->getUser (); - if (CODEPOT_ALWAYS_REQUIRE_SIGNIN && $login['id'] == '') + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') redirect ('main/signin'); $data['login'] = $login; @@ -109,7 +109,7 @@ class File extends Controller $this->load->model ('FileModel', 'files'); $login = $this->login->getUser (); - if (CODEPOT_ALWAYS_REQUIRE_SIGNIN && $login['id'] == '') + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') redirect ('main/signin'); $data['login'] = $login; diff --git a/codepot/src/codepot/controllers/project.php b/codepot/src/codepot/controllers/project.php index 77a1b216..b28a5584 100644 --- a/codepot/src/codepot/controllers/project.php +++ b/codepot/src/codepot/controllers/project.php @@ -25,7 +25,7 @@ class Project extends Controller $this->load->model ('ProjectModel', 'projects'); $login = $this->login->getUser (); - if (CODEPOT_ALWAYS_REQUIRE_SIGNIN && $login['id'] == '') + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') redirect ('main/signin'); $data['login'] = $login; diff --git a/codepot/src/codepot/controllers/source.php b/codepot/src/codepot/controllers/source.php index 9db21829..386095ca 100644 --- a/codepot/src/codepot/controllers/source.php +++ b/codepot/src/codepot/controllers/source.php @@ -33,7 +33,7 @@ class Source extends Controller $this->load->model ('SubversionModel', 'subversion'); $login = $this->login->getUser (); - if (CODEPOT_ALWAYS_REQUIRE_SIGNIN && $login['id'] == '') + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') redirect ('main/signin'); $data['login'] = $login; @@ -105,7 +105,7 @@ class Source extends Controller $this->load->model ('SubversionModel', 'subversion'); $login = $this->login->getUser (); - if (CODEPOT_ALWAYS_REQUIRE_SIGNIN && $login['id'] == '') + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') redirect ('main/signin'); $data['login'] = $login; @@ -164,7 +164,7 @@ class Source extends Controller $this->load->model ('SubversionModel', 'subversion'); $login = $this->login->getUser (); - if (CODEPOT_ALWAYS_REQUIRE_SIGNIN && $login['id'] == '') + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') redirect ('main/signin'); $data['login'] = $login; @@ -213,7 +213,7 @@ class Source extends Controller $this->load->model ('SubversionModel', 'subversion'); $login = $this->login->getUser (); - if (CODEPOT_ALWAYS_REQUIRE_SIGNIN && $login['id'] == '') + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') redirect ('main/signin'); $data['login'] = $login; @@ -262,7 +262,7 @@ class Source extends Controller $this->load->model ('SubversionModel', 'subversion'); $login = $this->login->getUser (); - if (CODEPOT_ALWAYS_REQUIRE_SIGNIN && $login['id'] == '') + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') redirect ('main/signin'); $data['login'] = $login; diff --git a/codepot/src/codepot/controllers/user.php b/codepot/src/codepot/controllers/user.php index 07714886..898047b5 100644 --- a/codepot/src/codepot/controllers/user.php +++ b/codepot/src/codepot/controllers/user.php @@ -27,7 +27,7 @@ class User extends Controller function home () { $login = $this->login->getUser (); - if (CODEPOT_ALWAYS_REQUIRE_SIGNIN && $login['id'] == '') + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') redirect ('main/signin'); $this->load->model ('SiteModel', 'sites'); @@ -74,7 +74,7 @@ class User extends Controller function projectlist () { $login = $this->login->getUser (); - if (CODEPOT_ALWAYS_REQUIRE_SIGNIN && $login['id'] == '') + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') redirect ('main/signin'); $this->load->model ('ProjectModel', 'projects'); diff --git a/codepot/src/codepot/controllers/wiki.php b/codepot/src/codepot/controllers/wiki.php index 0a9464ac..5672fe50 100644 --- a/codepot/src/codepot/controllers/wiki.php +++ b/codepot/src/codepot/controllers/wiki.php @@ -28,7 +28,7 @@ class Wiki extends Controller $this->load->model ('WikiModel', 'wikis'); $login = $this->login->getUser (); - if (CODEPOT_ALWAYS_REQUIRE_SIGNIN && $login['id'] == '') + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') redirect ('main/signin'); $data['login'] = $login; @@ -66,7 +66,7 @@ class Wiki extends Controller $this->load->model ('WikiModel', 'wikis'); $login = $this->login->getUser (); - if (CODEPOT_ALWAYS_REQUIRE_SIGNIN && $login['id'] == '') + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') redirect ('main/signin'); $data['login'] = $login; diff --git a/codepot/src/codepot/views/source_blame.php b/codepot/src/codepot/views/source_blame.php index 2157f106..940d64a4 100644 --- a/codepot/src/codepot/views/source_blame.php +++ b/codepot/src/codepot/views/source_blame.php @@ -121,7 +121,7 @@ print anchor ("source/history/{$project->id}/{$xpar}", $this->lang->line('Histor if ($fileext == "") $fileext = "html" ?> -
+
 load->view (
 				$diffclass = array_key_exists('rev1diffclass', $x)? $x['rev1diffclass']: 'diff';
 				print "";
 				print "
";
-				print htmlspecialchars($x['rev1line']);
+				if ($x['rev1line'] == '') print ' ';
+				else print htmlspecialchars($x['rev1line']);
 				print '
'; print ''; } @@ -200,7 +201,8 @@ $this->load->view ( $diffclass = array_key_exists('rev2diffclass', $x)? $x['rev2diffclass']: 'diff'; print ""; print "
";
-				print htmlspecialchars($x['rev2line']);
+				if ($x['rev2line'] == '') print ' ';
+				else print htmlspecialchars($x['rev2line']);
 				print '
'; print ''; } diff --git a/codepot/src/config.php.in b/codepot/src/config.php.in index df5b628d..9d991b30 100644 --- a/codepot/src/config.php.in +++ b/codepot/src/config.php.in @@ -13,12 +13,15 @@ function load_ini ($file) if (/*$cfg === FALSE*/ $cfg == FALSE) die ("ERROR: cannot parse $file"); $xcfgs = array ( - array ('default_banner', 'string', '@PACKAGE@'), array ('default_siteid', 'string', 'default'), + array ('default_banner', 'string', '@PACKAGE@'), + array ('language', 'string', 'auto'), - array ('always_require_signin', 'boolean', FALSE), array ('enable_websvn', 'boolean', FALSE), + array ('signin_compulsory', 'boolean', FALSE), + array ('https_compulsory', 'boolean', FALSE), + array ('https_url', 'string', 'https://${SERVER_NAME}${REQUEST_URI}'), array ('api_base_url', 'string', 'http://127.0.0.1'), array ('svn_base_url', 'string', 'http://${SERVER_NAME}:${SERVER_PORT}/svn'), diff --git a/codepot/src/css/common.css b/codepot/src/css/common.css index d690baf7..f07202da 100644 --- a/codepot/src/css/common.css +++ b/codepot/src/css/common.css @@ -121,6 +121,7 @@ body { margin-top: 0.2em; margin-bottom: 0.2em; font-weight: bold; + overflow: auto; } .content .mainarea .title a { diff --git a/codepot/src/css/project.css b/codepot/src/css/project.css index 273d2c79..ae28e1d1 100644 --- a/codepot/src/css/project.css +++ b/codepot/src/css/project.css @@ -54,6 +54,11 @@ position: relative; } +#project_source_file_mainarea_result_pre { + /* make it the same as font-size of info .title below */ + padding-top: 0.8em; +} + #project_source_file_mainarea_result_info { position: absolute; top: 0; @@ -93,6 +98,11 @@ position: relative; } +#project_source_blame_mainarea_result_pre { + /* make it the same as font-size of info .title below */ + padding-top: 0.8em; +} + #project_source_blame_mainarea_result_info { position: absolute; top: 0; diff --git a/codepot/src/index.php b/codepot/src/index.php index f9cfa523..1216c843 100644 --- a/codepot/src/index.php +++ b/codepot/src/index.php @@ -39,6 +39,30 @@ define('FCPATH', str_replace(SELF, '', __FILE__)); define('BASEPATH', $system_folder.'/'); define('APPPATH', $application_folder.'/'); +/* +|--------------------------------------------------------------- +| COMPULSORY HTTPS +|--------------------------------------------------------------- +*/ +if (CODEPOT_HTTPS_COMPULSORY) +{ + if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on') + { + /* force https except api calls */ + + $tail = substr ($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME'])); + //$tail = $_SERVER['PATH_INFO']; + if (strncmp ($tail, "/api/", 5) != 0) + { + require_once dirname(__FILE__) . '/codepot/libraries/converter.php'; + $converter = new Converter (); + $url = $converter->expand (CODEPOT_HTTPS_URL, $_SERVER); + header("Location: $url"); + exit; + } + } +} + /* |--------------------------------------------------------------- | LOAD THE FRONT CONTROLLER