def make_ca_context(ca, asset_depth=0): """ Create a base-context for rendering views. Includes app_config and JS/CSS includers. `asset_depth` indicates how far into the url hierarchy the assets are hosted. If 0, then they are at the root. If 1 then at /foo/, etc. """ context = flatten_app_config() copy = copytext.Copy(app_config.COPY_PATH) sheet = copy['community_area_data'] community_area = '' for row in sheet: if row['CA_number'] == ca: community_area = row break context['COPY'] = copytext.Copy(app_config.COPY_PATH) context['JS'] = JavascriptIncluder(asset_depth=asset_depth) context['CSS'] = CSSIncluder(asset_depth=asset_depth) context['CA'] = row return context
def _render_tumblr_theme(slug): """ Render out the tumblr theme. When handled as an URL, gets target=None. When called from fabfile as part of render(), gets target from env.settings. production: Renders files inline. staging/development: Points files to 127.0.0.1 {{ copy.key_name }} for bits of copy. Key name is the first column's value. """ # Set up context bits. context = flatten_app_config() # For copytext. context['copy'] = {} # For og image reference context['slug'] = slug # Loop over the copy in the sheet named for the slug. # Append it like it's a dict. for item in copytext.Copy()[slug]: context['copy'][item.key] = item.value # Open the theme's file. with open('tumblrs/%s/theme.html.tpl' % slug, 'r') as readfile: template_string = unicode(readfile.read()) # Render the template. return render_template_string(template_string, **context)
def _app_config_js(): """ Render app configuration to javascript. """ config = flatten_app_config() js = 'window.APP_CONFIG = ' + json.dumps(config, cls=BetterJSONEncoder) return js, 200, { 'Content-Type': 'application/javascript' }
def _app_config_js(): """ This includes both client-side config and some COPY vars we need in JS. """ config = flatten_app_config() js = 'window.APP_CONFIG = ' + json.dumps(config) + ';' features = {} data = copytext.Copy(app_config.COPY_PATH) for feature in data['feature_list']: features[feature['key']] = dict(zip(feature._columns, feature._row)) features = 'window.FEATURES = ' + json.dumps(features) + ';' return '\n'.join([js, features]), 200, { 'Content-Type': 'application/javascript' }
def make_context(asset_depth=0): """ Create a base-context for rendering views. Includes app_config and JS/CSS includers. `asset_depth` indicates how far into the url hierarchy the assets are hosted. If 0, then they are at the root. If 1 then at /foo/, etc. """ context = flatten_app_config() context['COPY'] = PlayersCopy(app_config.COPY_PATH) context['JS'] = JavascriptIncluder(asset_depth=asset_depth) context['CSS'] = CSSIncluder(asset_depth=asset_depth) return context
def _app_config_js(): config = flatten_app_config() js = 'window.APP_CONFIG = ' + json.dumps(config) return js, 200, { 'Content-Type': 'application/javascript' }
def _app_config_js(): config = flatten_app_config() js = "window.APP_CONFIG = " + json.dumps(config) return js, 200, {"Content-Type": "application/javascript"}
def _render_tumblr_theme(slug): context = flatten_app_config() return render_template('%s-theme.html' % slug, **context)
def _app_config_js(slug): config = flatten_app_config() config.update(flatten_post_config(slug)) js = 'window.APP_CONFIG = ' + json.dumps(config) return js, 200, { 'Content-Type': 'application/javascript' }
def _app_config_js(): config = flatten_app_config() js = 'window.APP_CONFIG = ' + json.dumps(config, cls=BetterJSONEncoder) return make_response(js, 200, { 'Content-Type': 'application/javascript' })
def _app_config_js(): config = flatten_app_config() js = 'window.APP_CONFIG = ' + json.dumps(config) return js, 200, {'Content-Type': 'application/javascript'}
def test_app_config_no_db_credentials(self): from render_utils import flatten_app_config config = flatten_app_config() self.assertIsNone(config.get('database'))