- portal page with - now fully editable - portal links

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3770 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2010-03-15 15:23:00 +00:00
parent 6436728892
commit 269df6b860
9 changed files with 219 additions and 11 deletions

View file

@ -3,6 +3,12 @@ Change Log
$Id$ $Id$
1.1
---
- portal page with - now fully editable - portal links
- calendar portlet
1.0 1.0
--- ---

View file

@ -277,10 +277,18 @@ class BaseView(GenericView, I18NView):
return self.adapted.description return self.adapted.description
@Lazy @Lazy
def dcTitle(self): def dublincore(self):
zdc = IZopeDublinCore(self.context) zdc = IZopeDublinCore(self.context)
zdc.languageInfo = self.languageInfo zdc.languageInfo = self.languageInfo
return zdc.title or self.title return zdc
@Lazy
def dcTitle(self):
return self.dublincore.title or self.title
@Lazy
def dcDescription(self):
return self.dublincore.description or self.description
@Lazy @Lazy
def headTitle(self): def headTitle(self):

View file

@ -46,6 +46,13 @@ In addition to the application site we need a loops system management site.
[u'jobs'] [u'jobs']
Portal Links
============
>>> from loops.system.site.link import Link
>>> from loops.system.site.browser import PortalPage
Agents and Jobs Agents and Jobs
=============== ===============

View file

@ -1,5 +1,5 @@
# #
# Copyright (c) 2009 Helmut Merz helmutm@cy55.de # Copyright (c) 2010 Helmut Merz helmutm@cy55.de
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -28,8 +28,11 @@ from zope.security import canAccess
from zope.traversing.api import getParent, getRoot, traverse from zope.traversing.api import getParent, getRoot, traverse
from zope.traversing.browser import absoluteURL from zope.traversing.browser import absoluteURL
from loops.browser.common import BaseView from cybertools.browser.action import actions
from loops.browser.action import DialogAction
from loops.browser.common import BaseView, adapted
from loops.browser.concept import ConceptView from loops.browser.concept import ConceptView
from loops.system.site.interfaces import ILink
from loops import util from loops import util
from loops.util import _ from loops.util import _
@ -37,6 +40,66 @@ from loops.util import _
site_macros = ViewPageTemplateFile('view_macros.pt') site_macros = ViewPageTemplateFile('view_macros.pt')
actions.register('createPortalLink', 'portlet', DialogAction,
title=_(u'Create Link...'),
description=_(u'Create a link to a loops site.'),
viewName='create_concept.html',
dialogName='createPortalLink',
typeToken='.loops/concepts/portal_link',
fixedType=True,
innerForm='inner_concept_form.html',
)
actions.register('editPortalLink', 'portlet', DialogAction,
title=_(u'Edit Link...'),
description=_(u'Modify link.'),
viewName='edit_concept.html',
dialogName='editPortalLink',
)
class PortalPage(ConceptView):
""" A query view linking to pages on other loops sites.
"""
@Lazy
def site_macros(self):
return site_macros.macros
@property
def macro(self):
return self.site_macros['portal_page']
@Lazy
def root(self):
return getRoot(self.context)
@Lazy
def portalLinks(self):
result = []
for c in self.context.getChildren():
link = adapted(c)
if ILink.providedBy(link):
site = traverse(self.root, link.site)
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
class SiteDetails(BaseView):
pass
# old loops_sites.html view
class SitesListing(ConceptView): class SitesListing(ConceptView):
@Lazy @Lazy
@ -61,7 +124,3 @@ class SitesListing(ConceptView):
result.append(SiteDetails(s, self.request)) result.append(SiteDetails(s, self.request))
return result return result
class SiteDetails(BaseView):
pass

View file

@ -5,6 +5,24 @@
xmlns:browser="http://namespaces.zope.org/browser" xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="loops"> i18n_domain="loops">
<zope:adapter factory="loops.system.site.link.Link" trusted="True" />
<zope:class class="loops.system.site.link.Link">
<require permission="zope.View"
interface="loops.system.site.interfaces.ILink" />
<require permission="zope.ManageContent"
set_schema="loops.system.site.interfaces.ILink" />
</zope:class>
<!-- views -->
<zope:adapter
name="portal_page.html"
for="loops.interfaces.IConcept
zope.publisher.interfaces.browser.IBrowserRequest"
provides="zope.interface.Interface"
factory="loops.system.site.browser.PortalPage"
permission="zope.View" />
<zope:adapter <zope:adapter
name="loops_sites.html" name="loops_sites.html"
for="loops.interfaces.IConcept for="loops.interfaces.IConcept

54
system/site/interfaces.py Normal file
View file

@ -0,0 +1,54 @@
#
# Copyright (c) 2010 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
#
"""
Interfaces for linking to other pages on a portal page.
$Id$
"""
from zope.interface import Interface, Attribute
from zope import interface, component, schema
from loops.interfaces import IConceptSchema
from loops.util import _
class ILink(IConceptSchema):
""" A link to a page in another loops site in the same instance.
"""
site = schema.TextLine(
title=_(u'Site'),
description=_(u'Path to the site to link to.'),
default=u'',
required=True)
path = schema.TextLine(
title=_(u'Path'),
description=_(u'Path within the view manager. Default: home'),
default=u'home',
required=False)
url = schema.TextLine(
title=_(u'URL'),
description=_(u'URL to use for the link. Default: '
u'generate from site and path settings.'),
default=u'',
required=False)

41
system/site/link.py Normal file
View file

@ -0,0 +1,41 @@
#
# Copyright (c) 2010 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
#
"""
Interfaces for linking to other pages on a portal page.
$Id$
"""
from zope.interface import implements
from zope import interface, component, schema
from loops.common import AdapterBase
from loops.system.site.interfaces import ILink
from loops.type import TypeInterfaceSourceList
from loops.util import _
TypeInterfaceSourceList.typeInterfaces += (ILink,)
class Link(AdapterBase):
implements(ILink)
_contextAttributes = list(ILink)

View file

@ -4,14 +4,29 @@
<!-- listings --> <!-- listings -->
<metal:work define-macro="portal_page">
<metal:title use-macro="view/concept_macros/concepttitle" />
<ul>
<tal:site tal:repeat="row item/portalLinks">
<li><a tal:attributes="href row/url"
tal:content="row/title">My Site</a>
<tal:description condition="row/description"><br />
<i tal:content="structure row/renderedDescription" />
</tal:description>
</li>
</tal:site>
</ul>
</metal:work>
<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>
<tal:site tal:repeat="row item/sites"> <tal:site tal:repeat="row item/sites">
<li><a tal:attributes="href row/url" <li><a tal:attributes="href row/url"
tal:content="row/dcTitle">My Site</a></li> tal:content="row/dcTitle">My Site</a></li>
</tal:site> </tal:site>
</ul> </ul>
</metal:work> </metal:work>

View file

@ -21,7 +21,7 @@ loops version specifications.
""" """
revision = '$Id$' revision = '$Id$'
version = '0.9' version = '1.1'
package = 'loops' package = 'loops'
from cybertools.util.version import versions from cybertools.util.version import versions