Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Commit

Permalink
Ready to use and to be tested :)
Browse files Browse the repository at this point in the history
  • Loading branch information
trollfot committed Feb 26, 2010
1 parent 1518a74 commit df41735
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/grokui/base/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from grokui.base.interfaces import IGrokUIRealm, IGrokUIPluginInfo
from grokui.base.interfaces import IUIPanel, IMainMenu
from grokui.base.info import BasePluginInfo
from grokui.base.namespace import GrokUILayer, GrokUISkin, GrokUINamespace
from grokui.base.namespace import GrokUILayer, GrokUISkin
from grokui.base.namespace import GrokUINamespace, GrokUIPluginsInfo
from grokui.base.contentproviders import Header, Footer, MainMenu, Messages
from grokui.base.layout import GrokUIView
from grokui.base.info import BasePluginInfo
6 changes: 6 additions & 0 deletions src/grokui/base/configure.zcml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<configure
xmlns:grok="http://namespaces.zope.org/grok"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns="http://namespaces.zope.org/zope">

<include package="grok" />
Expand All @@ -8,4 +9,9 @@
<include package="megrok.layout" file="messages.zcml" />
<grok:grok package="." />

<browser:defaultView
for="grokui.base.interfaces.IGrokUIPluginInfo"
name="index"
/>

</configure>
3 changes: 2 additions & 1 deletion src/grokui/base/contentproviders.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

import grok
from megrok.menu import Menu
from zope.interface import Interface
from zope.site.interfaces import IRootFolder
from zope.component import getUtility, getMultiAdapter
from zope.browsermenu.interfaces import IBrowserMenu
from grokui.base import IGrokUIRealm, GrokUILayer

grok.layer(GrokUILayer)
grok.context(IGrokUIRealm)
grok.context(Interface)


class Header(grok.ViewletManager):
Expand Down
42 changes: 36 additions & 6 deletions src/grokui/base/info.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,44 @@
# -*- coding: utf-8 -*-

import grokcore.component as grok
import grokcore.viewlet as grok
from megrok.layout import Page
from zope.component import getUtilitiesFor
from zope.location import LocationProxy
from zope.schema.fieldproperty import FieldProperty
from grokui.base.interfaces import IGrokUIPluginInfo
from zope.traversing.browser.absoluteurl import absoluteURL

from grokui.base import interfaces
from grokui.base import GrokUIPluginsInfo, GrokUIView, GrokUILayer

grok.templatedir('templates')


class BasePluginInfo(grok.GlobalUtility):
grok.baseclass()
grok.implements(IGrokUIPluginInfo)
grok.implements(interfaces.IGrokUIPluginInfo)

title = FieldProperty(interfaces.IGrokUIPluginInfo['title'])
description = FieldProperty(interfaces.IGrokUIPluginInfo['description'])
version = FieldProperty(interfaces.IGrokUIPluginInfo['version'])


class Plugins(GrokUIView):
grok.order(50)
grok.title(u'Information panels')

def plugins(self):
plugins = getUtilitiesFor(interfaces.IGrokUIPluginInfo)
for name, plugin in plugins:
located = LocationProxy(plugin, self.context, '++info++%s' % name)
yield dict(
url=absoluteURL(located, self.request),
version=located.version,
title=located.title,
description=located.description)


title = FieldProperty(IGrokUIPluginInfo['title'])
description = FieldProperty(IGrokUIPluginInfo['description'])
version = FieldProperty(IGrokUIPluginInfo['version'])
class PluginPage(Page):
grok.name('index')
grok.layer(GrokUILayer)
grok.implements(interfaces.IUIPanel)
grok.context(interfaces.IGrokUIPluginInfo)
3 changes: 2 additions & 1 deletion src/grokui/base/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from grok import util
from grokui.base import IGrokUIRealm, GrokUILayer, IUIPanel, MainMenu
from megrok.layout import Layout, Page
from zope.interface import Interface
from zope.traversing.browser.absoluteurl import absoluteURL

grok.layer(GrokUILayer)
Expand All @@ -15,7 +16,7 @@
class GrokUILayout(Layout):
"""The general layout for the administration
"""
grok.context(IGrokUIRealm)
grok.context(Interface)
title = u"Grok User Interface"

def update(self):
Expand Down
6 changes: 3 additions & 3 deletions src/grokui/base/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ def traverse(self, name, ignore):
return LocationProxy(self, self.root, "++grokui++")


class GrokUIPluginInfo(grok.MultiAdapter):
class GrokUIPluginsInfo(grok.MultiAdapter):
grok.name('info')
grok.provides(ITraversable)
grok.adapts(IGrokUIRealm, browser.IBrowserRequest)

def __init__(self, context, request):
self.root = context
self.context = context
self.request = request

def traverse(self, name, ignore):
info = queryUtility(IGrokUIPluginInfo, name=name)
if info is None:
raise NotFound(self.context, name, self.request)
return LocationProxy(info, self.context, "++info++%s" % name)
return LocationProxy(info, self.context, '++info++%s' % name)
3 changes: 3 additions & 0 deletions src/grokui/base/static/grok.css
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,6 @@ label {
font-weight: bold !important;
}

#plugins {
padding: 0.4em 3em;
}
5 changes: 5 additions & 0 deletions src/grokui/base/templates/pluginpage.pt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="plugin-page">
<h1 tal:content="context/title" />
<h2 tal:content="context/version" />
<p tal:content="context/description" />
</div>
3 changes: 2 additions & 1 deletion src/grokui/base/viewlets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
from z3c.flashmessage.interfaces import IMessageReceiver
from zope.browsermenu.interfaces import IBrowserMenu
from zope.authentication.interfaces import IUnauthenticatedPrincipal
from zope.interface import Interface
from zope.component import getUtility

grok.view(IUIPanel)
grok.context(IGrokUIRealm)
grok.context(Interface)
grok.templatedir("templates")


Expand Down

0 comments on commit df41735

Please sign in to comment.