Ejemplo n.º 1
0
def wrap_span(request, pageobj, key, data, id):
    pagename = pageobj.page_name
    fdata = format_wikitext(request, data)

    if not key:
        return fdata

    header = False

    if key == data:
        header = True

    if '->' in key:
        # Get indirection data, the same function get_metas uses
        linkdata = add_matching_redirs(request, request.page, {}, {}, {}, key,
                                       pagename, key)

        # Broken link, do not give anything editable as this will not
        # work in any case.
        if not linkdata:
            return fdata

        if key in linkdata:
            for pname in linkdata[key]:
                if not data:
                    pagename = pname
                    key = key.split('->')[-1]
                    break
                if data in linkdata[key][pname] or header:
                    pagename = pname
                    key = key.split('->')[-1]
                    break

    if data == fdata or header:
        return form_writer(
            u'<span data-page="%s" data-key="%s" data-index="%s">', pagename,
            key, str(id)) + fdata + '</span>'

    return form_writer(
        u'<span data-page="%s" data-key="%s" data-value="%s" data-index="%s">',
        pagename, key, data, str(id)) + fdata + '</span>'
Ejemplo n.º 2
0
def wrap_span(request, pageobj, key, data, id, parser=None):
    fdata = format_wikitext(request, data, parser)

    if not key:
        return fdata

    header = False

    if key == data:
        header = True

    if '->' in key:
        # Get indirection data, the same function get_metas uses
        linkdata = add_matching_redirs(request, request.page, {}, {}, {},
                                       key, pageobj.page_name, key)

        # Broken link, do not give anything editable as this will not
        # work in any case.
        if not linkdata:
            return fdata

        if key in linkdata:
            for pname in linkdata[key]:
                if not data:
                    pagename = pname
                    key = key.split('->')[-1]
                    break
                if data in linkdata[key][pname] or header:
                    pagename = pname
                    key = key.split('->')[-1]
                    break

    if data == fdata or header:
        return form_writer(
            u'<span data-page="%s" data-key="%s" data-index="%s">',
            pageobj.page_name, key, str(id)) + fdata + '</span>'

    return form_writer(
        u'<span data-page="%s" data-key="%s" data-value="%s" data-index="%s">',
        pageobj.page_name, key, data, str(id)) + fdata + '</span>'
Ejemplo n.º 3
0
 def wr(fmt, *args):
     request.write(form_writer(fmt, *args))
Ejemplo n.º 4
0
 def wr(fmt, *args):
     request.write(form_writer(fmt, *args))