Bleeding Edge

Contributed Stuff

Themes:

Macros:

Patches:

Development

Documentation

Sourcecode

Plugins

Those are my favorite/used 3parties plugins...

And those are the builtin macros...

Themes

Hosting

Running my privat wikis on webfaction.com (shared hosting) with a simple hosting plan (around 10$ a month) and also some bussiness stuff on a debian/ubuntu server. If anybody need helps just ask!

uWSGI Server

My ini file looks like this:

[uwsgi]

# Server
http = 127.0.0.1:<port>

# Path
chdir = /home/<username>/var/moinmoin/etc
pythonpath = /home/<username>/lib/python2.7/

# Static
check-static =  /home/<username>/var/www/

# General Routing
route = ^/$ rewrite:/wiki/

# WSGI Variables
route = ^/([^/]*) addvar:SCRIPT_NAME=/$1
route = ^/(?:[^/]*)/(.*) addvar:PATH_INFO=/$1

# WSGI 
wsgi-file = /home/<username>/var/moinmoin/etc/moin.wsgi
pidfile = /home/<username>/var/run/uwsgi-moinmoin.pid

# Modify Headers (disabled)
#add-header = Access-Control-Allow-Origin: http://heavy.ch
#add-header = Access-Control-Allow-Origin: https://heavy.ch
#add-header = Access-Control-Allow-Credentials true
#add-header = Access-Control-Allow-Methods: POST, GET, OPTIONS

# Process
master = true
workers = 6
#threads = 5
offload-threads = 6

# Safety
harakiri = 30
vacuum = true
#max-requests = 5000
reload-on-rss = 100
evil-reload-on-rss = 150

# Logfile
daemonize = /home/<username>/var/log/uwsgi-moinmoin.log
memory-report = true
stats = /home/<username>/var/run/uwsgi-log.socket

wsgi

# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - mod_wsgi driver script

    To use this, add those statements to your Apache's VirtualHost definition:

    # you will invoke your moin wiki at the root url, like http://servername/FrontPage:
    WSGIScriptAlias / /some/path/moin.wsgi

    # create some wsgi daemons - use someuser.somegroup same as your data_dir:
    WSGIDaemonProcess daemonname user=someuser group=somegroup processes=5 threads=10 maximum-requests=1000 umask=0007

    # use the daemons we defined above to process requests!
    WSGIProcessGroup daemonname

    @copyright: 2008 by MoinMoin:ThomasWaldmann
    @license: GNU GPL, see COPYING for details.
"""

import sys, os

# a) Configuration of Python's code search path
#    If you already have set up the PYTHONPATH environment variable for the
#    stuff you see below, you don't need to do a1) and a2).

# a1) Path of the directory where the MoinMoin code package is located.
#     Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
sys.path.insert(0, '/home/<username>/lib/python2.6')

# a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
#     See wiki/config/... for some sample config files.
sys.path.insert(0, '/home/<username>/<dir-to-moin-data>/etc')

# b) Configuration of moin's logging
#    If you have set up MOINLOGGINGCONF environment variable, you don't need this!
#    You also don't need this if you are happy with the builtin defaults.
#    See wiki/config/logging/... for some sample config files.
from MoinMoin import log
log.load_config('/home/<username>/<dir-to-moin-data>/etc/logfile.conf')

from MoinMoin.web.serving import make_application
from MoinMoin.web.serving import ProxyTrust

# Creating the WSGI application
# use shared=True to have moin serve the builtin static docs
# use shared=False to not have moin serve static docs
# use shared='/my/path/to/htdocs' to serve static docs from that path
application = make_application(shared=False, trusted_proxies=['127.0.0.1',])

Xapian

http://www.heavy.ch/wiki/Moin1/Xapian

MoinMoin 1.9.x behind a nginx (reverse proxy)

Edit your moin.wsgi file and change the wsgi application:

application = make_application(shared=False)

and add a param "trusted_proxies" with your current proxy ip:

from MoinMoin.web.serving import ProxyTrust

application = make_application(shared=False, trusted_proxies=['127.0.0.1',])

for more help see MoinMoin 1.9 Source Code

HTTPS / HTTP

Sometimes you want to run your website with http and after the user login in switch to https, I did the following:

You can configure your MoinMoin that the search works only if it has a minimum lenght and don't accept regular express (using too much memories on my system). You just have to modify (or copy into your local action plugin directory) the source from MoinMoin (action/fullsearch.py). the reason is, that otherwise a search for r:* is using too much memory (for my shared hosting enviroment).

--- /MoinMoin/action/fullsearch.py      2013-08-13 10:17:47.000000000 +0000
+++ fullsearch.py       2013-10-13 10:05:35.386265848 +0000
@@ -164,9 +164,9 @@
 
     # check for sensible search term
     stripped = needle.strip()
-    if len(stripped) == 0:
-        request.theme.add_msg(_('Please use a more selective search term instead '
-                'of {{{"%s"}}}', wiki=True) % wikiutil.escape(needle), "error")
+    lstripped = stripped.lower()
+    if (len(lstripped) < 2) or ('regex:' in lstripped) or ('r:' in lstripped) or ('*' in lstripped):
+        request.theme.add_msg(_('Please use a more selective search term instead of {{{"%s"}}}', wiki=True) % wikiutil.escape(needle), "error")
         Page(request, pagename).send_page()
         return
     needle = stripped

logrotate

I'm not sure if it is usefull for anybody, but I just configure logrotate to rotate the main moinmoin logfiles, e.g. edit-log and event-log.

logrotate.conf

monthly
rotate 12
create
minsize 5M

# rock
/home/moin/var/data/rock/event-log {
        size 5M
        nocreate
}
/home/moin/var/data/rock/edit-log {
        size 5M
        nocreate
}

script for starting logrotate (while stopping moinmoin):

/home/moin/bin/<dir-to-moin-data> stop
wait
echo "Starting logfile rotation"
logrotate -s /home/moin/etc/logrotate.status /home/moin/etc/logrotate.conf
wait
/home/moin/bin/<dir-to-moin-data> start

<!> Drawback is, that you will loose your page visits (hitcounts) on moinmoin and also the RecentChanges.. so maybe not good for everybody :-)

Statistics

I use Piwik for Web Analytics. For this I need first to setup this PHP/MySQL application (in this example under piwik.wikwiki.ch) and then add to wikiconfig or every farmwiki the page_footer2. you always need to change the idsite=x to match the configuration in your piwik site configuration.

Example in my wikiconfig.py/MyFarm.py:

    page_footer2 = """
                    <!-- Piwik -->
