2017-06-09 06:25:41 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# ScribeEngine - Open Source Blog Software #
|
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# Copyright (c) 2010-2017 Raoul Snyman #
|
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# This program is free software; you can redistribute it and/or modify it #
|
|
|
|
# under the terms of the GNU General Public License as published by the Free #
|
|
|
|
# Software Foundation; version 2 of the License. #
|
|
|
|
# #
|
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
|
|
|
# more details. #
|
|
|
|
# #
|
|
|
|
# You should have received a copy of the GNU General Public License along #
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
|
|
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
|
|
|
###############################################################################
|
|
|
|
"""
|
2019-02-14 23:01:27 +00:00
|
|
|
The :mod:`~scribeengine.helpers` module contains some theme helper methods
|
2017-06-09 06:25:41 +00:00
|
|
|
"""
|
|
|
|
from flask import current_app
|
2019-02-14 23:01:27 +00:00
|
|
|
from flask_themes2 import get_theme, render_theme_template
|
|
|
|
|
|
|
|
from scribeengine.models import Site
|
|
|
|
|
|
|
|
|
|
|
|
def get_site_details():
|
|
|
|
"""
|
|
|
|
Returns an object with the details of the site
|
|
|
|
"""
|
|
|
|
return Site(current_app.config.get('SITE_NAME', 'Example Blog'),
|
|
|
|
current_app.config.get('SITE_SLOGAN', 'From the Firehose'),
|
|
|
|
current_app.config.get('SITE_ABOUT', ''))
|
2017-06-09 06:25:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
def get_current_theme():
|
|
|
|
"""
|
|
|
|
Determine the current theme.
|
|
|
|
"""
|
|
|
|
ident = current_app.config.get('THEME_DEFAULT', 'quill')
|
|
|
|
return get_theme(ident)
|
|
|
|
|
|
|
|
|
|
|
|
def render(template, **context):
|
|
|
|
"""
|
|
|
|
Render a template, after selecting a theme
|
|
|
|
"""
|
2019-02-14 23:01:27 +00:00
|
|
|
context.update({'site': get_site_details(), 'archives': []})
|
2017-06-09 06:25:41 +00:00
|
|
|
return render_theme_template(get_current_theme(), template, **context)
|
2021-01-30 04:19:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
def render_admin(template, **context):
|
|
|
|
"""
|
|
|
|
Render a template, after selecting a theme
|
|
|
|
"""
|
|
|
|
context.update({'site': get_site_details()})
|
|
|
|
return render_theme_template('admin', template, **context)
|