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 get_page_by_slug(pagetype, pageref): """Receives Application Metrics transmissions.""" page = Page.query.filter_by(type=pagetype, id=pageref).first_or_404() return render_theme_template(g.theme, 'page.html', page=page, **defaults )
def render_template(template, **context): if cfg.theme == 'old': app.logger.warning("The old theme is deprecated from 0.16.0 and " "not keep maintained anymore." "In the future will be removed by completely") theme = session.get('theme', cfg.theme) return render_theme_template(theme, template, **context)
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 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 render_template(template, **context): theme = session.get('theme', cfg.theme) return render_theme_template(theme, template, **context)
def render(template, **context): return render_theme_template(flask.current_app.config["CUBEDASH_THEME"], template, **context)
def render(template, **context): theme = session.get('theme', app.config['DEFAULT_THEME']) return render_theme_template(theme, 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 index(): """Receives Application Metrics transmissions.""" return render_theme_template(g.theme, 'index.html', **defaults )
def error404(website, e): theme = get_theme(website.theme) return render_theme_template(theme, '404.html.jinja2'), 404
def error500(website, e): theme = get_theme(website.theme) return render_theme_template(theme, '500.html.jinja2'), 500