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
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).
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
Think of a good WikiName for the patch. It will be used to create a subpage under this page. Enter it here:
- 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
- MoinMoinPatch/1.9 MonthCalenderAndSidebar
- MoinMoinPatch/AddLdapAuthSasl
- MoinMoinPatch/AddTranslationDomainToCacheKey
- MoinMoinPatch/AutoAdminWrite
- MoinMoinPatch/AutoAdminWrite/2009-03-25 Irc Conversation
- MoinMoinPatch/AutoTableOfContents
- MoinMoinPatch/AutomaticSubscriptionOnEditPreference
- MoinMoinPatch/BingbotUaSpider
- MoinMoinPatch/CachingProxies
- MoinMoinPatch/CommitMails
- MoinMoinPatch/ConfigurableAuthNormalization
- MoinMoinPatch/DespamStreamliningOne
- MoinMoinPatch/DisablePureIndentation
- MoinMoinPatch/DisableRegexAndWildcardSearch
- MoinMoinPatch/DocbookPagelinks
- MoinMoinPatch/DocbookParserCaching
- MoinMoinPatch/ExpandVariablesForNewPageFromTemplate
- MoinMoinPatch/GuiRemoveEmptyListItems
- MoinMoinPatch/HierarchicalACL
- MoinMoinPatch/HttpAuthAutoEmail
- MoinMoinPatch/IncludeBySearchResults
- MoinMoinPatch/IncludeMacroWithDocBookFormatter
- MoinMoinPatch/IncludeOnlySuccessfullyMatchedPages
- MoinMoinPatch/IncludeOnlySuccessfullyMatchedPages/PageOne
- MoinMoinPatch/IncludeOnlySuccessfullyMatchedPages/PageTwo
- MoinMoinPatch/IncrementalDump
- MoinMoinPatch/LessConfusingRecentChanges
- MoinMoinPatch/LinkFromWikiConfigHelpToHelpOnOpenIDProvider
- MoinMoinPatch/ListLanguagePackagesContent
- MoinMoinPatch/LoadAllTtranslationDomains
- MoinMoinPatch/MultipleTemplatesSupportForNewPageMaro
- MoinMoinPatch/MySqlEventLog
- MoinMoinPatch/NaturalAttachmentUrls
- MoinMoinPatch/NewAccountApproveMail
- MoinMoinPatch/PackageManyPages
- MoinMoinPatch/ParentVariable
- MoinMoinPatch/ParsedInBodyHeaderFooter
- MoinMoinPatch/PretifyDocbookOutput
- MoinMoinPatch/PreventUserPreferencesCreateProfileFormSpoofing
- MoinMoinPatch/QuicklinksMenu
- MoinMoinPatch/RandomPageCustomLinktext
- MoinMoinPatch/RearrangeInfoOptions
- MoinMoinPatch/RefactorIncludeMacro
- MoinMoinPatch/RequestCli
- MoinMoinPatch/ReverseTimelineInPageHistory
- MoinMoinPatch/RssForPages
- MoinMoinPatch/RstParserMultilineMacros
- MoinMoinPatch/SameEmailSubjectFormatForEveryNotification
- MoinMoinPatch/SearchButtonDisable
- MoinMoinPatch/SecurityRules
- MoinMoinPatch/SecurityString
- MoinMoinPatch/SetuidFixReplaceOsAccess
- MoinMoinPatch/SetuidFixReplaceOsAccess/History
- MoinMoinPatch/ShortenedPageLinksExpandedInTooltip
- MoinMoinPatch/SpiderAllowedActions
- MoinMoinPatch/SubscribeAndUnsubscribeUsers
- MoinMoinPatch/SupportDifferentCharset
- MoinMoinPatch/SyncXMLRPCFaultMessageFix
- MoinMoinPatch/TableOfContentsHierarchicNumbers
- MoinMoinPatch/TableWithHeaderRows
- MoinMoinPatch/TitleSearchCreatePageIfNotExists
- MoinMoinPatch/TocNumberingStyle
- MoinMoinPatch/ToggleLineNumberForPrintAndI18N
- MoinMoinPatch/UserFriendlyImmutable
- MoinMoinPatch/ValidXHTMLOutput
- MoinMoinPatch/VerifyAccountCreationByEmail
- MoinMoinPatch/VirtualPages
- MoinMoinPatch/WikiMarkupLanguage
- 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
Since this page is very long by now, please use subpages for new patches!
Contents
- Contributing a new patch
- Current patches contributed by users
- Applied Patches
-
Old patches
- Create RSS change feeds with per-page granularity
- Random/Rotating logo
- TableOfContents Starting Depth
- Table borders
- Table Borders 2
- Eliminating vertical space before list(s)
- Redirecting External Links to Defuse Link Spam
- Making gdchart work on win32 with Python23
- Implement CSV separators and use Python's CSV module
- Send change notifications based on config file
- Add a special character inserter helper to the page editor
- Relative group page names
- Ignoring markup in SpellCheck
- Using Negotiate Authentication
- Make Moin friendlier to caching proxies
- Show a login link instead of Immutable page
- IRC parser with events support
- How to Implement a Patch
Create RSS change feeds with per-page granularity
This patch actually fixes three things -- two bugs, and one misfeature .
- ddiffs links to the most recent diff for all news items
- diffs always inserts the most recent diff for all news items
- The action always returns all the changes for the whole site
The patch blocks (in the attached diff) in order do the following:
- Look for a new variable, "sitewide", in the request.forms data
Returns only changes pertaining to the page the action is executed on, unless sitewide is set
- This block does two things (in order)
- Adds documentation for sitewide to the existing documentation
- Handles setting up appropriate channel descriptions, depending on if the feed is sitewide or page-specific
- Makes the ddiffs link point explicitly to the changes that correspond to the news item
- Makes the diffs show the real diff that corresponds to the news item
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
Random/Rotating logo
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)
- -- George Sherman
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
Is there a python file of the NewTableOfContents (with starting depth) available? If so, can someone please provide it here... thanks. I didn't know where to put this question.. I hope I'm not doing anything wrong.
Here you are. This is a slightly modified version for use with 1.3.4 NewTableOfContents-1.3.4.py
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:
note space between : and this line
- (until fixed in this wiki)
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
Redirecting External Links to Defuse Link Spam
These small changes stop link spammers from gaining any higher Google pagerank by adding link spam to your wiki pages.
Another anti-spam measure is to block links that are blacklisted. See the blacklist example on the SecurityPolicy page.
Here is another related example that checks if the user's domain is on the distributed server boycott list (sometimes spammers use open proxy servers).
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
I did not need this. Maybe it is fixed already? -- AlexanderSchremmer 2004-12-01 23:41:38
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:
(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.
I merged the first one into arch (support for other separators). I will not merge the second one because it depends on the standard module csv which is not Unicode-safe.
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:
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
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.
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:
This patch also removes username = username.title() from multiconfig.py. This is now in the default configuration for magle_username.
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
Show a login link instead of Immutable page
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:
- Download and install TortoiseHG.
Create a directory for your repositories, C:...\MyRepos
Determine which Moin release you want, visit http://hg.moinmo.in/moin
Start Windows Explorer, navigate to \MyRepos, right-click and select TortoiseHG >> Clone...
In Source path, enter http://hg.moinmo.in/moin/1.9
In Destination path, enter C:....\MyRepos\1.9
- Click Clone button, download will take about 5 minutes
- Test
- Open Windows Command Prompt
CD ...\MyRepos\1.9
- python wikserver.py
Open a browser and enter http://localhost:8080
- Open Windows Command Prompt
- Download your patch
Using Windows Explorer, navigate to ...\MyRepos\1.9, right-click and select HG Repository Explorer
Select Synchronize >> Import
- Click Browse and navigate to your patch download area, select patch file
- Click the Import button
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.