This repository has been archived on 2024-11-20. You can view files and clone it, but cannot push or open issues or pull requests.
old-scribeengine/scribeengine/helpers.py

62 lines
2.6 KiB
Python

# -*- 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 #
###############################################################################
"""
The :mod:`~scribeengine.helpers` module contains some theme helper methods
"""
from flask import current_app
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', ''))
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
"""
context.update({'site': get_site_details(), 'archives': []})
return render_theme_template(get_current_theme(), template, **context)
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)