Start to address lints
Getty Ritter
4 years ago
1 | 1 | #!/usr/bin/python2 |
2 | 2 | |
3 | 3 | import flask |
4 | import web | |
5 | 4 | import markdown |
6 | 5 | import pystache |
6 | import web | |
7 | ||
7 | 8 | import storage |
8 | import sys | |
9 | 9 | |
10 | 10 | web.template.ALLOWED_AST_NODES.append('Constant') |
11 | 11 | |
13 | 13 | |
14 | 14 | |
15 | 15 | class Templates: |
16 | ''' | |
17 | Local module to contain mustache templates | |
18 | ''' | |
16 | 19 | renderer = pystache.Renderer() |
17 | 20 | |
18 | 21 | def load_template(name): |
160 | 163 | @app.route('/tag/') |
161 | 164 | @main |
162 | 165 | 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('_')) | |
165 | 169 | tags = ( |
166 | 170 | (t, pretty(t), db.num_for_tag(t)) |
167 | 171 | for t in sorted(db.get_all_tags())) |
171 | 175 | @app.route('/tag/<tag>/') |
172 | 176 | @main |
173 | 177 | def get_tag(tag): |
174 | page = int(flask.request.args.get('page') or 0) | |
175 | data = db.get_designs_by_tag(tag, page) | |
176 |
|
|
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) | |
177 | 181 | pretty_tag = ' '.join(w.capitalize() |
178 | 182 | for w in tag.split('_')) |
179 | 183 | return (pretty_tag, |
181 | 185 | tag, |
182 | 186 | (render.design_tile(name, pics, 0, id) |
183 | 187 | for name, pics, desc, cat, id in data), |
184 | page, | |
185 | page > min, | |
186 |
p |
|
188 | pg_num, | |
189 | pg_num > pg_min, | |
190 | pg_num < pg_max)) | |
187 | 191 | |
188 | 192 | |
189 | 193 | @app.route('/<name>/') |
190 | 194 | @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)) | |
194 | 198 | |
195 | 199 | |
196 | 200 | # class admin: |