Other Market pages

This page is about patches for MoinMoin that are not included in the main code base. See PatchPolicy if you ask yourself about how we decide what gets in and what not. For extending in a different direction, see MoinMoinExtensions. For some clever moin tricks, see MoinMoinTips.

See MoinMoinDownload if you want to download the current developer code base including all bug fixes done by the core team.

Contributing a new patch

  1. First make sure you run the latest version of moin, see FrontPage (this is either the latest released version if you want to report a bug in a release, or that latest developer version, if the bug happens in a developer version).

  2. Check if the patch was already submitted. You may want to use the fulltext search. Be sure to start it with t:MoinMoinPatch/ to show bug pages only. You can also take a look at FeatureRequests for inspiration


    • Display context of search results
      Case-sensitive searching
  3. Think of a good WikiName for the patch. It will be used to create a subpage under this page. Enter it here:

  4. Read the instructions and fill in the requested data.

    (!) To subscribe to all existing or new bug reports, put MoinMoinPatch/.* into the subscribed pages listing on the page UserPreferences.

Current patches contributed by users

  1. MoinMoinPatch/1.9 MonthCalenderAndSidebar
  2. MoinMoinPatch/AddLdapAuthSasl
  3. MoinMoinPatch/AddTranslationDomainToCacheKey
  4. MoinMoinPatch/AutoAdminWrite
  5. MoinMoinPatch/AutoAdminWrite/2009-03-25 Irc Conversation
  6. MoinMoinPatch/AutoTableOfContents
  7. MoinMoinPatch/AutomaticSubscriptionOnEditPreference
  8. MoinMoinPatch/BingbotUaSpider
  9. MoinMoinPatch/CachingProxies
  10. MoinMoinPatch/CommitMails
  11. MoinMoinPatch/ConfigurableAuthNormalization
  12. MoinMoinPatch/DespamStreamliningOne
  13. MoinMoinPatch/DisablePureIndentation
  14. MoinMoinPatch/DisableRegexAndWildcardSearch
  15. MoinMoinPatch/DocbookPagelinks
  16. MoinMoinPatch/DocbookParserCaching
  17. MoinMoinPatch/ExpandVariablesForNewPageFromTemplate
  18. MoinMoinPatch/GuiRemoveEmptyListItems
  19. MoinMoinPatch/HierarchicalACL
  20. MoinMoinPatch/HttpAuthAutoEmail
  21. MoinMoinPatch/IncludeBySearchResults
  22. MoinMoinPatch/IncludeMacroWithDocBookFormatter
  23. MoinMoinPatch/IncludeOnlySuccessfullyMatchedPages
  24. MoinMoinPatch/IncludeOnlySuccessfullyMatchedPages/PageOne
  25. MoinMoinPatch/IncludeOnlySuccessfullyMatchedPages/PageTwo
  26. MoinMoinPatch/IncrementalDump
  27. MoinMoinPatch/LessConfusingRecentChanges
  28. MoinMoinPatch/LinkFromWikiConfigHelpToHelpOnOpenIDProvider
  29. MoinMoinPatch/ListLanguagePackagesContent
  30. MoinMoinPatch/LoadAllTtranslationDomains
  31. MoinMoinPatch/MultipleTemplatesSupportForNewPageMaro
  32. MoinMoinPatch/MySqlEventLog
  33. MoinMoinPatch/NaturalAttachmentUrls
  34. MoinMoinPatch/NewAccountApproveMail
  35. MoinMoinPatch/PackageManyPages
  36. MoinMoinPatch/ParentVariable
  37. MoinMoinPatch/ParsedInBodyHeaderFooter
  38. MoinMoinPatch/PretifyDocbookOutput
  39. MoinMoinPatch/PreventUserPreferencesCreateProfileFormSpoofing
  40. MoinMoinPatch/QuicklinksMenu
  41. MoinMoinPatch/RandomPageCustomLinktext
  42. MoinMoinPatch/RearrangeInfoOptions
  43. MoinMoinPatch/RefactorIncludeMacro
  44. MoinMoinPatch/RequestCli
  45. MoinMoinPatch/ReverseTimelineInPageHistory
  46. MoinMoinPatch/RssForPages
  47. MoinMoinPatch/RstParserMultilineMacros
  48. MoinMoinPatch/SameEmailSubjectFormatForEveryNotification
  49. MoinMoinPatch/SearchButtonDisable
  50. MoinMoinPatch/SecurityRules
  51. MoinMoinPatch/SecurityString
  52. MoinMoinPatch/SetuidFixReplaceOsAccess
  53. MoinMoinPatch/SetuidFixReplaceOsAccess/History
  54. MoinMoinPatch/ShortenedPageLinksExpandedInTooltip
  55. MoinMoinPatch/SpiderAllowedActions
  56. MoinMoinPatch/SubscribeAndUnsubscribeUsers
  57. MoinMoinPatch/SupportDifferentCharset
  58. MoinMoinPatch/SyncXMLRPCFaultMessageFix
  59. MoinMoinPatch/TableOfContentsHierarchicNumbers
  60. MoinMoinPatch/TableWithHeaderRows
  61. MoinMoinPatch/TitleSearchCreatePageIfNotExists
  62. MoinMoinPatch/TocNumberingStyle
  63. MoinMoinPatch/ToggleLineNumberForPrintAndI18N
  64. MoinMoinPatch/UserFriendlyImmutable
  65. MoinMoinPatch/ValidXHTMLOutput
  66. MoinMoinPatch/VerifyAccountCreationByEmail
  67. MoinMoinPatch/VirtualPages
  68. MoinMoinPatch/WikiMarkupLanguage
  69. MoinMoinPatch/WikiUtilSplit

