forked from nprapps/elections14
/
static_theme.py
50 lines (40 loc) · 1.02 KB
/
static_theme.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
from flask import Blueprint, render_template
from render_utils import make_context
import static_app
import app_config
theme = Blueprint(
'theme',
__name__,
url_prefix='/theme',
template_folder='theme/templates'
)
@theme.route('/less/<string:filename>')
def _theme_less(filename):
"""
Render LESS files.
"""
return static_app.less(filename, 'theme')
@theme.route('/js/app_config.js')
def _app_config_js():
"""
Render app configuration to javascript.
"""
return static_app._app_config_js()
@theme.route('/js/copy.js')
def _copy_js():
"""
Render copytext to javascript.
"""
return static_app._copy_js()
@theme.route('/<path:path>')
def _theme_static(path):
"""
Serve arbitrary files.
"""
return static_app.static(path, 'theme')
@theme.route('/theme')
def _theme():
context = make_context(static_path='theme', absolute=True)
context['tumblr_name'] = app_config.TUMBLR_NAME
return render_template('theme.html', **context)