Skip to content

Commit

Permalink
Merge pull request #95 from fluffy-critter/feature/breadcrumb
Browse files Browse the repository at this point in the history
Add breadcrumb trail
  • Loading branch information
fluffy-critter committed May 18, 2018
2 parents dabc5dd + 1788f45 commit f9344f4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions publ/category.py
Expand Up @@ -95,6 +95,21 @@ def image_search_path(self):
""" Get the image search path for the category """
return [os.path.join(config.content_folder, self.path)]

@cached_property
def breadcrumb(self):
""" Get the category hierarchy leading up to this category, including
root and self.
For example, path/to/long/category will return a list containing
Category('path'), Category('path/to'), and Category('path/to/long').
"""
ret = []
here = self
while here:
ret.append(here)
here = here.parent
return list(reversed(ret))

def _description(self, **kwargs):
if self._meta:
return flask.Markup(markdown.to_html(self._meta.get_payload(), config=kwargs,
Expand Down

0 comments on commit f9344f4

Please sign in to comment.