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_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' assert plaindata == 'Application, Active theme: plain'
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'
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
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
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
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')
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)
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
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')
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')
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')
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
def blog_about(): return render_theme_template('default', 'blog_about.html')
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'
def render(template, **kwargs): theme = app.config['THEME'] return render_theme_template(theme, template, **kwargs)
def render(template, **context): return render_theme_template(getTheme(), template, **context)
def render(template, **kwargs): return render_theme_template(app.config.get('THEME'), template, **kwargs)
def render_template(template, **context): return render_theme_template(get_current_theme(), template, **context)
def error404(website, e): theme = get_theme(website.theme) return render_theme_template(theme, '404.html'), 404
def error500(website, e): theme = get_theme(website.theme) return render_theme_template(theme, '500.html'), 500
def render_template(template, **context): return render_theme_template(get_current_theme(), template, **context)
def blog_about(): return render_theme_template('default', 'blog_about.html')
def render(template, **context): return render_theme_template(getTheme(), template, **context)
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)
def render(template, **context): theme = session.get('theme', app.config['DEFAULT_THEME']) return render_theme_template(theme, template, **context)
def render(template, **context): theme = session.get("theme", app.config["DEFAULT_THEME"]) return render_theme_template(theme, template, **context)