Skip to content

Commit

Permalink
Merge pull request #32 from dstufft/wiki
Browse files Browse the repository at this point in the history
Begin the start of a wiki configuration
  • Loading branch information
dstufft committed Jan 15, 2015
2 parents 12ed321 + 0ec09aa commit ca0c433
Show file tree
Hide file tree
Showing 16 changed files with 575 additions and 0 deletions.
1 change: 1 addition & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ SERVERS = [
"speed-web",
"tracker",
"pypa-web",
"wiki",
]

SUBNET1 = "192.168.50"
Expand Down
6 changes: 6 additions & 0 deletions pillar/base/haproxy.sls
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ haproxy:
- speed.python.org
check: "HEAD / HTTP/1.1\\r\\nHost:\\ speed.python.org"

wiki:
domains:
- wiki.python.org
- wiki-test.python.org
check: "HEAD /moin/ HTTP/1.1\\r\\nHost:\\ wiki.python.org"

redirects:
python.org:
target: www.python.org
Expand Down
21 changes: 21 additions & 0 deletions pillar/base/moin.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
moin:
wikis:
python:
name: Python Wiki
regex: '^https?://[^/]+(:\d+)?/moin.*$'
logo: '</a><a href="http://www.python.org"><img src="/wiki/europython/img/python-logo.gif" alt="Python" ></a><a name="logo">'
theme: europython
psf:
name: Private PSF Wiki
regex: '^https?://[^/]+(:\d+)?/psf.*$'
logo: Private PSF Wiki
acls:
before: "AdminGroup:read,write,delete,revert,admin"
default: ""
after: "MembersGroup:read,write,delete,revert All:"
linkspam: False
jython:
name: Jython Wiki
regex: '^https?://[^/]+(:\d+)?/jython.*$'
logo: '<img src="/wiki/europython/img/jython-new-small.gif" alt="JythonWiki">&nbsp;'
interwiki: JythonWiki
4 changes: 4 additions & 0 deletions pillar/base/tls.sls
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ tls:
roles:
- speed-web

wiki.psf.io:
roles:
- wiki

bootstrap.pypa.psf.io:
roles:
- web-pypa
1 change: 1 addition & 0 deletions pillar/dev/roles.sls
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ roles:
salt-master: "salt-master.vagrant.psf.io"
speed-web: "speed-web.vagrant.psf.io"
tracker: "tracker.vagrant.psf.io"
wiki: "wiki.vagrant.psf.io"

web-pypa: "pypa-web.vagrant.psf.io"
5 changes: 5 additions & 0 deletions pillar/dev/top.sls
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,8 @@ base:
'web-pypa':
- match: nodegroup
- firewall.rs-lb-backend

'wiki':
- match: nodegroup
- moin
- firewall.rs-lb-backend
1 change: 1 addition & 0 deletions pillar/prod/roles.sls
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ roles:
salt-master: "salt.iad1.psf.io"
speed-web: "speed-web.iad1.psf.io"
tracker: "bugs.iad1.psf.io"
wiki: "wiki.iad1.psf.io"

web-pypa: "web*.pypa.iad1.psf.io"
5 changes: 5 additions & 0 deletions pillar/prod/top.sls
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,8 @@ base:
'web-pypa':
- match: nodegroup
- firewall.rs-lb-backend

'wiki':
- match: nodegroup
- moin
- firewall.rs-lb-backend
176 changes: 176 additions & 0 deletions salt/moin/configs/farmconfig.py.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
#!python2
# -*- coding: utf-8 -*-
# IMPORTANT! This encoding (charset) setting MUST be correct! If you live in a
# western country and you don't know that you use utf-8, you probably want to
# use iso-8859-1 (or some other iso charset). If you use utf-8 (a Unicode
# encoding) you MUST use: coding: utf-8
# That setting must match the encoding your editor uses when you modify the
# settings below. If it does not, special non-ASCII chars will be wrong.

