Mercurial > libervia-web
annotate libervia/pages/blog/view/atom.xml/page_meta.py @ 1413:326730dc35da
install: update minimal Brython version to 3.9.2 to have fixed elements's `children` implementation:
Before 3.9.2, Brython had an implementation of `children` hidding the DOM method, and
which was returning all elements (like childNodes). 3.9.2 fixes it.
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 29 Apr 2021 16:36:26 +0200 |
parents | 089742e065e3 |
children | 106bae41f5c8 |
rev | line source |
---|---|
1216 | 1 #!/usr/bin/env python3 |
1239 | 2 |
1077
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 from libervia.server.constants import Const as C |
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 from sat.tools.common import uri |
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 | 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 | 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") |
1077
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 data = self.getRData(request) |
1216 | 15 service, node = data["service"], data.get("node") |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
16 self.checkCache( |
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 |
1216 | 21 blog_page = self.getPageByName("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 |
1216 | 25 template_data["request_uri"] = self.host.getExtBaseURL( |
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 ) |
1216 | 28 template_data["xmpp_uri"] = uri.buildXMPPUri( |
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 ) |
1216 | 31 blog_view = self.getPageByName("blog_view") |
32 template_data["http_uri"] = self.host.getExtBaseURL( | |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
33 request, blog_view.getURL(service.full(), node) |
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 | 38 template_data["updated"] = time.time() |