예제 #1
0
    def interwikilink(self, on, interwiki='', pagename='', **kw):
        if not on: return '</a>'
        
        wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(self.request, '%s:%s' % (interwiki, pagename))
        wikiurl = wikiutil.mapURL(self.request, wikiurl)

        if wikitag == 'Self': # for own wiki, do simple links
            import urllib
            if wikitail.find('#')>-1:
                wikitail, kw['anchor'] = wikitail.split('#', 1)
            wikitail = urllib.unquote(wikitail)
            return apply(self.pagelink, (on, wikiutil.AbsPageName(self.request, self.page.page_name, wikitail)), kw)
        else: # return InterWiki hyperlink
            href = wikiutil.join_wiki(wikiurl, wikitail)
            if wikitag_bad:
                html_class = 'badinterwiki'
            else:
                html_class = 'interwiki'

            icon = ''
            if self.request.user.show_fancy_links:
                icon = self.request.theme.make_icon('interwiki', {'wikitag': wikitag}) 
            return (self.url(1, href, title=wikitag, unescaped=0,
                pretty_url=kw.get('pretty_url', 0), css = html_class) +
                icon)
예제 #2
0
def macro_InterWiki(macro):
    interwiki_list = wikiutil.load_wikimap(macro.request)
    iwlist = interwiki_list.items()  # this is where we cached it
    iwlist.sort()
    fmt = macro.formatter
    output = []
    output.append(fmt.definition_list(1))
    for tag, url in iwlist:
        output.append(fmt.definition_term(1))
        output.append(fmt.code(1))
        output.append(fmt.url(1, wikiutil.join_wiki(url, "RecentChanges")))
        output.append(fmt.text(tag))
        output.append(fmt.url(0))
        output.append(fmt.code(0))
        output.append(fmt.definition_term(0))
        output.append(fmt.definition_desc(1))
        output.append(fmt.code(1))
        if "$PAGE" not in url:
            output.append(fmt.url(1, url))
            output.append(fmt.text(url))
            output.append(fmt.url(0))
        else:
            output.append(fmt.text(url))
        output.append(fmt.code(0))
        output.append(fmt.definition_desc(1))
    output.append(fmt.definition_list(0))
    return u"".join(output)
예제 #3
0
def macro_InterWiki(macro):
    interwiki_list = wikiutil.load_wikimap(macro.request)
    iwlist = interwiki_list.items()  # this is where we cached it
    iwlist.sort()
    fmt = macro.formatter
    output = []
    output.append(fmt.definition_list(1))
    for tag, url in iwlist:
        output.append(fmt.definition_term(1))
        output.append(fmt.code(1))
        output.append(fmt.url(1, wikiutil.join_wiki(url, 'RecentChanges')))
        output.append(fmt.text(tag))
        output.append(fmt.url(0))
        output.append(fmt.code(0))
        output.append(fmt.definition_term(0))
        output.append(fmt.definition_desc(1))
        output.append(fmt.code(1))
        if '$PAGE' not in url:
            output.append(fmt.url(1, url))
            output.append(fmt.text(url))
            output.append(fmt.url(0))
        else:
            output.append(fmt.text(url))
        output.append(fmt.code(0))
        output.append(fmt.definition_desc(1))
    output.append(fmt.definition_list(0))
    return u''.join(output)
예제 #4
0
 def testJoinWiki(self):
     tests = [(('http://example.org/', u'SomePage'), 'http://example.org/SomePage'),
              (('http://example.org/?page=$PAGE&action=show', u'SomePage'), 'http://example.org/?page=SomePage&action=show'),
              (('http://example.org/', u'Aktuelle\xc4nderungen'), 'http://example.org/Aktuelle%C3%84nderungen'),
              (('http://example.org/$PAGE/show', u'Aktuelle\xc4nderungen'), 'http://example.org/Aktuelle%C3%84nderungen/show'),
             ]
     for (baseurl, pagename), url in tests:
         assert wikiutil.join_wiki(baseurl, pagename) == url
