def test_theme_include_static(self): app = Flask(__name__) app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')] Themes(app, app_identifier='testing') with app.test_request_context('/'): data = render_template('static_parent.html').strip() url = static_file_url('plain', 'style.css') assert data == 'Application, Plain, %s' % url
def test_theme_static(self): app = Flask(__name__) app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')] 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_static_file_url(self): app = Flask(__name__) app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')] Themes(app, app_identifier='testing') with app.test_request_context('/'): url = static_file_url('cool', 'style.css') genurl = url_for('_themes.static', themeid='cool', filename='style.css') assert url == genurl
def favicon() : """ App favicon """ default = app.config['DEFAULT_THEME'] theme_id = app.config.get(u'THEME', default) theme = get_theme(theme_id) path = op.join(theme.static_path, 'img', 'favicon.png') if op.exists(path) : url = static_file_url(theme, 'img/favicon.png') else : url = url_for('static', filename='img/favicon.png') return redirect(url)
def get_img_files(theme): files = os.listdir(os.path.join(theme.static_path, 'img')) return [{'path': static_file_url(theme, os.path.join('img', f) )} for f in files]