"""
MoinMoin - Configuration for a wiki farm
If you run a single wiki only, you can keep the "wikis" list "as is"
(it has a single rule mapping all requests to mywiki.py).
Note that there are more config options than you'll find in
the version of this file that is installed by default; see
the module MoinMoin.config.multiconfig for a full list of names and their
default values.
Also, the URL http://moinmo.in/HelpOnConfiguration has
a list of config options.
"""


# Wikis in your farm --------------------------------------------------

# If you run multiple wikis, you need this list of pairs (wikiname, url
# regular expression). moin processes that list and tries to match the
# regular expression against the URL of this request - until it matches.
# Then it loads the <wikiname>.py config for handling that request.

# Important:
# * the left part is the wikiname enclosed in double quotes
# * the left part must be a valid python module name, so better use only
# lower letters "a-z" and "_". Do not use blanks, dots or minus there!
# E.g. use "foo_bar_org", NOT: "foo-bar.org"!
# * the right part is the url re, use r"..." for it
# * in the right part ".*" means "everything". Just "*" does not work like
# for filenames on the shell / commandline, you must use ".*" as it is a RE.
# * in the right part, "^" means "beginning" and "$" means "end"

wikis = [

# wikiname, url regular expression
# ---------------------------------------------------------------
{% for wiki, config in pillar["moin"]["wikis"].items() %}
("{{ wiki }}", r"{{ config.regex }}"),
{% endfor %}

# for multiple wikis, do something like this:
# ("wiki1", r"^http://wiki1\.example\.org/.*$"),
# ("wiki2", r"^https?://wiki2\.example\.org/.*$"),
]


# Common configuration for all wikis ----------------------------------

# Everything that should be configured the same way should go here,
# anything else that should be different should go to the single wiki's
# config.
# In that single wiki's config, we will use the class FarmConfig we define
# below as the base config settings and only override what's different.
#
# In exactly the same way, we first include MoinMoin's Config Defaults here -
# this is to get everything to sane defaults, so we need to change only what
# we like to have different:

from MoinMoin.config import multiconfig, url_prefix_static


# Now we subclass this DefaultConfig. This means that we inherit every setting
# from the DefaultConfig, except those we explicitely define different.

class FarmConfig(multiconfig.DefaultConfig):

url_prefix = "/wiki"
url_prefix_static = "/static"

include_doctype = True

traceback_show = False

# Disallow edits by users that are not logged in
acl_rights_default = u"Known:read,write,delete,revert All:read"

page_front_page = u"FrontPage"

# This isn't modified, so it can be shared amongst all the instances
data_underlay_dir = "/srv/moin/instances/underlay"

shared_intermap = "/etc/moin/shared_intermap.txt"

xapian_search = True
xapian_index_dir = "/srv/moin/xapian"

# Options people are likely to change due to personal taste
show_hosts = True # show hostnames?
nonexist_qm = False # show '?' for nonexistent?
backtick_meta = True # allow `inline typewriter`?
allow_extended_names = True # allow ["..."] markup?
edit_rows = 20 # editor size
edit_cols = 50
max_macro_size = 50 # max size of RecentChanges in KB (0=unlimited)
bang_meta = True # use ! to escape WikiNames?
show_section_numbers = False # enumerate headlines?
user_checkbox_defaults = {
"edit_on_doubleclick": False,
}

# Charting needs "gdchart" installed! (None to disable charting)
chart_options = {"width": 600, "height": 300}

# Disable certain actions that aren't very useful for us.
# by default this is "xmlrpc", "CopyPages", "MyPages"
actions_excluded = multiconfig.DefaultConfig.actions_excluded[:]

# this disables the user to create a zip file from a page
# and download this file
actions_excluded.append("PackagePages")

# this disables the user to sync pages to an other wiki, this works onl
# if xmlrpc is enabled
actions_excluded.append("SyncPages")

# the content should not be rendered as docbook
actions_excluded.append("RenderAsDocbook")

# noone on this wikis wants to mass (un)subscribe users to a page
actions_excluded.append("SubscribeUser")

