From 4e9605afce0c06e86a5b30114c6f5e5f029111ef Mon Sep 17 00:00:00 2001 From: bright-tools Date: Sun, 8 Nov 2015 22:06:45 +0000 Subject: [PATCH 1/5] Add support for ViewVC integration New plugin to allow linking of changeset information to an SVN repository fronted by ViewVC - http://www.viewvc.org/ --- SourceViewVC/LICENSE | 23 ++++ SourceViewVC/SourceViewVC.php | 169 ++++++++++++++++++++++++++ SourceViewVC/lang/strings_english.txt | 22 ++++ 3 files changed, 214 insertions(+) create mode 100755 SourceViewVC/LICENSE create mode 100755 SourceViewVC/SourceViewVC.php create mode 100755 SourceViewVC/lang/strings_english.txt diff --git a/SourceViewVC/LICENSE b/SourceViewVC/LICENSE new file mode 100755 index 000000000..9c6c2e6fb --- /dev/null +++ b/SourceViewVC/LICENSE @@ -0,0 +1,23 @@ +Copyright (c) 2015 John Bailey + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + diff --git a/SourceViewVC/SourceViewVC.php b/SourceViewVC/SourceViewVC.php new file mode 100755 index 000000000..cf329ea52 --- /dev/null +++ b/SourceViewVC/SourceViewVC.php @@ -0,0 +1,169 @@ +name = lang_get( 'plugin_SourceViewVC_title' ); + $this->description = lang_get( 'plugin_SourceViewVC_description' ); + + $this->version = '0.1'; + $this->requires = array( + 'MantisCore' => '1.2.0', + 'Source' => '0.16', + 'SourceSVN' => '0.16', + ); + + $this->author = 'John Bailey'; + $this->contact = 'dev@brightsilence.com'; + $this->url = 'https://github.com/bright-tools/source-integration'; + } + + public $type = 'viewvc'; + + public function show_type() { + return lang_get( 'plugin_SourceViewVC_svn' ); + } + + public function get_viewvc_url( $p_repo ) { + return isset( $p_repo->info['viewvc_url'] ) + ? $p_repo->info['viewvc_url'] + : ''; + } + + public function get_viewvc_name( $p_repo ) { + return isset( $p_repo->info['viewvc_name'] ) + ? $p_repo->info['viewvc_name'] + : ''; + } + + public function get_viewvc_use_checkout( $p_repo ) { + return isset( $p_repo->info['viewvc_use_checkout'] ) + ? $p_repo->info['viewvc_use_checkout'] + : false; + } + + public function get_viewvc_root_as_url( $p_repo ) { + return isset( $p_repo->info['viewvc_root_as_url'] ) + ? $p_repo->info['viewvc_root_as_url'] + : false; + } + + /** + * Builds the ViewVC URL base string + * @param object $p_repo repository + * @param string $p_file optional filename (as absolute path from root) + * @param array $p_opts optional additional ViewVC URL parameters + * @return string ViewVC URL + */ + protected function url_base( $p_repo, $p_file = '', $p_opts=array() ) { + $t_name = urlencode( $this->get_viewvc_name( $p_repo ) ); + $t_root_as_url = $this->get_viewvc_root_as_url( $p_repo ); + + $t_url = rtrim( $this->get_viewvc_url( $p_repo ), '/' ); + + if( $t_root_as_url ) { + $t_url_name = '/'.$t_name; + } else { + $t_url_name = ''; + $p_opts['root']=$t_name; + } + + return $t_url . $t_url_name . $p_file . '?' . http_build_query( $p_opts ); + } + + public function url_repo( $p_repo, $p_changeset=null ) { + $t_opts = array(); + + if ( !is_null( $p_changeset ) ) { + $t_opts['revision'] = $p_changeset->revision; + } + + return $this->url_base( $p_repo, '', $t_opts); + } + + public function url_changeset( $p_repo, $p_changeset ) { + $t_rev = $p_changeset->revision; + $t_opts = array(); + $t_opts['view'] = 'revision'; + $t_opts['revision'] = $t_rev; + + return $this->url_base( $p_repo, '', $t_opts ); + } + + public function url_file( $p_repo, $p_changeset, $p_file ) { + + # if the file has been removed, it doesn't exist in current revision + # so we generate a link to (current revision - 1) + $t_revision = ($p_file->action == 'rm') + ? $p_changeset->revision - 1 + : $p_changeset->revision; + $t_use_checkout = $this->get_viewvc_use_checkout( $p_repo ); + + $t_opts = array(); + $t_opts['revision'] = $t_revision; + + if( !$t_use_checkout ) + { + $t_opts['view'] = 'markup'; + } + + return $this->url_base( $p_repo, $p_file->filename, $t_opts ); + } + + public function url_diff( $p_repo, $p_changeset, $p_file ) { + if ( $p_file->action == 'rm' || $p_file->action == 'add' ) { + return ''; + } + + $t_opts = array(); + $t_opts['r1'] = $p_changeset->revision; + $t_opts['r2'] = $p_changeset->revision - 1; + + return $this->url_base( $p_repo, $p_file->filename, $t_opts ); + } + + public function update_repo_form( $p_repo ) { + $t_url = $this->get_viewvc_url( $p_repo ); + $t_name = $this->get_viewvc_name( $p_repo ); + $t_use_checkout = $this->get_viewvc_use_checkout( $p_repo ); + $t_root_as_url = $this->get_viewvc_root_as_url( $p_repo ); + +?> +> + + + +> + + + +> + +/> + +> + +/> + +info['viewvc_url'] = gpc_get_string( 'viewvc_url' ); + $p_repo->info['viewvc_name'] = gpc_get_string( 'viewvc_name' ); + $p_repo->info['viewvc_use_checkout'] = gpc_get_bool( 'viewvc_use_checkout', false ); + $p_repo->info['viewvc_root_as_url'] = gpc_get_bool( 'viewvc_root_as_url', false ); + + return parent::update_repo( $p_repo ); + } +} diff --git a/SourceViewVC/lang/strings_english.txt b/SourceViewVC/lang/strings_english.txt new file mode 100755 index 000000000..ce47090f4 --- /dev/null +++ b/SourceViewVC/lang/strings_english.txt @@ -0,0 +1,22 @@ +(With trailing slash)'; +$s_plugin_SourceViewVC_viewvc_name = 'ViewVC Name
(Repository directory)'; +$s_plugin_SourceViewVC_viewvc_root_as_url = 'ViewVC Root As URL Component Enabled?'; +$s_plugin_SourceViewVC_viewvc_use_checkout = 'ViewVC Checkout View Enabled?'; + +$s_plugin_SourceViewVC_svn_username = 'SVN Username'; +$s_plugin_SourceViewVC_svn_password = 'SVN Password'; +$s_plugin_SourceViewVC_standard_repo = 'Standard Repository
(trunk/branches/tags)'; +$s_plugin_SourceViewVC_trunk_path = 'Trunk Path
(Non-standard repository)'; +$s_plugin_SourceViewVC_branch_path = 'Branch Path
(Non-standard repository)'; +$s_plugin_SourceViewVC_tag_path = 'Tag Path
(Non-standard repository)'; +$s_plugin_SourceViewVC_ignore_paths = 'Ignore Other Paths
(Non-standard repository)'; From fb45fe1ed155fdb11360ed30933e773b9c30be7d Mon Sep 17 00:00:00 2001 From: bright-tools Date: Mon, 9 Nov 2015 19:45:49 +0000 Subject: [PATCH 2/5] Point to mantisbt-plugins rather than development fork --- SourceViewVC/SourceViewVC.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SourceViewVC/SourceViewVC.php b/SourceViewVC/SourceViewVC.php index cf329ea52..06ae71585 100755 --- a/SourceViewVC/SourceViewVC.php +++ b/SourceViewVC/SourceViewVC.php @@ -22,7 +22,7 @@ public function register() { $this->author = 'John Bailey'; $this->contact = 'dev@brightsilence.com'; - $this->url = 'https://github.com/bright-tools/source-integration'; + $this->url = 'https://github.com/mantisbt-plugins/source-integration'; } public $type = 'viewvc'; From 907ee71931aa33751fcc0a749e270cb7b7c5f043 Mon Sep 17 00:00:00 2001 From: bright-tools Date: Mon, 9 Nov 2015 20:19:51 +0000 Subject: [PATCH 3/5] Add documentation for new plugin --- README.md | 3 ++ docs/CONFIGURING.SourceViewVC.md | 67 ++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) mode change 100644 => 100755 README.md create mode 100755 docs/CONFIGURING.SourceViewVC.md diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 3fbba6e02..3e8844deb --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ plugins: * **SourceSFSVN**: SVN repositories hosted on [SourceForge](http://sourceforge.net/). * **SourceSVN**: SVN repositories locally accessible by the SVN binaries. +* **SourceViewVC**: SVN repositories accessible via a + [ViewVC](http://www.viewvc.org/) web frontend installation. * **SourceWebSVN**: SVN repositories accessible via a [WebSVN](http://www.websvn.info/) web frontend installation. @@ -88,6 +90,7 @@ enforced as of 2013-04-24. relevant plugin extension: * [SourceGithub](docs/CONFIGURING.SourceGithub.md) + * [SourceViewVC](docs/CONFIGURING.SourceViewVC.md) 9. Once configured, click the "Return to Repository" link and click either the "Import Everything" or "Import Newest Data" button to perform initial diff --git a/docs/CONFIGURING.SourceViewVC.md b/docs/CONFIGURING.SourceViewVC.md new file mode 100755 index 000000000..dd1ff9b3d --- /dev/null +++ b/docs/CONFIGURING.SourceViewVC.md @@ -0,0 +1,67 @@ +# SourceViewVC Configuration + +## Description + +The **SourceViewVC** extension plugin adds support for SVN repositories +with a [ViewVC](http://www.viewvc.org/) front-end. + +## Requirements + +The **SourceViewVC** plugin requires Mantis 1.2.16. See the +[README](../README.md#requirements) for further information. + +Ensure both the **Source** and **SourceViewVC** plugins are installed. +See the [README](../README.md#installation) for overall instructions. + + +## Configuration + +1. Click the *Repositories* link in the navigation bar. + +2. In the *Create Repository* section: + + - Enter the repository name in the *Name* text field. + - Select *ViewVC* from the *Type* pop-up menu. + - Click the *Create Repository* button. + +3. This will take you to the *Update Repository* page where you'll need to fill + in all the details for the repository: + + - The *Name* field should be pre-populated with the name you entered in Step 3a above. + + - Paste in the SVN repository's URL in the *URL* field + (e.g. `https://localhost.localdomain/repos/myrepo` or + `file:///var/repos/myrepo`). + + - Paste in the ViewVC installation's root URL in the *ViewVC URL* field + (e.g. `http://viewvc-server/viewvc/`). + + - Enter the name of the SVN repository, as it appears in the list seen in + ViewVC, in the *ViewVC Name* field + (e.g. `myrepo`) + + - If the ViewVC installation has the `root_as_url_component` option enabled + (see the `viewvc.conf` file) then enable the *ViewVC Root As URL Component + Enabled?* field + + - If the ViewVC installation has the checkout view enabled (the + `allowed_views` field list includes `co` in the `viewvc.conf` file) then + enable the *ViewVC Checkout View Enabled?* field + + - Enter the username of a user which has read access to the SVN repository in + the *SVN Username* field (e.g. "repo-user"). + + - Enter the password for the user in the *SVN Password* field + (e.g. "Sup4rSecre7"). + + - If your repository is configured with the standard `trunk`, `branches` & + `tags` folders at the top-level, select the *Standard Repository* field, + otherwise enter the appropriate paths into the *Trunk Path*, *Branch Path* + and *Tag Path* fields. + + - Click the *Update Repository* button. + +4. Click the *Import Everything* button to test connectivity and perform an + initial import of the repository changesets. + + **Note:** This may take a long time or even fail for large repositories. From ac08f55250473e4f720a6e3782da4497293b57eb Mon Sep 17 00:00:00 2001 From: bright-tools Date: Mon, 9 Nov 2015 20:30:13 +0000 Subject: [PATCH 4/5] Fix cross-reference --- docs/CONFIGURING.SourceViewVC.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/CONFIGURING.SourceViewVC.md b/docs/CONFIGURING.SourceViewVC.md index dd1ff9b3d..0be141577 100755 --- a/docs/CONFIGURING.SourceViewVC.md +++ b/docs/CONFIGURING.SourceViewVC.md @@ -7,7 +7,7 @@ with a [ViewVC](http://www.viewvc.org/) front-end. ## Requirements -The **SourceViewVC** plugin requires Mantis 1.2.16. See the +The **SourceViewVC** plugin requires Mantis 1.2.16. See the [README](../README.md#requirements) for further information. Ensure both the **Source** and **SourceViewVC** plugins are installed. @@ -27,7 +27,8 @@ See the [README](../README.md#installation) for overall instructions. 3. This will take you to the *Update Repository* page where you'll need to fill in all the details for the repository: - - The *Name* field should be pre-populated with the name you entered in Step 3a above. + - The *Name* field should be pre-populated with the name you entered in Step + 2a above. - Paste in the SVN repository's URL in the *URL* field (e.g. `https://localhost.localdomain/repos/myrepo` or @@ -38,15 +39,15 @@ See the [README](../README.md#installation) for overall instructions. - Enter the name of the SVN repository, as it appears in the list seen in ViewVC, in the *ViewVC Name* field - (e.g. `myrepo`) + (e.g. `myrepo`). - If the ViewVC installation has the `root_as_url_component` option enabled (see the `viewvc.conf` file) then enable the *ViewVC Root As URL Component - Enabled?* field + Enabled?* field. - If the ViewVC installation has the checkout view enabled (the `allowed_views` field list includes `co` in the `viewvc.conf` file) then - enable the *ViewVC Checkout View Enabled?* field + enable the *ViewVC Checkout View Enabled?* field. - Enter the username of a user which has read access to the SVN repository in the *SVN Username* field (e.g. "repo-user"). From 1f539c6be8bafb3bcfbe0444fa62172cc0adf168 Mon Sep 17 00:00:00 2001 From: bright-tools Date: Thu, 12 Nov 2015 17:38:03 +0000 Subject: [PATCH 5/5] Correct list of required plugins --- docs/CONFIGURING.SourceViewVC.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/CONFIGURING.SourceViewVC.md b/docs/CONFIGURING.SourceViewVC.md index 0be141577..009d0818a 100755 --- a/docs/CONFIGURING.SourceViewVC.md +++ b/docs/CONFIGURING.SourceViewVC.md @@ -10,10 +10,12 @@ with a [ViewVC](http://www.viewvc.org/) front-end. The **SourceViewVC** plugin requires Mantis 1.2.16. See the [README](../README.md#requirements) for further information. -Ensure both the **Source** and **SourceViewVC** plugins are installed. +Ensure that all of the following plugins are installed: +* **Source** +* **SourceSVN** +* **SourceViewVC** See the [README](../README.md#installation) for overall instructions. - ## Configuration 1. Click the *Repositories* link in the navigation bar.