diff --git a/CHANGES.txt b/CHANGES.txt index 666b26f..c1b99c7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -6,6 +6,9 @@ $Id$ 1.1 --- +- Lobo layout: provide new part: image grid; make sure image is not repeated if + it already appears in header part +- new special view 'listsubobjects' for nodes - allow for adoption of relations to a predicate interface; with example implementation for a 'has Role' predicate in loops.organize - external collection: provide functionality for automatically populate diff --git a/browser/concept.py b/browser/concept.py index 8c693cb..9fa7d5e 100644 --- a/browser/concept.py +++ b/browser/concept.py @@ -350,7 +350,12 @@ class ConceptView(BaseView): #IOptions(adapted(pr.predicate))('hide_parents_for', [])): IOptions(pr.predicate)('hide_parents_for', [])): return True - hideRoles = IOptions(adapted(pr.first.conceptType))('hide_for', None) + hideRoles = None + options = component.queryAdapter(adapted(pr.first), IOptions) + if options is not None: + hideRoles = options('hide_for', None) + if not hideRoles: + hideRoles = IOptions(adapted(pr.first.conceptType))('hide_for', None) if hideRoles is not None: principal = self.request.principal if (IUnauthenticatedPrincipal.providedBy(principal) and @@ -395,10 +400,28 @@ class ConceptView(BaseView): fv = FilterView(self.context, self.request) rels = self.context.getResourceRelations() for r in rels: - #yield self.childViewFactory(r, self.request, contextIsSecond=True) if fv.check(r.first): yield ResourceRelationView(r, self.request, contextIsSecond=True) + @Lazy + def resourcesList(self): + from loops.browser.resource import ResourceRelationView + return [ResourceRelationView(r, self.request, contextIsSecond=True) + for r in self.context.getResourceRelations()] + + @Lazy + def resourcesByType(self): + result = dict(texts=[], images=[], files=[]) + for rv in self.resourcesList: + r = rv.context + if r.contentType.startswith('text/'): + result['texts'].append(r) + if r.contentType.startswith('image/'): + result['images'].append(r) + else: + result['files'].append(r) + return result + def unique(self, rels): result = Jeep() for r in rels: diff --git a/browser/configure.zcml b/browser/configure.zcml index ea0441b..8466f45 100644 --- a/browser/configure.zcml +++ b/browser/configure.zcml @@ -509,6 +509,14 @@ factory="loops.browser.node.ListResources" permission="zope.View" /> + + + + Creators: + tal:content="info/label">Meta: + + + +
+ + + + + + + + + + + + + + @@ -48,5 +70,4 @@
+

Information

Meta:
-
diff --git a/browser/lobo/configure.zcml b/browser/lobo/configure.zcml index 6355601..0be24a7 100644 --- a/browser/lobo/configure.zcml +++ b/browser/lobo/configure.zcml @@ -39,6 +39,14 @@ factory="loops.browser.lobo.standard.List2" permission="zope.View" /> + + diff --git a/browser/lobo/standard.pt b/browser/lobo/standard.pt index f344cc6..6c4c2ba 100644 --- a/browser/lobo/standard.pt +++ b/browser/lobo/standard.pt @@ -12,9 +12,9 @@
+ -

@@ -29,10 +29,8 @@
- - -
  + +
 
@@ -48,14 +46,24 @@
-
- -
+ +
+
- +
 
