示例#1
0
文件: views.py 项目: blakev/quokka
def configure(app):
    app.add_url_rule('/mediafiles/<path:filename>', view_func=media)
    app.add_url_rule('/template_files/<path:filename>',
                     view_func=template_files)
    app.add_url_rule('/theme_template_files/<identifier>/<path:filename>',
                     view_func=theme_template_files)
    for filepath in app.config.get('MAP_STATIC_ROOT', []):
        app.add_url_rule(filepath, view_func=static_from_root)

    # Match content detail, .html added to distinguish from channels
    # better way? how?
    CONTENT_EXTENSION = app.config.get("CONTENT_EXTENSION", "html")
    app.add_url_rule('/<path:long_slug>.{0}'.format(CONTENT_EXTENSION),
                     view_func=ContentDetail.as_view('detail'))

    # Atom Feed
    app.add_url_rule('/<path:long_slug>.atom', view_func=FeedAtom.as_view('atom_list'))
    app.add_url_rule('/tag/<tag>.atom', view_func=TagAtom.as_view('atom_tag'))

    # RSS Feed
    app.add_url_rule('/<path:long_slug>.xml', view_func=FeedRss.as_view('rss_list'))
    app.add_url_rule('/tag/<tag>.xml', view_func=TagRss.as_view('rss_tag'))

    # Tag list
    app.add_url_rule('/tag/<tag>/', view_func=TagList.as_view('tag'))

    # Match channels by its long_slug mpath
    app.add_url_rule('/<path:long_slug>/',
                     view_func=ContentList.as_view('list'))
    # Home page
    app.add_url_rule(
        '/',
        view_func=ContentList.as_view('home'),
        defaults={"long_slug": Channel.get_homepage('long_slug') or "home"}
    )
示例#2
0
文件: views.py 项目: zming619/quokka
def configure(app):
    app.add_quokka_url_rule('/sitemap.xml',
                            view_func=SiteMap.as_view('sitemap'))
    app.add_quokka_url_rule('/mediafiles/<path:filename>', view_func=media)
    app.add_quokka_url_rule('/template_files/<path:filename>',
                            view_func=template_files)
    app.add_quokka_url_rule(
        '/theme_template_files/<identifier>/<path:filename>',
        view_func=theme_template_files)
    for filepath in app.config.get('MAP_STATIC_ROOT', []):
        app.add_quokka_url_rule(filepath, view_func=static_from_root)

    # Match content detail, .html added to distinguish from channels
    # better way? how?
    content_extension = app.config.get("CONTENT_EXTENSION", "html")
    app.add_quokka_url_rule('/<path:long_slug>.{0}'.format(content_extension),
                            view_func=ContentDetail.as_view('detail'))

    # Draft preview
    app.add_quokka_url_rule('/<path:long_slug>.preview',
                            view_func=ContentDetailPreview.as_view('preview'))

    # Atom Feed
    app.add_quokka_url_rule('/<path:long_slug>.atom',
                            view_func=FeedAtom.as_view('atom_list'))
    app.add_quokka_url_rule('/tag/<tag>.atom',
                            view_func=TagAtom.as_view('atom_tag'))

    # RSS Feed
    app.add_quokka_url_rule('/<path:long_slug>.xml',
                            view_func=FeedRss.as_view('rss_list'))
    app.add_quokka_url_rule('/tag/<tag>.xml',
                            view_func=TagRss.as_view('rss_tag'))

    # Tag list
    app.add_quokka_url_rule('/tag/<tag>/', view_func=TagList.as_view('tag'))

    # Match channels by its long_slug mpath
    app.add_quokka_url_rule('/<path:long_slug>/',
                            view_func=ContentList.as_view('list'))
    # Home page
    app.add_quokka_url_rule(
        '/',
        view_func=ContentList.as_view('home'),
        defaults={"long_slug": Channel.get_homepage('long_slug') or "home"})