work in progress: lobo layout components
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3992 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
751bc4a7d3
commit
1343619d11
4 changed files with 131 additions and 26 deletions
|
@ -23,7 +23,7 @@ ZCML setup):
|
|||
Using the Lobo Blueprint-based Layout Views
|
||||
===========================================
|
||||
|
||||
>>> from loops.browser.lobo.standard import Grid3, Single1
|
||||
>>> from loops.browser.lobo.standard import Layout
|
||||
|
||||
|
||||
Fin de partie
|
||||
|
|
|
@ -8,7 +8,15 @@
|
|||
<!-- Views for the Lobo skin / grid-based layout -->
|
||||
|
||||
<zope:adapter
|
||||
name="page.grid.3"
|
||||
name="lobo_layout"
|
||||
for="loops.interfaces.IConcept
|
||||
loops.browser.skin.Lobo"
|
||||
provides="zope.interface.Interface"
|
||||
factory="loops.browser.lobo.standard.Layout"
|
||||
permission="zope.View" />
|
||||
|
||||
<zope:adapter
|
||||
name="lobo_g3"
|
||||
for="loops.interfaces.IConcept
|
||||
loops.browser.skin.Lobo"
|
||||
provides="zope.interface.Interface"
|
||||
|
@ -16,11 +24,27 @@
|
|||
permission="zope.View" />
|
||||
|
||||
<zope:adapter
|
||||
name="page.single.1"
|
||||
name="lobo_l1"
|
||||
for="loops.interfaces.IConcept
|
||||
loops.browser.skin.Lobo"
|
||||
provides="zope.interface.Interface"
|
||||
factory="loops.browser.lobo.standard.Single1"
|
||||
factory="loops.browser.lobo.standard.List1"
|
||||
permission="zope.View" />
|
||||
|
||||
<zope:adapter
|
||||
name="lobo_h1"
|
||||
for="loops.interfaces.IConcept
|
||||
loops.browser.skin.Lobo"
|
||||
provides="zope.interface.Interface"
|
||||
factory="loops.browser.lobo.standard.Header1"
|
||||
permission="zope.View" />
|
||||
|
||||
<zope:adapter
|
||||
name="lobo_h2"
|
||||
for="loops.interfaces.IConcept
|
||||
loops.browser.skin.Lobo"
|
||||
provides="zope.interface.Interface"
|
||||
factory="loops.browser.lobo.standard.Header2"
|
||||
permission="zope.View" />
|
||||
|
||||
</configure>
|
||||
|
|
|
@ -1,23 +1,64 @@
|
|||
<html i18n:domain="loops">
|
||||
|
||||
|
||||
<metal:block define-macro="basic">
|
||||
<metal:block define-macro="layout">
|
||||
<tal:part repeat="part item/getParts">
|
||||
<metal:part use-macro="part/macro" />
|
||||
</tal:part>
|
||||
</metal:block>
|
||||
|
||||
<h1 tal:attributes="ondblclick item/openEditWindow"
|
||||
tal:content="item/title" />
|
||||
<tal:cell repeat="cell item/content">
|
||||
|
||||
<metal:block define-macro="grid">
|
||||
<tal:cell repeat="cell part/getChildren">
|
||||
<div tal:attributes="class cell/cssClass;
|
||||
style cell/style">
|
||||
<a tal:attributes="href cell/url;
|
||||
title cell/object/description">
|
||||
<img tal:condition="cell/img"
|
||||
tal:attributes="src cell/img/src"/>
|
||||
<metal:image use-macro="item/macros/image" />
|
||||
<b tal:content="cell/text" /><br />
|
||||
<i tal:content="cell/object/description" />
|
||||
</a>
|
||||
</div>
|
||||
</tal:cell>
|
||||
</metal:block>
|
||||
|
||||
|
||||
<metal:block define-macro="list1">
|
||||
<div>List1</div>
|
||||
</metal:block>
|
||||
|
||||
|
||||
<metal:block define-macro="header1">
|
||||
<metal:headline use-macro="item/macros/headline" />
|
||||
<div tal:define="cell part/setupConcept">
|
||||
<metal:image use-macro="item/macros/image" />
|
||||
<br />
|
||||
</div>
|
||||
</metal:block>
|
||||
|
||||
|
||||
<metal:block define-macro="header2">
|
||||
<metal:headline use-macro="item/macros/headline" />
|
||||
<div tal:define="cell part/setupConcept">
|
||||
<metal:image use-macro="item/macros/image" />
|
||||
<br />
|
||||
</div>
|
||||
</metal:block>
|
||||
|
||||
|
||||
<!-- basic component macros -->
|
||||
|
||||
<metal:image define-macro="image">
|
||||
<img tal:condition="cell/img"
|
||||
tal:attributes="src cell/img/src" />
|
||||
</metal:image>
|
||||
|
||||
|
||||
<metal:block define-macro="headline">
|
||||
<h1 tal:attributes="ondblclick item/openEditWindow"
|
||||
tal:content="item/title" />
|
||||
<div tal:condition="item/description">
|
||||
<i tal:content="item/description" /><br /> </div>
|
||||
</metal:block>
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
|
||||
# Copyright (c) 2010 Helmut Merz helmutm@cy55.de
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -17,11 +17,12 @@
|
|||
#
|
||||
|
||||
"""
|
||||
View class(es) for integrating external objects.
|
||||
View classes for lobo (blueprint-based) layouts.
|
||||
|
||||
$Id$
|
||||
"""
|
||||
|
||||
from cgi import parse_qs
|
||||
from zope import interface, component
|
||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||
from zope.cachedescriptors.property import Lazy
|
||||
|
@ -38,10 +39,7 @@ class Base(ConceptView):
|
|||
|
||||
template = standard_template
|
||||
templateName = 'lobo.standard'
|
||||
macroName = 'basic'
|
||||
imageSize = 'small'
|
||||
height = 260
|
||||
gridPattern = ['span-2', 'span-2', 'span-2 last']
|
||||
macroName = None
|
||||
|
||||
@Lazy
|
||||
def macros(self):
|
||||
|
@ -51,16 +49,42 @@ class Base(ConceptView):
|
|||
def macro(self):
|
||||
return self.macros[self.macroName]
|
||||
|
||||
def content(self):
|
||||
|
||||
class Layout(Base):
|
||||
|
||||
macroName = 'layout'
|
||||
|
||||
def getParts(self):
|
||||
result = []
|
||||
for idx, c in enumerate(self.context.getChildren([self.defaultPredicate])):
|
||||
result.append(self.setupItem(idx, c))
|
||||
ann = self.request.annotations.get('loops.view', {})
|
||||
params = parse_qs(ann.get('params') or '')
|
||||
parts = (params.get('parts') or ['h1,g3'])[0].split(',')
|
||||
for p in parts:
|
||||
viewName = 'lobo_' + p
|
||||
view = component.queryMultiAdapter((self.context, self.request),
|
||||
name=viewName)
|
||||
if view is not None:
|
||||
result.append(view)
|
||||
return result
|
||||
|
||||
def setupItem(self, idx, obj):
|
||||
|
||||
class BasePart(Base):
|
||||
|
||||
imageSize = 'small'
|
||||
height = 260
|
||||
gridPattern = []
|
||||
|
||||
def getChildren(self):
|
||||
result = []
|
||||
for idx, c in enumerate(self.context.getChildren([self.defaultPredicate])):
|
||||
result.append(self.setupConcept(idx, c))
|
||||
return result
|
||||
|
||||
def setupConcept(self, idx=0, obj=None):
|
||||
if obj is None:
|
||||
obj = self.context
|
||||
text = obj.title
|
||||
url = self.nodeView.getUrlForTarget(obj)
|
||||
# TODO: use layout settings of context and c for display
|
||||
style = 'height: %ipx' % self.height
|
||||
return dict(text=text, url=url, cssClass=self.getCssClass(idx, obj),
|
||||
style=style, img=self.getImageData(idx, obj),
|
||||
|
@ -68,7 +92,8 @@ class Base(ConceptView):
|
|||
|
||||
def getCssClass(self, idx, obj):
|
||||
pattern = self.gridPattern
|
||||
return pattern[idx % len(pattern)]
|
||||
if pattern:
|
||||
return pattern[idx % len(pattern)]
|
||||
|
||||
def getImageData(self, idx, concept):
|
||||
for r in concept.getResources([self.defaultPredicate]):
|
||||
|
@ -78,12 +103,27 @@ class Base(ConceptView):
|
|||
return dict(src=src)
|
||||
|
||||
|
||||
class Grid3(Base):
|
||||
class Grid3(BasePart):
|
||||
|
||||
pass
|
||||
macroName = 'grid'
|
||||
imageSize = 'small'
|
||||
height = 260
|
||||
gridPattern = ['span-2', 'span-2', 'span-2 last']
|
||||
|
||||
|
||||
class Single1(Base):
|
||||
class List1(BasePart):
|
||||
|
||||
macroName = 'list1'
|
||||
|
||||
|
||||
class Header1(BasePart):
|
||||
|
||||
macroName = 'header1'
|
||||
|
||||
|
||||
class Header2(BasePart):
|
||||
|
||||
macroName = 'header2'
|
||||
imageSize = 'medium'
|
||||
|
||||
pass
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue