示例#1
0
def page_variant_url(page, variant):
    '''
    TODO: Hacked together to implement new page views.
    Refactor url functions.
    '''
    label = _url.quote(page.label)
    if variant == model.Text.HEAD:
        variant = None
    else:
        variant = _url.quote(variant)
    return _url.build(page.instance, 'page', label, member=variant)
示例#2
0
文件: tag_helper.py 项目: alkadis/vcv
 def url_(tag, instance, **kwargs):
     ident = None
     try:
         ident = _url.quote(tag.name)
     except KeyError:
         ident = tag.id
     return _url.build(instance, u'tag', ident, **kwargs)
示例#3
0
 def url_(tag, instance, **kwargs):
     ident = None
     try:
         ident = _url.quote(tag.name)
     except KeyError:
         ident = tag.id
     return _url.build(instance, u'tag', ident, **kwargs)
示例#4
0
def url(page, in_context=True, member=None, **kwargs):
    if in_context and page.proposal and not member:
        return proposal.url(page.proposal, **kwargs)
    if (in_context and member is None and page.is_sectionpage() and
            page.sectionpage_root() != page):
        if u'anchor' not in kwargs:
            kwargs[u'anchor'] = u'subpage-%i' % page.id
        return url(page.sectionpage_root(), in_context=False, **kwargs)
    label = _url.quote(page.label)
    return _url.build(page.instance, 'page', label, member=member, **kwargs)
示例#5
0
def url(text, **kwargs):
    import page_helper as page
    if text is None:
        return ''
    in_context = (text == text.page.variant_head(text.variant))
    url = page.url(text.page, in_context=in_context)
    if text.page.has_variants and text.variant != text.HEAD:
        url += u'/' + _url.quote(text.variant)
    if text != text.page.variant_head(text.variant):
        url += u';' + str(text.id)
    return _url.append_member_and_format(url, **kwargs)
示例#6
0
def url(text, **kwargs):
    import page_helper as page
    if text is None:
        return ''
    in_context = (text == text.page.variant_head(text.variant))
    url = page.url(text.page, in_context=in_context)
    if text.page.has_variants and text.variant != text.HEAD:
        url += u'/' + _url.quote(text.variant)
    if text != text.page.variant_head(text.variant):
        url += u';' + str(text.id)
    return _url.append_member_and_format(url, **kwargs)
示例#7
0
def page_text_url(page, text, member=None):
    label = '%s;%d' % (_url.quote(page.label), text.id)
    return _url.build(page.instance, 'page', label, member=member)