gdritter repos frony-ritter-designs / 169f686
Start to address lints Getty Ritter 4 years ago
1 changed file(s) with 17 addition(s) and 13 deletion(s). Collapse all Expand all
11 #!/usr/bin/python2
22
33 import flask
4 import web
54 import markdown
65 import pystache
6 import web
7
78 import storage
8 import sys
99
1010 web.template.ALLOWED_AST_NODES.append('Constant')
1111
1313
1414
1515 class Templates:
16 '''
17 Local module to contain mustache templates
18 '''
1619 renderer = pystache.Renderer()
1720
1821 def load_template(name):
160163 @app.route('/tag/')
161164 @main
162165 def get_all_tags():
163 def pretty(t): return ' '.join(w.capitalize()
164 for w in t.split('_'))
166 def pretty(t):
167 return ' '.join(w.capitalize()
168 for w in t.split('_'))
165169 tags = (
166170 (t, pretty(t), db.num_for_tag(t))
167171 for t in sorted(db.get_all_tags()))
171175 @app.route('/tag/<tag>/')
172176 @main
173177 def get_tag(tag):
174 page = int(flask.request.args.get('page') or 0)
175 data = db.get_designs_by_tag(tag, page)
176 min, max = db.max_page_range_for_tag(tag)
178 pg_num = int(flask.request.args.get('page') or 0)
179 data = db.get_designs_by_tag(tag, pg_num)
180 pg_min, pg_max = db.max_page_range_for_tag(tag)
177181 pretty_tag = ' '.join(w.capitalize()
178182 for w in tag.split('_'))
179183 return (pretty_tag,
181185 tag,
182186 (render.design_tile(name, pics, 0, id)
183187 for name, pics, desc, cat, id in data),
184 page,
185 page > min,
186 page < max))
188 pg_num,
189 pg_num > pg_min,
190 pg_num < pg_max))
187191
188192
189193 @app.route('/<name>/')
190194 @main
191 def page(name):
192 pg = db.get_page(name)
193 return (pg.title, markdown.markdown(pg.text))
195 def get_page(name):
196 page = db.get_page(name)
197 return (page.title, markdown.markdown(page.text))
194198
195199
196200 # class admin: