annotate libervia/web/pages/blog/view/atom.xml/page_meta.py @ 1548:66aa6e140ebb

browser: make `jid_search` more generic: rel 423
author Goffi <goffi@goffi.org>
date Wed, 09 Aug 2023 00:22:16 +0200
parents eb00d593801d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
1 #!/usr/bin/env python3
1239
f511f8fbbf8a fixed shebangs
Goffi <goffi@goffi.org>
parents: 1216
diff changeset
2
1518
eb00d593801d refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
3 from libervia.web.server.constants import Const as C
eb00d593801d refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
4 from libervia.backend.tools.common import uri
1077
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
5 import time
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
6
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
7 name = "blog_feed_atom"
1077
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 access = C.PAGES_ACCESS_PUBLIC
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
9 template = "blog/atom.xml"
1077
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
10
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
11
1323
a20fe9eb307b pages (blog/view/atom.xml): fixed items management after blog_view changes
Goffi <goffi@goffi.org>
parents: 1239
diff changeset
12 async def prepare_render(self, request):
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1083
diff changeset
13 request.setHeader("Content-Type", "application/atom+xml; charset=utf-8")
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
14 data = self.get_r_data(request)
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
15 service, node = data["service"], data.get("node")
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
16 self.check_cache(
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1083
diff changeset
17 request, C.CACHE_PUBSUB, service=service, node=node, short="microblog"
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1083
diff changeset
18 )
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1083
diff changeset
19 data["show_comments"] = False
1077
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
20 template_data = request.template_data
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
21 blog_page = self.get_page_by_name("blog_view")
1323
a20fe9eb307b pages (blog/view/atom.xml): fixed items management after blog_view changes
Goffi <goffi@goffi.org>
parents: 1239
diff changeset
22 await blog_page.prepare_render(self, request)
a20fe9eb307b pages (blog/view/atom.xml): fixed items management after blog_view changes
Goffi <goffi@goffi.org>
parents: 1239
diff changeset
23 items = data["blog_items"]['items']
1077
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
24
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
25 template_data["request_uri"] = self.host.get_ext_base_url(
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1083
diff changeset
26 request, request.path.decode("utf-8")
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1083
diff changeset
27 )
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
28 template_data["xmpp_uri"] = uri.build_xmpp_uri(
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
29 "pubsub", subtype="microblog", path=service.full(), node=node
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1083
diff changeset
30 )
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
31 blog_view = self.get_page_by_name("blog_view")
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
32 template_data["http_uri"] = self.host.get_ext_base_url(
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1326
diff changeset
33 request, blog_view.get_url(service.full(), node)
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1083
diff changeset
34 )
1077
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 if items:
1323
a20fe9eb307b pages (blog/view/atom.xml): fixed items management after blog_view changes
Goffi <goffi@goffi.org>
parents: 1239
diff changeset
36 template_data["updated"] = items[0]['updated']
1077
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 else:
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
38 template_data["updated"] = time.time()