Exemplo n.º 1
0
def view_page(page, user=None, is_admin=False, revision=None):
    page = page.get_redirected()

    if page.title.startswith("Label:") and not page.body:
        page.body = DEFAULT_LABEL_BODY % {"title": page.title, "label": page.title[6:]}

    data = {
        'page': page,
        'is_admin': is_admin,
        'is_plain': page.get_property('format') == 'plain',
        'can_edit': access.can_edit_page(page.title, user, is_admin),
        'page_labels': page.get_property('labels', []),
        'revision': revision,
    }

    # logging.debug(data)

    if settings.get('enable-map'):
        if page.get_property('map_label'):
            data['map_url'] = '/w/pages/map?label=' + util.uurlencode(page.get_property('map_label'))
        elif data['can_edit'] or page.geopt:
            data['map_url'] = '/w/map?page=' + util.uurlencode(page.title)

    if revision:
        logging.debug(u'Viewing page "%s" (revision %s)' % (data['page'].title, revision))
    else:
        logging.debug(u'Viewing page "%s"' % data['page'].title)
    return render('view_page.html', data)
Exemplo n.º 2
0
def view_page(page, user=None, is_admin=False, revision=None):
    page = page.get_redirected()

    if page.title.startswith("Label:") and not page.body:
        page.body = DEFAULT_LABEL_BODY % {"title": page.title, "label": page.title[6:]}

    data = {
        "page": page,
        "is_admin": is_admin,
        "is_plain": page.get_property("format") == "plain",
        "can_edit": access.can_edit_page(page.title, user, is_admin),
        "page_labels": page.get_property("labels", []),
        "revision": revision,
    }

    # logging.debug(data)

    if settings.get("enable-map"):
        if page.get_property("map_label"):
            data["map_url"] = "/w/pages/map?label=" + util.uurlencode(page.get_property("map_label"))
        elif data["can_edit"] or page.geopt:
            data["map_url"] = "/w/map?page=" + util.uurlencode(page.title)

    if revision:
        logging.debug(u'Viewing page "%s" (revision %s)' % (data["page"].title, revision))
    else:
        logging.debug(u'Viewing page "%s"' % data["page"].title)
    return render("view_page.html", data)
Exemplo n.º 3
0
def view_page(page, user=None, is_admin=False, revision=None):
    page = page.get_redirected()

    if page.title.startswith("Label:") and not page.body:
        page.body = DEFAULT_LABEL_BODY % {"title": page.title, "label": page.title[6:]}

    data = {
        'page': page,
        'is_admin': is_admin,
        'is_plain': page.get_property('format') == 'plain',
        'can_edit': access.can_edit_page(page.title, user, is_admin),
        'page_labels': page.get_property('labels', []),
        'revision': revision,
    }

    # logging.debug(data)

    if settings.get('enable-map'):
        if page.get_property('map_label'):
            data['map_url'] = '/w/pages/map?label=' + util.uurlencode(page.get_property('map_label'))
        elif data['can_edit'] or page.geopt:
            data['map_url'] = '/w/map?page=' + util.uurlencode(page.title)

    if revision:
        logging.debug(u'Viewing page "%s" (revision %s)' % (data['page'].title, revision))
    else:
        logging.debug(u'Viewing page "%s"' % data['page'].title)
    return render('view_page.html', data)
Exemplo n.º 4
0
def view_page(page, user=None, is_admin=False):
    page = page.get_redirected()
    data = {
        'page': page,
        'is_admin': is_admin,
        'is_plain': page.get_property('format') == 'plain',
        'can_edit': access.can_edit_page(page.title, user, is_admin),
        'page_labels': page.get_property('labels', []),
    }

    logging.debug(data)

    if settings.get('enable-map'):
        if page.get_property('map_label'):
            data['map_url'] = '/w/pages/map?label=' + util.uurlencode(page.get_property('map_label'))
        elif data['can_edit'] or page.geopt:
            data['map_url'] = '/w/map?page=' + util.uurlencode(page.title)

    logging.debug(u'Viewing page "%s"' % data['page'].title)
    return render('view_page.html', data)
Exemplo n.º 5
0
def uurlencode(value):
    return util.uurlencode(value)
Exemplo n.º 6
0
def uurlencode(value):
    return util.uurlencode(value)
Exemplo n.º 7
0
 def test_uurlencode_filter(self):
     self.assertEquals(util.uurlencode(None), '')
     self.assertEquals(util.uurlencode('foo bar'), 'foo_bar')
     self.assertEquals(util.uurlencode(u'тест'), '%D1%82%D0%B5%D1%81%D1%82')
Exemplo n.º 8
0
 def test_uurlencode_filter(self):
     self.assertEquals(util.uurlencode(None), '')
     self.assertEquals(util.uurlencode('foo bar'), 'foo_bar')
     self.assertEquals(util.uurlencode(u'тест'), '%D1%82%D0%B5%D1%81%D1%82')