Glossary and glossary item views
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2183 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
9ad4c68809
commit
4b239e150a
3 changed files with 66 additions and 29 deletions
|
@ -1,5 +1,23 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2007 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
|
||||||
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Demonstration view.
|
View classes for glossary and glossary items.
|
||||||
|
|
||||||
$Id$
|
$Id$
|
||||||
"""
|
"""
|
||||||
|
@ -8,30 +26,24 @@ $Id$
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||||
|
|
||||||
from loops.browser import common
|
from loops.browser.concept import ConceptView
|
||||||
from loops.browser.concept import ConceptRelationView
|
|
||||||
from loops.common import adapted
|
from loops.common import adapted
|
||||||
from loops import util
|
from loops import util
|
||||||
|
|
||||||
|
|
||||||
template = ViewPageTemplateFile('view_macros.pt')
|
template = ViewPageTemplateFile('view_macros.pt')
|
||||||
conceptMacrosTemplate = common.conceptMacrosTemplate
|
|
||||||
|
|
||||||
|
|
||||||
class GlossaryItemView(common.BaseView):
|
class GlossaryView(ConceptView):
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def macro(self):
|
||||||
|
return template.macros['glossary']
|
||||||
|
|
||||||
|
|
||||||
|
class GlossaryItemView(ConceptView):
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def macro(self):
|
def macro(self):
|
||||||
return template.macros['glossaryitem']
|
return template.macros['glossaryitem']
|
||||||
|
|
||||||
@Lazy
|
|
||||||
def conceptMacros(self):
|
|
||||||
return conceptMacrosTemplate.macros
|
|
||||||
|
|
||||||
@Lazy
|
|
||||||
def children(self):
|
|
||||||
rels = sorted(self.context.getChildRelations(),
|
|
||||||
key=(lambda x: x.second.title.lower()))
|
|
||||||
for r in rels:
|
|
||||||
yield ConceptRelationView(r, self.request, contextIsSecond=True)
|
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,22 @@
|
||||||
i18n_domain="zope"
|
i18n_domain="zope"
|
||||||
>
|
>
|
||||||
|
|
||||||
<page for="*"
|
<zope:adapter
|
||||||
name="glossaryitem.html"
|
name="glossary.html"
|
||||||
class=".browser.GlossaryItemView"
|
for="loops.interfaces.IConcept
|
||||||
permission="zope.View" />
|
zope.publisher.interfaces.browser.IBrowserRequest"
|
||||||
|
provides="zope.interface.Interface"
|
||||||
|
factory="loops.knowledge.glossary.browser.GlossaryView"
|
||||||
|
permission="zope.View"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<zope:adapter
|
||||||
|
name="glossaryitem.html"
|
||||||
|
for="loops.interfaces.IConcept
|
||||||
|
zope.publisher.interfaces.browser.IBrowserRequest"
|
||||||
|
provides="zope.interface.Interface"
|
||||||
|
factory="loops.knowledge.glossary.browser.GlossaryItemView"
|
||||||
|
permission="zope.View"
|
||||||
|
/>
|
||||||
|
|
||||||
</configure>
|
</configure>
|
||||||
|
|
|
@ -1,17 +1,29 @@
|
||||||
<!-- ZPT macros for demo view -->
|
<!-- ZPT macros for loops.knowledge.glossary views -->
|
||||||
|
|
||||||
<metal:block define-macro="glossaryitem">
|
|
||||||
|
|
||||||
|
<metal:block define-macro="glossary">
|
||||||
<metal:title use-macro="item/conceptMacros/concepttitle" />
|
<metal:title use-macro="item/conceptMacros/concepttitle" />
|
||||||
|
<div> </div>
|
||||||
<div>siehe:
|
<div tal:repeat="related item/children">
|
||||||
<span tal:repeat="related item/children">
|
|
||||||
<a href="#"
|
<a href="#"
|
||||||
tal:content="related/title"
|
tal:content="related/title"
|
||||||
tal:attributes="href string:${view/url}/.target${related/uniqueId}">
|
tal:attributes="href python: view.getUrlForTarget(related)">
|
||||||
|
Topic
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</metal:block>
|
||||||
|
|
||||||
|
|
||||||
|
<metal:block define-macro="glossaryitem">
|
||||||
|
<metal:title use-macro="item/conceptMacros/concepttitle" />
|
||||||
|
<p>
|
||||||
|
<span tal:repeat="related item/children">
|
||||||
|
<tal:start condition="repeat/related/start">
|
||||||
|
<span i18n:translate="">siehe</span>:</tal:start>
|
||||||
|
<a href="#"
|
||||||
|
tal:content="related/title"
|
||||||
|
tal:attributes="href python: view.getUrlForTarget(related)">
|
||||||
Topic
|
Topic
|
||||||
</a><tal:comma condition="not:repeat/related/end">,</tal:comma>
|
</a><tal:comma condition="not:repeat/related/end">,</tal:comma>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</p>
|
||||||
|
|
||||||
</metal:block>
|
</metal:block>
|
||||||
|
|
Loading…
Add table
Reference in a new issue