<div><a href="http://piwik.org" title="Open source analytics" onclick="window.open(this.href);return(false);">
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://piwik.wikiwiki.ch/" : "http://statistik.wikiwiki.ch/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
piwik_action_name = '';
piwik_idsite = 2;
piwik_url = pkBaseURL + "piwik.php";
piwik_log(piwik_action_name, piwik_idsite, piwik_url);
</script>
<object><noscript><p>Open source analytics <img src="http://piwik.wikiwiki.ch/piwik.php?idsite=2" style="border:0" alt=""/></p></noscript></object></a></div>
<!-- End Piwik Tag -->
    """

Screenshot of Piwik: attachment:screenshot-piwik.png

Speed Up the MissingPage

We have a big wiki, where we use also use an hierarchical page structured approach. It can easily happen that a page contains around 1000 sub pages. to add then a new sub pages it's takes around 5-20s to load first the missin page (from the underlay). the problem is the included macro with call the action LikePages. This is very slow and it seems the problem lays how it calculating/finding the matches... my solution was just to add a new MissingPage page and removing the macro LikePages. Not nice but working for me :-)

Use Search Syntax in Include

A simple patch to use the search for include also.

SearchInclude.py

--- MoinMoin/macro/Include.py   2013-08-13 10:17:47.000000000 +0000
+++ SearchInclude.py    2013-06-29 19:41:59.794222009 +0000
@@ -1,12 +1,8 @@
 # -*- coding: iso-8859-1 -*-
 """
-    MoinMoin - Include macro
+    MoinMoin - SearchInclude macro
 
-    This macro includes the formatted content of the given page(s). See
-
-        http://purl.net/wiki/moinmaster/HelpOnMacros/Include
-
-    for detailed docs.
+    This macro includes the formatted content of the given page(s).
 
     @copyright: 2000-2004 Juergen Hermann <jh@web.de>,
                 2000-2001 Richard Jones <richard@bizarsoftware.com.au>
@@ -19,7 +15,7 @@
 generates_headings = True
 
 import re, StringIO
-from MoinMoin import wikiutil
+from MoinMoin import search, wikiutil
 from MoinMoin.Page import Page
 
 
@@ -73,16 +69,30 @@
         this_page._macroInclude_pagelist = {}
 
     # get list of pages to include
-    inc_name = wikiutil.AbsPageName(this_page.page_name, args.group('name'))
-    pagelist = [inc_name]
-    if inc_name.startswith("^"):
-        try:
-            inc_match = re.compile(inc_name)
-        except re.error:
-            pass # treat as plain page name
-        else:
-            # Get user filtered readable page list
-            pagelist = request.rootpage.getPageList(filter=inc_match.match)
+    #inc_name = wikiutil.AbsPageName(this_page.page_name, args.group('name'))
+    pagelist = []
+    #if inc_name.startswith("^"):
+    #    try:
+    #        inc_match = re.compile(inc_name)
+    #    except re.error:
+    #        pass # treat as plain page name
+    #    else:
+    #        # Get user filtered readable page list
+    #        pagelist = request.rootpage.getPageList(filter=inc_match.match)
+    try:
+        #results = search.searchPages(macro.request, args.group('name'),
+        #                             titlesearch=1, case=0,
+        #                             sort='page_name')
+        results = search.searchPages(macro.request, args.group('name'),
+                                     titlesearch=1, case=0,
+                                     sort='page_name')
+
+        for foundpage in results.hits:
+            pagelist.append(wikiutil.AbsPageName(this_page.page_name, foundpage.page.page_name))
+
+    except ValueError:
+        result = macro.formatter.text('Error')
+        return result
 
     # sort and limit page list
     pagelist.sort()


MoinMoin: MarcelHäfner/Work (last edited 2013-11-04 21:36:42 by MarcelHäfner)