##// END OF EJS Templates
svn: Move path computation from themplate to python.
Martin Bornhold -
r570:bb5e4c7c default
parent child Browse files
Show More
@@ -1,64 +1,65 b''
1 # Auto generated configuration for use with the Apache mod_dav_svn module.
1 # Auto generated configuration for use with the Apache mod_dav_svn module.
2 #
2 #
3 # WARNING: Make sure your Apache instance which runs the mod_dav_svn module is
3 # WARNING: Make sure your Apache instance which runs the mod_dav_svn module is
4 # only accessible by RhodeCode. Otherwise everyone is able to browse
4 # only accessible by RhodeCode. Otherwise everyone is able to browse
5 # the repositories or run subversion operations (checkout/commit/etc.).
5 # the repositories or run subversion operations (checkout/commit/etc.).
6 #
6 #
7 # The mod_dav_svn module does not support subversion repositories which are
7 # The mod_dav_svn module does not support subversion repositories which are
8 # organized in subfolders. To support the repository groups of RhodeCode it is
8 # organized in subfolders. To support the repository groups of RhodeCode it is
9 # required to provide a <Location> block for each group pointing to the
9 # required to provide a <Location> block for each group pointing to the
10 # repository group sub folder.
10 # repository group sub folder.
11 #
11 #
12 # To ease the configuration RhodeCode auto generates this file whenever a
12 # To ease the configuration RhodeCode auto generates this file whenever a
13 # repository group is created/changed/deleted. Auto generation can be configured
13 # repository group is created/changed/deleted. Auto generation can be configured
14 # in the ini file.
14 # in the ini file.
15 #
15 #
16 # To include this configuration into your apache config you can use the
16 # To include this configuration into your apache config you can use the
17 # `Include` directive. See the following example snippet of a virtual host how
17 # `Include` directive. See the following example snippet of a virtual host how
18 # to include this configuration file.
18 # to include this configuration file.
19 #
19 #
20 # <VirtualHost *:8080>
20 # <VirtualHost *:8080>
21 # ServerAdmin webmaster@localhost
21 # ServerAdmin webmaster@localhost
22 # DocumentRoot /var/www/html
22 # DocumentRoot /var/www/html
23 # ErrorLog ${'${APACHE_LOG_DIR}'}/error.log
23 # ErrorLog ${'${APACHE_LOG_DIR}'}/error.log
24 # CustomLog ${'${APACHE_LOG_DIR}'}/access.log combined
24 # CustomLog ${'${APACHE_LOG_DIR}'}/access.log combined
25 # Include /path/to/generated/mod_dav_svn.conf
25 # Include /path/to/generated/mod_dav_svn.conf
26 # </VirtualHost>
26 # </VirtualHost>
27
27
28
28
29 <Location ${location_root}>
29 <Location ${location_root}>
30 # The mod_dav_svn module takes the username from the apache request object.
30 # The mod_dav_svn module takes the username from the apache request object.
31 # Without authorization this will be empty and no username is logged for the
31 # Without authorization this will be empty and no username is logged for the
32 # transactions. This will result in "(no author)" for each revision. The
32 # transactions. This will result in "(no author)" for each revision. The
33 # following directives implement a fake authentication that allows every
33 # following directives implement a fake authentication that allows every
34 # username/password combination.
34 # username/password combination.
35 AuthType Basic
35 AuthType Basic
36 AuthName "Subversion proxy"
36 AuthName "Subversion proxy"
37 AuthBasicProvider anon
37 AuthBasicProvider anon
38 Anonymous *
38 Anonymous *
39 Require valid-user
39 Require valid-user
40
40
41 DAV svn
41 DAV svn
42 SVNParentPath ${parent_path_root}
42 SVNParentPath ${parent_path_root}
43 SVNListParentPath ${'On' if svn_list_parent_path else 'Off'}
43 SVNListParentPath ${'On' if svn_list_parent_path else 'Off'}
44
44
45 Allow from all
45 Allow from all
46 Order allow,deny
46 Order allow,deny
47 </Location>
47 </Location>
48
48
49 % for repo_group in repo_groups:
49 % for location, parent_path in repo_group_paths:
50 <Location ${location_root_stripped}${repo_group.full_path}>
50
51 <Location ${location}>
51 AuthType Basic
52 AuthType Basic
52 AuthName "Subversion proxy"
53 AuthName "Subversion proxy"
53 AuthBasicProvider anon
54 AuthBasicProvider anon
54 Anonymous *
55 Anonymous *
55 Require valid-user
56 Require valid-user
56
57
57 DAV svn
58 DAV svn
58 SVNParentPath ${parent_path_root_stripped}${repo_group.full_path}
59 SVNParentPath ${parent_path}
59 SVNListParentPath ${'On' if svn_list_parent_path else 'Off'}
60 SVNListParentPath ${'On' if svn_list_parent_path else 'Off'}
60
61
61 Allow from all
62 Allow from all
62 Order allow,deny
63 Order allow,deny
63 </Location>
64 </Location>
64 % endfor
65 % endfor
@@ -1,55 +1,62 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2016-2016 RhodeCode GmbH
3 # Copyright (C) 2016-2016 RhodeCode GmbH
4 #
4 #
5 # This program is free software: you can redistribute it and/or modify
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
7 # (only), as published by the Free Software Foundation.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU Affero General Public License
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
16 #
17 # This program is dual-licensed. If you wish to learn more about the
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import os
21 import os
22
22
23 from pyramid.renderers import render
23 from pyramid.renderers import render
24
24
25 from rhodecode.model.db import RepoGroup
25 from rhodecode.model.db import RepoGroup
26 from . import config_keys
26 from . import config_keys
27
27
28
28
29 def generate_mod_dav_svn_config(settings):
29 def generate_mod_dav_svn_config(settings):
30 """
30 """
31 Generate the configuration file for use with subversion's mod_dav_svn
31 Generate the configuration file for use with subversion's mod_dav_svn
32 module. The configuration has to contain a <Location> block for each
32 module. The configuration has to contain a <Location> block for each
33 available repository group because the mod_dav_svn module does not support
33 available repository group because the mod_dav_svn module does not support
34 repositories organized in sub folders.
34 repositories organized in sub folders.
35 """
35 """
36 filepath = settings[config_keys.config_file_path]
36 filepath = settings[config_keys.config_file_path]
37 parent_path_root = settings[config_keys.parent_path_root]
37 parent_path_root = settings[config_keys.parent_path_root]
38 list_parent_path = settings[config_keys.list_parent_path]
38 list_parent_path = settings[config_keys.list_parent_path]
39 location_root = settings[config_keys.location_root]
39 location_root = settings[config_keys.location_root]
40
40
41 # Render the configuration to string.
41 # Prepare render context.
42 template = 'rhodecode:svn_support/templates/mod-dav-svn.conf.mako'
42 repo_group_paths = []
43 for repo_group in RepoGroup.get_all_repo_groups():
44 group_path = repo_group.full_path_splitted
45 location = os.path.join(location_root, *group_path)
46 parent_path = os.path.join(parent_path_root, *group_path)
47 repo_group_paths.append((location, parent_path))
48
43 context = {
49 context = {
44 'location_root': location_root,
50 'location_root': location_root,
45 'location_root_stripped': location_root.rstrip(os.path.sep),
46 'parent_path_root': parent_path_root,
51 'parent_path_root': parent_path_root,
47 'parent_path_root_stripped': parent_path_root.rstrip(os.path.sep),
52 'repo_group_paths': repo_group_paths,
48 'repo_groups': RepoGroup.get_all_repo_groups(),
49 'svn_list_parent_path': list_parent_path,
53 'svn_list_parent_path': list_parent_path,
50 }
54 }
55
56 # Render the configuration template to string.
57 template = 'rhodecode:svn_support/templates/mod-dav-svn.conf.mako'
51 mod_dav_svn_config = render(template, context)
58 mod_dav_svn_config = render(template, context)
52
59
53 # Write configuration to file.
60 # Write configuration to file.
54 with open(filepath, 'w') as file_:
61 with open(filepath, 'w') as file_:
55 file_.write(mod_dav_svn_config)
62 file_.write(mod_dav_svn_config)
General Comments 0
You need to be logged in to leave comments. Login now