18 """Bases HTML components: |
18 """Bases HTML components: |
19 |
19 |
20 * the rql input form |
20 * the rql input form |
21 * the logged user link |
21 * the logged user link |
22 """ |
22 """ |
|
23 from __future__ import with_statement |
23 |
24 |
24 __docformat__ = "restructuredtext en" |
25 __docformat__ = "restructuredtext en" |
25 _ = unicode |
26 _ = unicode |
26 |
27 |
27 from logilab.mtconverter import xml_escape |
28 from logilab.mtconverter import xml_escape |
28 from rql import parse |
29 from rql import parse |
29 |
30 |
30 from cubicweb.selectors import (yes, multi_etypes_rset, match_form_params, |
31 from cubicweb.selectors import (yes, multi_etypes_rset, |
|
32 match_form_params, match_context, |
31 anonymous_user, authenticated_user) |
33 anonymous_user, authenticated_user) |
32 from cubicweb.schema import display_name |
34 from cubicweb.schema import display_name |
|
35 from cubicweb.utils import wrap_on_write |
33 from cubicweb.uilib import toggle_action |
36 from cubicweb.uilib import toggle_action |
34 from cubicweb.web import component |
37 from cubicweb.web import component |
35 from cubicweb.web.htmlwidgets import (MenuWidget, PopupBoxMenu, BoxSeparator, |
38 from cubicweb.web.htmlwidgets import (MenuWidget, PopupBoxMenu, BoxSeparator, |
36 BoxLink) |
39 BoxLink) |
37 |
40 |
162 def call(self): |
165 def call(self): |
163 title = self._cw.property_value('ui.site-title') |
166 title = self._cw.property_value('ui.site-title') |
164 if title: |
167 if title: |
165 self.w(u'<span id="appliName"><a href="%s">%s</a></span>' % ( |
168 self.w(u'<span id="appliName"><a href="%s">%s</a></span>' % ( |
166 self._cw.base_url(), xml_escape(title))) |
169 self._cw.base_url(), xml_escape(title))) |
167 |
|
168 |
|
169 class SeeAlsoVComponent(component.RelatedObjectsVComponent): |
|
170 """display any entity's see also""" |
|
171 __regid__ = 'seealso' |
|
172 context = 'navcontentbottom' |
|
173 rtype = 'see_also' |
|
174 role = 'subject' |
|
175 order = 40 |
|
176 # register msg not generated since no entity use see_also in cubicweb itself |
|
177 title = _('contentnavigation_seealso') |
|
178 help = _('contentnavigation_seealso_description') |
|
179 |
170 |
180 |
171 |
181 class EtypeRestrictionComponent(component.Component): |
172 class EtypeRestrictionComponent(component.Component): |
182 """displays the list of entity types contained in the resultset |
173 """displays the list of entity types contained in the resultset |
183 to be able to filter accordingly. |
174 to be able to filter accordingly. |
227 else: |
218 else: |
228 html.insert(0, u'<span class="selected">%s</span>' % _('Any')) |
219 html.insert(0, u'<span class="selected">%s</span>' % _('Any')) |
229 self.w(u' | '.join(html)) |
220 self.w(u' | '.join(html)) |
230 self.w(u'</div>') |
221 self.w(u'</div>') |
231 |
222 |
232 |
223 # contextual components ######################################################## |
233 class MetaDataComponent(component.EntityVComponent): |
224 |
|
225 # class SeeAlsoVComponent(component.RelatedObjectsVComponent): |
|
226 # """display any entity's see also""" |
|
227 # __regid__ = 'seealso' |
|
228 # context = 'navcontentbottom' |
|
229 # rtype = 'see_also' |
|
230 # role = 'subject' |
|
231 # order = 40 |
|
232 # # register msg not generated since no entity use see_also in cubicweb itself |
|
233 # title = _('ctxcomponents_seealso') |
|
234 # help = _('ctxcomponents_seealso_description') |
|
235 |
|
236 |
|
237 class MetaDataComponent(component.EntityCtxComponent): |
234 __regid__ = 'metadata' |
238 __regid__ = 'metadata' |
235 context = 'navbottom' |
239 context = 'navbottom' |
236 order = 1 |
240 order = 1 |
237 |
241 |
238 def cell_call(self, row, col, view=None): |
242 def render_body(self, w): |
239 self.wview('metadata', self.cw_rset, row=row, col=col) |
243 self.entity.view('metadata', w=w) |
240 |
244 |
241 |
245 |
242 def registration_callback(vreg): |
246 class SectionLayout(component.Layout): |
243 vreg.register_all(globals().values(), __name__, (SeeAlsoVComponent,)) |
247 __select__ = match_context('navtop', 'navbottom', |
244 if 'see_also' in vreg.schema: |
248 'navcontenttop', 'navcontentbottom') |
245 vreg.register(SeeAlsoVComponent) |
249 cssclass = 'section' |
|
250 |
|
251 def render(self, w): |
|
252 if self.init_rendering(): |
|
253 view = self.cw_extra_kwargs['view'] |
|
254 w(u'<div class="%s %s" id="%s">' % (self.cssclass, view.cssclass, |
|
255 view.domid)) |
|
256 with wrap_on_write(w, '<h4>') as wow: |
|
257 view.render_title(wow) |
|
258 view.render_body(w) |
|
259 w(u'</div>\n') |
|
260 |
|
261 |
|
262 # def registration_callback(vreg): |
|
263 # vreg.register_all(globals().values(), __name__, (SeeAlsoVComponent,)) |
|
264 # if 'see_also' in vreg.schema: |
|
265 # vreg.register(SeeAlsoVComponent) |