improve and extend book layout: show images
This commit is contained in:
parent
1c1f259d4f
commit
8f19077602
3 changed files with 40 additions and 3 deletions
|
@ -413,7 +413,7 @@ class ConceptView(BaseView):
|
|||
if r.order != pos:
|
||||
r.order = pos
|
||||
|
||||
def resources(self):
|
||||
def getResources(self):
|
||||
form = self.request.form
|
||||
#if form.get('loops.viewName') == 'index.html' and self.editable:
|
||||
if self.editable:
|
||||
|
@ -430,6 +430,9 @@ class ConceptView(BaseView):
|
|||
if fv.check(r.first):
|
||||
yield ResourceRelationView(r, self.request, contextIsSecond=True)
|
||||
|
||||
def resources(self):
|
||||
return self.getResources()
|
||||
|
||||
@Lazy
|
||||
def resourcesList(self):
|
||||
from loops.browser.resource import ResourceRelationView
|
||||
|
|
|
@ -77,6 +77,30 @@ class SectionView(Base, ConceptView):
|
|||
def sectionType(self):
|
||||
return self.conceptManager['section']
|
||||
|
||||
def getResources(self):
|
||||
relViews = super(SectionView, self).getResources()
|
||||
return relViews
|
||||
|
||||
@Lazy
|
||||
def textResources(self):
|
||||
self.images = [[]]
|
||||
result = []
|
||||
idx = 0
|
||||
for rv in self.getResources():
|
||||
if rv.context.contentType.startswith('text/'):
|
||||
idx += 1
|
||||
result.append(rv)
|
||||
self.images.append([])
|
||||
else:
|
||||
self.registerDojoLightbox()
|
||||
url = self.nodeView.getUrlForTarget(rv.context)
|
||||
src = '%s/mediaasset.html?v=small' % url
|
||||
fullSrc = '%s/mediaasset.html?v=medium' % url
|
||||
img = dict(src=src, fullImageUrl=fullSrc, title=rv.title,
|
||||
description=rv.description, url=url, object=rv)
|
||||
self.images[idx].append(img)
|
||||
return result
|
||||
|
||||
def getCssClassForResource(self, r):
|
||||
for c in r.context.getConcepts([self.defaultPredicate]):
|
||||
if c.conceptType == self.documentTypeType:
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
<metal:section define-macro="section">
|
||||
<metal:info use-macro="view/concept_macros/concepttitle" />
|
||||
<div tal:repeat="related item/resources">
|
||||
<div tal:repeat="related item/textResources">
|
||||
<div class="span-4">
|
||||
<div tal:attributes="class python:
|
||||
item.getCssClassForResource(related)"
|
||||
|
@ -36,7 +36,8 @@
|
|||
string:$resourceBase/cybertools.icons/vcard_edit.png" /></a>
|
||||
<a i18n:translate="" i18n:attributes="title"
|
||||
title="Edit with external editor."
|
||||
tal:condition="related/xeditable"
|
||||
xxtal:condition="related/xeditable"
|
||||
tal:condition="nothing"
|
||||
tal:attributes="href string:$url/external_edit?version=this">
|
||||
<img tal:attributes="src
|
||||
string:$resourceBase/cybertools.icons/application_edit.png" /></a>
|
||||
|
@ -45,6 +46,15 @@
|
|||
<a tal:content="parent/title"
|
||||
tal:attributes="href python:view.getUrlForTarget(parent)" />
|
||||
</div>
|
||||
<div tal:repeat="image python:
|
||||
item.images[repeat['related'].index() + 1]">
|
||||
<a dojoType="dojox.image.Lightbox" group="mediasset"
|
||||
i18n:attributes="title"
|
||||
tal:attributes="href image/fullImageUrl;
|
||||
title image/title">
|
||||
<img tal:attributes="src image/src;
|
||||
alt image/title" /></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</metal:section>
|
||||
|
|
Loading…
Add table
Reference in a new issue