예제 #5
0
파일: xml_docbook.py 프로젝트: imosts/flume
    def interwikilink(self, on, interwiki='', pagename='', **kw):
        if not on:
            return self.url(on,kw)

        wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(self.request, '%s:%s' % (interwiki, pagename))
        wikiurl = wikiutil.mapURL(self.request, wikiurl)
        href = wikiutil.join_wiki(wikiurl, wikitail)

        return self.url(on, href)
    def interwikilink(self, on, interwiki='', pagename='', **kw):
        if not on:
            return self.url(on, **kw)

        wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_interwiki(self.request, interwiki, pagename)
        wikiurl = wikiutil.mapURL(self.request, wikiurl)
        href = wikiutil.join_wiki(wikiurl, wikitail)
        if kw.has_key("anchor"):
            href="%s#%s"%(href, kw['anchor'])

        if pagename == self.page.page_name:
            kw['is_self']=True

        return self.url(on, href, **kw)
예제 #7
0
    def interwikilink(self, on, interwiki='', pagename='', **kw):
        if not on:
            return self.url(on, **kw)

        wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_interwiki(
            self.request, interwiki, pagename)
        wikiurl = wikiutil.mapURL(self.request, wikiurl)
        href = wikiutil.join_wiki(wikiurl, wikitail)
        if kw.has_key("anchor"):
            href = "%s#%s" % (href, kw['anchor'])

        if pagename == self.page.page_name:
            kw['is_self'] = True

        return self.url(on, href, **kw)
예제 #8
0
    def interwiki(self, url_and_text, **kw):
        # TODO: maybe support [wiki:Page http://wherever/image.png] ?
        if len(url_and_text) == 1:
            url = url_and_text[0]
            text = None
        else:
            url, text = url_and_text

        # keep track of whether this is a self-reference, so links
        # are always shown even the page doesn't exist.
        is_self_reference = 0
        url2 = url.lower()
        if url2.startswith("wiki:self:"):
            url = url[10:]  # remove "wiki:self:"
            is_self_reference = 1
        elif url2.startswith("wiki:"):
            url = url[5:]  # remove "wiki:"

        tag, tail = wikiutil.split_wiki(url)
        if text is None:
            if tag:
                text = tail
            else:
                text = url
                url = ""
        elif (
            url.startswith(wikiutil.CHILD_PREFIX)
            or is_self_reference  # fancy link to subpage [wiki:/SubPage text]
            or Page(self.request, url).exists()  # [wiki:Self:LocalPage text] or [:LocalPage:text]
        ):  # fancy link to local page [wiki:LocalPage text]
            return self._word_repl(url, text)

        wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(self.request, url)
        href = wikiutil.join_wiki(wikiurl, wikitail)

        # check for image URL, and possibly return IMG tag
        if not kw.get("pretty_url", 0) and wikiutil.isPicture(wikitail):
            return self.formatter.image(src=href)

        # link to self?
        if wikitag is None:
            return self._word_repl(wikitail)

        return (
            self.formatter.interwikilink(1, tag, tail)
            + self.formatter.text(text)
            + self.formatter.interwikilink(0, tag, tail)
        )
예제 #9
0
    def interwiki(self, url_and_text, **kw):
        # TODO: maybe support [wiki:Page http://wherever/image.png] ?
        if len(url_and_text) == 1:
            url = url_and_text[0]
            text = None
        else:
            url, text = url_and_text

        # keep track of whether this is a self-reference, so links
        # are always shown even the page doesn't exist.
        is_self_reference = 0
        url2 = url.lower()
        if url2.startswith('wiki:self:'):
            url = url[10:]  # remove "wiki:self:"
            is_self_reference = 1
        elif url2.startswith('wiki:'):
            url = url[5:]  # remove "wiki:"

        tag, tail = wikiutil.split_wiki(url)
        if text is None:
            if tag:
                text = tail
            else:
                text = url
                url = ""
        elif (url.startswith(wikiutil.CHILD_PREFIX)
              or  # fancy link to subpage [wiki:/SubPage text]
              is_self_reference
              or  # [wiki:Self:LocalPage text] or [:LocalPage:text]
              Page(self.request, url).exists()
              ):  # fancy link to local page [wiki:LocalPage text]
            return self._word_repl(url, text)

        wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(
            self.request, url)
        href = wikiutil.join_wiki(wikiurl, wikitail)

        # check for image URL, and possibly return IMG tag
        if not kw.get('pretty_url', 0) and wikiutil.isPicture(wikitail):
            return self.formatter.image(src=href)

        # link to self?
        if wikitag is None:
            return self._word_repl(wikitail)

        return (self.formatter.interwikilink(1, tag, tail) +
                self.formatter.text(text) +
                self.formatter.interwikilink(0, tag, tail))