# makes it impossible for users to save a raw copy of the markup easy to a
# file
actions_excluded.append("Save")

actions_excluded.append("Load")
actions_excluded.append("twikidraw")
actions_excluded.append("anywikidraw")

# check where that in 1.9 is used
# actions_excluded.append("cache")

actions_excluded.append("chart")
# can be removed after language packs are installed
# actions_excluded("LanguageSetup")

actions_excluded.append("pollsistersites")

# language setup only needs to be done after update/reinstall
actions_excluded.append("language_setup")

# don't need a server
actions_excluded.append("serveopenid")

actions_excluded.append("showtags")
actions_excluded.append("sisterpages")
actions_excluded.append("thread_monitor")

# mail functions. use empty mail_smarthost to disable.
# mail_smarthost = 'mail.python.org'
mail_smarthost = 'localhost'
mail_from = 'Python Wiki <wiki@python.org>'

language_default = "en"
language_ignore_browser = True

page_category_regex = ur"(?P<all>Category(?P<key>\S+))"
page_dict_regex = ur"(?P<all>(?P<key>\S+)Dict)"
page_group_regex = ur"(?P<all>(?P<key>\S+)Group)"
page_template_regex = ur"(?P<all>(?P<key>\S+)Template)"

# caching_formats = []

# Link spam protection for public wikis (uncomment to enable).
# Needs a reliable internet connection.
from MoinMoin.security.antispam import SecurityPolicy
11 changes: 11 additions & 0 deletions salt/moin/configs/gunicorn.conf.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CONFIG = {
"mode": "wsgi",
"user": "moin",
"group": "moin",
"args": [
"--bind", "unix:/var/run/gunicorn/moin.sock",
"--workers", "{{ grains.num_cpus * 4 }}",
"--pythonpath", "/usr/share/moin/server/",
"moin_wsgi",
],
}
36 changes: 36 additions & 0 deletions salt/moin/configs/moin-nginx.conf.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
upstream app_server {
server unix:/var/run/gunicorn/moin.sock fail_timeout=0;
}

server {
listen 9000 ssl;
server_name wiki.python.org;

ssl_certificate /etc/ssl/private/wiki.psf.io.pem;
ssl_certificate_key /etc/ssl/private/wiki.psf.io.pem;

include fastly_params;

error_log /var/log/nginx/wiki.error.log;
access_log /var/log/nginx/wiki.access.log main;

location = / {
return 301 /moin/;
}

location /static/europython/ {
alias /srv/moin/europython/;
}

location /static/ {
alias /usr/share/moin/htdocs/;
}

location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;

proxy_pass http://app_server;
}
}
32 changes: 32 additions & 0 deletions salt/moin/configs/moin_wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import sys
import urlparse

from MoinMoin.web.serving import make_application

sys.path.insert(0, "/etc/moin")


class ScriptFixerMiddleware(object):

def __init__(self, application):
self.application = application

def __call__(self, environ, start_response):
if not environ.get("SCRIPT_NAME"):
path = environ.get("PATH_INFO", "")
if path.startswith("/"):
path = path[1:]

parsed = urlparse.urlparse(path)

script_name = "/".join(parsed.path.split("/")[:1])
if not script_name.startswith("/"):
script_name = "/" + script_name

environ["SCRIPT_NAME"] = script_name
environ["PATH_INFO"] = "/".join(parsed.path.split("/")[1:])

return self.application(environ, start_response)


application = ScriptFixerMiddleware(make_application(shared=False))
5 changes: 5 additions & 0 deletions salt/moin/configs/shared_intermap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PEP http://www.python.org/dev/peps/pep-$PAGE/
SF http://bugs.python.org/issue$PAGE
PythonMac http://pythonmac.org/wiki/
WxPython http://wiki.wxpython.org/index.cgi/
ISBN http://www.amazon.com/exec/obidos/ASIN/$PAGE/pythonsoftwar-20

0 comments on commit ca0c433

Please sign in to comment.