Пример #1
0
    def test_render_theme_template(self):
        app = Flask(__name__)
        app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')]
        setup_themes(app, app_identifier='testing')

        with app.test_request_context('/'):
            coolsrc = render_theme_template('cool', 'hello.html').strip()
            plainsrc = render_theme_template('plain', 'hello.html').strip()
            assert coolsrc == 'Hello from Cool Blue v2.'
            assert plainsrc == 'Hello from the application'
Пример #2
0
    def test_render_theme_template(self):
        app = Flask(__name__)
        app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')]
        setup_themes(app, app_identifier='testing')

        with app.test_request_context('/'):
            coolsrc = render_theme_template('cool', 'hello.html').strip()
            plainsrc = render_theme_template('plain', 'hello.html').strip()
            assert coolsrc == 'Hello from Cool Blue v2.'
            assert plainsrc == 'Hello from the application'
Пример #3
0
    def test_active_theme(self):
        app = Flask(__name__)
        app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')]
        setup_themes(app, app_identifier='testing')

        with app.test_request_context('/'):
            appdata = render_template('active.html').strip()
            cooldata = render_theme_template('cool', 'active.html').strip()
            plaindata = render_theme_template('plain', 'active.html').strip()
            assert appdata == 'Application, Active theme: none'
            assert cooldata == 'Cool Blue v2, Active theme: cool'
            assert plaindata == 'Application, Active theme: plain'
Пример #4
0
    def test_active_theme(self):
        app = Flask(__name__)
        app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')]
        setup_themes(app, app_identifier='testing')

        with app.test_request_context('/'):
            appdata = render_template('active.html').strip()
            cooldata = render_theme_template('cool', 'active.html').strip()
            plaindata = render_theme_template('plain', 'active.html').strip()
            assert appdata == 'Application, Active theme: none'
            assert cooldata == 'Cool Blue v2, Active theme: cool'
            assert plaindata == 'Application, Active theme: plain'
Пример #5
0
def node(website, folder, node):
    folderob = Folder.query.filter_by(name=folder, website=website).first()
    if folderob is None:
        # Are we handling a /node/custom_url case?
        folderob = Folder.query.filter_by(name=u'',
                                          website=website).first_or_404()
        nodeob = Node.query.filter_by(name=folder,
                                      folder=folderob).first_or_404()
        # The node exists. Let the path handler figure out what to do with it
        return path_handler(path=u'/' + nodeob.name + u'/' + node)
    else:
        nodeob = Node.query.filter_by(name=node,
                                      folder=folderob).first_or_404()

    # For the context processor to pick up theme for this request
    # and for the nodehelper to know the current folder
    g.folder = folderob
    if node_registry[nodeob.type].view_handler is not None:
        # This node type is capable of rendering itself
        return node_registry[nodeob.type].view_handler(eventapp,
                                                       folderob.website,
                                                       folderob, nodeob).GET()
    elif node_registry[nodeob.type].render:
        theme = get_theme(folderob.theme)
        return render_theme_template(theme,
                                     nodeob.template,
                                     website=folderob.website,
                                     folder=folderob,
                                     title=nodeob.title,
                                     node=nodeob,
                                     _fallback=False)
    else:
        abort(404)  # We don't know how to render anything else
Пример #6
0
    def test_theme_static(self):
        app = Flask(__name__)
        app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')]
        setup_themes(app, app_identifier='testing')

        with app.test_request_context('/'):
            coolurl = static_file_url('cool', 'style.css')
            cooldata = render_theme_template('cool', 'static.html').strip()
            assert cooldata == 'Cool Blue v2, %s' % coolurl
Пример #7
0
    def test_theme_static(self):
        app = Flask(__name__)
        app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')]
        setup_themes(app, app_identifier='testing')

        with app.test_request_context('/'):
            coolurl = static_file_url('cool', 'style.css')
            cooldata = render_theme_template('cool', 'static.html').strip()
            assert cooldata == 'Cool Blue v2, %s' % coolurl
Пример #8
0
def feed(website):
    theme = get_theme(website.theme)
    posts = rootfeed(website)
    if posts:
        updated = max(posts[0].revisions.published.updated_at, posts[0].published_at).isoformat() + 'Z'
    else:
        updated = datetime.utcnow().isoformat() + 'Z'
    return Response(render_theme_template(theme, 'feed.xml',
            feedid=url_for('index', _external=True),
            website=website, title=website.title, posts=posts, updated=updated),
        content_type='application/atom+xml; charset=utf-8')
Пример #9
0
 def GET(self):
     form = ConfirmForm()
     theme = get_theme(self.folder.theme)
     return render_theme_template(theme,
                                  self.node.template,
                                  website=self.website,
                                  folder=self.folder,
                                  title=self.node.title,
                                  node=self.node,
                                  form=form,
                                  _fallback=False)
Пример #10
0
def node(folder, node):
    # For the context processor to pick up theme for this request
    # and for the nodehelper to know the current folder
    g.folder = folder
    if node_registry[node.type].view_handler is not None:
        # This node type is capable of rendering itself
        return node_registry[node.type].view_handler(eventapp, folder.website, folder, node).GET()
    elif node_registry[node.type].render:
        theme = get_theme(folder.theme)
        return render_theme_template(theme, node.template,
            website=folder.website, folder=folder, title=node.title, node=node, _fallback=False)
    else:
        abort(404)  # We don't know how to render anything else