예제 #10
0
    def _interwiki_repl(self, word, groups):
        """Handle InterWiki links."""
        wiki = groups.get('interwiki_wiki')
        page = groups.get('interwiki_page')
        wikipage = "%s:%s" % (wiki, page)
        self.__add_meta(wikipage, groups)

        _, iw_wiki, iw_page, _ = resolve_interwiki(self.request, wiki, page)
        # Accept and store all interwiki-style links at this time, so
        # that changing the interwiki list does not require rehashing
        # the wikis. This means you need to check the validity of iw
        # links at runtime.
        iw_url = join_wiki(iw_wiki, iw_page)

        self.currentitems.append(('interwiki', (wikipage, wikipage)))
        self.new_item = False
        return u''
예제 #11
0
    def _interwiki_repl(self, word, groups):
        """Handle InterWiki links."""
        wiki = groups.get('interwiki_wiki')
        page = groups.get('interwiki_page')
        wikipage = "%s:%s" % (wiki, page)
        self.__add_meta(wikipage, groups)

        _, iw_wiki, iw_page, _ = resolve_interwiki(self.request, 
                                                        wiki, page)
        # Accept and store all interwiki-style links at this time, so
        # that changing the interwiki list does not require rehashing
        # the wikis. This means you need to check the validity of iw
        # links at runtime.
        iw_url = join_wiki(iw_wiki, iw_page)

        self.currentitems.append(('interwiki', (wikipage, wikipage)))
        self.new_item = False
        return u''
예제 #12
0
def macro_IncludePage(macro, src=str, width=str, height=str, **kwargs):
    request = macro.request
    formatter = macro.formatter
    _ = request.getText
    named_params = dict(kwargs)
    
    # Prepare URL
    src = wikiutil.escape(src)
    if _is_url(src):
        pass
    elif _is_interwiki(src):
        wiki, page = wikiutil.split_interwiki(src)
        wikitag, wikiurl, wikitail, err = wikiutil.resolve_interwiki(request, wiki, page)
        src = wikiutil.join_wiki(wikiurl, wikitail)
    else:
        src = Page(request, src).url(request)
    
    # Escape other parameters and set defaults
    width = wikiutil.escape(width)
    height = wikiutil.escape(height)
    align = wikiutil.escape(named_params.get("align", ""))
    scrolling = wikiutil.escape(named_params.get("scrolling", "auto"))
    marginheight= wikiutil.escape(named_params.get("marginheight","0"))
    marginwidth = wikiutil.escape(named_params.get("marginwidth", "0"))
    frameborder = wikiutil.escape(named_params.get("frameborder","0"))
    longdesc = wikiutil.escape(named_params.get("longdesc",""))
    
    # Output stuff
    result = """
<iframe src="%(src)s" width="%(width)s" height="%(height)s" align="%(align)s" scrolling="%(scrolling)s" marginheight="%(marginheight)s" marginwidth="%(marginwidth)s" frameborder="%(frameborder)s" longdesc="%(longdesc)s">
    <p>%(error_msg)s <a href="%(src)s">%(src)s</a> </p>
</iframe>
""" % { 'src': src,
                 'width': width,
                 'height': height,
                 'align': align,
                 'scrolling': scrolling,
                 'marginheight': marginheight,
                 'marginwidth': marginwidth,
                 'frameborder': frameborder,
                 'longdesc': longdesc,
                 'error_msg': _("Your browser cannot display inlined frames. You can call the inlined page through the following link:") }
    
    return formatter.rawHTML(result)
