# HG changeset patch # User Tero Marttila # Date 1412424836 -10800 # Node ID ad32cf3a25fa041836170c71def1782cec7b298e # Parent 16ab69a5569ae389485f4461a9696f4c151d22b8 pngtile.store: change list() to yield name, type tuples rather than appending / to dirs diff -r 16ab69a5569a -r ad32cf3a25fa pngtile/image.py --- a/pngtile/image.py Sat Oct 04 03:28:57 2014 +0300 +++ b/pngtile/image.py Sat Oct 04 15:13:56 2014 +0300 @@ -76,6 +76,13 @@ yield html.li(html.a(href=href(*path), *[part])) + def render_dir_item (self, name, type): + if type: + return html.a(href=name, *[name]) + else: + dir = name + '/' + return html.a(href=dir, *[dir]) + def render_dir (self, request, name, items): """ request: werkzeug.Request @@ -97,10 +104,11 @@ html.ol(class_='breadcrumb', *self.render_dir_breadcrumb(name)), ]), html.div(class_='list', *[ - html.ul(class_='list-group', *[html.li(class_='list-group-item', *[ - html.a(href=item, *[item]) - ]) for item in items] - ), + html.ul(class_='list-group', *[ + html.li(class_='list-group-item', *[ + self.render_dir_item(name, type) for name, type in items + ]) for name, type in items + ]), ]), ]), ), diff -r 16ab69a5569a -r ad32cf3a25fa pngtile/store.py --- a/pngtile/store.py Sat Oct 04 03:28:57 2014 +0300 +++ b/pngtile/store.py Sat Oct 04 15:13:56 2014 +0300 @@ -102,7 +102,7 @@ # skip inaccessible dirs continue - yield name + '/' + yield name, None # examine ext if '.' in name: @@ -113,7 +113,7 @@ # show .png files with a .cache file if name_type in self.IMAGE_TYPES and os.path.exists(os.path.join(root, name_base + '.cache')): - yield name + yield name, name_type def open (self, url): """