|
1 # |
|
2 # Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net> |
|
3 # All Rights Reserved. |
|
4 # |
|
5 # This software is subject to the provisions of the Zope Public License, |
|
6 # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. |
|
7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
|
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
|
10 # FOR A PARTICULAR PURPOSE. |
|
11 # |
|
12 |
|
13 __docformat__ = 'restructuredtext' |
|
14 |
|
15 # import standard library |
|
16 |
|
17 # import interfaces |
|
18 from pyams_skin.layer import IPyAMSLayer |
|
19 from zope.component.interfaces import IObjectEvent, ObjectEvent |
|
20 |
|
21 # import packages |
|
22 from pyams_template.template import layout_config |
|
23 from zope.interface import implementer, invariant, Interface, Attribute, Invalid |
|
24 from zope.configuration.fields import GlobalInterface |
|
25 from zope.schema import Text, TextLine, Choice, Int, Bool |
|
26 |
|
27 from pyams_skin import _ |
|
28 |
|
29 |
|
30 class ISkin(Interface): |
|
31 """Skin interface |
|
32 |
|
33 Skins are registered as utilities implementing this interface |
|
34 and defining request layer as attribute |
|
35 """ |
|
36 |
|
37 label = TextLine(title="Skin name") |
|
38 |
|
39 layer = GlobalInterface(title="Request layer", |
|
40 description="This interface will be used to tag request layer", |
|
41 required=True) |
|
42 |
|
43 |
|
44 class ISkinChangedEvent(IObjectEvent): |
|
45 """Skin changed event""" |
|
46 |
|
47 |
|
48 @implementer(ISkinChangedEvent) |
|
49 class SkinChangedEvent(ObjectEvent): |
|
50 """Request skin changed event""" |
|
51 |
|
52 |
|
53 class ISkinnable(Interface): |
|
54 """Skinnable content interface""" |
|
55 |
|
56 can_inherit_skin = Attribute("Check if skin can be inherited") |
|
57 |
|
58 inherit_skin = Bool(title=_("Inherit parent skin?"), |
|
59 description=_("Should we reuse parent skin?"), |
|
60 required=True, |
|
61 default=False) |
|
62 |
|
63 no_inherit_skin = Bool(title=_("Don't inherit parent skin?"), |
|
64 description=_("Should we override parent skin?"), |
|
65 required=True, |
|
66 default=True) |
|
67 |
|
68 skin_parent = Attribute("Skin parent (local or inherited)") |
|
69 |
|
70 skin = Choice(title=_("Custom graphic theme"), |
|
71 description=_("This theme will be used to handle graphic design (colors and images)"), |
|
72 vocabulary='PyAMS user skins', |
|
73 required=False) |
|
74 |
|
75 @invariant |
|
76 def check_skin(self): |
|
77 if self.no_inherit_skin and not self.skin: |
|
78 raise Invalid(_("You must select a custom skin or inherit from parent!")) |
|
79 |
|
80 def get_skin(self, request=None): |
|
81 """Get skin matching this content""" |
|
82 |
|
83 |
|
84 class IUserSkinnable(ISkinnable): |
|
85 """User skinnable content interface""" |
|
86 |
|
87 |
|
88 @layout_config(template='templates/fullpage-layout.pt', layer=IPyAMSLayer) |
|
89 class IFullPage(Interface): |
|
90 """Full page marker interface""" |
|
91 |
|
92 |
|
93 @layout_config(template='templates/fullpage-modal-layout.pt', layer=IPyAMSLayer) |
|
94 class IModalFullPage(IFullPage): |
|
95 """Full page modal dialog marker interface""" |
|
96 |
|
97 dialog_class = Attribute("Default dialog CSS class") |
|
98 |
|
99 |
|
100 @layout_config(template='templates/inner-layout.pt', layer=IPyAMSLayer) |
|
101 class IInnerPage(Interface): |
|
102 """Inner page marker interface""" |
|
103 |
|
104 |
|
105 @layout_config(template='templates/widget-layout.pt', layer=IPyAMSLayer) |
|
106 class IWidgetInnerPage(IInnerPage): |
|
107 """Inner page with widget marker interface""" |
|
108 |
|
109 |
|
110 @layout_config(template='templates/modal-layout.pt', layer=IPyAMSLayer) |
|
111 class IModalPage(Interface): |
|
112 """Modal page marker interface""" |
|
113 |
|
114 |
|
115 class IDialog(IModalPage): |
|
116 """Modal dialog interface""" |
|
117 |
|
118 modal_class = TextLine(title="Modal dialog CSS class", |
|
119 default='modal-medium') |
|
120 |
|
121 |
|
122 class IPageHeader(Interface): |
|
123 """Page header interface used by 'header' content provider""" |
|
124 |
|
125 back_url = TextLine(title="Back URL", |
|
126 required=False) |
|
127 |
|
128 back_target = TextLine(title="Back URL target", |
|
129 description="HTML target selector, or None for full page target", |
|
130 required=False) |
|
131 |
|
132 icon_class = TextLine(title='Icon CSS class') |
|
133 |
|
134 title = TextLine(title='Page title') |
|
135 |
|
136 title_badge = TextLine(title="Title badge") |
|
137 |
|
138 title_badge_class = TextLine(title="Title badge class") |
|
139 |
|
140 subtitle = TextLine(title='Page sub-title') |
|
141 |
|
142 subtitle_badge = TextLine(title="Sub-title badge") |
|
143 |
|
144 subtitle_badge_class = TextLine(title="Sub-title badge class") |
|
145 |
|
146 |
|
147 class IContentHelp(Interface): |
|
148 """Content help block""" |
|
149 |
|
150 outer_margin = Int(title='Outer margin size', |
|
151 default=0) |
|
152 |
|
153 status = TextLine(title='Help status', |
|
154 default='info') |
|
155 |
|
156 header = TextLine(title='Help header') |
|
157 |
|
158 message = Text(title='Help message') |
|
159 |
|
160 message_format = Choice(title='Help message format', |
|
161 vocabulary='PyAMS HTML renderers') |
|
162 |
|
163 |
|
164 class IContentTitle(Interface): |
|
165 """Content title interface""" |
|
166 |
|
167 title = Attribute("Content title") |
|
168 |
|
169 |
|
170 class IContextTitlePrefix(Interface): |
|
171 """Context title prefix interface""" |
|
172 |
|
173 prefix = Attribute("Context title prefix") |
|
174 |
|
175 |
|
176 class IContentSearch(Interface): |
|
177 """Content search interface""" |
|
178 |
|
179 def get_search_results(self, data): |
|
180 """Extract search results from given data |
|
181 |
|
182 `data` is a dictionary containing search fields |
|
183 """ |
|
184 |
|
185 |
|
186 class ISearchPage(Interface): |
|
187 """Search page marker interface""" |