Exemple #1
0
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)

    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?
    app.add_url_rule('/<path:long_slug>.html',
                     view_func=ContentDetail.as_view('detail'))
    # Match channels by its long_slug mpath
    app.add_url_rule('/<path:long_slug>/',
                     view_func=ContentList.as_view('list'))

    app.add_url_rule('/questions/<path:pretty_slug>.html',
                     view_func=QuestionDetail.as_view('question-detail'))


    # Home page
    app.add_url_rule(
        '/',
        view_func=ContentList.as_view('home'),
        defaults={"long_slug": Channel.get_homepage('long_slug') or "home"}
    )
Exemple #2
0
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'))

    # 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"})
Exemple #3
0
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'))

    # 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"}
    )
Exemple #4
0
 def get_default_channel(cls):
     default_channel = cls.DEFAULT_CHANNEL
     try:
         return Channel.objects.get(long_slug=default_channel)
     except Exception as e:
         logger.warning(str(e))
         return Channel.get_homepage()
Exemple #5
0
 def get_default_channel(cls):
     default_channel = cls.DEFAULT_CHANNEL
     try:
         return Channel.objects.get(long_slug=default_channel)
     except Exception as e:
         logger.warning(str(e))
         return Channel.get_homepage()
Exemple #6
0
 def inject():
     now = datetime.datetime.now()
     return dict(channels=Channel.objects(published=True,
                                          available_at__lte=now,
                                          parent=None),
                 Config=Config,
                 Content=Content,
                 Channel=Channel,
                 homepage=Channel.get_homepage(),
                 Link=Link)
 def inject():
     now = datetime.datetime.now()
     return dict(
         channels=Channel.objects(published=True,
                                  available_at__lte=now,
                                  parent=None),
         Config=Config,
         Content=Content,
         Channel=Channel,
         homepage=Channel.get_homepage()
     )
Exemple #8
0
def configure(app):
    # Match content detail, .html added to distinguish from channels
    # better way? how?
    app.add_url_rule('/<path:long_slug>.html',
                     view_func=ContentDetail.as_view('detail'))
    # 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('slug') or "home"}
    )
Exemple #9
0
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)

    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?
    app.add_url_rule('/<path:long_slug>.html',
                     view_func=ContentDetail.as_view('detail'))
    # 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"})