annotate libervia/pages/u/page_meta.py @ 1180:cc16d93d4181 0.7.0b1

0.7.0b1 release
author Goffi <goffi@goffi.org>
date Sun, 05 May 2019 20:42:14 +0200
parents 469d0de8da0e
children 67ec22356457
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
929
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python2.7
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
3
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
4 from libervia.server.constants import Const as C
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
5 from twisted.internet import defer
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
6 from twisted.words.protocols.jabber import jid
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
7
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
8 """page used to target a user profile, e.g. for public blog"""
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
9
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
10 name = u"user"
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
11 access = C.PAGES_ACCESS_PUBLIC # can be a callable
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
12 template = u"blog/articles.html"
1020
1c9b6d2c30b5 pages (u): activated URL caching, avoiding bridge calls on each request.
Goffi <goffi@goffi.org>
parents: 929
diff changeset
13 url_cache = True
929
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
14
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
15
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
16 @defer.inlineCallbacks
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
17 def parse_url(self, request):
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
18 try:
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
19 prof_requested = self.nextPath(request)
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
20 except IndexError:
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
21 self.pageError(request)
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
22
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
23 data = self.getRData(request)
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
24
1098
01e95ec9df9e server, pages: fixed blocking calls to bridge by using bridgeCall instead
Goffi <goffi@goffi.org>
parents: 1083
diff changeset
25 target_profile = yield self.host.bridgeCall("profileNameGet", prof_requested)
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1098
diff changeset
26 request.template_data[u"target_profile"] = target_profile
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1098
diff changeset
27 target_jid = yield self.host.bridgeCall(
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1098
diff changeset
28 "asyncGetParamA", "JabberID", "Connection", "value", profile_key=target_profile
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1098
diff changeset
29 )
929
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
30 target_jid = jid.JID(target_jid)
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1098
diff changeset
31 data[u"service"] = target_jid
929
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
32
1171
469d0de8da0e pages (blog, u): added atom feed link in "links" template data.
Goffi <goffi@goffi.org>
parents: 1159
diff changeset
33 # if URL is parsed here, we'll have atom.xml available and we need to
469d0de8da0e pages (blog, u): added atom feed link in "links" template data.
Goffi <goffi@goffi.org>
parents: 1159
diff changeset
34 # add the link to the page
469d0de8da0e pages (blog, u): added atom feed link in "links" template data.
Goffi <goffi@goffi.org>
parents: 1159
diff changeset
35 atom_url = self.getSubPageURL(request, u'user_blog_feed_atom')
469d0de8da0e pages (blog, u): added atom feed link in "links" template data.
Goffi <goffi@goffi.org>
parents: 1159
diff changeset
36 request.template_data.setdefault(u'links', []).append({
469d0de8da0e pages (blog, u): added atom feed link in "links" template data.
Goffi <goffi@goffi.org>
parents: 1159
diff changeset
37 u"href": atom_url,
469d0de8da0e pages (blog, u): added atom feed link in "links" template data.
Goffi <goffi@goffi.org>
parents: 1159
diff changeset
38 u"type": "application/atom+xml",
469d0de8da0e pages (blog, u): added atom feed link in "links" template data.
Goffi <goffi@goffi.org>
parents: 1159
diff changeset
39 u"rel": "alternate",
469d0de8da0e pages (blog, u): added atom feed link in "links" template data.
Goffi <goffi@goffi.org>
parents: 1159
diff changeset
40 u"title": "{target_profile}'s blog".format(target_profile=target_profile)})
469d0de8da0e pages (blog, u): added atom feed link in "links" template data.
Goffi <goffi@goffi.org>
parents: 1159
diff changeset
41
929
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
42
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
43 @defer.inlineCallbacks
2345577da5ca pages (u): added u page for user public pages, for now it display blog items
Goffi <goffi@goffi.org>
parents:
diff changeset
44 def prepare_render(self, request):
1034
f82c355ffa6e pages (u): top page (blog) is now cached
Goffi <goffi@goffi.org>
parents: 1020
diff changeset
45 data = self.getRData(request)
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1098
diff changeset
46 self.checkCache(
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1098
diff changeset
47 request, C.CACHE_PUBSUB, service=data[u"service"], node=None, short="microblog"
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1098
diff changeset
48 )
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1098
diff changeset
49 self.pageRedirect(u"blog_view", request)
1159
4e716967893a page (u): fixed blog posting
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
50
4e716967893a page (u): fixed blog posting
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
51 def on_data_post(self, request):
4e716967893a page (u): fixed blog posting
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
52 return self.getPageByName(u"blog_view").on_data_post(self, request)