Set custom layouts without ZCML
authorThierry Florac <thierry.florac@onf.fr>
Wed, 07 Oct 2015 17:52:40 +0200
changeset 84 25cf058f7e1d
parent 83 e7386933c184
child 85 0dd5876f9d70
Set custom layouts without ZCML
src/pyams_skin/interfaces/__init__.py
src/pyams_skin/interfaces/templates/fullpage-layout.pt
src/pyams_skin/interfaces/templates/fullpage-modal-layout.pt
src/pyams_skin/interfaces/templates/inner-layout.pt
src/pyams_skin/interfaces/templates/modal-layout.pt
src/pyams_skin/interfaces/templates/widget-layout.pt
src/pyams_skin/templates/fullpage-layout.pt
src/pyams_skin/templates/fullpage-modal-layout.pt
src/pyams_skin/templates/inner-layout.pt
src/pyams_skin/templates/modal-layout.pt
src/pyams_skin/templates/widget-layout.pt
--- a/src/pyams_skin/interfaces/__init__.py	Wed Sep 09 11:53:09 2015 +0200
+++ b/src/pyams_skin/interfaces/__init__.py	Wed Oct 07 17:52:40 2015 +0200
@@ -15,9 +15,11 @@
 # import standard library
 
 # import interfaces
+from pyams_skin.layer import IPyAMSLayer
 from zope.component.interfaces import IObjectEvent, ObjectEvent
 
 # import packages
+from pyams_template.template import layout_config
 from zope.interface import implementer, Interface, Attribute
 from zope.configuration.fields import GlobalInterface
 from zope.schema import Text, TextLine, Choice, Int
@@ -63,24 +65,29 @@
                   vocabulary='PyAMS skins')
 
 
+@layout_config(template='templates/fullpage-layout.pt', layer=IPyAMSLayer)
 class IFullPage(Interface):
     """Full page marker interface"""
 
 
+@layout_config(template='templates/fullpage-modal-layout.pt', layer=IPyAMSLayer)
 class IModalFullPage(IFullPage):
     """Full page modal dialog marker interface"""
 
     dialog_class = Attribute("Default dialog CSS class")
 
 
+@layout_config(template='templates/inner-layout.pt', layer=IPyAMSLayer)
 class IInnerPage(Interface):
     """Inner page marker interface"""
 
 
+@layout_config(template='templates/widget-layout.pt', layer=IPyAMSLayer)
 class IWidgetInnerPage(IInnerPage):
     """Inner page with widget marker interface"""
 
 
