Mercurial > libervia-web
comparison libervia/web/pages/blog/view/atom.xml/page_meta.py @ 1518:eb00d593801d
refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 02 Jun 2023 16:49:28 +0200 |
parents | libervia/pages/blog/view/atom.xml/page_meta.py@106bae41f5c8 |
children |
comparison
equal
deleted
inserted
replaced
1517:b8ed9726525b | 1518:eb00d593801d |
---|---|
1 #!/usr/bin/env python3 | |
2 | |
3 from libervia.web.server.constants import Const as C | |
4 from libervia.backend.tools.common import uri | |
5 import time | |
6 | |
7 name = "blog_feed_atom" | |
8 access = C.PAGES_ACCESS_PUBLIC | |
9 template = "blog/atom.xml" | |
10 | |
11 | |
12 async def prepare_render(self, request): | |
13 request.setHeader("Content-Type", "application/atom+xml; charset=utf-8") | |
14 data = self.get_r_data(request) | |
15 service, node = data["service"], data.get("node") | |
16 self.check_cache( | |
17 request, C.CACHE_PUBSUB, service=service, node=node, short="microblog" | |
18 ) | |
19 data["show_comments"] = False | |
20 template_data = request.template_data | |
21 blog_page = self.get_page_by_name("blog_view") | |
22 await blog_page.prepare_render(self, request) | |
23 items = data["blog_items"]['items'] | |
24 | |
25 template_data["request_uri"] = self.host.get_ext_base_url( | |
26 request, request.path.decode("utf-8") | |
27 ) | |
28 template_data["xmpp_uri"] = uri.build_xmpp_uri( | |
29 "pubsub", subtype="microblog", path=service.full(), node=node | |
30 ) | |
31 blog_view = self.get_page_by_name("blog_view") | |
32 template_data["http_uri"] = self.host.get_ext_base_url( | |
33 request, blog_view.get_url(service.full(), node) | |
34 ) | |
35 if items: | |
36 template_data["updated"] = items[0]['updated'] | |
37 else: | |
38 template_data["updated"] = time.time() |