view MoinMoin/action/ @ 2374:629dea07759f

do not parse single-quoted page names as quoted fixes bugs with ['text_html'] being a link
author Johannes Berg <johannes AT sipsolutions DOT net>
date Thu, 12 Jul 2007 14:40:06 +0200
parents 01f05e74aa9c
children 07ab9d4b8bb8
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
    MoinMoin -  This Action is used to create a supplementation subpage e.g. a Discussion page below a comon page

    derived from the newpage macro by Vito Miliano ( et al

    @copyright: 2006-2007 MoinMoin:ReimarBauer
    @license: GNU GPL, see COPYING for details.
from MoinMoin.Page import Page
from MoinMoin.wikiutil import quoteWikinameURL

def execute(pagename, request):
    _ = request.getText
    sub_page_name = request.cfg.supplementation_page_name
    sub_page_template = request.cfg.supplementation_page_template
    newpagename = "%s/%s" % (pagename, sub_page_name)

    if pagename.endswith(sub_page_name): # sub_sub_page redirects to sub_page
        query = {}
        url = Page(request, pagename).url(request, query, relative=False)
    elif and request.user.may.write(newpagename):
        query = {}
        url = Page(request, newpagename).url(request, query, relative=False)
        test = Page(request, newpagename)
        if test.exists(): # page is defined -> redirect
        else:  # page will be created from template
            query = {'action': 'edit', 'backto': newpagename, 'template': quoteWikinameURL(sub_page_template)}
            url = Page(request, newpagename).url(request, query, relative=False)