work in progress: more lobo layout views
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3989 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
		
							parent
							
								
									e20e35c4fd
								
							
						
					
					
						commit
						751bc4a7d3
					
				
					 5 changed files with 106 additions and 20 deletions
				
			
		
							
								
								
									
										33
									
								
								browser/lobo/README.txt
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								browser/lobo/README.txt
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,33 @@ | |||
| =============================================================== | ||||
| loops - Linked Objects for Organization and Processing Services | ||||
| =============================================================== | ||||
| 
 | ||||
|   ($Id$) | ||||
| 
 | ||||
| Let's do some basic set up | ||||
| 
 | ||||
|   >>> from zope.app.testing.setup import placefulSetUp, placefulTearDown | ||||
|   >>> site = placefulSetUp(True) | ||||
| 
 | ||||
|   >>> from zope import component, interface | ||||
| 
 | ||||
| and setup a simple loops site with a concept manager and some concepts | ||||
| (with all the type machinery, what in real life is done via standard | ||||
| ZCML setup): | ||||
| 
 | ||||
|   >>> from loops.tests.setup import TestSite | ||||
|   >>> t = TestSite(site) | ||||
|   >>> concepts, resources, views = t.setup() | ||||
| 
 | ||||
| 
 | ||||
| Using the Lobo Blueprint-based Layout Views | ||||
| =========================================== | ||||
| 
 | ||||
|   >>> from loops.browser.lobo.standard import Grid3, Single1 | ||||
| 
 | ||||
| 
 | ||||
| Fin de partie | ||||
| ============= | ||||
| 
 | ||||
|   >>> placefulTearDown() | ||||
| 
 | ||||
|  | @ -8,11 +8,19 @@ | |||
|   <!-- Views for the Lobo skin / grid-based layout --> | ||||
| 
 | ||||
|   <zope:adapter | ||||
|         name="lobo.page.3columns-basic" | ||||
|         name="page.grid.3" | ||||
|         for="loops.interfaces.IConcept | ||||
|              zope.publisher.interfaces.browser.IBrowserRequest" | ||||
|              loops.browser.skin.Lobo" | ||||
|         provides="zope.interface.Interface" | ||||
|         factory="loops.browser.lobo.standard.Basic3Columns" | ||||
|         factory="loops.browser.lobo.standard.Grid3" | ||||
|         permission="zope.View" /> | ||||
| 
 | ||||
|   <zope:adapter | ||||
|         name="page.single.1" | ||||
|         for="loops.interfaces.IConcept | ||||
|              loops.browser.skin.Lobo" | ||||
|         provides="zope.interface.Interface" | ||||
|         factory="loops.browser.lobo.standard.Single1" | ||||
|         permission="zope.View" /> | ||||
| 
 | ||||
| </configure> | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| <html i18n:domain="loops"> | ||||
| 
 | ||||
| 
 | ||||
| <metal:block define-macro="basic-image"> | ||||
| <metal:block define-macro="basic"> | ||||
| 
 | ||||
|   <h1 tal:attributes="ondblclick item/openEditWindow" | ||||
|       tal:content="item/title" /> | ||||
|  |  | |||
|  | @ -34,33 +34,56 @@ from loops.common import adapted | |||
| standard_template = ViewPageTemplateFile('standard.pt') | ||||
| 
 | ||||
| 
 | ||||
| class Basic3Columns(ConceptView): | ||||
| class Base(ConceptView): | ||||
| 
 | ||||
|     template = standard_template | ||||
|     templateName = 'lobo.standard' | ||||
|     macroName = 'basic' | ||||
|     imageSize = 'small' | ||||
|     height = 260 | ||||
|     gridPattern = ['span-2', 'span-2', 'span-2 last'] | ||||
| 
 | ||||
|     @Lazy | ||||
|     def standard_macros(self): | ||||
|         return self.controller.getTemplateMacros('lobo.standard', standard_template) | ||||
|     def macros(self): | ||||
|         return self.controller.getTemplateMacros(self.templateName, self.template) | ||||
| 
 | ||||
|     @property | ||||
|     def macro(self): | ||||
|         return self.standard_macros['basic-image'] | ||||
|         return self.macros[self.macroName] | ||||
| 
 | ||||
|     def content(self): | ||||
|         result = [] | ||||
|         for idx, c in enumerate(self.context.getChildren([self.defaultPredicate])): | ||||
|             text = c.title | ||||
|             url = self.nodeView.getUrlForTarget(c) | ||||
|             # TODO: use layout settings of c for display | ||||
|             cssClass = 'span-2' | ||||
|             if idx % 3 == 2: | ||||
|                 cssClass += ' last' | ||||
|             style = 'height: 260px' | ||||
|             result.append(dict(text=text, url=url, cssClass=cssClass, | ||||
|                                style=style, img=self.getImageData(c), | ||||
|                                object=adapted(c))) | ||||
|             result.append(self.setupItem(idx, c)) | ||||
|         return result | ||||
| 
 | ||||
|     def getImageData(self, concept): | ||||
|     def setupItem(self, idx, obj): | ||||
|         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), | ||||
|                     object=adapted(obj)) | ||||
| 
 | ||||
|     def getCssClass(self, idx, obj): | ||||
|         pattern = self.gridPattern | ||||
|         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=small' % self.nodeView.getUrlForTarget(r) | ||||
|                 src = ('%s/mediaasset.html?v=%s' % | ||||
|                             (self.nodeView.getUrlForTarget(r), self.imageSize)) | ||||
|                 return dict(src=src) | ||||
| 
 | ||||
| 
 | ||||
| class Grid3(Base): | ||||
| 
 | ||||
|     pass | ||||
| 
 | ||||
| 
 | ||||
| class Single1(Base): | ||||
| 
 | ||||
|     pass | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										22
									
								
								browser/lobo/tests.py
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										22
									
								
								browser/lobo/tests.py
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,22 @@ | |||
| # $Id$ | ||||
| 
 | ||||
| import unittest, doctest | ||||
| from zope.testing.doctestunit import DocFileSuite | ||||
| from zope.interface.verify import verifyClass | ||||
| 
 | ||||
| class Test(unittest.TestCase): | ||||
|     "Basic tests for the browser.lobo sub-package." | ||||
| 
 | ||||
|     def testSomething(self): | ||||
|         pass | ||||
| 
 | ||||
| 
 | ||||
| def test_suite(): | ||||
|     flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS | ||||
|     return unittest.TestSuite(( | ||||
|                 unittest.makeSuite(Test), | ||||
|                 DocFileSuite('README.txt', optionflags=flags), | ||||
|             )) | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     unittest.main(defaultTest='test_suite') | ||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 helmutm
						helmutm