provide view for book section that shows all contained resources
This commit is contained in:
parent
49d2401bb4
commit
99ade04957
5 changed files with 54 additions and 17 deletions
|
@ -27,10 +27,19 @@
|
||||||
<tal:actions condition="view/showObjectActions">
|
<tal:actions condition="view/showObjectActions">
|
||||||
<div metal:use-macro="views/node_macros/object_actions" />
|
<div metal:use-macro="views/node_macros/object_actions" />
|
||||||
</tal: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"
|
<a tal:omit-tag="python: level > 1"
|
||||||
tal:attributes="href request/URL"
|
tal:attributes="href request/URL"
|
||||||
tal:content="item/title">Title</a>
|
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>
|
</h1>
|
||||||
</metal:title>
|
</metal:title>
|
||||||
<p tal:define="description description|item/renderedDescription"
|
<p tal:define="description description|item/renderedDescription"
|
||||||
|
|
|
@ -227,6 +227,15 @@ class ResourceView(BaseView):
|
||||||
response.setHeader('Last-Modified', modified.strftime(format))
|
response.setHeader('Last-Modified', modified.strftime(format))
|
||||||
return data
|
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):
|
def renderText(self, text, contentType):
|
||||||
if contentType == 'text/restructured' and wikiLinksActive(self.loopsRoot):
|
if contentType == 'text/restructured' and wikiLinksActive(self.loopsRoot):
|
||||||
# TODO: make this more flexible/configurable
|
# TODO: make this more flexible/configurable
|
||||||
|
@ -400,15 +409,6 @@ class DocumentView(ResourceView):
|
||||||
@Lazy
|
@Lazy
|
||||||
def view(self): return self
|
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
|
@Lazy
|
||||||
def inlineEditable(self):
|
def inlineEditable(self):
|
||||||
return (self.inlineEditingActive
|
return (self.inlineEditingActive
|
||||||
|
|
|
@ -24,6 +24,7 @@ from cgi import parse_qs
|
||||||
from zope import interface, component
|
from zope import interface, component
|
||||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
|
from zope.traversing.api import getName
|
||||||
|
|
||||||
from cybertools.typology.interfaces import IType
|
from cybertools.typology.interfaces import IType
|
||||||
from loops.browser.lobo import standard
|
from loops.browser.lobo import standard
|
||||||
|
@ -52,8 +53,24 @@ class Base(object):
|
||||||
|
|
||||||
class SectionView(Base, ConceptView):
|
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):
|
class PageLayout(Base, standard.Layout):
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@ type(u'documenttype', u'Dokumentenart', options=u'qualifier:assign',
|
||||||
# book types
|
# book types
|
||||||
type(u'book', u'Buch', viewName=u'', typeInterface=u'',
|
type(u'book', u'Buch', viewName=u'', typeInterface=u'',
|
||||||
options=u'action.portlet:create_subtype,edit_concept')
|
options=u'action.portlet:create_subtype,edit_concept')
|
||||||
type(u'page', u'Seite', viewName=u'page_layout',
|
#type(u'page', u'Seite', viewName=u'page_layout',
|
||||||
typeInterface=u'loops.compound.book.interfaces.IPage',
|
# typeInterface=u'loops.compound.book.interfaces.IPage',
|
||||||
options=u'action.portlet:edit_concept')
|
# options=u'action.portlet:edit_concept')
|
||||||
type(u'section', u'Kapitel', viewName=u'section_view', typeInterface=u'',
|
type(u'section', u'Kapitel', viewName=u'section_view', typeInterface=u'',
|
||||||
options=u'action.portlet:create_subtype,edit_concept')
|
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
|
# document types
|
||||||
concept(u'keyquestions', u'Leitfragen', u'documenttype')
|
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'quote', u'Zitat', u'documenttype')
|
||||||
concept(u'story', u'Geschichte', u'documenttype')
|
concept(u'story', u'Geschichte', u'documenttype')
|
||||||
concept(u'usecase', u'Fallbeispiel', u'documenttype')
|
concept(u'usecase', u'Fallbeispiel', u'documenttype')
|
||||||
|
@ -28,4 +28,4 @@ concept(u'usecase', u'Fallbeispiel', u'documenttype')
|
||||||
# book structure
|
# book structure
|
||||||
child(u'book', u'section', u'issubtype', usePredicate=u'ispartof')
|
child(u'book', u'section', u'issubtype', usePredicate=u'ispartof')
|
||||||
child(u'section', 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')
|
||||||
|
|
|
@ -1,13 +1,24 @@
|
||||||
<html i18n:domain="loops">
|
<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">
|
<metal:part define-macro="headline">
|
||||||
<div tal:define="cell part/getView">
|
<div tal:define="cell part/getView">
|
||||||
<metal:headline use-macro="item/macros/headline" />
|
<metal:headline use-macro="item/macros/headline" />
|
||||||
</div>
|
</div>
|
||||||
</metal:part>
|
</metal:part>
|
||||||
|
|
||||||
|
|
||||||
<metal:part define-macro="text">
|
<metal:part define-macro="text">
|
||||||
<tal:cell repeat="cell part/getResources">
|
<tal:cell repeat="cell part/getResources">
|
||||||
<div tal:attributes="class cell/cssClass">
|
<div tal:attributes="class cell/cssClass">
|
||||||
|
|
Loading…
Add table
Reference in a new issue