diff --git a/browser/resource.py b/browser/resource.py
index 015c57b..8ec1e95 100644
--- a/browser/resource.py
+++ b/browser/resource.py
@@ -40,6 +40,7 @@ from zope.traversing.browser import absoluteURL
from cybertools.browser.action import actions
from cybertools.meta.interfaces import IOptions
from cybertools.typology.interfaces import IType
+from cybertools.util.html import extractFirstPart
from cybertools.xedit.browser import ExternalEditorView, fromUnicode
from loops.browser.action import DialogAction, TargetAction
from loops.browser.common import EditForm, BaseView
@@ -252,6 +253,12 @@ class ResourceView(BaseView):
#return util.toUnicode(wp.render(self.request))
return super(ResourceView, self).renderText(text, contentType)
+ def renderShortText(self):
+ return self.renderDescription() or self.createShortText(self.render())
+
+ def createShortText(self, text=None):
+ return extractFirstPart(text or self.render())
+
def download(self):
""" Force download, e.g. of a PDF file """
return self.show(True)
diff --git a/compound/README.txt b/compound/README.txt
index 976111f..2f1d441 100644
--- a/compound/README.txt
+++ b/compound/README.txt
@@ -355,7 +355,7 @@ Books, Sections, and Pages
>>> importPath = os.path.join(os.path.dirname(__file__), 'book')
>>> importData(loopsRoot, importPath, 'loops_book_de.dmp')
- >>> from loops.compound.book.browser import PageLayout
+ >>> from loops.compound.book.browser import BookView, SectionView, TopicView
Fin de partie
diff --git a/compound/book/base.py b/compound/book/base.py
deleted file mode 100644
index 80579fe..0000000
--- a/compound/book/base.py
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# Copyright (c) 2012 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
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-"""
-Implementation of book and book components
-"""
-
-from zope.cachedescriptors.property import Lazy
-from zope.interface import implements
-from zope.traversing.api import getName
-
-from loops.compound.base import Compound
-from loops.compound.book.interfaces import IPage
-from loops.type import TypeInterfaceSourceList
-
-
-TypeInterfaceSourceList.typeInterfaces += (IPage,)
-
-
-class Page(Compound):
-
- implements(IPage)
-
- compoundPredicateNames = ['ispartof', 'standard']
-
- @Lazy
- def documentType(self):
- return self.context.getConceptManager()['documenttype']
-
- def getParts(self):
- result = {}
- for r in super(Page, self).getParts():
- for parent in r.getParents():
- if parent.conceptType == self.documentType:
- item = result.setdefault(getName(parent), [])
- item.append(r)
- return result
diff --git a/compound/book/browser.py b/compound/book/browser.py
index d71a89a..98009c7 100644
--- a/compound/book/browser.py
+++ b/compound/book/browser.py
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2012 Helmut Merz helmutm@cy55.de
+# Copyright (c) 2013 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
@@ -45,10 +45,22 @@ class Base(object):
def book_macros(self):
return book_template.macros
+ @Lazy
+ def documentTypeType(self):
+ return self.conceptManager['documenttype']
+
+ @Lazy
+ def sectionType(self):
+ return self.conceptManager['section']
+
@Lazy
def isPartOfPredicate(self):
return self.conceptManager['ispartof']
+ @Lazy
+ def showNavigation(self):
+ return self.typeOptions.show_navigation
+
@Lazy
def breadcrumbsParent(self):
for p in self.context.getParents([self.isPartOfPredicate]):
@@ -82,34 +94,8 @@ class Base(object):
if self.editable:
return 'index.html'
-
-class BookOverview(Base, ConceptView):
-
- @Lazy
- def macro(self):
- return book_template.macros['book']
-
-
-class SectionView(Base, ConceptView):
-
- @Lazy
- def macro(self):
- return book_template.macros['section']
-
- @Lazy
- def documentTypeType(self):
- return self.conceptManager['documenttype']
-
- @Lazy
- def showNavigation(self):
- return self.typeOptions.show_navigation
-
- @Lazy
- def sectionType(self):
- return self.conceptManager['section']
-
def getResources(self):
- relViews = super(SectionView, self).getResources()
+ relViews = super(Base, self).getResources()
return relViews
@Lazy
@@ -144,64 +130,23 @@ class SectionView(Base, ConceptView):
yield c
-# layout parts - probably obsolete:
+class BookView(Base, ConceptView):
-class PageLayout(Base, standard.Layout):
-
- def getParts(self):
- parts = ['headline', 'keyquestions', 'quote', 'maintext',
- 'story', 'tip', 'usecase']
- return self.getPartViews(parts)
+ @Lazy
+ def macro(self):
+ return book_template.macros['book']
-class PagePart(object):
+class SectionView(Base, ConceptView):
- template = book_template
- templateName = 'compound.book'
- macroName = 'text'
- partName = None # define in subclass
- gridPattern = ['span-4']
-
- def getResources(self):
- result = []
- res = self.adapted.getParts().get(self.partName) or []
- for idx, r in enumerate(res):
- result.append(standard.ResourceView(
- r, self.request, parent=self, idx=idx))
- return result
+ @Lazy
+ def macro(self):
+ return book_template.macros['section']
-class Headline(PagePart, standard.Header2):
+class TopicView(Base, ConceptView):
- macroName = 'headline'
+ @Lazy
+ def macro(self):
+ return book_template.macros['topic']
-
-class MainText(PagePart, standard.BasePart):
-
- partName = 'maintext'
-
-
-class KeyQuestions(PagePart, standard.BasePart):
-
- partName = 'keyquestions'
-
-
-class Story(PagePart, standard.BasePart):
-
- partName = 'story'
-
-
-class Tip(PagePart, standard.BasePart):
-
- partName = 'tip'
-
-
-class UseCase(PagePart, standard.BasePart):
-
- partName = 'usecase'
-
-
-class Quote(PagePart, standard.BasePart):
-
- partName = 'quote'
- gridPattern = ['span-2 last']
diff --git a/compound/book/configure.zcml b/compound/book/configure.zcml
index 4ff408f..09a374a 100644
--- a/compound/book/configure.zcml
+++ b/compound/book/configure.zcml
@@ -3,18 +3,6 @@
xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="loops">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/compound/book/interfaces.py b/compound/book/interfaces.py
deleted file mode 100644
index 3dd1e43..0000000
--- a/compound/book/interfaces.py
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright (c) 2012 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
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-"""
-Books, sections, pages...
-"""
-
-from zope.interface import Interface, Attribute
-from zope import interface, component, schema
-
-from loops.compound.interfaces import ICompound
-from loops.util import _
-
-
-class IPage(ICompound):
-
- pass
diff --git a/compound/book/loops_book_de.dmp b/compound/book/loops_book_de.dmp
index 5185bb2..a7d846f 100644
--- a/compound/book/loops_book_de.dmp
+++ b/compound/book/loops_book_de.dmp
@@ -4,11 +4,11 @@ type(u'documenttype', u'Dokumentenart', options=u'qualifier:assign',
# book types
type(u'book', u'Buch', viewName=u'book_overview', 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'section', u'Kapitel', viewName=u'section_view', typeInterface=u'',
options=u'action.portlet:create_subtype,edit_concept')
+#type(u'topic', u'Thema', viewName=u'book_topic_view',
+# typeInterface=u'loops.knowledge.interfaces.ITopic',
+# options=u'action.portlet:create_topic,edit_topic')
concept(u'system', u'System', u'domain')
@@ -30,4 +30,3 @@ 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')
diff --git a/compound/book/view_macros.pt b/compound/book/view_macros.pt
index 576c224..298f67d 100644
--- a/compound/book/view_macros.pt
+++ b/compound/book/view_macros.pt
@@ -2,7 +2,9 @@
-
+
@@ -37,71 +39,81 @@
-
-
-
-
-
- ![]()
-
- ![]()
+
+
+
-
-
-
- ![]()
+
+
+
+
+
+ ![]()
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+ Children
+
+ Text Elements
+