Mercurial > libervia-web
view libervia/pages/blog/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 | e45480b6ba24 |
line wrap: on
line source
#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- from libervia.server.constants import Const as C from twisted.words.protocols.jabber import jid from twisted.internet import defer from libervia.server import session_iface from sat.core.log import getLogger log = getLogger("pages/blog") name = u"blog" access = C.PAGES_ACCESS_PUBLIC template = u"blog/discover.html" @defer.inlineCallbacks def prepare_render(self, request): profile = self.getProfile(request) template_data = request.template_data if profile is not None: __, entities_own, entities_roster = yield self.host.bridgeCall( "discoFindByFeatures", [], [(u"pubsub", u"pep")], True, False, True, True, True, profile, ) entities = template_data[u"disco_entities"] = ( entities_own.keys() + entities_roster.keys() ) entities_url = template_data[u"entities_url"] = {} identities = template_data[u"identities"] = self.host.getSessionData( request, session_iface.ISATSession ).identities for entity_jid_s in entities: entities_url[entity_jid_s] = self.getPageByName("blog_view").getURL( entity_jid_s ) if entity_jid_s not in identities: identities[entity_jid_s] = yield self.host.bridgeCall( u"identityGet", entity_jid_s, profile ) def on_data_post(self, request): jid_str = self.getPostedData(request, u"jid") try: jid_ = jid.JID(jid_str) except RuntimeError: self.pageError(request, C.HTTP_BAD_REQUEST) url = self.getPageByName(u"blog_view").getURL(jid_.full()) self.HTTPRedirect(request, url)