Пример #11
0
def folder_feed(folder):
    theme = get_theme(folder.theme)
    posts = folderfeed(folder)
    if posts:
        updated = posts[0].published_at.isoformat() + 'Z'
    else:
        updated = datetime.utcnow().isoformat() + 'Z'
    return Response(render_theme_template(
            theme, 'feed.xml',
            feedid=url_for('folder', folder=folder.name),
            website=folder.website,
            title=u"%s — %s" % (folder.title or folder.name, folder.website.title),
            posts=posts, updated=updated),
        content_type='application/atom+xml; charset=utf-8')
Пример #12
0
def folder_feed(folder):
    theme = get_theme(folder.theme)
    posts = folderfeed(folder)
    if posts:
        updated = posts[0].published_at.isoformat() + 'Z'
    else:
        updated = datetime.utcnow().isoformat() + 'Z'
    return Response(render_theme_template(
        theme,
        'feed.xml',
        feedid=url_for('folder', folder=folder.name),
        website=folder.website,
        title=u"%s — %s" % (folder.title or folder.name, folder.website.title),
        posts=posts,
        updated=updated),
                    content_type='application/atom+xml; charset=utf-8')
Пример #13
0
def feed(website):
    theme = get_theme(website.theme)
    posts = rootfeed(website)
    if posts:
        updated = max(posts[0].revisions.published.updated_at,
                      posts[0].published_at).isoformat() + 'Z'
    else:
        updated = datetime.utcnow().isoformat() + 'Z'
    return Response(render_theme_template(theme,
                                          'feed.xml',
                                          feedid=url_for('index',
                                                         _external=True),
                                          website=website,
                                          title=website.title,
                                          posts=posts,
                                          updated=updated),
                    content_type='application/atom+xml; charset=utf-8')
Пример #14
0
def node(website, folder, node):
    folderob = Folder.query.filter_by(name=folder, website=website).first()
    if folderob is None:
        # Are we handling a /node/custom_url case?
        folderob = Folder.query.filter_by(name=u'', website=website).first_or_404()
        nodeob = Node.query.filter_by(name=folder, folder=folderob).first_or_404()
        # The node exists. Let the path handler figure out what to do with it
        return path_handler(path=u'/' + nodeob.name + u'/' + node)
    else:
        nodeob = Node.query.filter_by(name=node, folder=folderob).first_or_404()

    # For the context processor to pick up theme for this request
    # and for the nodehelper to know the current folder
    g.folder = folderob
    if node_registry[nodeob.type].view_handler is not None:
        # This node type is capable of rendering itself
        return node_registry[nodeob.type].view_handler(eventapp, folderob.website, folderob, nodeob).GET()
    elif node_registry[nodeob.type].render:
        theme = get_theme(folderob.theme)
        return render_theme_template(theme, nodeob.template,
            website=folderob.website, folder=folderob, title=nodeob.title, node=nodeob, _fallback=False)
    else:
        abort(404)  # We don't know how to render anything else
Пример #15
0
def blog_about():
    return render_theme_template('default', 'blog_about.html')
Пример #16
0
        app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')]
        setup_themes(app, app_identifier='testing')

        with app.test_request_context('/'):
            src = themes_blueprint.jinja_loader.get_source(
                app.jinja_env, '_themes/cool/hello.html'
            )
            assert src[0].strip() == 'Hello from Cool Blue v2.'

    def test_render_theme_template(self):
        app = Flask(__name__)
        app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')]
        setup_themes(app, app_identifier='testing')

        with app.test_request_context('/'):
            coolsrc = render_theme_template('cool', 'hello.html').strip()
            plainsrc = render_theme_template('plain', 'hello.html').strip()
            assert coolsrc == 'Hello from Cool Blue v2.'
            assert plainsrc == 'Hello from the application'

    def test_active_theme(self):
        app = Flask(__name__)
        app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')]
        setup_themes(app, app_identifier='testing')

        with app.test_request_context('/'):
            appdata = render_template('active.html').strip()
            cooldata = render_theme_template('cool', 'active.html').strip()
            plaindata = render_theme_template('plain', 'active.html').strip()
            assert appdata == 'Application, Active theme: none'
            assert cooldata == 'Cool Blue v2, Active theme: cool'
Пример #17
0
def render(template, **kwargs):
    theme = app.config['THEME']
    return render_theme_template(theme, template, **kwargs)
Пример #18
0
def render(template, **context):
    return render_theme_template(getTheme(), template, **context)
Пример #19
0
def render(template, **kwargs):
    return render_theme_template(app.config.get('THEME'), template, **kwargs)
Пример #20
0
def render_template(template, **context):
    return render_theme_template(get_current_theme(), template, **context)
Пример #21
0
def error404(website, e):
    theme = get_theme(website.theme)
    return render_theme_template(theme, '404.html'), 404
Пример #22
0
def error500(website, e):
    theme = get_theme(website.theme)
    return render_theme_template(theme, '500.html'), 500
Пример #23
0
def render_template(template, **context):
    return render_theme_template(get_current_theme(), template, **context)
Пример #24
0
def blog_about():
    return render_theme_template('default', 'blog_about.html')
Пример #25
0
def render(template, **context):
    return render_theme_template(getTheme(), template, **context)
Пример #26
0
 def GET(self):
     form = ConfirmForm()
     theme = get_theme(self.folder.theme)
     return render_theme_template(theme, self.node.template,
         website=self.website, folder=self.folder, title=self.node.title, node=self.node,
         form=form, _fallback=False)
Пример #27
0
def render(template, **context):
    theme = session.get('theme', app.config['DEFAULT_THEME'])
    return render_theme_template(theme, template, **context)
Пример #28
0
def render(template, **context):
    theme = session.get("theme", app.config["DEFAULT_THEME"])
    return render_theme_template(theme, template, **context)