예제 #13
0
    def _macro_InterWiki(self, args):
        from StringIO import StringIO

        # load interwiki list
        dummy = wikiutil.resolve_wiki(self.request, '')

        buf = StringIO()
        buf.write('<dl>')
        list = self.cfg._interwiki_list.items() # this is where we cached it
        list.sort()
        for tag, url in list:
            buf.write('<dt><tt><a href="%s">%s</a></tt></dt>' % (
                wikiutil.join_wiki(url, 'RecentChanges'), tag))
            if url.find('$PAGE') == -1:
                buf.write('<dd><tt><a href="%s">%s</a></tt></dd>' % (url, url))
            else:
                buf.write('<dd><tt>%s</tt></dd>' % url)
        buf.write('</dl>')

        return self.formatter.rawHTML(buf.getvalue())
예제 #14
0
    def interwiki(self, url_and_text, **kw):
        # TODO: maybe support [wiki:Page http://wherever/image.png] ?
        if len(url_and_text) == 1:
            url = url_and_text[0]
            text = None
        else:
            url, text = url_and_text

        url = url[5:] # remove "wiki:"
        if text is None:
            tag, tail = wikiutil.split_wiki(url)
            if tag:
                text = tail
            else:
                text = url
                url = ""
        elif config.allow_subpages and url.startswith(wikiutil.CHILD_PREFIX):
            # fancy link to subpage [wiki:/SubPage text]
            return self._word_repl(url, text)
        elif Page(self.request, url).exists():
            # fancy link to local page [wiki:LocalPage text]
            return self._word_repl(url, text)

        wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(self.request, url)
        href = wikiutil.join_wiki(wikiurl, wikitail)

        # check for image URL, and possibly return IMG tag
        if not kw.get('pretty_url', 0) and wikiutil.isPicture(wikitail):
            return self.formatter.image(src=href)

        # link to self?
        if wikitag is None:
            return self._word_repl(wikitail)
              
        return (self.formatter.interwikilink(1, wikitag, wikitail) + 
                self.formatter.text(text) +
                self.formatter.interwikilink(0))
