# HG changeset patch # User Goffi # Date 1516562613 -3600 # Node ID 2ae3b6291456cb8218c1dffb2effe512a7f052d5 # Parent 2cb60ef2a76f200220664c91944d39f20fa3c184 pages (common/blog): handle tags filtering using "/tag/[tag]" in path diff -r 2cb60ef2a76f -r 2ae3b6291456 src/pages/common/blog/page_meta.py --- a/src/pages/common/blog/page_meta.py Sun Jan 21 20:21:46 2018 +0100 +++ b/src/pages/common/blog/page_meta.py Sun Jan 21 20:23:33 2018 +0100 @@ -59,7 +59,12 @@ else: if filter_kw == u'id': try: - data['item'] = self.nextPath(request) + data[u'item'] = self.nextPath(request) + except IndexError: + self.pageError(request, C.HTTP_BAD_REQUEST) + elif filter_kw == u'tag': + try: + data[u'tag'] = self.nextPath(request) except IndexError: self.pageError(request, C.HTTP_BAD_REQUEST) else: @@ -139,6 +144,9 @@ extra[u'rsm_after'] = params[u'after'] elif u'before' in params: extra[u'rsm_before'] = params[u'before'] + tag = data.get('tag') + if tag: + extra[u'mam_filter_{}'.format(C.MAM_FILTER_CATEGORY)] = tag blog_data, items = yield getBlogData(self, request, service, node, item_id, extra, profile) template_data = request.template_data @@ -169,7 +177,14 @@ blog_view = self.getPageByName(u'blog_view') template_data[u'items'] = data[u'items'] = items - template_data[u'items_http_uri'] = {item.id: self.host.getExtBaseURL(request, blog_view.getURL(service.full(), node or '@', u'id', item.id)) for item in items} + template_data[u'item_http_uri'] = items_http_uri = {} + template_data[u'tags_http_uri'] = tags_http_uri = {} + for item in items: + service_s = service.full() + items_http_uri[item.id] = self.host.getExtBaseURL(request, blog_view.getURL(service_s, node or '@', u'id', item.id)) + for tag in item.tags: + if tag not in tags_http_uri: + tags_http_uri[tag] = self.host.getExtBaseURL(request, blog_view.getURL(service_s, node or '@', u'tag', tag)) template_data[u'allow_commenting'] = data.get(u'allow_commenting', False)