@@ -67,18 +75,25 @@ - - + + @@ -89,14 +104,21 @@ - + + class cell/img/cssClass; + alt cell/title" /> + + + diff --git a/browser/lobo/standard.py b/browser/lobo/standard.py index 1e0de59..fb847cd 100644 --- a/browser/lobo/standard.py +++ b/browser/lobo/standard.py @@ -31,7 +31,6 @@ from cybertools.typology.interfaces import IType from loops.browser.concept import ConceptView as BaseConceptView from loops.browser.concept import ConceptRelationView as BaseConceptRelationView from loops.browser.resource import ResourceView as BaseResourceView -from loops.browser.resource import ResourceRelationView as BaseResourceRelationView from loops.common import adapted, baseObject @@ -64,7 +63,6 @@ class ConceptView(BaseConceptView): def __init__(self, context, request): super(ConceptView, self).__init__(baseObject(context), request) - self.adapted = context @Lazy def resources(self): @@ -78,6 +76,11 @@ class ConceptView(BaseConceptView): result['files'].append(r) return result + @Lazy + def images(self): + for r in self.resources['images']: + yield r + # properties from base class: title, description, renderedDescription @Lazy @@ -113,23 +116,19 @@ class ConceptView(BaseConceptView): @Lazy def img(self): self.registerDojoLightbox() # also provides access to info popup - for r in self.resources['images']: - url = self.nodeView.getUrlForTarget(r) - src = ('%s/mediaasset.html?v=%s' % (url, self.parentView.imageSize)) - return dict(src=src, url=url, - cssClass=self.parentView.imageCssClass) + for r in self.parentView.parent.images: + # fetch from iterator on layout object: avoid duplicates + url = self.nodeView.getUrlForTarget(r) + src = ('%s/mediaasset.html?v=%s' % (url, self.parentView.imageSize)) + fullSrc = ('%s/mediaasset.html?v=%s' % (url, self.parentView.fullImageSize)) + adImg = adapted(r) + showInfo = adImg.showInfo and adImg.metaInfo + return dict(src=src, fullImageUrl=fullSrc, title=r.title, + url=url, cssClass=self.parentView.imageCssClass, + showInfo=showInfo) -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): +class Layout(Base, ConceptView): macroName = 'layout' @@ -140,11 +139,13 @@ class Layout(Base): parts = (self.options('parts') or self.typeOptions('parts') or ['h1', 'g3']) + ti = adapted(self.context.conceptType).typeInterface for p in parts: viewName = 'lobo_' + p view = component.queryMultiAdapter((self.context, self.request), name=viewName) if view is not None: + view.parent = self result.append(view) return result @@ -152,9 +153,11 @@ class Layout(Base): class BasePart(Base): imageSize = 'small' + fullImageSize = 'medium' imageCssClass = '' height = 260 gridPattern = [] + showImage = True def getChildren(self): subtypeNames = (self.params.get('subtypes') or [''])[0].split(',') @@ -175,6 +178,12 @@ class BasePart(Base): view.parentView = self return view + def getImages(self): + result = [] + for idx, img in enumerate(self.parent.images): + result.append(ResourceView(img, self.request, parent=self, idx=idx)) + return result + class Grid3(BasePart): @@ -198,6 +207,14 @@ class List2(BasePart): gridPattern = [['span-4 clear', 'span-2 last']] +class Header0(BasePart): + + macroName = 'header' + cssClass = ['span-6 last', 'clear'] + showImage = False + cssClass = ['', 'span-6 last', 'clear'] + + class Header1(BasePart): macroName = 'header' @@ -212,13 +229,46 @@ class Header2(BasePart): cssClass = ['span-4', 'span-2 last', 'clear'] -# layout components for presenting lists of resources +# resource parts -class ResourceRelationView(BaseResourceRelationView): + +class ImageGrid3(BasePart): + + macroName = 'imagegrid' + imageSize = 'small' + height = 'auto; padding-bottom: 10px' + gridPattern = ['span-2', 'span-2', 'span-2 last'] + + +# relation views, used for cells (components) of lists and grids + +class ConceptRelationView(BaseConceptRelationView, ConceptView): def __init__(self, relation, request, contextIsSecond=False, parent=None, idx=0): - BaseResourceRelationView.__init__(self, relation, request, contextIsSecond) + BaseConceptRelationView.__init__(self, relation, request, contextIsSecond) + self.parentView = parent + self.idx = idx + + @Lazy + def img(self): + self.registerDojoLightbox() # also provides access to info popup + for r in self.images: + # fetch from iterator on layout object: avoid duplicates + url = self.nodeView.getUrlForTarget(r) + src = ('%s/mediaasset.html?v=%s' % (url, self.parentView.imageSize)) + fullSrc = ('%s/mediaasset.html?v=%s' % (url, self.parentView.fullImageSize)) + adImg = adapted(r) + showInfo = adImg.showInfo and adImg.metaInfo + return dict(src=src, fullImageUrl=fullSrc, title=r.title, + url=url, cssClass=self.parentView.imageCssClass, + showInfo=showInfo) + + +class ResourceView(BaseResourceView): + + def __init__(self, resource, request, parent=None, idx=0): + BaseResourceView.__init__(self, resource, request) self.parentView = parent self.idx = idx @@ -241,25 +291,10 @@ class ResourceRelationView(BaseResourceRelationView): self.registerDojoLightbox() # also provides access to info popup url = self.nodeView.getUrlForTarget(self.context) src = ('%s/mediaasset.html?v=%s' % (url, self.parentView.imageSize)) - return dict(src=src, url=url, - cssClass=self.parentView.imageCssClass) - -class ResourcesPart(BasePart): - - def getResources(self): - result = [] - resourceRels = self.context.getResourceRelations() - for idx, r in enumerate(resourceRels): - result.append(ResourceRelationView(r, self.request, - contextIsSecond=True, parent=self, idx=idx)) - return result - - -class ResourceGrid3(ResourcesPart): - - macroName = 'rgrid' - imageSize = 'small' - height = 'auto; padding-bottom: 10px' - gridPattern = ['span-2', 'span-2', 'span-2 last'] - + fullSrc = ('%s/mediaasset.html?v=%s' % (url, self.parentView.fullImageSize)) + adImg = adapted(self.context) + showInfo = adImg.showInfo and adImg.metaInfo + return dict(src=src, fullImageUrl=fullSrc, title=self.context.title, + url=url, cssClass=self.parentView.imageCssClass, + showInfo=showInfo) diff --git a/browser/node.py b/browser/node.py index 5b295fd..2ac755c 100644 --- a/browser/node.py +++ b/browser/node.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2010 Helmut Merz helmutm@cy55.de +# Copyright (c) 2011 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 @@ -607,6 +607,15 @@ class ObjectInfo(NodeView): return self.request.get('dialog', 'object_info') +class MetaInfo(ObjectInfo): + + __call__ = innerHtml + + @Lazy + def macro(self): + return self.macros['meta_info'] + + class InlineEdit(NodeView): """ Provides inline editor as inner HTML""" @@ -676,6 +685,11 @@ class ListChildren(SpecialNodeView): macroName = 'listchildren' +class ListSubobjects(SpecialNodeView): + + macroName = 'listsubobjects' + + class ConfigureView(NodeView): """ An editing view for configuring a node, optionally creating a target object. diff --git a/browser/node_macros.pt b/browser/node_macros.pt index 0c2151b..2f7af3c 100644 --- a/browser/node_macros.pt +++ b/browser/node_macros.pt @@ -166,12 +166,47 @@ Resource Title + tal:content="related/title">Concept Title
+ +
+ Listing +
+
+
+

Children

+ +
+
+

Resources

+ +
+
+
+ +
-
+ +

Title