예제 #15
0
    def visit_reference(self, node):
        """
            Pass links to MoinMoin to get the correct wiki space url. Extract
            the url and pass it on to the html4css1 writer to handle. Inline
            images are also handled by visit_image. Not sure what the "drawing:"
            link scheme is used for, so for now it is handled here.

            Also included here is a hack to allow MoinMoin macros. This routine
            checks for a link which starts with "<<". This link is passed to the
            MoinMoin formatter and the resulting markup is inserted into the
            document in the place of the original link reference.
        """
        if 'refuri' in node.attributes:
            refuri = node['refuri']
            prefix = ''
            link = refuri
            if ':' in refuri:
                prefix, link = refuri.lstrip().split(':', 1)

            # First see if MoinMoin should handle completely. Exits through add_wiki_markup.
            if refuri.startswith('<<') and refuri.endswith('>>'):  # moin macro
                self.process_wiki_text(refuri)
                self.wiki_text = self.fixup_wiki_formatting(self.wiki_text)
                self.add_wiki_markup()

            if prefix == 'drawing':
                self.process_wiki_text("[[%s]]" % refuri)
                self.wiki_text = self.fixup_wiki_formatting(self.wiki_text)
                self.add_wiki_markup()

            # From here down, all links are handled by docutils (except
            # missing attachments), just fixup node['refuri'].
            if prefix == 'attachment':
                if not AttachFile.exists(self.request,
                                         self.request.page.page_name, link):
                    # Attachment doesn't exist, give to MoinMoin to insert upload text.
                    self.process_wiki_text("[[%s]]" % refuri)
                    self.wiki_text = self.fixup_wiki_formatting(self.wiki_text)
                    self.add_wiki_markup()
                # Attachment exists, just get a link to it.
                node['refuri'] = AttachFile.getAttachUrl(
                    self.request.page.page_name, link, self.request)
                if not [
                        i for i in node.children
                        if i.__class__ == docutils.nodes.image
                ]:
                    node['classes'].append(prefix)
            elif prefix == 'wiki':
                wiki_name, page_name = wikiutil.split_interwiki(link)
                wikitag, wikiurl, wikitail, err = wikiutil.resolve_interwiki(
                    self.request, wiki_name, page_name)
                wikiurl = wikiutil.mapURL(self.request, wikiurl)
                node['refuri'] = wikiutil.join_wiki(wikiurl, wikitail)
                # Only add additional class information if the reference does
                # not have a child image (don't want to add additional markup
                # for images with targets).
                if not [
                        i for i in node.children
                        if i.__class__ == docutils.nodes.image
                ]:
                    node['classes'].append('interwiki')
            elif prefix == 'javascript':
                # is someone trying to do XSS with javascript?
                node['refuri'] = 'javascript:alert("it does not work")'
            elif prefix != '':
                # Some link scheme (http, file, https, mailto, etc.), add class
                # information if the reference doesn't have a child image (don't
                # want additional markup for images with targets).
                # Don't touch the refuri.
                if not [
                        i for i in node.children
                        if i.__class__ == docutils.nodes.image
                ]:
                    node['classes'].append(prefix)
            else:
                # Default case - make a link to a wiki page.
                pagename, anchor = wikiutil.split_anchor(refuri)
                page = Page(
                    self.request,
                    wikiutil.AbsPageName(self.formatter.page.page_name,
                                         pagename))
                node['refuri'] = page.url(self.request, anchor=anchor)
                if not page.exists():
                    node['classes'].append('nonexistent')
        html4css1.HTMLTranslator.visit_reference(self, node)
    def username(self, d):
        """ Assemble the username / userprefs link as dropdown menu
        Assemble a login link instead in case of no login user.

        @param d: parameter dictionary
        @rtype: unicode
        @return: username html
        """
        request = self.request
        _ = request.getText

        userlinks = []
        userbutton = u''
        loginbutton = u''

        # Add username/homepage link for registered users. We don't care
        # if it exists, the user can create it.
        if request.user.valid and request.user.name:
            interwiki = wikiutil.getInterwikiHomePage(request)
            name = request.user.name
            aliasname = request.user.aliasname
            if not aliasname:
                aliasname = name
            title = "%s @ %s" % (aliasname, interwiki[0])
            # make user button
            userbutton = u'%s<span class="nav-maxwidth-100">%s</span><span class="padding"></span><span class="caret"></span>%s' % (
                request.formatter.url(1, url="#", css="menu-nav-user dropdown-toggle", **{"data-toggle": "dropdown", "rel": "nofollow"}),
                request.formatter.text(name),
                request.formatter.url(0),
                )
            # link to (interwiki) user homepage
            wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_interwiki(self.request, *interwiki)
            wikiurl = wikiutil.mapURL(self.request, wikiurl)
            href = wikiutil.join_wiki(wikiurl, wikitail)
            homelink = (request.formatter.url(1, href, title=title, css='menu-dd-userhome', rel="nofollow") +
                       request.formatter.text(name) +
                       request.formatter.url(0))
            userlinks.append(homelink)

            # link to userprefs action
            if 'userprefs' not in self.request.cfg.actions_excluded:
                userlinks.append(d['page'].link_to_raw(request, text=_('Settings'), css_class='menu-dd-userprefs',
                                                       querystr={'action': 'userprefs'}, rel='nofollow'))
            # logout link
            if request.user.auth_method in request.cfg.auth_can_logout:
                userlinks.append(d['page'].link_to_raw(request, text=_('Logout'), css_class='menu-dd-logout',
                                                       querystr={'action': 'logout', 'logout': 'logout'}, rel='nofollow'))
        else:
            query = {'action': 'login'}
            # special direct-login link if the auth methods want no input
            if request.cfg.auth_login_inputs == ['special_no_input']:
                query['login'] = '******'
            if request.cfg.auth_have_login:
                loginbutton = (d['page'].link_to_raw(request, text=_("Login"),
                                                     querystr=query, css_class='menu-nav-login', rel='nofollow'))

        if userbutton:
            userlinks_html = u'</li>\n                <li>'.join(userlinks)
            html = u'''
            <li class="dropdown">
              %s
              <ul class="dropdown-menu">
                <li>%s</li>
              </ul>
            </li> <!-- /dropdown -->
''' % (userbutton, userlinks_html)

        elif loginbutton:
            html = u'''
            <li>
              %s
            </li>
''' % loginbutton

        else:
            html = u''

        return html
