||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). 1. 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 . <> 1. Think of a good WikiName for the patch. It will be used to create a subpage under this page. Enter it here: . <> 1. 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 <>. = Current patches contributed by users = <> = 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! <><><> == 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 1. diffs always inserts the most recent diff for all news items 1. 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. [[attachment: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`: {{{ #!python ... # NOTE: if you make logo_url a *list* of valid images, one will be # chosen at random on each page refresh. logo_url = [url_prefix + '/img/moinmoin.gif', '/myimages/someotherlogo.gif'] ... # if logo_url is a list, randomly select one of the items import types if type(logo_url) is types.ListType: import random 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 <> [[attachment:TableOfContents-startdepth.diff]] * Is there a python file of the ~+New''''''Table''''''Of''''''Contents +~(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 [[attachment: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. " (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 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 <> == Redirecting External Links to Defuse Link Spam == These small changes stop link spammers from gaining any higher Google pagerank by adding [[http://en.wikipedia.org/wiki/Link_spam|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. ---- . Here is another related example that checks if the user's domain is on the [[http://dsbl.org/main|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 {{{ #!python import socket import os from os import environ from MoinMoin.util.antispam import SecurityPolicy as Sec from MoinMoin.security import Permissions # adapted from http://www.fiction.net/blong/programs/python/rbl.py def onblacklist(hostname, aggressive=True): yes_addr = "127.0.0.2" if aggressive: #use unconfirmed DSBL list root_name = "unconfirmed.dsbl.org" else: root_name = "list.dsbl.org" addr = socket.gethostbyname(hostname) addr_parts = addr.split('.') addr_parts.reverse() check_name = '.'.join(addr_parts + [root_name]) try: check_addr = socket.gethostbyname(check_name) except socket.error: check_addr = None return (check_addr == yes_addr) class SecurityPolicy(Sec): def save(self,editor,newtext,datastamp,**kw): bl = onblacklist(editor.request.remote_addr) if bl: msg = 'Posting behind open proxies forbidden' raise editor.SaveError(msg) 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 <> 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: {{{ #!python gdchart.option(**self.options) s = "delete.me" gdchart.chart(*((style, size, s, labels) + tuple(args))) 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. * 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: {{attachment:moinmoin-1.3.4-editor-insert-screenshot.png}} Download the patch file as [[attachment:moinmoin-1.3.4-editor-insert-patch.diff]] for 1.3.4, or [[attachment: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 {{{
}}} 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 : the stuff in between angle brackets 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 <> == 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. [[attachment: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: {{{ #!python from farmconfig import FarmConfig import pwd def mangle_negotiate(username): try: return pwd.getpwnam(username)[4].replace(' ', '') except: return username class Config(FarmConfig): auth_http_enabled = 1 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]]. [[attachment:moin-cache-friendly.diff]] is the diff, against current arch (patch 730). - add to moin 1.5 branch [[attachment: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.*) # Message """, re.VERBOSE + re.UNICODE) + pattern1 = re.compile(r""" + ((\[|\()? + (?P