Applied Patches

These features are already merged, but if you don't run the latest code now you may find them useful.

Old patches

Create RSS change feeds with per-page granularity

This patch actually fixes three things -- two bugs, and one misfeature :) .

  1. ddiffs links to the most recent diff for all news items
  2. diffs always inserts the most recent diff for all news items
  3. The action always returns all the changes for the whole site

The patch blocks (in the attached diff) in order do the following:

I might also squeeze in one more change (if it's possible), which is to set the title of each news entry to the user comment that goes with that entry's patch.

moin-1.3.4-rss_rc.py-per_page_feeds.patch

This patch can be applied from the root directory of the moin-1.3.4.tar.gz file structure with the following command:

patch -p0 < moin-1.3.4-rss_rc.py-per_page_feeds.patch

This code randomizes, from a set of images, the logo at the top of each page. This is akin to how the Python logo changes at the Python.org website.

Simply add this to moin_config.py:

   1 ...
   2 # NOTE: if you make logo_url a *list* of valid images, one will be
   3 #       chosen at random on each page refresh.
   4 logo_url = [url_prefix + '/img/moinmoin.gif', '/myimages/someotherlogo.gif']
   5 ...
   6 # if logo_url is a list, randomly select one of the items
   7 import types
   8 if type(logo_url) is types.ListType:
   9     import random
  10     logo_url = random.choice(logo_url)

TableOfContents Starting Depth

Right now, you can specify the maxdepth of a table of contents ([[TableOfContents]]).

With this patch, you can also specify the starting depth - e.g. to leave the first heading-level for page title: [[TableOfContents(4,2)]] would generate a list starting with level 2 titles, going down to level-4 titles. -- DanielaNicklas 2003-12-04 16:02:43

TableOfContents-startdepth.diff

Table borders

I'm just moving some content from OpenWiki, by default OpenWiki shows the borders on all tables, even for empty cells. I made it possible just by adding the following line to the related 'css' files (moin\htdocs\classic\css):

table {
        border-collapse: collapse;
        border-spacing: 0;
        empty-cells: show;
}

Also, you might want to see the borders 'stronger', when viewing on screen, replace the 'td' style by this one, on the 'screen.css' file:

td {
        border: 1pt solid gray;
}

Table Borders 2

The current default nearly-invisible table boarder in 1.2.1 seems nonstandard and unsuitable. I haven't found a way to control whether a table has borders - e.g. "<tableborder="1"> (or ="0") doesn't seem to make any difference.

Until more control is available, Here is an alternate replacement for the 'td' definition in the css files that seems to produce what a normal html page with <table border=1> produces.

table {
        border: 1px outset;
}
td {
        border: 1px inset;
}

-- NealMcBurnett 2004-04-26

Eliminating vertical space before list(s)

I was rather annoyed when I put some details in a list it become separated from previous paragraph like that:

With help of NirSoffer this can be easily eliminated if you put in theme (ex. classic/css/common.css)

p {margin-bottom: 0;}
ol {margin-top: 0;}
ul {margin-top: 0;}

-- MikeRovner 2004-06-10 19:24:20

These small changes stop link spammers from gaining any higher Google pagerank by adding link spam to your wiki pages.

See RedirectingExternalLinks.

Another anti-spam measure is to block links that are blacklisted. See the blacklist example on the SecurityPolicy page.


This version can be used on mod_python instances where env is missing. Also, I put some extra code to use both this check and GlobalAntiSpamSolution. just import SecurityPolicy from this file...

... There should be a way to stack more than one SecurityPolicy without having to resort to code like this... rdfm ot gmail dat com

   1 import socket
   2 import os
   3 from os import environ
   4 from MoinMoin.util.antispam import SecurityPolicy as Sec
   5 from MoinMoin.security import Permissions
   6 # adapted from http://www.fiction.net/blong/programs/python/rbl.py
   7 def onblacklist(hostname, aggressive=True):
   8     yes_addr = "127.0.0.2"
   9     if aggressive: #use unconfirmed DSBL list
  10         root_name = "unconfirmed.dsbl.org"
  11     else:
  12         root_name = "list.dsbl.org"
  13     addr = socket.gethostbyname(hostname)
  14     addr_parts = addr.split('.')
  15     addr_parts.reverse()
  16     check_name = '.'.join(addr_parts + [root_name])
  17     try:
  18         check_addr = socket.gethostbyname(check_name)
  19     except socket.error:
  20         check_addr = None
  21     return (check_addr == yes_addr)
  22 class SecurityPolicy(Sec):
  23     def save(self,editor,newtext,datastamp,**kw):
  24         bl = onblacklist(editor.request.remote_addr)
  25         if bl:
  26             msg = 'Posting behind open proxies forbidden'
  27             raise editor.SaveError(msg)
  28         return ((not bl) and Sec.save(self, editor,newtext,datastamp,**kw))

Making gdchart work on win32 with Python23

The current gdchart from http://www.nullcube.com/software/pygdchart/pygdchart0.6.1-w32-py23.zip will crash python.exe on win32 (tested on WindowsXP, with Moin-1.2.3 and Moin-1.3beta2).

I think the error is in the gdchart.pyd (the test example in the zip file is also failing). The gdchart.pyd fail when the 3. argument to gdchart.chart is not a string (==filename).

A quick fix is to install the gdchart.pyd from above zip file and patch moinmoin\stats\chart.py(last lines of draw method) to:

   1         gdchart.option(**self.options)
   2         s = "delete.me"
   3         gdchart.chart(*((style, size, s, labels) + tuple(args)))
   4         output.write(file(s,"rb").read())

(feel free to make this code a bit nicer (write to temporary directory, test for win32, delete file when finish, ...)

Implement CSV separators and use Python's CSV module

Python's CSV module supports escaping and customized separators; it would be nice to use it if possible. Here were two patches that add the features.

Send change notifications based on config file

See /CommitMails for a new version of this -- JustinMason

Add a special character inserter helper to the page editor

This patch by DeronMeranda adds a small bar below the page editor textarea which allows the user to just click on symbols to insert them into the page. This is particularly useful for users without international keyboards that need to occasionally insert accented or other unusual characters. Some minimal amount of Wiki markup is also supported which should help novice users. This was inspired by the similar Wikimedia feature. This patch requires Javascript support in the browser to work, but should work on most browsers. Here is a sample screenshot:

moinmoin-1.3.4-editor-insert-screenshot.png

Download the patch file as moinmoin-1.3.4-editor-insert-patch.diff for 1.3.4, or moinmoin-1.3.5-editor-insert-patch.diff for 1.3.5.

This patch was made against the 1.3.4/1.3.5 MoinMoin sources, and you can apply it by copying the diff file into an unmodified source tree and running,

   patch -p0 < moinmoin-1.3.5-editor-insert-patch.diff

You can also use the -b option to save the original files before patching. This patch modifies some core Python code, as well as adding documentation to the HelpOnConfiguration page, and some new CSS stylesheet rules to the three core styles.

To enable, add this to your wikiconfig.py configuration file:

    edit_insert_tags_enabled = 1

If you use your own custom or add-on stylesheets, the new content in the page editor is within a <div> section with an id of editor-insert-tags. If you want to change the set of characters that are presented, all the appropriate data is in located in the MoinMoin/config.py file.

See also the GuiEditor in moin 1.5+ for a similar function without patching.

Relative group page names

See NickWelch/RelativeGroups.

Ignoring markup in SpellCheck

This applies to both HTML in pages (through a macro or formatter) as well as wiki markup table attributes like <rowstyle>: the stuff in between angle brackets <like this> is not text that we want to spell check. A very naive but simple way to ignore such markup is by simply stripping it out:

(pseudo-patch)

@line 138 of actions/SpellCheck.py in 1.3.3
     text = page.get_raw_body()
+    text = re.sub('<[^>]*>', '', text)

-- NickWelch 2005-04-12 23:34:12

Using Negotiate Authentication

This patch allows MoinMoin to use usernames supplied by the httpd when using things like mod_auth_kerb. Additionally it adds a facility to mangle usernames.

moin-negotiate-auth.diff

Username mangling ca be done in the configuration. What I use is stripping the Kerberos Realm and looking up the gecos field of the user and replacing blanks in it to get a suitable WikiName. The parts of the configuration could look like this:

   1 from farmconfig import FarmConfig
   2 import pwd
   3 def mangle_negotiate(username):
   4     try:
   5         return pwd.getpwnam(username)[4].replace(' ', '')
   6     except:
   7         return username
   8 class Config(FarmConfig):
   9     auth_http_enabled = 1
  10     mangle_username = {'Negotiate' : mangle_negotiate}

This patch also removes username = username.title() from multiconfig.py. This is now in the default configuration for magle_username.

-- JoergWendland

Make Moin friendlier to caching proxies

See /CachingProxies.

moin-cache-friendly.diff is the diff, against current arch (patch 730). - add to moin 1.5 branch

vary-cookie.diff is the patch to be added to the above. - added to moin 1.5 branch

This patch adds a login link if the user is not logged in and the page cannot be edited currently:

--- moin--main--1.3/MoinMoin/theme/__init__.py  2005-05-10 20:20:19.000000000 +0200
+++ moin--local-branch--AlexanderSchremmer/MoinMoin/theme/__init__.py   2005-06-26 16:11:38.224625000 +0200
@@ -971,8 +971,11 @@
         # Page actions
         if page.isWritable() and request.user.may.write(page.page_name):
             add(link(request, quotedname + '?action=edit', _('Edit')))
+        elif not request.user.valid:
+            preferencesPage = wikiutil.getSysPage(request, 'UserPreferences')
+            add(preferencesPage.link_to(request, text=_("Login to Edit")))
         else:
-            add(_('Immutable Page', formatted=False))
+            add(_('Immutable Page', formatted=False))

         add(link(request, quotedname + '?action=diff',
                  _('Show Changes', formatted=False)))

It was written by Henrik Nilsen Omma.

IRC parser with events support

The old parser does not support displaying of events like join, part, action, etc. There is TODO in the code but I just can't wait for it. So I wrote my own. I know nothing about python so the code might be a little bit ugly. But it works though.

--- irc.py      2005-09-05 18:03:03.409459512 +0800
+++ irc.py      2005-09-05 18:33:00.861205312 +0800
@@ -36,6 +36,12 @@
             \s+                            # Space between the nick and message
             (?P<msg>.*)                    # Message
         """, re.VERBOSE + re.UNICODE)
+        pattern1 = re.compile(r"""
+            ((\[|\()?
+                (?P<time>([\d]?\d[:.]?)+)
+            (\]|\))?\s+)?
+            (?P<action>\*\s+.*)
+        """, re.VERBOSE + re.UNICODE)
         self.out.write(formatter.table(1))
         for line in lines:
             match = pattern.match(line)
@@ -46,5 +52,16 @@
                     self.out.write(formatter.text(match.group(g) or ''))
                     self.out.write(formatter.table_cell(0))
                 self.out.write(formatter.table_row(0))
+            match1 = pattern1.match(line)
+            if match1:
+                self.out.write(formatter.table_row(1))
+                for g in ('time', 'action'):
+                    if g == 'action':
+                        self.out.write(formatter.table_cell(1, {'colspan':'2'}))
+                    else:
+                        self.out.write(formatter.table_cell(1))
+                    self.out.write(formatter.text(match1.group(g) or ''))
+                    self.out.write(formatter.table_cell(0))
+                self.out.write(formatter.table_row(0))
         self.out.write(formatter.table(0))

-- PatrickLi 2005-09-05 10:22:20

How to Implement a Patch

Aplogies for the question, but I cannot find anywhere on the search (or google, or others...) where it tells you how to actually apply a patch - can anyone help?

See there: http://en.wikipedia.org/wiki/Patch_%28Unix%29

Assuming you are a Windows user:

There are a lot of things that can go wrong, even if you do everything right. Your patch may not fit because the source file in the repository was updated after the patch was created. Assuming the patch fits, the best way to apply the patch to your production wiki is to do a "normal" upgrade -- in the root of your repository there is a setup.py.


CategoryMarket

MoinMoin: MoinMoinPatch (last edited 2010-06-11 20:37:01 by RogerHaase)