gdritter repos frony-ritter-designs / 71d4259
Use text list for category list Getty Ritter 4 years ago
2 changed file(s) with 16 addition(s) and 2 deletion(s). Collapse all Expand all
3030 design_page = load_template("design_page")
3131 design_tile = load_template("design_tile")
3232 design_list = load_template("design_list")
33 text_list = load_template("text_list")
3334
3435
3536 def slugify(string):
128129 @main
129130 def get_all_categories():
130131 categories = db.all_categories()
131 return "Category", render.select_category(categories)
132 return "Category", Templates.text_list(categories)
132133
133134
134135 @app.route("/category/<cat>/")
108108 return " ".join(w.capitalize() for w in self.tag.split())
109109
110110
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
111124 THUMB_SIZE = (100, 100)
112125
113126
133146
134147 def all_categories(self):
135148 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])
137150
138151 def get_category_name(self, id):
139152 if id in self.categories: