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)
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)
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)
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)
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)