improve representation of individual link objects
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3771 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
269df6b860
commit
31179360ce
3 changed files with 70 additions and 30 deletions
|
@ -57,63 +57,78 @@ actions.register('editPortalLink', 'portlet', DialogAction,
|
||||||
dialogName='editPortalLink',
|
dialogName='editPortalLink',
|
||||||
)
|
)
|
||||||
|
|
||||||
class PortalPage(ConceptView):
|
|
||||||
""" A query view linking to pages on other loops sites.
|
class Base(ConceptView):
|
||||||
"""
|
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def site_macros(self):
|
def site_macros(self):
|
||||||
return site_macros.macros
|
return site_macros.macros
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def root(self):
|
||||||
|
return getRoot(self.context)
|
||||||
|
|
||||||
|
|
||||||
|
class PortalPage(Base):
|
||||||
|
""" A query view linking to pages on other loops sites.
|
||||||
|
"""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def macro(self):
|
def macro(self):
|
||||||
return self.site_macros['portal_page']
|
return self.site_macros['portal_page']
|
||||||
|
|
||||||
@Lazy
|
|
||||||
def root(self):
|
|
||||||
return getRoot(self.context)
|
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def portalLinks(self):
|
def portalLinks(self):
|
||||||
result = []
|
result = []
|
||||||
for c in self.context.getChildren():
|
for c in self.context.getChildren():
|
||||||
link = adapted(c)
|
info = PortalLink(c, self.request).targetInfo
|
||||||
if ILink.providedBy(link):
|
if info is not None:
|
||||||
site = traverse(self.root, link.site)
|
result.append(info)
|
||||||
path = link.path or 'home'
|
|
||||||
target = traverse(site, 'views/' + path)
|
|
||||||
if canAccess(target, 'title'):
|
|
||||||
siteInfo = SiteDetails(target, self.request)
|
|
||||||
siteInfo.title = link.title
|
|
||||||
if link.description:
|
|
||||||
siteInfo.description = link.description
|
|
||||||
if link.url:
|
|
||||||
siteInfo.url = link.url
|
|
||||||
result.append(siteInfo)
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
class SiteDetails(BaseView):
|
class LinkInfo(Base):
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
# old loops_sites.html view
|
class PortalLink(Base):
|
||||||
|
|
||||||
class SitesListing(ConceptView):
|
@property
|
||||||
|
def macro(self):
|
||||||
|
return self.site_macros['portal_link']
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def site_macros(self):
|
def targetInfo(self):
|
||||||
return site_macros.macros
|
link = self.adapted
|
||||||
|
if not ILink.providedBy(link):
|
||||||
|
return None
|
||||||
|
site = traverse(self.root, link.site, None)
|
||||||
|
if site is None:
|
||||||
|
return None
|
||||||
|
path = link.path or 'home'
|
||||||
|
target = traverse(site, 'views/' + path, None)
|
||||||
|
if target is None:
|
||||||
|
return None
|
||||||
|
if not canAccess(target, 'title'):
|
||||||
|
return None
|
||||||
|
info = LinkInfo(target, self.request)
|
||||||
|
info.title = link.title
|
||||||
|
if link.description:
|
||||||
|
info.description = link.description
|
||||||
|
if link.url:
|
||||||
|
info.url = link.url
|
||||||
|
return info
|
||||||
|
|
||||||
|
|
||||||
|
# old loops_sites.html view
|
||||||
|
|
||||||
|
class SitesListing(Base):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def macro(self):
|
def macro(self):
|
||||||
return self.site_macros['sites_listing']
|
return self.site_macros['sites_listing']
|
||||||
|
|
||||||
@Lazy
|
|
||||||
def root(self):
|
|
||||||
return getRoot(self.context)
|
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def sites(self):
|
def sites(self):
|
||||||
result = []
|
result = []
|
||||||
|
@ -121,6 +136,6 @@ class SitesListing(ConceptView):
|
||||||
for p in paths:
|
for p in paths:
|
||||||
s = traverse(self.root, p)
|
s = traverse(self.root, p)
|
||||||
if canAccess(s, 'title'):
|
if canAccess(s, 'title'):
|
||||||
result.append(SiteDetails(s, self.request))
|
result.append(LinkInfo(s, self.request))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,14 @@
|
||||||
factory="loops.system.site.browser.PortalPage"
|
factory="loops.system.site.browser.PortalPage"
|
||||||
permission="zope.View" />
|
permission="zope.View" />
|
||||||
|
|
||||||
|
<zope:adapter
|
||||||
|
name="portal_link.html"
|
||||||
|
for="loops.interfaces.IConcept
|
||||||
|
zope.publisher.interfaces.browser.IBrowserRequest"
|
||||||
|
provides="zope.interface.Interface"
|
||||||
|
factory="loops.system.site.browser.PortalLink"
|
||||||
|
permission="zope.View" />
|
||||||
|
|
||||||
<zope:adapter
|
<zope:adapter
|
||||||
name="loops_sites.html"
|
name="loops_sites.html"
|
||||||
for="loops.interfaces.IConcept
|
for="loops.interfaces.IConcept
|
||||||
|
|
|
@ -19,6 +19,23 @@
|
||||||
</metal:work>
|
</metal:work>
|
||||||
|
|
||||||
|
|
||||||
|
<metal:work define-macro="portal_link"
|
||||||
|
tal:define="info nocall:item/targetInfo">
|
||||||
|
<metal:title use-macro="view/concept_macros/concepttitle" />
|
||||||
|
<metal:block use-macro="view/concept_macros/conceptfields" />
|
||||||
|
<tal:target condition="nocall:info">
|
||||||
|
<h3 i18n:translate="">Link Target</h3>
|
||||||
|
<div>
|
||||||
|
<a tal:attributes="href info/url"
|
||||||
|
tal:content="info/title" /></div>
|
||||||
|
<div tal:condition="info/description"
|
||||||
|
tal:content="structure info/renderedDescription" />
|
||||||
|
</tal:target>
|
||||||
|
</metal:work>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- obsolete, replaced by portal_page -->
|
||||||
|
|
||||||
<metal:work define-macro="sites_listing">
|
<metal:work define-macro="sites_listing">
|
||||||
<h2 i18n:translate="">loops Sites</h2>
|
<h2 i18n:translate="">loops Sites</h2>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
Loading…
Add table
Reference in a new issue