gdritter repos frony-ritter-designs / a770c93
autopep8 Getty Ritter 4 years ago
2 changed file(s) with 12 addition(s) and 3 deletion(s). Collapse all Expand all
1111
1212 app = flask.Flask(__name__)
1313
14
1415 class Templates:
1516 renderer = pystache.Renderer()
1617
2223 main = load_template('main')
2324 design_page = load_template('design_page')
2425 design_tile = load_template('design_tile')
26
2527
2628 def slugify(string):
2729 def process(char):
116118 page < max))
117119
118120
119
120121 @app.route('/category/')
121122 @main
122123 def get_all_categories():
123124 categories = db.all_categories()
124125 return 'Category', render.select_category(categories)
126
125127
126128 @app.route('/category/<cat>/')
127129 @main
138140 page > min,
139141 page < (max - 1)))
140142
143
141144 @app.route('/category/<cat>/tag/<tag>/')
142145 @main
143146 def get_category_with_tag(cat, tag):
157160 @app.route('/tag/')
158161 @main
159162 def get_all_tags():
160 pretty = lambda t: ' '.join(w.capitalize()
161 for w in t.split('_'))
163 def pretty(t): return ' '.join(w.capitalize()
164 for w in t.split('_'))
162165 tags = (
163166 (t, pretty(t), db.num_for_tag(t))
164167 for t in sorted(db.get_all_tags()))
165168 return 'All Tags', render.select_tag(tags)
169
166170
167171 @app.route('/tag/<tag>/')
168172 @main
44 from PIL import Image
55
66 import typing
7
78
89 def slugify(string):
910 def process(char):
2223 def thumb(self):
2324 return self.image[:-4] + '_thumb' + self.image[-4:]
2425
26
2527 class PageContent:
2628 def __init__(self, source):
2729 self.source = source
3436 return self.source
3537 else:
3638 return self.source[:256] + '...'
39
3740
3841 class Design(typing.NamedTuple):
3942 title: str
5255 if self.images:
5356 return self.images[0].thumb()
5457
58
5559 THUMB_SIZE = (100, 100)
60
5661
5762 class DB:
5863