Ejemplo n.º 1
0
def execute(macro, args):
    request = macro.request
    pagename = macro.formatter.page.page_name
    
    # Get matches
    start, end, matches = LikePages.findMatches(pagename, request)

    # Render matches
    if matches and not isinstance(matches, (str, unicode)):
        import StringIO
        out = StringIO.StringIO()
        request.redirect(out)
        LikePages.showMatches(pagename, request, start, end, matches, False)
        request.redirect()
        return out.getvalue()
    return args
Ejemplo n.º 2
0
def execute(macro, args):
    request = macro.request
    pagename = macro.formatter.page.page_name
    
    # Get matches
    start, end, matches = LikePages.findMatches(pagename, request)

    # Render matches
    if matches and not isinstance(matches, (str, unicode)):
        return request.redirectedOutput(LikePages.showMatches, pagename, request, start, end, matches, False)

    return args
Ejemplo n.º 3
0
def macro_LikePages(macro, text=u'(none)'):
    request = macro.request
    # we don't want to spend much CPU for spiders requesting nonexisting pages
    if not request.isSpiderAgent:
        pagename = macro.formatter.page.page_name

        # Get matches
        start, end, matches = LikePages.findMatches(pagename, request)

        # Render matches
        if matches and not isinstance(matches, (str, unicode)):
            return request.redirectedOutput(LikePages.showMatches, pagename, request, start, end, matches, False)
        else:
            # if we did not find any similar pages, we just render the text we got as argument:
            return request.formatter.text(text)
    # bots get nothing:
    return ''
Ejemplo n.º 4
0
def macro_LikePages(macro, text=u'(none)'):
    request = macro.request
    # we don't want to spend much CPU for spiders requesting nonexisting pages
    if not request.isSpiderAgent:
        pagename = macro.formatter.page.page_name

        # Get matches
        start, end, matches = LikePages.findMatches(pagename, request)

        # Render matches
        if matches and not isinstance(matches, (str, unicode)):
            return request.redirectedOutput(LikePages.showMatches, pagename,
                                            request, start, end, matches,
                                            False)
        else:
            # if we did not find any similar pages, we just render the text we got as argument:
            return request.formatter.text(text)
    # bots get nothing:
    return ''