comparison libervia/pages/blog/view/page_meta.py @ 1376:1b94a5ab155f

pages (blog/view): Full-Text Search is used when `search` query argument is present the new `LiberviaPage.handleSearch` method implements FTS in PubSub based features.
author Goffi <goffi@goffi.org>
date Fri, 11 Dec 2020 17:35:06 +0100
parents a0954b6610aa
children 1357d04107d1
comparison
equal deleted inserted replaced
1375:e943b0c8eec5 1376:1b94a5ab155f
159 159
160 return blog_data 160 return blog_data
161 161
162 async def prepare_render(self, request): 162 async def prepare_render(self, request):
163 data = self.getRData(request) 163 data = self.getRData(request)
164 template_data = request.template_data
164 page_max = data.get("page_max", 10) 165 page_max = data.get("page_max", 10)
165 # if the comments are not explicitly hidden, we show them 166 # if the comments are not explicitly hidden, we show them
166 service, node, item_id, show_comments = data.get('service', ''), data.get('node', ''), data.get('item'), data.get('show_comments', True) 167 service, node, item_id, show_comments = (
168 data.get('service', ''),
169 data.get('node', ''),
170 data.get('item'),
171 data.get('show_comments', True)
172 )
167 profile = self.getProfile(request) 173 profile = self.getProfile(request)
168 if profile is None: 174 if profile is None:
169 profile = C.SERVICE_PROFILE 175 profile = C.SERVICE_PROFILE
170 profile_connected = False 176 profile_connected = False
171 else: 177 else:
176 extra = {} 182 extra = {}
177 else: 183 else:
178 extra = self.getPubsubExtra(request, page_max=page_max) 184 extra = self.getPubsubExtra(request, page_max=page_max)
179 tag = data.get('tag') 185 tag = data.get('tag')
180 if tag: 186 if tag:
181 extra['mam_filter_{}'.format(C.MAM_FILTER_CATEGORY)] = tag 187 extra[f'mam_filter_{C.MAM_FILTER_CATEGORY}'] = tag
188 self.handleSearch(request, extra)
182 189
183 ## main data ## 190 ## main data ##
184 # we get data from backend/XMPP here 191 # we get data from backend/XMPP here
185 blog_items = await getBlogItems(self, request, service, node, item_id, extra, profile) 192 blog_items = await getBlogItems(self, request, service, node, item_id, extra, profile)
186 193
187 ## navigation ## 194 ## navigation ##
188 # no let's fill service, node and pagination URLs 195 # no let's fill service, node and pagination URLs
189 template_data = request.template_data
190 if 'service' not in template_data: 196 if 'service' not in template_data:
191 template_data['service'] = service 197 template_data['service'] = service
192 if 'node' not in template_data: 198 if 'node' not in template_data:
193 template_data['node'] = node 199 template_data['node'] = node
194 target_profile = template_data.get('target_profile') 200 target_profile = template_data.get('target_profile')