first steps towards using/integrating the viewlet and menu stuff

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@629 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2005-10-18 06:01:13 +00:00
parent 1570c8d680
commit 14a324412a
7 changed files with 128 additions and 1 deletions

View file

@ -38,6 +38,19 @@
fields="title"
/>
<menu
id="mmain"
title="main Menu"
/>
<menuItem
action="demo"
for="zope.interface.Interface"
menu="mmain"
title="Demo"
permission="zope.Public"
/>
<include package=".skin" />
</configure>

53
browser/menu.py Normal file
View file

@ -0,0 +1,53 @@
#
# Copyright (c) 2005 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
#
"""
cybertools menu.
$Id$
"""
from zope.app import zapi
from zope.app.pagetemplate.simpleviewclass import simple
from zope.viewlet.viewlet import ViewletBase, SimpleViewletClass
from zope.app.publisher.interfaces.browser import IBrowserMenu
class MenuViewlet(ViewletBase):
""" Menu viewlet.
"""
def getMenu(self):
menu = zapi.getUtility(IBrowserMenu, name='mmain')
return menu
def GenericMenuViewlet(template, offering=None, bases=(), name=u'', weight=0):
#return SimpleViewletClass(template, offering,
# bases + (MenuViewletBase,), name, weight)
if offering is None:
offering = sys._getframe(1).f_globals
bases += (MenuViewletBase, simple)
class_ = type("GenericMenuViewlet from %s" % template, bases,
{'index' : ViewletPageTemplateFile(template, offering),
'_weight' : weight,
'__name__' : name})
return class_

View file

@ -32,4 +32,24 @@
<resource name="bg_cyberview.gif" image="bg_cyberview.gif"
layer="cyberview" />
<zope:interface interface="cybertools.browser.viewlets.ILeft"
type="zope.contentprovider.interfaces.IContentProviderType" />
<viewletManager
name="navMenu"
provides="cybertools.browser.viewlets.ILeft"
template="left_slot.pt"
permission="zope.Public"
layer="cyberview"
/>
<viewlet
name="navMenu"
manager="cybertools.browser.viewlets.ILeft"
template="menu_viewlet.pt"
class="cybertools.browser.menu.MenuViewlet"
permission="zope.Public"
layer="cyberview"
/>
</configure>

10
browser/skin/left_slot.pt Normal file
View file

@ -0,0 +1,10 @@
<div>
Headline
</div>
<div tal:repeat="viewlet options/viewlets">
<div tal:content="structure python: viewlet(viewlet=viewlet)">
<!--<div tal:repeat="item python: menu.getMenuItems(context, request)">
<span tal:replace="item/title"/>
</div>-->
</div>
</div>

View file

@ -0,0 +1,2 @@
<div tal:define="menu options/viewlet/getMenu"
tal:content="python: menu.getMenuItems(context, request)" />

View file

@ -27,13 +27,13 @@
<table class="columns">
<tr>
<td class="left">
<span metal:use-macro="context/@@standard_macros/navigation_box" />
<!--
<span metal:use-macro="context/@@standard_macros/commontasks_box" />
<span metal:use-macro="context/@@standard_macros/metadata_box" />
<span metal:use-macro="context/@@standard_macros/views_box" />
<span metal:use-macro="context/@@standard_macros/actions_box" />
-->
<div tal:replace="structure provider:navMenu" />
</td>
<td class="main">
<!--

29
browser/viewlets.py Normal file
View file

@ -0,0 +1,29 @@
#
# Copyright (c) 2005 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
#
"""
cybertools regions.
$Id$
"""
from zope.viewlet.interfaces import IViewletManager
class ILeft(IViewletManager):
""" Left slot.
"""