From 07a5b937f5b94d505cb1c23eaea33f21ceeeef5c Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 9 Apr 2015 09:33:04 +0000 Subject: [PATCH] added a new configuration item code_folder_readme --- codepot/etc/codepot.ini.in | 8 +++++ codepot/src/codepot/controllers/code.php | 45 ++++++++++++++++-------- codepot/src/config.php.in | 4 ++- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/codepot/etc/codepot.ini.in b/codepot/etc/codepot.ini.in index bd9b4908..76ca8550 100644 --- a/codepot/etc/codepot.ini.in +++ b/codepot/etc/codepot.ini.in @@ -238,3 +238,11 @@ svn_min_commit_message_length = "0" svn_restricted_topdirs = "" svn_restriction_allowed_subdir_depth_min = 0 svn_restriction_allowed_subdir_depth_max = 0 + + +;------------------------------------------------------------------------------ +; List of README files to show in the code folder view. +; The first file found is shown. You can specify multiple file name +; separated by a comma. +;------------------------------------------------------------------------------ +code_folder_readme = "README.wiki,README.txt,README"; diff --git a/codepot/src/codepot/controllers/code.php b/codepot/src/codepot/controllers/code.php index e5fe3f40..7fc816b5 100644 --- a/codepot/src/codepot/controllers/code.php +++ b/codepot/src/codepot/controllers/code.php @@ -110,13 +110,18 @@ class Code extends Controller $data['readme_text'] = ''; $data['readme_file'] = ''; - foreach (array('README.wiki', 'README.txt', 'README') as $rf) + foreach (explode(',', CODEPOT_CODE_FOLDER_README) as $rf) { - $readme = $this->subversion->getFile ($projectid, $path . '/' . $rf, $rev); - if ($readme !== FALSE) + $rf = trim($rf); + if (strlen($rf) > 0) { - $data['readme_text'] = $readme['content']; - $data['readme_file'] = $rf; + $readme = $this->subversion->getFile ($projectid, $path . '/' . $rf, $rev); + if ($readme !== FALSE) + { + $data['readme_text'] = $readme['content']; + $data['readme_file'] = $rf; + break; + } } } $this->load->view ($this->VIEW_FOLDER, $data); @@ -576,13 +581,18 @@ class Code extends Controller $data['readme_text'] = ''; $data['readme_file'] = ''; - foreach (array('README.wiki', 'README.txt', 'README') as $rf) + foreach (explode(',', CODEPOT_CODE_FOLDER_README) as $rf) { - $readme = $this->subversion->getFile ($projectid, $path . '/' . $rf, $rev); - if ($readme !== FALSE) + $rf = trim($rf); + if (strlen($rf) > 0) { - $data['readme_text'] = $readme['content']; - $data['readme_file'] = $rf; + $readme = $this->subversion->getFile ($projectid, $path . '/' . $rf, $rev); + if ($readme !== FALSE) + { + $data['readme_text'] = $readme['content']; + $data['readme_file'] = $rf; + break; + } } } $this->load->view ($this->VIEW_FOLDER, $data); @@ -648,13 +658,18 @@ class Code extends Controller $data['readme_text'] = ''; $data['readme_file'] = ''; - foreach (array('README.wiki', 'README.txt', 'README') as $rf) + foreach (explode(',', CODEPOT_CODE_FOLDER_README) as $rf) { - $readme = $this->subversion->getFile ($projectid, $path . '/' . $rf, $rev); - if ($readme !== FALSE) + $rf = trim($rf); + if (strlen($rf) > 0) { - $data['readme_text'] = $readme['content']; - $data['readme_file'] = $rf; + $readme = $this->subversion->getFile ($projectid, $path . '/' . $rf, $rev); + if ($readme !== FALSE) + { + $data['readme_text'] = $readme['content']; + $data['readme_file'] = $rf; + break; + } } } $this->load->view ($this->VIEW_FOLDER, $data); diff --git a/codepot/src/config.php.in b/codepot/src/config.php.in index cdd1c44a..115143a5 100644 --- a/codepot/src/config.php.in +++ b/codepot/src/config.php.in @@ -87,7 +87,9 @@ function load_ini ($file) array ('svn_min_commit_message_length', 'integer', 0), array ('svn_restricted_topdirs', 'string', ''), array ('svn_restriction_allowed_subdir_depth_min', 'integer', 0), - array ('svn_restriction_allowed_subdir_depth_max', 'integer', 0) + array ('svn_restriction_allowed_subdir_depth_max', 'integer', 0), + + array ('code_folder_readme', 'string', 'README') ); foreach ($xcfgs as $x)