Mercurial > libervia-website
annotate pages/news/page_meta.py @ 28:e7c7327f9f25
refactoring: fix imports and names in doc following modules hierarchy refactoring
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 02 Jun 2023 17:48:38 +0200 |
parents | 5fd933e238bb |
children |
rev | line source |
---|---|
28
e7c7327f9f25
refactoring: fix imports and names in doc following modules hierarchy refactoring
Goffi <goffi@goffi.org>
parents:
22
diff
changeset
|
1 from libervia.web.server.constants import Const as C |
0 | 2 from twisted.words.protocols.jabber import jid |
28
e7c7327f9f25
refactoring: fix imports and names in doc following modules hierarchy refactoring
Goffi <goffi@goffi.org>
parents:
22
diff
changeset
|
3 from libervia.backend.core.i18n import _ |
e7c7327f9f25
refactoring: fix imports and names in doc following modules hierarchy refactoring
Goffi <goffi@goffi.org>
parents:
22
diff
changeset
|
4 from libervia.backend.core.log import getLogger |
0 | 5 |
6 log = getLogger(__name__) | |
7 | |
6 | 8 name = "news" |
9 template = "news/news.html" | |
0 | 10 service = None |
11 node = None | |
12 | |
13 | |
8
dc880664a8ec
modernisation of the theme using Bulma
Goffi <goffi@goffi.org>
parents:
6
diff
changeset
|
14 async def prepare_render(self, request): |
0 | 15 global service, node |
16 if service is None: | |
22
5fd933e238bb
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
8
diff
changeset
|
17 blog_dict = self.config_get('news_blog_dict', {}) |
0 | 18 try: |
19 service = jid.JID(blog_dict['service']) | |
20 except RuntimeError as e: | |
6 | 21 log.warning(_("Can't parse service in news_blog_dict: {e}").format(e=e)) |
0 | 22 service = None |
23 except KeyError: | |
6 | 24 log.warnning(_("Missing service in news_blog_dict")) |
0 | 25 service = None |
6 | 26 node = blog_dict.get('node', '') |
0 | 27 if not blog_dict or service is None: |
6 | 28 log.warning(_('No value set for news_blog_dict, "news" page can\'t be used')) |
22
5fd933e238bb
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
8
diff
changeset
|
29 self.page_error(request, C.HTTP_SERVICE_UNAVAILABLE) |
0 | 30 |
22
5fd933e238bb
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
8
diff
changeset
|
31 data = self.get_r_data(request) |
6 | 32 data['service'] = service |
33 data['node'] = node | |
0 | 34 |
22
5fd933e238bb
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
8
diff
changeset
|
35 # self.check_cache( |
0 | 36 # request, C.CACHE_PUBSUB, service=service, node=node, short="microblog") |
37 | |
38 # we now need blog items, using blog common page | |
39 # this will fill the "items" template data | |
22
5fd933e238bb
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
8
diff
changeset
|
40 blog_page = self.get_page_by_name("blog_view") |
8
dc880664a8ec
modernisation of the theme using Bulma
Goffi <goffi@goffi.org>
parents:
6
diff
changeset
|
41 await blog_page.prepare_render(self, request) |