Mercurial > libervia-web
comparison src/pages/common/blog/page_meta.py @ 1024:2ae3b6291456
pages (common/blog): handle tags filtering using "/tag/[tag]" in path
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 21 Jan 2018 20:23:33 +0100 |
parents | fc1c913cc9d1 |
children | 36e5945d064c |
comparison
equal
deleted
inserted
replaced
1023:2cb60ef2a76f | 1024:2ae3b6291456 |
---|---|
57 except IndexError: | 57 except IndexError: |
58 pass | 58 pass |
59 else: | 59 else: |
60 if filter_kw == u'id': | 60 if filter_kw == u'id': |
61 try: | 61 try: |
62 data['item'] = self.nextPath(request) | 62 data[u'item'] = self.nextPath(request) |
63 except IndexError: | |
64 self.pageError(request, C.HTTP_BAD_REQUEST) | |
65 elif filter_kw == u'tag': | |
66 try: | |
67 data[u'tag'] = self.nextPath(request) | |
63 except IndexError: | 68 except IndexError: |
64 self.pageError(request, C.HTTP_BAD_REQUEST) | 69 self.pageError(request, C.HTTP_BAD_REQUEST) |
65 else: | 70 else: |
66 # invalid filter keyword | 71 # invalid filter keyword |
67 log.warning(_(u"invalid filter keyword: {filter_kw}").format(filter_kw=filter_kw)) | 72 log.warning(_(u"invalid filter keyword: {filter_kw}").format(filter_kw=filter_kw)) |
137 extra = {u'rsm_max': u'10'} | 142 extra = {u'rsm_max': u'10'} |
138 if u'after' in params: | 143 if u'after' in params: |
139 extra[u'rsm_after'] = params[u'after'] | 144 extra[u'rsm_after'] = params[u'after'] |
140 elif u'before' in params: | 145 elif u'before' in params: |
141 extra[u'rsm_before'] = params[u'before'] | 146 extra[u'rsm_before'] = params[u'before'] |
147 tag = data.get('tag') | |
148 if tag: | |
149 extra[u'mam_filter_{}'.format(C.MAM_FILTER_CATEGORY)] = tag | |
142 | 150 |
143 blog_data, items = yield getBlogData(self, request, service, node, item_id, extra, profile) | 151 blog_data, items = yield getBlogData(self, request, service, node, item_id, extra, profile) |
144 template_data = request.template_data | 152 template_data = request.template_data |
145 if items: | 153 if items: |
146 if not item_id: | 154 if not item_id: |
167 if show_comments: | 175 if show_comments: |
168 yield appendComments(self, items, identities, profile) | 176 yield appendComments(self, items, identities, profile) |
169 | 177 |
170 blog_view = self.getPageByName(u'blog_view') | 178 blog_view = self.getPageByName(u'blog_view') |
171 template_data[u'items'] = data[u'items'] = items | 179 template_data[u'items'] = data[u'items'] = items |
172 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} | 180 template_data[u'item_http_uri'] = items_http_uri = {} |
181 template_data[u'tags_http_uri'] = tags_http_uri = {} | |
182 for item in items: | |
183 service_s = service.full() | |
184 items_http_uri[item.id] = self.host.getExtBaseURL(request, blog_view.getURL(service_s, node or '@', u'id', item.id)) | |
185 for tag in item.tags: | |
186 if tag not in tags_http_uri: | |
187 tags_http_uri[tag] = self.host.getExtBaseURL(request, blog_view.getURL(service_s, node or '@', u'tag', tag)) | |
173 template_data[u'allow_commenting'] = data.get(u'allow_commenting', False) | 188 template_data[u'allow_commenting'] = data.get(u'allow_commenting', False) |
174 | 189 |
175 | 190 |
176 @defer.inlineCallbacks | 191 @defer.inlineCallbacks |
177 def on_data_post(self, request): | 192 def on_data_post(self, request): |