glossary grouped by first letter
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2254 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
85fe131a14
commit
2c78b3d76a
3 changed files with 51 additions and 6 deletions
|
@ -22,6 +22,7 @@ Definition of the concept view classes.
|
||||||
$Id$
|
$Id$
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from itertools import groupby
|
||||||
from zope import interface, component, schema
|
from zope import interface, component, schema
|
||||||
from zope.app import zapi
|
from zope.app import zapi
|
||||||
from zope.app.catalog.interfaces import ICatalog
|
from zope.app.catalog.interfaces import ICatalog
|
||||||
|
@ -139,16 +140,17 @@ class ConceptView(BaseView):
|
||||||
widget.setRenderedValue(value)
|
widget.setRenderedValue(value)
|
||||||
yield dict(title=f.title, value=value, id=n, widget=widget)
|
yield dict(title=f.title, value=value, id=n, widget=widget)
|
||||||
|
|
||||||
def children(self):
|
def children(self, topLevelOnly=True, sort=True):
|
||||||
cm = self.loopsRoot.getConceptManager()
|
cm = self.loopsRoot.getConceptManager()
|
||||||
hasType = cm.getTypePredicate()
|
hasType = cm.getTypePredicate()
|
||||||
standard = cm.getDefaultPredicate()
|
standard = cm.getDefaultPredicate()
|
||||||
#rels = self.context.getChildRelations()
|
#rels = self.context.getChildRelations()
|
||||||
rels = (ConceptRelationView(r, self.request, contextIsSecond=True)
|
rels = (ConceptRelationView(r, self.request, contextIsSecond=True)
|
||||||
for r in self.context.getChildRelations(sort=None))
|
for r in self.context.getChildRelations(sort=None))
|
||||||
rels = sorted(rels, key=lambda r: (r.order, r.title.lower()))
|
if sort:
|
||||||
|
rels = sorted(rels, key=lambda r: (r.order, r.title.lower()))
|
||||||
for r in rels:
|
for r in rels:
|
||||||
if r.predicate == hasType:
|
if topLevelOnly and r.predicate == hasType:
|
||||||
# only show top-level entries for type instances:
|
# only show top-level entries for type instances:
|
||||||
skip = False
|
skip = False
|
||||||
for parent in r.context.getParents((standard,)):
|
for parent in r.context.getParents((standard,)):
|
||||||
|
@ -157,7 +159,17 @@ class ConceptView(BaseView):
|
||||||
break
|
break
|
||||||
if skip: continue
|
if skip: continue
|
||||||
yield r
|
yield r
|
||||||
#yield ConceptRelationView(r, self.request, contextIsSecond=True)
|
|
||||||
|
def childrenAlphaGroups(self):
|
||||||
|
letters = []
|
||||||
|
relations = {}
|
||||||
|
rels = self.children(topLevelOnly=False, sort=False)
|
||||||
|
rels = sorted(rels, key=lambda r: r.title.lower())
|
||||||
|
for letter, group in groupby(rels, lambda r: r.title.lower()[0]):
|
||||||
|
letter = letter.upper()
|
||||||
|
letters.append(letter)
|
||||||
|
relations[letter] = list(group)
|
||||||
|
return dict(letters=letters, relations=relations)
|
||||||
|
|
||||||
def parents(self):
|
def parents(self):
|
||||||
rels = sorted(self.context.getParentRelations(),
|
rels = sorted(self.context.getParentRelations(),
|
||||||
|
|
|
@ -112,6 +112,22 @@ img.notselected {
|
||||||
border: 2px solid #eff8ff;
|
border: 2px solid #eff8ff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.navlink {
|
||||||
|
font-size: 130%;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navlink a {
|
||||||
|
font-weight: bold;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitle {
|
||||||
|
font-size: 140%;
|
||||||
|
font-weight: bold;
|
||||||
|
margin: 1em 0 0.5em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* search stuff */
|
/* search stuff */
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,32 @@
|
||||||
<!-- ZPT macros for loops.knowledge.glossary views -->
|
<!-- ZPT macros for loops.knowledge.glossary views -->
|
||||||
|
|
||||||
<metal:block define-macro="glossary">
|
<metal:block define-macro="glossary"
|
||||||
|
tal:define="data item/childrenAlphaGroups">
|
||||||
<metal:title use-macro="item/conceptMacros/concepttitle" />
|
<metal:title use-macro="item/conceptMacros/concepttitle" />
|
||||||
|
<div><a name="top"> </a></div>
|
||||||
|
<div>
|
||||||
|
<span tal:repeat="letter python: [chr(c) for c in range(ord('A'), ord('Z')+1)]"
|
||||||
|
class="navlink">
|
||||||
|
<a href="#"
|
||||||
|
tal:omit-tag="python: letter not in data['letters']"
|
||||||
|
tal:attributes="href string:#$letter"
|
||||||
|
tal:content="letter">A</a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div> </div>
|
<div> </div>
|
||||||
<div tal:repeat="related item/children">
|
<div tal:repeat="letter data/letters">
|
||||||
|
<div class="subtitle"><a name="A" href="#top"
|
||||||
|
tal:attributes="name letter"
|
||||||
|
tal:content="letter">A</a>
|
||||||
|
</div>
|
||||||
|
<div tal:repeat="related data/relations/?letter|python:[]">
|
||||||
<a href="#"
|
<a href="#"
|
||||||
tal:content="related/title"
|
tal:content="related/title"
|
||||||
tal:attributes="href python: view.getUrlForTarget(related);
|
tal:attributes="href python: view.getUrlForTarget(related);
|
||||||
title related/description">
|
title related/description">
|
||||||
Topic
|
Topic
|
||||||
</a>
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</metal:block>
|
</metal:block>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue