Use text list for category list
Getty Ritter
4 years ago
30 | 30 |
design_page = load_template("design_page")
|
31 | 31 |
design_tile = load_template("design_tile")
|
32 | 32 |
design_list = load_template("design_list")
|
| 33 |
text_list = load_template("text_list")
|
33 | 34 |
|
34 | 35 |
|
35 | 36 |
def slugify(string):
|
|
128 | 129 |
@main
|
129 | 130 |
def get_all_categories():
|
130 | 131 |
categories = db.all_categories()
|
131 | |
return "Category", render.select_category(categories)
|
| 132 |
return "Category", Templates.text_list(categories)
|
132 | 133 |
|
133 | 134 |
|
134 | 135 |
@app.route("/category/<cat>/")
|
108 | 108 |
return " ".join(w.capitalize() for w in self.tag.split())
|
109 | 109 |
|
110 | 110 |
|
| 111 |
class Link(typing.NamedTuple):
|
| 112 |
url: str
|
| 113 |
name: str
|
| 114 |
|
| 115 |
@classmethod
|
| 116 |
def from_category(cls, c):
|
| 117 |
return cls(name=c.nicename, url=f"/category/{c.name}")
|
| 118 |
|
| 119 |
|
| 120 |
class LinkList(typing.NamedTuple):
|
| 121 |
elements: typing.List[Link]
|
| 122 |
|
| 123 |
|
111 | 124 |
THUMB_SIZE = (100, 100)
|
112 | 125 |
|
113 | 126 |
|
|
133 | 146 |
|
134 | 147 |
def all_categories(self):
|
135 | 148 |
categories = self._db.select("categories")
|
136 | |
return [(c.name, c.id, c.nicename) for c in categories]
|
| 149 |
return LinkList(elements=[Link.from_category(c) for c in categories])
|
137 | 150 |
|
138 | 151 |
def get_category_name(self, id):
|
139 | 152 |
if id in self.categories:
|