-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtarbell_config.py
100 lines (80 loc) · 3.43 KB
/
tarbell_config.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# -*- coding: utf-8 -*-
"""
Tarbell project configuration
"""
from flask import Blueprint, g, render_template
import ftfy
import jinja2
# To test for photos
import os
blueprint = Blueprint('baseball-stadium-food', __name__)
@blueprint.app_template_filter('test_for_wrigley')
def test_for_wrigley(f):
stadium = f["STADIUM"].upper()
if "WRIGLEY" in stadium:
return True
return False
@blueprint.app_template_filter('format_price')
def format_price(price):
return '${:,.2f}'.format(price)
@blueprint.app_template_filter('has_photo')
def has_photo(f):
"""
Takes the food item id and checks if there exists a correpsonding photo
with the same filename in the img/items folder. Returns true if so.
"""
potential_image_path = "img/items/" + f["ID"] + ".jpg"
return os.path.isfile(potential_image_path)
@blueprint.app_template_filter('get_food_types')
def get_food_types(food, categories):
"""
Takes the food categories and an individual food item.
It returns a string of space-seperated data-* attributes
for the javascript to reference when filtering food items.
"""
retval = ""
for c in categories:
filter_category = c['type']
food_item = c['filter'].upper()
if filter_category == "food" and food[food_item] == 1:
retval = retval + " data-" + food_item.lower()
# Clear out the whitespaces on the ends
return retval.strip()
# Google spreadsheet key
SPREADSHEET_KEY = "1lHN02OwGCnEknjPJv0jr5gd0mUtZbi4iM3ts2BZyyoc"
# Exclude these files from publication
EXCLUDES = ['*.ai', 'img/src','node_scripts', 'subtemplates', '*.md', 'requirements.txt', 'node_modules', 'sass', 'js/src', 'package.json', 'Gruntfile.js']
# Spreadsheet cache lifetime in seconds. (Default: 4)
# SPREADSHEET_CACHE_TTL = 4
# Create JSON data at ./data.json, disabled by default
# CREATE_JSON = True
# Get context from a local file or URL. This file can be a CSV or Excel
# spreadsheet file. Relative, absolute, and remote (http/https) paths can be
# used.
# CONTEXT_SOURCE_FILE = ""
# EXPERIMENTAL: Path to a credentials file to authenticate with Google Drive.
# This is useful for for automated deployment. This option may be replaced by
# command line flag or environment variable. Take care not to commit or publish
# your credentials file.
# CREDENTIALS_PATH = ""
# S3 bucket configuration
S3_BUCKETS = {
# Provide target -> s3 url pairs, such as:
# "mytarget": "mys3url.bucket.url/some/path"
# then use tarbell publish mytarget to publish to it
"production": "graphics.chicagotribune.com/baseball-stadium-food",
"staging": "apps.beta.tribapps.com/baseball-stadium-food",
}
# Default template variables
DEFAULT_CONTEXT = {
'_P2P_PUBLISHING_VARIABLES_': u"Don't edit these. They'll still work, for now, but you should instead make an entry in the p2p_content_items worksheet",
'data': { 'another_key': { 'description': u'This is another description.',
'key': u'another_key'},
'example_key': { 'description': u'This is a description of a key.',
'key': u'example_key'}},
'example_key': u'This is an example of a template variable provided by the google spreadsheet',
'name': 'baseball-stadium-food',
'p2p_content_items': [ { 'content_type': u'htmlstory',
'template': u'_htmlstory.html'}],
'title': 'Baseball stadium food'
}