Mercurial > libervia-web
annotate libervia/pages/blog/view/atom.xml/page_meta.py @ 1128:6414fd795df4
server, pages: multi-sites refactoring:
Libervia is now handling external sites (i.e. other sites than Libervia official site).
The external site are declared in sites_path_public_dict (in [DEFAULT] section) which is read by template engine, then they are linked to virtual host with vhosts_dict (linking host name to site name) in [libervia] section.
Sites are only instanced once, so adding an alias is just a matter of mapping the alias host name in vhosts_dict with the same site name.
menu_json and url_redirections_dict can now accept keys named after site name, which will be linked to the data for the site. Data for default site can still be keyed at first level.
Libervia official pages are added to external site (if pages are not overriden), allowing to call pages of the framework and to have facilities like login handling.
Deprecated url_redirections_profile option has been removed.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 14 Sep 2018 21:41:28 +0200 |
parents | 28e3eb3bb217 |
children | b2d067339de3 |
rev | line source |
---|---|
1077
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/env python2.7 |
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
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 |
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 name = u"blog_feed_atom" |
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 access = C.PAGES_ACCESS_PUBLIC |
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 template = u"blog/atom.xml" |
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 |
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 @defer.inlineCallbacks |
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 def prepare_render(self, request): |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
16 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
|
17 data = self.getRData(request) |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
18 service, node = data[u"service"], data.get(u"node") |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
19 self.checkCache( |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
20 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
|
21 ) |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
22 data["show_comments"] = False |
1077
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 template_data = request.template_data |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
24 blog_page = self.getPageByName(u"blog_view") |
1077
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 yield blog_page.prepare_render(self, request) |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
26 items = data[u"items"] |
1077
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
28 template_data[u"request_uri"] = self.host.getExtBaseURL( |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
29 request, request.path.decode("utf-8") |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
30 ) |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
31 template_data[u"xmpp_uri"] = uri.buildXMPPUri( |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
32 u"pubsub", subtype=u"microblog", path=service.full(), node=node |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
33 ) |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
34 blog_view = self.getPageByName(u"blog_view") |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
35 template_data[u"http_uri"] = self.host.getExtBaseURL( |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
36 request, blog_view.getURL(service.full(), node) |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
37 ) |
1077
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 if items: |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
39 template_data[u"updated"] = items[0].updated |
1077
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 else: |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1083
diff
changeset
|
41 template_data[u"updated"] = time.time() |