+@layout_config(template='templates/modal-layout.pt', layer=IPyAMSLayer)
 class IModalPage(Interface):
     """Modal page marker interface"""
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_skin/interfaces/templates/fullpage-layout.pt	Wed Oct 07 17:52:40 2015 +0200
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html lang="fr-FR"
+	  tal:define="config extension:back_configuration;
+				  static extension:static_configuration;"
+	  tal:attributes="lang request.locale_name">
+<head>
+	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+	<meta charset="utf-8">
+
+	<title tal:content="view.title | context.title | config.title | nothing"></title>
+
+	<meta name="HandheldFriendly" content="True">
+	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
+
+	<tal:if define="icon config.icon | nothing; url extension:absolute_url(icon);" condition="icon">
+		<!-- Favorite icon -->
+		<link rel="shortcut icon" tal:attributes="href url" type="image/x-icon">
+		<link rel="icon" tal:attributes="href url" type="image/x-icon">
+	</tal:if>
+
+	<tal:var replace="extension:resources" />
+
+</head>
+<body tal:attributes="class static.body_css_class">
+
+	<!-- Content -->
+	<div id="content" style="opacity: 1;">
+		<!--[if lt IE 9]>
+		<h1>Votre navigateur est trop ancien. Veuillez installer une version 9 ou sup&eacute;rieure d'Internet Explorer.</h1>
+		<![endif]-->
+		<tal:var content="structure provider:pagelet" />
+	</div>
+	<!-- end content -->
+
+	<!-- Javascript extensions -->
+	<tal:var content="structure provider:pyams.jsextensions" />
+	<!-- end Javascript extensions -->
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_skin/interfaces/templates/fullpage-modal-layout.pt	Wed Oct 07 17:52:40 2015 +0200
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html lang="fr-FR"
+	  tal:define="config extension:back_configuration;
+				  static extension:static_configuration;"
+	  tal:attributes="lang request.locale_name">
+<head>
+	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+	<meta charset="utf-8">
+
+	<title tal:content="view.title | context.title | config.title | nothing"></title>
+
+	<meta name="HandheldFriendly" content="True">
+	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
+
+	<tal:if define="icon config.icon | nothing; url extension:absolute_url(icon);" condition="icon">
+		<!-- Favorite icon -->
+		<link rel="shortcut icon" tal:attributes="href url" type="image/x-icon">
+		<link rel="icon" tal:attributes="href url" type="image/x-icon">
+	</tal:if>
+
+	<tal:var replace="extension:resources" />
+
+</head>
+<body tal:attributes="class static.body_css_class">
+
+	<!-- Content -->
+	<div id="content" style="opacity: 1;">
+		<!--[if lt IE 9]>
+		<h1>Your browser is too old. Please use Internet Explorer version 9 or later.</h1>
+		<![endif]-->
+		<div class="modal-dialog modal-medium"
+			 tal:attributes="class string:modal-dialog ${view.dialog_class | 'modal-medium'}">
+			<tal:var replace="structure provider:pagelet" />
+		</div>
+	</div>
+	<!-- end content -->
+
+	<!-- Javascript extensions -->
+	<tal:var content="structure provider:pyams.jsextensions" />
+	<!-- end Javascript extensions -->
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_skin/interfaces/templates/inner-layout.pt	Wed Oct 07 17:52:40 2015 +0200
@@ -0,0 +1,3 @@
+<tal:var content="structure provider:content_header" />
+<tal:var content="structure provider:content_help" />
+<tal:var content="structure provider:pagelet" />
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_skin/interfaces/templates/modal-layout.pt	Wed Oct 07 17:52:40 2015 +0200
@@ -0,0 +1,4 @@
+<div class="modal-dialog modal-medium"
+	 tal:attributes="class string:modal-dialog ${view.dialog_class}">
+	<tal:var replace="structure provider:pagelet" />
+</div>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_skin/interfaces/templates/widget-layout.pt	Wed Oct 07 17:52:40 2015 +0200
@@ -0,0 +1,16 @@
+<tal:var content="structure provider:content_header" />
+<tal:var content="structure provider:content_help" />
+<div class="ams-widget" i18n:domain="onf_website"
+	 tal:attributes="data-ams-data extension:object_data(view)">
+	<header>
+		<span tal:condition="view.widget_icon_class | nothing"
+			  class="widget-icon"><i tal:attributes="class view.widget_icon_class"></i>
+		</span>
+		<h2 tal:content="view.title">Title</h2>
+		<tal:var content="structure provider:pyams.widget_title" />
+		<tal:var content="structure provider:pyams.toolbar" />
+	</header>
+	<div class="widget-body">
+		<tal:var content="structure provider:pagelet" />
+	</div>
+</div>
--- a/src/pyams_skin/templates/fullpage-layout.pt	Wed Sep 09 11:53:09 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-<!DOCTYPE html>
-<html lang="fr-FR"
-	  tal:define="config extension:configuration;
-				  static extension:static_configuration;"
-	  tal:attributes="lang request.locale_name">
-<head>
-	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
-	<meta charset="utf-8">
-
-	<title tal:content="view.title | context.title | config.title | nothing"></title>
-	<meta name="description" tal:attributes="content config.description | nothing">
-	<meta name="author" tal:attributes="content config.author | nothing">
-
-	<meta name="HandheldFriendly" content="True">
-	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
-
-	<tal:if define="icon config.icon | nothing; url extension:absolute_url(icon);" condition="icon">
-		<!-- Favorite icon -->
-		<link rel="shortcut icon" tal:attributes="href url" type="image/x-icon">
-		<link rel="icon" tal:attributes="href url" type="image/x-icon">
-	</tal:if>
-
-	<tal:var replace="extension:resources" />
-
-</head>
-<body tal:attributes="class static.body_css_class">
-
-	<!-- Content -->
-	<div id="content" style="opacity: 1;">
-		<!--[if lt IE 9]>
-		<h1>Votre navigateur est trop ancien. Veuillez installer une version 9 ou sup&eacute;rieure d'Internet Explorer.</h1>
-		<![endif]-->
-		<tal:var content="structure provider:pagelet" />
-	</div>
-	<!-- end content -->
-
-	<!-- Javascript extensions -->
-	<tal:var content="structure provider:pyams.jsextensions" />
-	<!-- end Javascript extensions -->
-</body>
-</html>
--- a/src/pyams_skin/templates/fullpage-modal-layout.pt	Wed Sep 09 11:53:09 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-<!DOCTYPE html>
-<html lang="fr-FR"
-	  tal:define="config extension:configuration;
-				  static extension:static_configuration;"
-	  tal:attributes="lang request.locale_name">
-<head>
-	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
-	<meta charset="utf-8">
-
-	<title tal:content="view.title | context.title | config.title | nothing"></title>
-	<meta name="description" tal:attributes="content config.description | nothing">
-	<meta name="author" tal:attributes="content config.author | nothing">
-
-	<meta name="HandheldFriendly" content="True">
-	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
-
-	<tal:if define="icon config.icon | nothing; url extension:absolute_url(icon);" condition="icon">
-		<!-- Favorite icon -->
-		<link rel="shortcut icon" tal:attributes="href url" type="image/x-icon">
-		<link rel="icon" tal:attributes="href url" type="image/x-icon">
-	</tal:if>
-
-	<tal:var replace="extension:resources" />
-
-</head>
-<body tal:attributes="class static.body_css_class">
-
-	<!-- Content -->
-	<div id="content" style="opacity: 1;">
-		<!--[if lt IE 9]>
-		<h1>Your browser is too old. Please use Internet Explorer version 9 or later.</h1>
-		<![endif]-->
-		<div class="modal-dialog modal-medium"
-			 tal:attributes="class string:modal-dialog ${view.dialog_class | 'modal-medium'}">
-			<tal:var replace="structure provider:pagelet" />
-		</div>
-	</div>
-	<!-- end content -->
-
-	<!-- Javascript extensions -->
-	<tal:var content="structure provider:pyams.jsextensions" />
-	<!-- end Javascript extensions -->
-</body>
-</html>
--- a/src/pyams_skin/templates/inner-layout.pt	Wed Sep 09 11:53:09 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-<tal:var content="structure provider:content_header" />
-<tal:var content="structure provider:content_help" />
-<tal:var content="structure provider:pagelet" />
--- a/src/pyams_skin/templates/modal-layout.pt	Wed Sep 09 11:53:09 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-<div class="modal-dialog modal-medium"
-	 tal:attributes="class string:modal-dialog ${view.dialog_class}">
-	<tal:var replace="structure provider:pagelet" />
-</div>
--- a/src/pyams_skin/templates/widget-layout.pt	Wed Sep 09 11:53:09 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-<tal:var content="structure provider:content_header" />
-<tal:var content="structure provider:content_help" />
-<div class="ams-widget" i18n:domain="onf_website"
-	 tal:attributes="data-ams-data extension:object_data(view)">
-	<header>
-		<span tal:condition="view.widget_icon_class | nothing"
-			  class="widget-icon"><i tal:attributes="class view.widget_icon_class"></i>
-		</span>
-		<h2 tal:content="view.title">Title</h2>
-		<tal:var content="structure provider:pyams.widget_title" />
-		<tal:var content="structure provider:pyams.toolbar" />
-	</header>
-	<div class="widget-body">
-		<tal:var content="structure provider:pagelet" />
-	</div>
-</div>