diff --git a/SourceViewVC/LICENSE b/SourceViewVC/LICENSE new file mode 100755 index 0000000..9c6c2e6 --- /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 0000000..cf329ea --- /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 0000000..ce47090 --- /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)';