--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_portal/templates/pagelet.pt Tue Oct 11 16:05:13 2016 +0200
@@ -0,0 +1,24 @@
+<div class="portal-page"
+ tal:define="template_config view.template_configuration;
+ portlet_config view.portlet_configuration;"
+ i18n:domain="pyams_portal">
+ <div class="rows">
+ <div class="row" tal:repeat="row range(template_config.rows)">
+ <div class="slots">
+ <tal:loop repeat="slot_name template_config.get_slots(row)">
+ <div class="slot"
+ tal:define="slot_config template_config.get_slot_configuration(slot_name)"
+ tal:condition="slot_config.visible"
+ tal:attributes="class string:slot col ${slot_config.get_css_class()}">
+ <div class="portlets">
+ <div class="portlet"
+ tal:repeat="portlet_id template_config.slot_config[slot_name].portlet_ids">
+ <tal:var replace="structure view.render_portlet(portlet_id)">Content</tal:var>
+ </div>
+ </div>
+ </div>
+ </tal:loop>
+ </div>
+ </div>
+ </div>
+</div>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_portal/views.py Tue Oct 11 16:05:13 2016 +0200
@@ -0,0 +1,57 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+from pyams_default_theme.layer import IPyAMSDefaultLayer
+from pyams_portal.interfaces import IPortalContext, IPortalPage, IPortalTemplateConfiguration, \
+ IPortalPortletsConfiguration, IPortletRenderer, IPortlet
+
+# import packages
+from pyams_default_theme.page import BaseIndexPage
+from pyams_pagelet.pagelet import pagelet_config
+from pyams_template.template import template_config
+from pyramid.decorator import reify
+
+
+@pagelet_config(name='', context=IPortalContext, layer=IPyAMSDefaultLayer)
+@template_config(template='templates/pagelet.pt', layer=IPyAMSDefaultLayer)
+class PortalContextIndexPage(BaseIndexPage):
+ """Portal context index page"""
+
+ @reify
+ def page(self):
+ return IPortalPage(self.context)
+
+ @reify
+ def template_configuration(self):
+ return IPortalTemplateConfiguration(self.page.template)
+
+ @reify
+ def portlet_configuration(self):
+ return IPortalPortletsConfiguration(self.context)
+
+ def get_portlet(self, name):
+ return self.request.registry.getUtility(IPortlet, name=name)
+
+ def render_portlet(self, portlet_id):
+ settings = self.portlet_configuration.get_portlet_configuration(portlet_id).settings
+ renderer = self.request.registry.queryMultiAdapter((self.context, self.request, self, settings),
+ IPortletRenderer)
+ if renderer is not None:
+ return renderer()
+ else:
+ return ''