예제 #17
0
    def visit_reference(self, node):
        """
            Pass links to MoinMoin to get the correct wiki space url. Extract
            the url and pass it on to the html4css1 writer to handle. Inline
            images are also handled by visit_image. Not sure what the "drawing:"
            link scheme is used for, so for now it is handled here.

            Also included here is a hack to allow MoinMoin macros. This routine
            checks for a link which starts with "<<". This link is passed to the
            MoinMoin formatter and the resulting markup is inserted into the
            document in the place of the original link reference.
        """
        if 'refuri' in node.attributes:
            refuri = node['refuri']
            prefix = ''
            link = refuri
            if ':' in refuri:
                prefix, link = refuri.lstrip().split(':', 1)

            # First see if MoinMoin should handle completely. Exits through add_wiki_markup.
            if refuri.startswith('<<') and refuri.endswith('>>'): # moin macro
                self.process_wiki_text(refuri)
                self.wiki_text = self.fixup_wiki_formatting(self.wiki_text)
                self.add_wiki_markup()

            if prefix == 'drawing':
                self.process_wiki_text("[[%s]]" % refuri)
                self.wiki_text = self.fixup_wiki_formatting(self.wiki_text)
                self.add_wiki_markup()

            # From here down, all links are handled by docutils (except
            # missing attachments), just fixup node['refuri'].
            if prefix == 'attachment':
                if not AttachFile.exists(self.request, self.request.page.page_name, link):
                    # Attachment doesn't exist, give to MoinMoin to insert upload text.
                    self.process_wiki_text("[[%s]]" % refuri)
                    self.wiki_text = self.fixup_wiki_formatting(self.wiki_text)
                    self.add_wiki_markup()
                # Attachment exists, just get a link to it.
                node['refuri'] = AttachFile.getAttachUrl(self.request.page.page_name, link, self.request)
                if not [i for i in node.children if i.__class__ == docutils.nodes.image]:
                    node['classes'].append(prefix)
            elif prefix == 'wiki':
                wiki_name, page_name = wikiutil.split_interwiki(link)
                wikitag, wikiurl, wikitail, err = wikiutil.resolve_interwiki(self.request, wiki_name, page_name)
                wikiurl = wikiutil.mapURL(self.request, wikiurl)
                node['refuri'] = wikiutil.join_wiki(wikiurl, wikitail)
                # Only add additional class information if the reference does
                # not have a child image (don't want to add additional markup
                # for images with targets).
                if not [i for i in node.children if i.__class__ == docutils.nodes.image]:
                    node['classes'].append('interwiki')
            elif prefix != '':
                # Some link scheme (http, file, https, mailto, etc.), add class
                # information if the reference doesn't have a child image (don't
                # want additional markup for images with targets).
                # Don't touch the refuri.
                if not [i for i in node.children if i.__class__ == docutils.nodes.image]:
                    node['classes'].append(prefix)
            else:
                # Default case - make a link to a wiki page.
                pagename, anchor = wikiutil.split_anchor(refuri)
                page = Page(self.request, wikiutil.AbsPageName(self.formatter.page.page_name, pagename))
                node['refuri'] = page.url(self.request, anchor=anchor)
                if not page.exists():
                    node['classes'].append('nonexistent')
        html4css1.HTMLTranslator.visit_reference(self, node)
