work in progress: layouts for the Lobo skin
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3998 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
cffadbdf14
commit
068eef9753
3 changed files with 106 additions and 42 deletions
|
@ -12,11 +12,13 @@
|
|||
<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">
|
||||
<a tal:attributes="href cell/targetUrl;
|
||||
title cell/description">
|
||||
<metal:image use-macro="item/macros/image" />
|
||||
<b tal:content="cell/text" /><br />
|
||||
<i tal:content="cell/object/description" />
|
||||
<div class="legend">
|
||||
<b tal:content="cell/title" /><br />
|
||||
<i tal:content="cell/description" />
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</tal:cell>
|
||||
|
@ -24,22 +26,34 @@
|
|||
|
||||
|
||||
<metal:block define-macro="list1">
|
||||
<div>List1</div>
|
||||
<tal:cell repeat="cell part/getChildren">
|
||||
<div tal:attributes="class python:cell.cssClass[0]">
|
||||
<a tal:attributes="href cell/targetUrl;
|
||||
title cell/description">
|
||||
<metal:image use-macro="item/macros/image" />
|
||||
</a>
|
||||
</div>
|
||||
<div tal:attributes="class python:cell.cssClass[1]">
|
||||
<b tal:content="cell/title" /><br />
|
||||
<i tal:content="cell/description" />
|
||||
</div>
|
||||
</tal:cell>
|
||||
</metal:block>
|
||||
|
||||
|
||||
<metal:block define-macro="header1">
|
||||
<metal:headline use-macro="item/macros/headline" />
|
||||
<div tal:define="cell part/setupConcept">
|
||||
<div tal:define="cell part/getView">
|
||||
<metal:headline use-macro="item/macros/headline" />
|
||||
<metal:image use-macro="item/macros/image" />
|
||||
<br />
|
||||
<metal:text use-macro="item/macros/text" />
|
||||
<br style="clear: both" />
|
||||
</div>
|
||||
</metal:block>
|
||||
|
||||
|
||||
<metal:block define-macro="header2">
|
||||
<metal:headline use-macro="item/macros/headline" />
|
||||
<div tal:define="cell part/setupConcept">
|
||||
<div tal:define="cell part/getView">
|
||||
<metal:image use-macro="item/macros/image" />
|
||||
<br />
|
||||
</div>
|
||||
|
@ -50,15 +64,22 @@
|
|||
|
||||
<metal:image define-macro="image">
|
||||
<img tal:condition="cell/img"
|
||||
tal:attributes="src cell/img/src" />
|
||||
tal:attributes="src cell/img/src;
|
||||
class cell/img/cssClass" />
|
||||
</metal:image>
|
||||
|
||||
|
||||
<metal:block define-macro="text">
|
||||
<span tal:content="structure cell/renderedText" />
|
||||
</metal:block>
|
||||
|
||||
|
||||
<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>
|
||||
<h1 tal:attributes="ondblclick cell/openEditWindow">
|
||||
<a tal:attributes="href cell/targetUrl"
|
||||
tal:content="cell/title" /></h1>
|
||||
<div tal:condition="cell/description">
|
||||
<i tal:content="cell/description" /><br /> </div>
|
||||
</metal:block>
|
||||
|
||||
|
||||
|
|
|
@ -28,14 +28,15 @@ from zope.app.pagetemplate import ViewPageTemplateFile
|
|||
from zope.cachedescriptors.property import Lazy
|
||||
|
||||
from cybertools.typology.interfaces import IType
|
||||
from loops.browser.concept import ConceptView
|
||||
from loops.browser.concept import ConceptView as BaseConceptView
|
||||
from loops.browser.concept import ConceptRelationView as BaseConceptRelationView
|
||||
from loops.common import adapted
|
||||
|
||||
|
||||
standard_template = ViewPageTemplateFile('standard.pt')
|
||||
|
||||
|
||||
class Base(ConceptView):
|
||||
class Base(BaseConceptView):
|
||||
|
||||
template = standard_template
|
||||
templateName = 'lobo.standard'
|
||||
|
@ -50,6 +51,54 @@ class Base(ConceptView):
|
|||
return self.macros[self.macroName]
|
||||
|
||||
|
||||
class ConceptView(BaseConceptView):
|
||||
|
||||
def __init__(self, context, request, parent=None, idx=0):
|
||||
super(ConceptView, self).__init__(context, request)
|
||||
self.parentView = parent
|
||||
self.idx = idx
|
||||
|
||||
# properties from base class: title, description, renderedDescription
|
||||
|
||||
@Lazy
|
||||
def renderedText(self):
|
||||
for r in self.context.getResources([self.defaultPredicate]):
|
||||
if r.contentType.startswith('text/'):
|
||||
return self.renderText(r.data, r.contentType)
|
||||
|
||||
@Lazy
|
||||
def targetUrl(self):
|
||||
return self.nodeView.getUrlForTarget(self.context)
|
||||
|
||||
@Lazy
|
||||
def cssClass(self):
|
||||
pattern = self.parentView.gridPattern
|
||||
if pattern:
|
||||
return pattern[self.idx % len(pattern)]
|
||||
|
||||
@Lazy
|
||||
def style(self):
|
||||
return 'height: %ipx' % self.parentView.height
|
||||
|
||||
@Lazy
|
||||
def img(self):
|
||||
for r in self.context.getResources([self.defaultPredicate]):
|
||||
if r.contentType.startswith('image/'):
|
||||
src = ('%s/mediaasset.html?v=%s' %
|
||||
(self.nodeView.getUrlForTarget(r),
|
||||
self.parentView.imageSize))
|
||||
return dict(src=src, cssClass=self.parentView.imageCssClass)
|
||||
|
||||
|
||||
class ConceptRelationView(BaseConceptRelationView, ConceptView):
|
||||
|
||||
def __init__(self, relation, request, contextIsSecond=False,
|
||||
parent=None, idx=0):
|
||||
BaseConceptRelationView.__init__(self, relation, request, contextIsSecond)
|
||||
self.parentView = parent
|
||||
self.idx = idx
|
||||
|
||||
|
||||
class Layout(Base):
|
||||
|
||||
macroName = 'layout'
|
||||
|
@ -71,36 +120,20 @@ class Layout(Base):
|
|||
class BasePart(Base):
|
||||
|
||||
imageSize = 'small'
|
||||
imageCssClass = ''
|
||||
height = 260
|
||||
gridPattern = []
|
||||
|
||||
def getChildren(self):
|
||||
result = []
|
||||
for idx, c in enumerate(self.context.getChildren([self.defaultPredicate])):
|
||||
result.append(self.setupConcept(idx, c))
|
||||
for idx, r in enumerate(
|
||||
self.context.getChildRelations([self.defaultPredicate])):
|
||||
result.append(ConceptRelationView(r, self.request,
|
||||
contextIsSecond=True, parent=self, idx=idx))
|
||||
return result
|
||||
|
||||
def setupConcept(self, idx=0, obj=None):
|
||||
if obj is None:
|
||||
obj = self.context
|
||||
text = obj.title
|
||||
url = self.nodeView.getUrlForTarget(obj)
|
||||
style = 'height: %ipx' % self.height
|
||||
return dict(text=text, url=url, cssClass=self.getCssClass(idx, obj),
|
||||
style=style, img=self.getImageData(idx, obj),
|
||||
object=adapted(obj))
|
||||
|
||||
def getCssClass(self, idx, obj):
|
||||
pattern = self.gridPattern
|
||||
if pattern:
|
||||
return pattern[idx % len(pattern)]
|
||||
|
||||
def getImageData(self, idx, concept):
|
||||
for r in concept.getResources([self.defaultPredicate]):
|
||||
if r.contentType.startswith('image/'):
|
||||
src = ('%s/mediaasset.html?v=%s' %
|
||||
(self.nodeView.getUrlForTarget(r), self.imageSize))
|
||||
return dict(src=src)
|
||||
def getView(self):
|
||||
return ConceptView(self.context, self.request, parent=self)
|
||||
|
||||
|
||||
class Grid3(BasePart):
|
||||
|
@ -114,11 +147,15 @@ class Grid3(BasePart):
|
|||
class List1(BasePart):
|
||||
|
||||
macroName = 'list1'
|
||||
imageSize = 'small'
|
||||
gridPattern = [['span-2', 'span-4 last']]
|
||||
|
||||
|
||||
class Header1(BasePart):
|
||||
|
||||
macroName = 'header1'
|
||||
imageSize = 'small'
|
||||
imageCssClass = 'flow-left'
|
||||
|
||||
|
||||
class Header2(BasePart):
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
a[href]:hover {
|
||||
text-decoration: none;
|
||||
color: #803000;
|
||||
color: #6060c0;
|
||||
}
|
||||
|
||||
pre {
|
||||
|
@ -335,12 +335,12 @@ div.menu-1, div.menu-2 {
|
|||
|
||||
.flow-left {
|
||||
float: left;
|
||||
padding: 0.4em 0.8em 0.8em 0;
|
||||
padding: 0 20px 5px 0;
|
||||
}
|
||||
|
||||
.flow-right {
|
||||
float: right;
|
||||
padding: 0.4em 0.8em 0.8em 0;
|
||||
padding: 0 0 5px 20px;
|
||||
}
|
||||
|
||||
div.image {
|
||||
|
@ -411,6 +411,12 @@ img.notselected {
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* lobo layout-specific classes */
|
||||
|
||||
.legend {
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
/* comments */
|
||||
|
||||
div.comment {
|
||||
|
|
Loading…
Add table
Reference in a new issue