1.1 --- a/README.txt Sat Oct 15 23:58:51 2011 +0200
1.2 +++ b/README.txt Tue Jul 10 16:23:54 2012 +0200
1.3 @@ -107,8 +107,7 @@
1.4
1.5 web_static_dir A directory from which static resources are to be served.
1.6 This directory need only be specified in a limited hosting
1.7 - environment (see below for more details), and only for
1.8 - MoinMoin 1.8.
1.9 + environment (see below for more details).
1.10
1.11 web_site_dir The directory where sites available to the Apache Web
1.12 server are defined. This directory may just be a place
1.13 @@ -135,6 +134,12 @@
1.14
1.15 url_path The URL path (after the host details) of the Wiki.
1.16
1.17 +static_url_path The URL path (after the host details) of the Wiki's static
1.18 + resources. This is only required if a limited hosting
1.19 + environment enforces separate "htdocs" and "cgi-bin"
1.20 + directories, and the static resources must be placed in
1.21 + the "htdocs" directory.
1.22 +
1.23 superuser The superuser of the Wiki.
1.24
1.25 site_name The name of the Wiki.
1.26 @@ -176,9 +181,13 @@
1.27 web_static_dir = /path/to/www/htdocs
1.28 web_site_dir =
1.29
1.30 +url_path = /mysite/cgi-bin
1.31 +static_url_path = /mysite
1.32 +
1.33 If the web_static_dir setting is left blank, the static resources will be
1.34 placed alongside the CGI script. Some environments have .cgi files served as
1.35 -CGI scripts and other files served statically.
1.36 +CGI scripts and other files served statically; in such cases, static_url_path
1.37 +can also be left blank.
1.38
1.39 Inside the directory used to hold static resources, a subdirectory will be
1.40 created to hold the static content used by MoinMoin.
1.41 @@ -277,6 +286,16 @@
1.42 CMDsyntax Tested with 0.91
1.43 Source: http://www.boddie.org.uk/david/Projects/Python/CMDSyntax/index.html
1.44
1.45 +New in moinsetup 0.4 (Changes since moinsetup 0.3)
1.46 +--------------------------------------------------
1.47 +
1.48 + * Added edit and event log permissions/ownership commands to the postinstall
1.49 + scripts.
1.50 + * Fixed the .htaccess file location for limited hosting environments, using
1.51 + the static resources directory in preference to the application directory.
1.52 + * Added support for separate static URL paths enforced by limited hosting
1.53 + environments.
1.54 +
1.55 New in moinsetup 0.3 (Changes since moinsetup 0.2)
1.56 --------------------------------------------------
1.57
2.1 --- a/moinsetup.py Sat Oct 15 23:58:51 2011 +0200
2.2 +++ b/moinsetup.py Tue Jul 10 16:23:54 2012 +0200
2.3 @@ -3,7 +3,7 @@
2.4 """
2.5 A setup and configuration script for MoinMoin.
2.6
2.7 -Copyright (C) 2010, 2011 Paul Boddie <paul@boddie.org.uk>
2.8 +Copyright (C) 2010, 2011, 2012 Paul Boddie <paul@boddie.org.uk>
2.9
2.10 This program is free software; you can redistribute it and/or modify it under
2.11 the terms of the GNU General Public License as published by the Free Software
2.12 @@ -57,23 +57,31 @@
2.13 """
2.14
2.15 apache_site_extra = """
2.16 -Alias %(static_url_path)s "%(htdocs_dir)s/"
2.17 +Alias %(static_url_resources_path)s "%(htdocs_dir)s/"
2.18 """
2.19
2.20 # Limited hosting .htaccess definitions require the following settings to be
2.21 -# configured in the main Apache configuration files:
2.22 +# configured in the main Apache configuration files for the directory where
2.23 +# .htaccess is to be deployed:
2.24 +#
2.25 +# AllowOverride FileInfo Limit
2.26 #
2.27 -# Options ExecCGI FollowSymLinks Indexes SymLinksIfOwnerMatch
2.28 -# AllowOverride FileInfo Limit
2.29 +# The following settings are required for the directory where the moin.cgi
2.30 +# script is to be deployed:
2.31 +#
2.32 +# Options ExecCGI FollowSymLinks SymLinksIfOwnerMatch
2.33 # AddHandler cgi-script .cgi
2.34 +#
2.35 +# If a DirectoryIndex directive is also desired, the Indexes option must be set.
2.36 +# Such a directive is not desirable where the static and dynamic resources are
2.37 +# in different places, however.
2.38
2.39 apache_htaccess_combined_mod_rewrite = """
2.40 -DirectoryIndex moin.cgi
2.41 RewriteEngine On
2.42 -RewriteBase %(url_path)s
2.43 +RewriteBase %(final_url_path)s
2.44 RewriteCond %%{REQUEST_FILENAME} !-f
2.45 RewriteCond %%{REQUEST_FILENAME} !-d
2.46 -RewriteRule ^(.*) moin.cgi/$1 [PT,L,QSA]
2.47 +RewriteRule ^(.*) %(url_path)s/moin.cgi/$1 [PT,L,QSA]
2.48 """
2.49
2.50 # Post-setup templates.
2.51 @@ -91,6 +99,12 @@
2.52 find '%(htdocs_dir)s' -type d | xargs setfacl -m u:%(web_user)s:rx
2.53 """
2.54
2.55 +postsetup_setfacl_logs = """
2.56 +if [ -e "%(common_dir)s/data/*-log" ]; then
2.57 + setfacl -m g:%(web_group)s:rw %(common_dir)s/data/*-log
2.58 +fi
2.59 +"""
2.60 +
2.61 postsetup_chown_chmod = """#!/bin/sh
2.62
2.63 chown -R %(this_user)s.%(web_group)s '%(common_dir)s/data'
2.64 @@ -103,6 +117,12 @@
2.65 chown -R %(this_user)s.%(web_group)s '%(htdocs_dir)s'
2.66 """
2.67
2.68 +postsetup_chown_logs = """
2.69 +if [ -e "%(common_dir)s/data/*-log" ]; then
2.70 + chown %(this_user)s.%(web_group)s %(common_dir)s/data/*-log
2.71 +fi
2.72 +"""
2.73 +
2.74 # Utility functions.
2.75
2.76 def readfile(filename):
2.77 @@ -350,7 +370,8 @@
2.78
2.79 def __init__(self, moin_distribution=None, prefix=None,
2.80 site_packages=None, web_app_dir=None, web_static_dir=None, web_site_dir=None,
2.81 - common_dir=None, farm_config=None, site_config=None, url_path=None,
2.82 + common_dir=None, farm_config=None, site_config=None,
2.83 + url_path=None, static_url_path=None,
2.84 superuser=None, site_name=None, site_identifier=None, front_page_name=None,
2.85 theme_default=None):
2.86
2.87 @@ -384,6 +405,8 @@
2.88 (overrides the 'common_dir' setting)
2.89 * url_path - the URL path at which the Wiki will be made
2.90 available (such as / or /mywiki)
2.91 + * static_url_path - optional: the URL path at which static resources
2.92 + will be made available (such as / or /mywiki)
2.93 * superuser - the name of the site's superuser (such as
2.94 "AdminUser", can be omitted)
2.95 * site_name - the name of the site (such as "My Wiki")
2.96 @@ -416,10 +439,8 @@
2.97 if not url_path:
2.98 raise TypeError, "The 'url_path' setting must be specified."
2.99
2.100 - if url_path != "/" and url_path.endswith("/"):
2.101 - self.url_path = url_path[:-1]
2.102 - else:
2.103 - self.url_path = url_path
2.104 + self.url_path = self._tidy_url_path(url_path)
2.105 + self.static_url_path = self._tidy_url_path(static_url_path)
2.106
2.107 # Define and create specific directories.
2.108 # Here are the configuration and actual Wiki data directories.
2.109 @@ -464,14 +485,38 @@
2.110 #
2.111 # This allows multiple Wiki instances to have their own static resources
2.112 # in the same hosting area.
2.113 + #
2.114 + # Where a separate static URL path has been given, the resources are
2.115 + # located under that path:
2.116 + #
2.117 + # / -> /moin_static187
2.118 + # /hgwiki -> /hgwiki/moin_static187
2.119
2.120 - self.static_url_path = self.url_path + (self.url_path != "/" and "-" or "") + self.get_static_identifier()
2.121 + # The final URL path is the principal location of the Wiki.
2.122 +
2.123 + self.final_url_path = self.static_url_path or self.url_path
2.124 +
2.125 + # The static URL resources path is the specific location of static
2.126 + # resources.
2.127 +
2.128 + self.static_url_resources_path = \
2.129 + self.final_url_path + \
2.130 + (self.static_url_path
2.131 + and (self.static_url_path != "/"
2.132 + and "/"
2.133 + or "")
2.134 + or (self.final_url_path != "/"
2.135 + and "-"
2.136 + or "")) + \
2.137 + self.get_static_identifier()
2.138 +
2.139 + self.static_dir_name = self.static_url_resources_path.split("/")[-1]
2.140
2.141 # In limited hosting, the static resources directory is related to
2.142 - # the URL path.
2.143 + # the URL path, either a specified static URL path or the general path.
2.144
2.145 if self.limited_hosting():
2.146 - self.htdocs_dir = join(self.web_static_dir or self.web_app_dir, self.static_url_path.lstrip("/"))
2.147 + self.htdocs_dir = join(self.web_static_dir or self.web_app_dir, self.static_dir_name)
2.148
2.149 # Otherwise, a mapping is made to the directory.
2.150 # This may be placed in a special static directory if desired.
2.151 @@ -511,6 +556,12 @@
2.152 def _get_abspath(self, d):
2.153 return d and abspath(d) or None
2.154
2.155 + def _tidy_url_path(self, url_path):
2.156 + if url_path != "/" and url_path.endswith("/"):
2.157 + return url_path[:-1]
2.158 + else:
2.159 + return url_path
2.160 +
2.161 def get_moin_version(self):
2.162
2.163 "Return the MoinMoin version."
2.164 @@ -769,7 +820,7 @@
2.165 # NOTE: with the version, but more specific locations are probably
2.166 # NOTE: acceptable if less efficient.
2.167
2.168 - url_prefix_static = "%r" % self.static_url_path
2.169 + url_prefix_static = "%r" % self.static_url_resources_path
2.170
2.171 # Use a farm configuration file.
2.172
2.173 @@ -882,10 +933,12 @@
2.174 if not site_file_configured:
2.175 note("Site file not configured: script name not changed.")
2.176 else:
2.177 + url_path = self.final_url_path
2.178 +
2.179 if self.moin_version.startswith("1.9"):
2.180 - s = moin_cgi_fix_script_name.sub(r"\1\2 %r" % self.url_path, s)
2.181 + s = moin_cgi_fix_script_name.sub(r"\1\2 %r" % url_path, s)
2.182 else:
2.183 - s = moin_cgi_properties.sub(r"\1\2 %r" % {"script_name" : self.url_path}, s)
2.184 + s = moin_cgi_properties.sub(r"\1\2 %r" % {"script_name" : url_path}, s)
2.185
2.186 # NOTE: Use CGI for now.
2.187
2.188 @@ -953,7 +1006,7 @@
2.189 # Otherwise, use an .htaccess file.
2.190
2.191 else:
2.192 - site_def = join(self.web_app_dir, ".htaccess")
2.193 + site_def = join(self.web_static_dir or self.web_app_dir, ".htaccess")
2.194
2.195 s = apache_htaccess_combined_mod_rewrite % self.__dict__
2.196
2.197 @@ -990,13 +1043,14 @@
2.198 vars.update(self.__dict__)
2.199 vars.update(locals())
2.200
2.201 - for postinst_script, start, extra in [
2.202 - (postinst_scripts[0], postsetup_chown_chmod, postsetup_chown_extra),
2.203 - (postinst_scripts[1], postsetup_setfacl, postsetup_setfacl_extra)
2.204 + for postinst_script, start, extra, logs in [
2.205 + (postinst_scripts[0], postsetup_chown_chmod, postsetup_chown_extra, postsetup_chown_logs),
2.206 + (postinst_scripts[1], postsetup_setfacl, postsetup_setfacl_extra, postsetup_setfacl_logs)
2.207 ]:
2.208
2.209 s = start % vars
2.210 s += extra % vars
2.211 + s += logs % vars
2.212
2.213 writefile(postinst_script, s)
2.214 chmod(postinst_script, 0755)