예제 #18
0
파일: MyPages.py 프로젝트: steveyen/moingo
def execute(pagename, request):
    from MoinMoin import wikiutil
    from MoinMoin.Page import Page

    _ = request.getText
    thispage = Page(request, pagename)

    if request.user.valid:
        username = request.user.name
    else:
        username = ''

    if not username:
        request.theme.add_msg(_('Please log in first.'), "error")
        return thispage.send_page()

    userhomewiki = request.cfg.user_homewiki
    if userhomewiki != 'Self' and userhomewiki != request.cfg.interwikiname:
        interwiki = wikiutil.getInterwikiHomePage(request, username=username)
        wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_interwiki(request, *interwiki)
        wikiurl = wikiutil.mapURL(request, wikiurl)
        homepageurl = wikiutil.join_wiki(wikiurl, wikitail)
        request.http_redirect('%s?action=MyPages' % homepageurl)

    homepage = Page(request, username)
    if not homepage.exists():
        request.theme.add_msg(_('Please first create a homepage before creating additional pages.'), "error")
        return homepage.send_page()

    pagecontent = _("""\
You can add some additional sub pages to your already existing homepage here.

You can choose how open to other readers or writers those pages shall be,
access is controlled by group membership of the corresponding group page.

Just enter the sub page's name and click on the button to create a new page.

Before creating access protected pages, make sure the corresponding group page
exists and has the appropriate members in it. Use HomepageGroupsTemplate for creating
the group pages.

||'''Add a new personal page:'''||'''Related access control list group:'''||
||<<NewPage(HomepageReadWritePageTemplate,read-write page,%(username)s)>>||[[%(username)s/ReadWriteGroup]]||
||<<NewPage(HomepageReadPageTemplate,read-only page,%(username)s)>>||[[%(username)s/ReadGroup]]||
||<<NewPage(HomepagePrivatePageTemplate,private page,%(username)s)>>||%(username)s only||

""")
    pagecontent = pagecontent % locals()

    pagecontent = pagecontent.replace('\n', '\r\n')

    from MoinMoin.parser.text_moin_wiki import Parser as WikiParser
    request.emit_http_headers()

    # This action generate data using the user language
    request.setContentLanguage(request.lang)
    request.theme.send_title(_('MyPages management'), page=homepage)

    parser = WikiParser(pagecontent, request)
    p = Page(request, "$$$")
    request.formatter.setPage(p)
    parser.format(request.formatter)

    # Start content - IMPORTANT - without content div, there is no direction support!
    request.write(request.formatter.startContent("content"))

    request.write(request.formatter.endContent())
    request.theme.send_footer(homepage.page_name)
    request.theme.send_closing_html()
예제 #19
0
파일: MyPages.py 프로젝트: aahlad/soar
def execute(pagename, request):
    from MoinMoin import wikiutil
    from MoinMoin.Page import Page

    _ = request.getText
    thispage = Page(request, pagename)

    if request.user.valid:
        username = request.user.name
    else:
        username = ''

    if not username:
        request.theme.add_msg(_('Please log in first.'), "error")
        return thispage.send_page()

    userhomewiki = request.cfg.user_homewiki
    if userhomewiki != 'Self' and userhomewiki != request.cfg.interwikiname:
        interwiki = wikiutil.getInterwikiHomePage(request, username=username)
        wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_interwiki(
            request, *interwiki)
        wikiurl = wikiutil.mapURL(request, wikiurl)
        homepageurl = wikiutil.join_wiki(wikiurl, wikitail)
        request.http_redirect('%s?action=MyPages' % homepageurl)

    homepage = Page(request, username)
    if not homepage.exists():
        request.theme.add_msg(
            _('Please first create a homepage before creating additional pages.'
              ), "error")
        return homepage.send_page()

    pagecontent = _("""\
You can add some additional sub pages to your already existing homepage here.

You can choose how open to other readers or writers those pages shall be,
access is controlled by group membership of the corresponding group page.

Just enter the sub page's name and click on the button to create a new page.

Before creating access protected pages, make sure the corresponding group page
exists and has the appropriate members in it. Use HomepageGroupsTemplate for creating
the group pages.

||'''Add a new personal page:'''||'''Related access control list group:'''||
||<<NewPage(HomepageReadWritePageTemplate,read-write page,%(username)s)>>||[[%(username)s/ReadWriteGroup]]||
||<<NewPage(HomepageReadPageTemplate,read-only page,%(username)s)>>||[[%(username)s/ReadGroup]]||
||<<NewPage(HomepagePrivatePageTemplate,private page,%(username)s)>>||%(username)s only||

""")
    pagecontent = pagecontent % locals()

    pagecontent = pagecontent.replace('\n', '\r\n')

    from MoinMoin.parser.text_moin_wiki import Parser as WikiParser

    # This action generate data using the user language
    request.setContentLanguage(request.lang)
    request.theme.send_title(_('MyPages management'), page=homepage)

    parser = WikiParser(pagecontent, request)
    p = Page(request, "$$$")
    request.formatter.setPage(p)
    parser.format(request.formatter)

    # Start content - IMPORTANT - without content div, there is no direction support!
    request.write(request.formatter.startContent("content"))

    request.write(request.formatter.endContent())
    request.theme.send_footer(homepage.page_name)
    request.theme.send_closing_html()