def _render_level(subdir, path='', indent=' '): if subdir: folder_icon = "fa-plus-square-o" if path == tag_prefix else "fa-plus-square-o" hidden = 'style="display: none;"' if path != tag_prefix else '' ul = indent + '<ul>\n' if isinstance(subdir, dict): for k in sorted(subdir.keys(), key=str.lower): if k: v = subdir[k] uk = ThreadStore.tag_unescape(k).rstrip(':') count = v.pop('_count') # TODO: handle case when no counts pulled, will have empty leafs and leaf lists item = '<span tag="%s">%s</span> <span class="item-count">%s</span></span>' % (path + k, uk, count) if v: ul += indent + ' <li %s><span class="folder-item"><i class="tree-folder fa %s"></i>%s</span>\n' % (hidden, folder_icon, item) ul += _render_level(v, path + k + ('.' if k[-1] != ':' else ''), indent + ' ') else: ul += indent + ' <li %s>%s\n' % (hidden, item) ul += indent + ' </li>\n' elif isinstance(subdir, list): for v in sorted(subdir, key=str.lower): ul += indent + ' <li %s><span tag="%s">%s</span>\n' % (hidden, path + v, ThreadStore.tag_unescape(v)) ul += indent + ' </li>\n' return ul + indent + '</ul>\n' else: return ''
def home_feed(self, item): "extract home feed" # strip threadreader.feeds.<user> & unescape return ThreadStore.tag_unescape('.'.join(item['_collection'].split('.')[3:]))