provide view for book section that shows all contained resources

This commit is contained in:
Helmut Merz 2012-06-22 14:15:33 +02:00
parent 49d2401bb4
commit 99ade04957
5 changed files with 54 additions and 17 deletions

View file

@ -27,10 +27,19 @@
<tal:actions condition="view/showObjectActions">
<div metal:use-macro="views/node_macros/object_actions" />
</tal:actions>
<h1 tal:attributes="ondblclick item/openEditWindow">
<h1 tal:define="tabview item/tabview|nothing"
tal:attributes="ondblclick item/openEditWindow">
<a tal:omit-tag="python: level > 1"
tal:attributes="href request/URL"
tal:content="item/title">Title</a>
<a title="Show tabular view"
i18n:attributes="title"
tal:condition="tabview"
tal:attributes="href
string:${item/targetUrl}?loops.viewName=$tabview">
<img tal:attributes="src
string:$resourceBase/cybertools.icons/table.png" />
</a>
</h1>
</metal:title>
<p tal:define="description description|item/renderedDescription"

View file

@ -227,6 +227,15 @@ class ResourceView(BaseView):
response.setHeader('Last-Modified', modified.strftime(format))
return data
def render(self):
""" Return the rendered content (data) of the context object.
"""
self.recordAccess('render', target=self.uniqueId)
ctx = adapted(self.context)
text = ctx.data
contentType = ctx.contentType
return self.renderText(ctx.data, ctx.contentType)
def renderText(self, text, contentType):
if contentType == 'text/restructured' and wikiLinksActive(self.loopsRoot):
# TODO: make this more flexible/configurable
@ -400,15 +409,6 @@ class DocumentView(ResourceView):
@Lazy
def view(self): return self
def render(self):
""" Return the rendered content (data) of the context object.
"""
self.recordAccess('render', target=self.uniqueId)
ctx = adapted(self.context)
text = ctx.data
contentType = ctx.contentType
return self.renderText(ctx.data, ctx.contentType)
@Lazy
def inlineEditable(self):
return (self.inlineEditingActive

View file

@ -24,6 +24,7 @@ from cgi import parse_qs
from zope import interface, component
from zope.app.pagetemplate import ViewPageTemplateFile
from zope.cachedescriptors.property import Lazy
from zope.traversing.api import getName
from cybertools.typology.interfaces import IType
from loops.browser.lobo import standard
@ -52,8 +53,24 @@ class Base(object):
class SectionView(Base, ConceptView):
pass
@Lazy
def macro(self):
return book_template.macros['section']
@Lazy
def tabview(self):
if self.editable:
return 'index.html'
def getCssClassForResource(self, r):
documentType = self.conceptManager['documenttype']
for c in r.context.getConcepts([self.defaultPredicate]):
if c.conceptType == documentType:
return getName(c)
return 'textelement'
# layout parts - probably obsolete:
class PageLayout(Base, standard.Layout):

View file

@ -4,9 +4,9 @@ type(u'documenttype', u'Dokumentenart', options=u'qualifier:assign',
# book types
type(u'book', u'Buch', viewName=u'', typeInterface=u'',
options=u'action.portlet:create_subtype,edit_concept')
type(u'page', u'Seite', viewName=u'page_layout',
typeInterface=u'loops.compound.book.interfaces.IPage',
options=u'action.portlet:edit_concept')
#type(u'page', u'Seite', viewName=u'page_layout',
# typeInterface=u'loops.compound.book.interfaces.IPage',
# options=u'action.portlet:edit_concept')
type(u'section', u'Kapitel', viewName=u'section_view', typeInterface=u'',
options=u'action.portlet:create_subtype,edit_concept')
@ -20,7 +20,7 @@ concept(u'issubtype', u'is Subtype', u'predicate', options=u'hide_children',
# document types
concept(u'keyquestions', u'Leitfragen', u'documenttype')
concept(u'maintext', u'Haupttext', u'documenttype')
concept(u'textelement', u'Textabschnitt', u'documenttype')
concept(u'quote', u'Zitat', u'documenttype')
concept(u'story', u'Geschichte', u'documenttype')
concept(u'usecase', u'Fallbeispiel', u'documenttype')
@ -28,4 +28,4 @@ concept(u'usecase', u'Fallbeispiel', u'documenttype')
# book structure
child(u'book', u'section', u'issubtype', usePredicate=u'ispartof')
child(u'section', u'section', u'issubtype', usePredicate=u'ispartof')
child(u'section', u'page', u'issubtype', usePredicate=u'ispartof')
#child(u'section', u'page', u'issubtype', usePredicate=u'ispartof')

View file

@ -1,13 +1,24 @@
<html i18n:domain="loops">
<metal:section define-macro="section">
<metal:info use-macro="view/concept_macros/concepttitle" />
<div tal:repeat="related item/resources">
<div tal:attributes="class python:
item.getCssClassForResource(related)"
tal:content="structure related/render" />
</div>
</metal:section>
<!-- layout part macros - obsolete? -->
<metal:part define-macro="headline">
<div tal:define="cell part/getView">
<metal:headline use-macro="item/macros/headline" />
</div>
</metal:part>
<metal:part define-macro="text">
<tal:cell repeat="cell part/getResources">
<div tal:attributes="class cell/cssClass">