Skip to content

Commit 4f2fba6

Browse files
committed
Add new ViewVC integration plugin
New plugin to allow linking of changeset information to an SVN repository fronted by ViewVC - http://www.viewvc.org/ PR #141
2 parents 2d031b4 + 1f539c6 commit 4f2fba6

File tree

5 files changed

+287
-0
lines changed

5 files changed

+287
-0
lines changed

README.md

100644100755
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ plugins:
3333
* **SourceSFSVN**: SVN repositories hosted on
3434
[SourceForge](http://sourceforge.net/).
3535
* **SourceSVN**: SVN repositories locally accessible by the SVN binaries.
36+
* **SourceViewVC**: SVN repositories accessible via a
37+
[ViewVC](http://www.viewvc.org/) web frontend installation.
3638
* **SourceWebSVN**: SVN repositories accessible via a
3739
[WebSVN](http://www.websvn.info/) web frontend installation.
3840

@@ -88,6 +90,7 @@ enforced as of 2013-04-24.
8890
relevant plugin extension:
8991

9092
* [SourceGithub](docs/CONFIGURING.SourceGithub.md)
93+
* [SourceViewVC](docs/CONFIGURING.SourceViewVC.md)
9194

9295
9. Once configured, click the "Return to Repository" link and click either
9396
the "Import Everything" or "Import Newest Data" button to perform initial

SourceViewVC/LICENSE

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Copyright (c) 2015 John Bailey
2+
3+
Permission is hereby granted, free of charge, to any person
4+
obtaining a copy of this software and associated documentation
5+
files (the "Software"), to deal in the Software without
6+
restriction, including without limitation the rights to use,
7+
copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the
9+
Software is furnished to do so, subject to the following
10+
conditions:
11+
12+
The above copyright notice and this permission notice shall be
13+
included in all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+

SourceViewVC/SourceViewVC.php

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
<?php
2+
3+
# Copyright (c) 2015 John Bailey
4+
# Copyright (c) 2012 John Reese
5+
# Licensed under the MIT license
6+
7+
if ( false === include_once( config_get( 'plugin_path' ) . 'SourceSVN/SourceSVN.php' ) ) {
8+
return;
9+
}
10+
11+
class SourceViewVCPlugin extends SourceSVNPlugin {
12+
public function register() {
13+
$this->name = lang_get( 'plugin_SourceViewVC_title' );
14+
$this->description = lang_get( 'plugin_SourceViewVC_description' );
15+
16+
$this->version = '0.1';
17+
$this->requires = array(
18+
'MantisCore' => '1.2.0',
19+
'Source' => '0.16',
20+
'SourceSVN' => '0.16',
21+
);
22+
23+
$this->author = 'John Bailey';
24+
$this->contact = '[email protected]';
25+
$this->url = 'https://github.com/mantisbt-plugins/source-integration';
26+
}
27+
28+
public $type = 'viewvc';
29+
30+
public function show_type() {
31+
return lang_get( 'plugin_SourceViewVC_svn' );
32+
}
33+
34+
public function get_viewvc_url( $p_repo ) {
35+
return isset( $p_repo->info['viewvc_url'] )
36+
? $p_repo->info['viewvc_url']
37+
: '';
38+
}
39+
40+
public function get_viewvc_name( $p_repo ) {
41+
return isset( $p_repo->info['viewvc_name'] )
42+
? $p_repo->info['viewvc_name']
43+
: '';
44+
}
45+
46+
public function get_viewvc_use_checkout( $p_repo ) {
47+
return isset( $p_repo->info['viewvc_use_checkout'] )
48+
? $p_repo->info['viewvc_use_checkout']
49+
: false;
50+
}
51+
52+
public function get_viewvc_root_as_url( $p_repo ) {
53+
return isset( $p_repo->info['viewvc_root_as_url'] )
54+
? $p_repo->info['viewvc_root_as_url']
55+
: false;
56+
}
57+
58+
/**
59+
* Builds the ViewVC URL base string
60+
* @param object $p_repo repository
61+
* @param string $p_file optional filename (as absolute path from root)
62+
* @param array $p_opts optional additional ViewVC URL parameters
63+
* @return string ViewVC URL
64+
*/
65+
protected function url_base( $p_repo, $p_file = '', $p_opts=array() ) {
66+
$t_name = urlencode( $this->get_viewvc_name( $p_repo ) );
67+
$t_root_as_url = $this->get_viewvc_root_as_url( $p_repo );
68+
69+
$t_url = rtrim( $this->get_viewvc_url( $p_repo ), '/' );
70+
71+
if( $t_root_as_url ) {
72+
$t_url_name = '/'.$t_name;
73+
} else {
74+
$t_url_name = '';
75+
$p_opts['root']=$t_name;
76+
}
77+
78+
return $t_url . $t_url_name . $p_file . '?' . http_build_query( $p_opts );
79+
}
80+
81+
public function url_repo( $p_repo, $p_changeset=null ) {
82+
$t_opts = array();
83+
84+
if ( !is_null( $p_changeset ) ) {
85+
$t_opts['revision'] = $p_changeset->revision;
86+
}
87+
88+
return $this->url_base( $p_repo, '', $t_opts);
89+
}
90+
91+
public function url_changeset( $p_repo, $p_changeset ) {
92+
$t_rev = $p_changeset->revision;
93+
$t_opts = array();
94+
$t_opts['view'] = 'revision';
95+
$t_opts['revision'] = $t_rev;
96+
97+
return $this->url_base( $p_repo, '', $t_opts );
98+
}
99+
100+
public function url_file( $p_repo, $p_changeset, $p_file ) {
101+
102+
# if the file has been removed, it doesn't exist in current revision
103+
# so we generate a link to (current revision - 1)
104+
$t_revision = ($p_file->action == 'rm')
105+
? $p_changeset->revision - 1
106+
: $p_changeset->revision;
107+
$t_use_checkout = $this->get_viewvc_use_checkout( $p_repo );
108+
109+
$t_opts = array();
110+
$t_opts['revision'] = $t_revision;
111+
112+
if( !$t_use_checkout )
113+
{
114+
$t_opts['view'] = 'markup';
115+
}
116+
117+
return $this->url_base( $p_repo, $p_file->filename, $t_opts );
118+
}
119+
120+
public function url_diff( $p_repo, $p_changeset, $p_file ) {
121+
if ( $p_file->action == 'rm' || $p_file->action == 'add' ) {
122+
return '';
123+
}
124+
125+
$t_opts = array();
126+
$t_opts['r1'] = $p_changeset->revision;
127+
$t_opts['r2'] = $p_changeset->revision - 1;
128+
129+
return $this->url_base( $p_repo, $p_file->filename, $t_opts );
130+
}
131+
132+
public function update_repo_form( $p_repo ) {
133+
$t_url = $this->get_viewvc_url( $p_repo );
134+
$t_name = $this->get_viewvc_name( $p_repo );
135+
$t_use_checkout = $this->get_viewvc_use_checkout( $p_repo );
136+
$t_root_as_url = $this->get_viewvc_root_as_url( $p_repo );
137+
138+
?>
139+
<tr <?php echo helper_alternate_class() ?>>
140+
<td class="category"><?php echo lang_get( 'plugin_SourceViewVC_viewvc_url' ) ?></td>
141+
<td><input name="viewvc_url" maxlength="250" size="40" value="<?php echo string_attribute( $t_url ) ?>"/></td>
142+
</tr>
143+
<tr <?php echo helper_alternate_class() ?>>
144+
<td class="category"><?php echo lang_get( 'plugin_SourceViewVC_viewvc_name' ) ?></td>
145+
<td><input name="viewvc_name" maxlength="250" size="40" value="<?php echo string_attribute( $t_name ) ?>"/></td>
146+
</tr>
147+
<tr <?php echo helper_alternate_class() ?>>
148+
<td class="category"><?php echo lang_get( 'plugin_SourceViewVC_viewvc_root_as_url' ) ?></td>
149+
<td><input name="viewvc_root_as_url" type="checkbox" <?php echo ($t_root_as_url ? 'checked="checked"' : '') ?>/></td>
150+
</tr>
151+
<tr <?php echo helper_alternate_class() ?>>
152+
<td class="category"><?php echo lang_get( 'plugin_SourceViewVC_viewvc_use_checkout' ) ?></td>
153+
<td><input name="viewvc_use_checkout" type="checkbox" <?php echo ($t_use_checkout ? 'checked="checked"' : '') ?>/></td>
154+
</tr>
155+
<?php
156+
157+
return parent::update_repo_form( $p_repo );
158+
}
159+
160+
public function update_repo( $p_repo ) {
161+
162+
$p_repo->info['viewvc_url'] = gpc_get_string( 'viewvc_url' );
163+
$p_repo->info['viewvc_name'] = gpc_get_string( 'viewvc_name' );
164+
$p_repo->info['viewvc_use_checkout'] = gpc_get_bool( 'viewvc_use_checkout', false );
165+
$p_repo->info['viewvc_root_as_url'] = gpc_get_bool( 'viewvc_root_as_url', false );
166+
167+
return parent::update_repo( $p_repo );
168+
}
169+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
# Copyright (c) 2012 John Reese
4+
# Licensed under the MIT license
5+
6+
$s_plugin_SourceViewVC_ = '';
7+
$s_plugin_SourceViewVC_title = 'Subversion / ViewVC Integration';
8+
$s_plugin_SourceViewVC_description = 'Adds Subversion integration to the Source plugin framework using the ViewVC app.';
9+
10+
$s_plugin_SourceViewVC_svn = 'ViewVC';
11+
$s_plugin_SourceViewVC_viewvc_url = 'ViewVC URL<br/><span class="small">(With trailing slash)</span>';
12+
$s_plugin_SourceViewVC_viewvc_name = 'ViewVC Name<br/><span class="small">(Repository directory)</span>';
13+
$s_plugin_SourceViewVC_viewvc_root_as_url = 'ViewVC Root As URL Component Enabled?';
14+
$s_plugin_SourceViewVC_viewvc_use_checkout = 'ViewVC Checkout View Enabled?';
15+
16+
$s_plugin_SourceViewVC_svn_username = 'SVN Username';
17+
$s_plugin_SourceViewVC_svn_password = 'SVN Password';
18+
$s_plugin_SourceViewVC_standard_repo = 'Standard Repository<br/><span class="small">(trunk/branches/tags)</span>';
19+
$s_plugin_SourceViewVC_trunk_path = 'Trunk Path<br/><span class="small">(Non-standard repository)</span>';
20+
$s_plugin_SourceViewVC_branch_path = 'Branch Path<br/><span class="small">(Non-standard repository)</span>';
21+
$s_plugin_SourceViewVC_tag_path = 'Tag Path<br/><span class="small">(Non-standard repository)</span>';
22+
$s_plugin_SourceViewVC_ignore_paths = 'Ignore Other Paths<br/><span class="small">(Non-standard repository)</span>';

docs/CONFIGURING.SourceViewVC.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# SourceViewVC Configuration
2+
3+
## Description
4+
5+
The **SourceViewVC** extension plugin adds support for SVN repositories
6+
with a [ViewVC](http://www.viewvc.org/) front-end.
7+
8+
## Requirements
9+
10+
The **SourceViewVC** plugin requires Mantis 1.2.16. See the
11+
[README](../README.md#requirements) for further information.
12+
13+
Ensure that all of the following plugins are installed:
14+
* **Source**
15+
* **SourceSVN**
16+
* **SourceViewVC**
17+
See the [README](../README.md#installation) for overall instructions.
18+
19+
## Configuration
20+
21+
1. Click the *Repositories* link in the navigation bar.
22+
23+
2. In the *Create Repository* section:
24+
25+
- Enter the repository name in the *Name* text field.
26+
- Select *ViewVC* from the *Type* pop-up menu.
27+
- Click the *Create Repository* button.
28+
29+
3. This will take you to the *Update Repository* page where you'll need to fill
30+
in all the details for the repository:
31+
32+
- The *Name* field should be pre-populated with the name you entered in Step
33+
2a above.
34+
35+
- Paste in the SVN repository's URL in the *URL* field
36+
(e.g. `https://localhost.localdomain/repos/myrepo` or
37+
`file:///var/repos/myrepo`).
38+
39+
- Paste in the ViewVC installation's root URL in the *ViewVC URL* field
40+
(e.g. `http://viewvc-server/viewvc/`).
41+
42+
- Enter the name of the SVN repository, as it appears in the list seen in
43+
ViewVC, in the *ViewVC Name* field
44+
(e.g. `myrepo`).
45+
46+
- If the ViewVC installation has the `root_as_url_component` option enabled
47+
(see the `viewvc.conf` file) then enable the *ViewVC Root As URL Component
48+
Enabled?* field.
49+
50+
- If the ViewVC installation has the checkout view enabled (the
51+
`allowed_views` field list includes `co` in the `viewvc.conf` file) then
52+
enable the *ViewVC Checkout View Enabled?* field.
53+
54+
- Enter the username of a user which has read access to the SVN repository in
55+
the *SVN Username* field (e.g. "repo-user").
56+
57+
- Enter the password for the user in the *SVN Password* field
58+
(e.g. "Sup4rSecre7").
59+
60+
- If your repository is configured with the standard `trunk`, `branches` &
61+
`tags` folders at the top-level, select the *Standard Repository* field,
62+
otherwise enter the appropriate paths into the *Trunk Path*, *Branch Path*
63+
and *Tag Path* fields.
64+
65+
- Click the *Update Repository* button.
66+
67+
4. Click the *Import Everything* button to test connectivity and perform an
68+
initial import of the repository changesets.
69+
70+
**Note:** This may take a long time or even fail for large repositories.

0 commit comments

Comments
 (0)