Mercurial > libervia-web
annotate libervia/pages/blog/view/atom.xml/page_meta.py @ 1323:a20fe9eb307b
pages (blog/view/atom.xml): fixed items management after blog_view changes
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 02 Aug 2020 20:57:55 +0200 |
parents | f511f8fbbf8a |
children | 089742e065e3 |
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 |
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 from libervia.server.constants import Const as C |
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 from twisted.internet import defer |
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 from sat.tools.common import uri |
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 import time |
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 |
1216 | 9 name = "blog_feed_atom" |
1077
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 access = C.PAGES_ACCESS_PUBLIC |
1216 | 11 template = "blog/atom.xml" |
1077
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 |
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 |
1323
a20fe9eb307b
pages (blog/view/atom.xml): fixed items management after blog_view changes
Goffi <goffi@goffi.org>
parents:
1239
diff
changeset
|
14 async def prepare_render(self, request): |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
15 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
|
16 data = self.getRData(request) |
1216 | 17 service, node = data["service"], data.get("node") |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
18 self.checkCache( |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
19 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
|
20 ) |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
21 data["show_comments"] = False |
1077
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 template_data = request.template_data |
1216 | 23 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
|
24 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
|
25 items = data["blog_items"]['items'] |
1077
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 |
1216 | 27 template_data["request_uri"] = self.host.getExtBaseURL( |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
28 request, request.path.decode("utf-8") |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
29 ) |
1216 | 30 template_data["xmpp_uri"] = uri.buildXMPPUri( |
31 "pubsub", subtype="microblog", path=service.full(), node=node | |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
32 ) |
1216 | 33 blog_view = self.getPageByName("blog_view") |
34 template_data["http_uri"] = self.host.getExtBaseURL( | |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
35 request, blog_view.getURL(service.full(), node) |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
36 ) |
1077
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 if items: |
1323
a20fe9eb307b
pages (blog/view/atom.xml): fixed items management after blog_view changes
Goffi <goffi@goffi.org>
parents:
1239
diff
changeset
|
38 template_data["updated"] = items[0]['updated'] |
1077
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 else: |
1216 | 40 template_data["updated"] = time.time() |