Start fixing tags
Getty Ritter
4 years ago
163 | 163 |
@app.route('/tag/')
|
164 | 164 |
@main
|
165 | 165 |
def get_all_tags():
|
166 | |
def pretty(t):
|
167 | |
return ' '.join(w.capitalize()
|
168 | |
for w in t.split('_'))
|
169 | 166 |
tags = (
|
170 | |
(t, pretty(t), db.num_for_tag(t))
|
| 167 |
(t.tag, t.pretty(), t.count)
|
171 | 168 |
for t in sorted(db.get_all_tags()))
|
172 | 169 |
return 'All Tags', render.select_tag(tags)
|
173 | 170 |
|
55 | 55 |
if self.images:
|
56 | 56 |
return self.images[0].thumb()
|
57 | 57 |
|
| 58 |
class Tag(typing.NamedTuple):
|
| 59 |
tag: str
|
| 60 |
count: int
|
| 61 |
|
| 62 |
def pretty(self):
|
| 63 |
return ' '.join(w.capitalize() for w in self.tag.split())
|
58 | 64 |
|
59 | 65 |
THUMB_SIZE = (100, 100)
|
60 | 66 |
|
|
279 | 285 |
return (0, 1 + (num_designs // self.per_page))
|
280 | 286 |
|
281 | 287 |
def get_all_tags(self):
|
282 | |
all_tags = [
|
283 | |
t.tag_name for t in
|
284 | |
self._db.query(
|
285 | |
'select distinct tag_name from tags')]
|
286 | |
return all_tags
|
| 288 |
return [
|
| 289 |
Tag(t.tag_name, t.n) for t in
|
| 290 |
self._db.query('select t.tag_name, count(*) as n '
|
| 291 |
'from designs d, tags t '
|
| 292 |
'where d.id = t.design_id '
|
| 293 |
'group by t.tag_name')
|
| 294 |
]
|
287 | 295 |
|
288 | 296 |
def get_designs_by_tag(self, tag, offset=0):
|
289 | 297 |
ds = self._db.query(
|