view data/plugin/macro/LinkTo.py @ 654:8c828d7b6cd4 tip

PDFList: check for pyPdf.utils.PdfReadError
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Wed, 07 Dec 2016 14:27:25 +0100
parents 127da830be6c
children
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - LinkTo

    print a list of pages who links to the current page

    @copyright:  2001 Juergen Hermann <jh@web.de>,
                 2011-2016 MoinMoin:ReimarBauer

    @license: GNU GPL, see COPYING for details.
"""
Dependencies = ["namespace"]

def macro_LinkTo(macro, reverse=False):
    request = macro.request
    formatter = request.formatter
    pages = request.rootpage.getPageDict()
    pagelist = pages.keys()
    pageobjs = []
    for name in pagelist:
        if request.page.page_name in pages[name].getPageLinks(request):
            pageobjs.append(pages[name])

    links = [''.join([formatter.listitem(1),
                formatter.url(1, href=page.url(request, escape=0)),
                page.page_name,
                formatter.url(0)]) for page in pageobjs]
    links.sort()
    if reverse:
        links.reverse()
    return ''.join(links)