Пример #1
0
def tag_url(tag, prepend_site=False):
    from liquidluck.writers.base import content_url
    from liquidluck.options import settings
    prefix = settings.site.get('prefix', '')
    url = settings.site.get('url')
    tagcloud = settings.writers.get('tagcloud', None)
    if prepend_site and tagcloud:
        return '%s#%s' % (content_url(url, prefix, 'tag', 'index.html'), tag)
    if tagcloud:
        return '%s#%s' % (content_url(prefix, 'tag', 'index.html'), tag)
    if prepend_site:
        return content_url(url, prefix, 'tag', tag, 'index.html')
    return content_url(prefix, 'tag', tag, 'index.html')
Пример #2
0
def test_content_url():
    assert content_url('index.html') == '/'

    settings.permalink = '{{category}}/{{filename}}.html'
    assert content_url(10) == '/10.html'
    assert content_url('a') == '/a.html'
    assert content_url('a.html') == '/a.html'
    assert content_url('a/') == '/a.html'
    assert content_url('a', 'b') == '/a/b.html'
    assert content_url('a/index.html') == '/a/'
    assert content_url('a/feed.xml') == '/a/feed.xml'
    assert content_url(10) == '/10.html'

    settings.permalink = '{{category}}/{{filename}}'
    assert content_url('a') == '/a'
    assert content_url('a.html') == '/a'
    assert content_url('a/') == '/a'
    assert content_url('a', 'b') == '/a/b'
    assert content_url('a/index.html') == '/a/'
    assert content_url('a/feed.xml') == '/a/feed'
    assert content_url(10) == '/10'

    settings.permalink = '{{category}}/{{filename}}/'
    assert content_url('a') == '/a/'
    assert content_url('a.html') == '/a/'
    assert content_url('a/') == '/a/'
    assert content_url('a', 'b') == '/a/b/'
    assert content_url('a/index.html') == '/a/'
    assert content_url('a/feed.xml') == '/a/feed/'
    assert content_url(10) == '/10/'
def tag_url(tag):
    from liquidluck.writers.base import content_url
    from liquidluck.options import settings
    prefix = settings.site.get('prefix', '')
    return content_url(prefix, 'tag', tag, 'index.html')
def year_url(post):
    from liquidluck.writers.base import content_url
    from liquidluck.options import settings
    prefix = settings.site.get('prefix', '')
    return content_url(prefix, post.date.year, 'index.html')
Пример #5
0
def test_content_url():
    assert content_url("index.html") == "/"

    settings.permalink = "{{category}}/{{filename}}.html"
    assert content_url(10) == "/10.html"
    assert content_url("a") == "/a.html"
    assert content_url("a.html") == "/a.html"
    assert content_url("a/") == "/a.html"
    assert content_url("a", "b") == "/a/b.html"
    assert content_url("a/index.html") == "/a/"
    assert content_url("a/feed.xml") == "/a/feed.xml"
    assert content_url(10) == "/10.html"

    settings.permalink = "{{category}}/{{filename}}"
    assert content_url("a") == "/a"
    assert content_url("a.html") == "/a"
    assert content_url("a/") == "/a"
    assert content_url("a", "b") == "/a/b"
    assert content_url("a/index.html") == "/a/"
    assert content_url("a/feed.xml") == "/a/feed"
    assert content_url(10) == "/10"

    settings.permalink = "{{category}}/{{filename}}/"
    assert content_url("a") == "/a/"
    assert content_url("a.html") == "/a/"
    assert content_url("a/") == "/a/"
    assert content_url("a", "b") == "/a/b/"
    assert content_url("a/index.html") == "/a/"
    assert content_url("a/feed.xml") == "/a/feed/"
    assert content_url(10) == "/10/"