[Checkins] SVN: jquery.demo/trunk/src/jquery/demo/ Added reST editor sample

Roger Ineichen roger at projekt01.ch
Thu May 24 06:30:09 EDT 2007


Log message for revision 75926:
  Added reST editor sample
  Added JSON form sample

Changed:
  A   jquery.demo/trunk/src/jquery/demo/SETUP.cfg
  A   jquery.demo/trunk/src/jquery/demo/__init__.py
  A   jquery.demo/trunk/src/jquery/demo/configure.zcml
  A   jquery.demo/trunk/src/jquery/demo/i18n.py
  A   jquery.demo/trunk/src/jquery/demo/jquery.demo-configure.zcml
  A   jquery.demo/trunk/src/jquery/demo/jsonform/
  A   jquery.demo/trunk/src/jquery/demo/jsonform/__init__.py
  A   jquery.demo/trunk/src/jquery/demo/jsonform/app.py
  A   jquery.demo/trunk/src/jquery/demo/jsonform/browser.py
  A   jquery.demo/trunk/src/jquery/demo/jsonform/browser.zcml
  A   jquery.demo/trunk/src/jquery/demo/jsonform/configure.zcml
  A   jquery.demo/trunk/src/jquery/demo/jsonform/index.pt
  A   jquery.demo/trunk/src/jquery/demo/jsonform/interfaces.py
  A   jquery.demo/trunk/src/jquery/demo/resteditor/
  A   jquery.demo/trunk/src/jquery/demo/resteditor/__init__.py
  A   jquery.demo/trunk/src/jquery/demo/resteditor/app.py
  A   jquery.demo/trunk/src/jquery/demo/resteditor/browser.py
  A   jquery.demo/trunk/src/jquery/demo/resteditor/browser.zcml
  A   jquery.demo/trunk/src/jquery/demo/resteditor/configure.zcml
  A   jquery.demo/trunk/src/jquery/demo/resteditor/index.pt
  A   jquery.demo/trunk/src/jquery/demo/resteditor/interfaces.py
  A   jquery.demo/trunk/src/jquery/demo/resteditor/resteditor.css

-=-
Added: jquery.demo/trunk/src/jquery/demo/SETUP.cfg
===================================================================
--- jquery.demo/trunk/src/jquery/demo/SETUP.cfg	                        (rev 0)
+++ jquery.demo/trunk/src/jquery/demo/SETUP.cfg	2007-05-24 10:30:08 UTC (rev 75926)
@@ -0,0 +1,3 @@
+<data-files zopeskel/etc/package-includes>
+  jquery.demo-*.zcml
+</data-files>

Added: jquery.demo/trunk/src/jquery/demo/__init__.py
===================================================================
--- jquery.demo/trunk/src/jquery/demo/__init__.py	                        (rev 0)
+++ jquery.demo/trunk/src/jquery/demo/__init__.py	2007-05-24 10:30:08 UTC (rev 75926)
@@ -0,0 +1,16 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id: layer.py 197 2007-04-13 05:03:32Z rineichen $
+"""

Added: jquery.demo/trunk/src/jquery/demo/configure.zcml
===================================================================
--- jquery.demo/trunk/src/jquery/demo/configure.zcml	                        (rev 0)
+++ jquery.demo/trunk/src/jquery/demo/configure.zcml	2007-05-24 10:30:08 UTC (rev 75926)
@@ -0,0 +1,70 @@
+<configure
+    xmlns:zope="http://namespaces.zope.org/zope"
+    xmlns="http://namespaces.zope.org/browser"
+    xmlns:z3c="http://namespaces.zope.org/z3c"
+    i18n_domain="jquery.demo">
+
+  <include package=".resteditor" />
+  <include package=".jsonform" />
+
+
+  <!-- register additional JQuery javascripts for z3c.website -->
+  <configure package="jquery.javascript">
+    <resource
+        name="xmlhttp.js"
+        file="js/xmlhttp.js"
+        layer="z3c.website.layer.IWebSiteBrowserLayer"
+        />
+
+    <resource
+        name="json.js"
+        file="js/json.js"
+        layer="z3c.website.layer.IWebSiteBrowserLayer"
+        />
+
+    <resource
+        name="jquery.js"
+        file="js/jquery.js"
+        layer="z3c.website.layer.IWebSiteBrowserLayer"
+        />
+
+    <resource
+        name="jquery.pack.js"
+        file="js/jquery.pack.js"
+        layer="z3c.website.layer.IWebSiteBrowserLayer"
+        />
+
+
+    <!-- viewlets -->
+    <viewlet
+        name="xmlhttp.js"
+        for="*"
+        manager="z3c.website.layer.IJavaScript"
+        class="jquery.javascript.browser.XMLHTTPJavaScriptViewlet"
+        permission="zope.Public"
+        layer="z3c.website.layer.IWebSiteBrowserLayer"
+        weight="0"
+        />
+
+    <viewlet
+        name="json.js"
+        for="*"
+        manager="z3c.website.layer.IJavaScript"
+        class="jquery.javascript.browser.JSONJavaScriptViewlet"
+        permission="zope.Public"
+        layer="z3c.website.layer.IWebSiteBrowserLayer"
+        weight="1"
+        />
+
+    <viewlet
+        name="jquery.pack.js"
+        for="*"
+        manager="z3c.website.layer.IJavaScript"
+        class="jquery.javascript.browser.JQueryPackJavaScriptViewlet"
+        permission="zope.Public"
+        layer="z3c.website.layer.IWebSiteBrowserLayer"
+        weight="2"
+        />
+  </configure>
+
+</configure>

Added: jquery.demo/trunk/src/jquery/demo/i18n.py
===================================================================
--- jquery.demo/trunk/src/jquery/demo/i18n.py	                        (rev 0)
+++ jquery.demo/trunk/src/jquery/demo/i18n.py	2007-05-24 10:30:08 UTC (rev 75926)
@@ -0,0 +1,19 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id: layer.py 197 2007-04-13 05:03:32Z rineichen $
+"""
+import zope.i18nmessageid
+
+MessageFactory = zope.i18nmessageid.MessageFactory('jquery.demo')

Added: jquery.demo/trunk/src/jquery/demo/jquery.demo-configure.zcml
===================================================================
--- jquery.demo/trunk/src/jquery/demo/jquery.demo-configure.zcml	                        (rev 0)
+++ jquery.demo/trunk/src/jquery/demo/jquery.demo-configure.zcml	2007-05-24 10:30:08 UTC (rev 75926)
@@ -0,0 +1 @@
+<include package="jquery.demo" />

Added: jquery.demo/trunk/src/jquery/demo/jsonform/__init__.py
===================================================================
--- jquery.demo/trunk/src/jquery/demo/jsonform/__init__.py	                        (rev 0)
+++ jquery.demo/trunk/src/jquery/demo/jsonform/__init__.py	2007-05-24 10:30:08 UTC (rev 75926)
@@ -0,0 +1,16 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id: layer.py 197 2007-04-13 05:03:32Z rineichen $
+"""

Added: jquery.demo/trunk/src/jquery/demo/jsonform/app.py
===================================================================
--- jquery.demo/trunk/src/jquery/demo/jsonform/app.py	                        (rev 0)
+++ jquery.demo/trunk/src/jquery/demo/jsonform/app.py	2007-05-24 10:30:08 UTC (rev 75926)
@@ -0,0 +1,46 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id: layer.py 197 2007-04-13 05:03:32Z rineichen $
+"""
+
+import zope.interface
+from zope.schema.fieldproperty import FieldProperty
+from z3c.website import sample
+from jquery.demo.jsonform import interfaces
+
+
+class JSONFormSample(sample.Sample):
+    """JSON form sample."""
+
+    zope.interface.implements(interfaces.IJSONFormSample)
+
+
+class AnotherSessionData(object):
+    """None persistent sample content object for storing in a session."""
+
+    zope.interface.implements(interfaces.IAnotherSessionData)
+
+    asciiField = FieldProperty(interfaces.IAnotherSessionData['asciiField'])
+    asciiLineField = FieldProperty(
+        interfaces.IAnotherSessionData['asciiLineField'])
+    dateField = FieldProperty(interfaces.IAnotherSessionData['dateField'])
+    datetimeField = FieldProperty(
+        interfaces.IAnotherSessionData['datetimeField'])
+    decimalField = FieldProperty(
+        interfaces.IAnotherSessionData['decimalField'])
+    dottedNameField = FieldProperty(
+        interfaces.IAnotherSessionData['dottedNameField'])
+    floatField = FieldProperty(interfaces.IAnotherSessionData['floatField'])
+    idField = FieldProperty(interfaces.IAnotherSessionData['idField'])

Added: jquery.demo/trunk/src/jquery/demo/jsonform/browser.py
===================================================================
--- jquery.demo/trunk/src/jquery/demo/jsonform/browser.py	                        (rev 0)
+++ jquery.demo/trunk/src/jquery/demo/jsonform/browser.py	2007-05-24 10:30:08 UTC (rev 75926)
@@ -0,0 +1,62 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id: layer.py 197 2007-04-13 05:03:32Z rineichen $
+"""
+__docformat__ = "reStructuredText"
+
+import zope.interface
+import zope.component
+
+from z3c.website.i18n import MessageFactory as _
+from z3c.website.browser.page import PageAddForm
+from z3c.demo.calculator import calculator
+
+from z3c.template.interfaces import ILayoutTemplate
+from z3c.form.interfaces import IWidgets
+from z3c.form import form
+from z3c.form import field
+from z3c.website.browser.sample import SampleAddForm
+from z3c.website.browser.sample import SessionDataEditForm
+from jquery.demo.jsonform import interfaces
+from jquery.demo.jsonform import app
+
+
+class AddForm(SampleAddForm):
+
+    label = _('Add JSON form sample')
+    factory = app.JSONFormSample
+
+
+class SampleForm(SessionDataEditForm):
+    """Sample edit form"""
+
+    # we apply the JQuery xpath to this form name
+    id = u'JSONValidateSample'
+
+    fields = field.Fields(interfaces.IAnotherSessionData).select('asciiField', 
+        'asciiLineField', 'dateField', 'datetimeField', 'decimalField', 
+        'dottedNameField', 'floatField', 'idField')
+
+    def getContentFactory(self):
+        return app.AnotherSessionData
+
+    def publishTraverse(self, request, name):
+        if name == 'jsonValidate':
+            view = zope.component.queryMultiAdapter((self, request), name=name)
+            if view is None:
+                raise NotFound(self, name, request)
+            return view
+        else:
+            raise NotFound(self, name, request)

Added: jquery.demo/trunk/src/jquery/demo/jsonform/browser.zcml
===================================================================
--- jquery.demo/trunk/src/jquery/demo/jsonform/browser.zcml	                        (rev 0)
+++ jquery.demo/trunk/src/jquery/demo/jsonform/browser.zcml	2007-05-24 10:30:08 UTC (rev 75926)
@@ -0,0 +1,66 @@
+<configure
+    xmlns:zope="http://namespaces.zope.org/zope"
+    xmlns="http://namespaces.zope.org/browser"
+    xmlns:z3c="http://namespaces.zope.org/z3c"
+    i18n_domain="jquery.demo">
+
+  <z3c:pagelet
+      name="addJQueryJSONForm.html"
+      for="z3c.website.interfaces.ISamples"
+      provides="z3c.website.interfaces.ISampleAddForm"
+      class=".browser.AddForm"
+      layer="z3c.website.layer.IWebSiteBrowserLayer"
+      permission="z3c.website.ManageSite"
+      />
+
+  <z3c:pagelet
+      name="index.html"
+      for=".interfaces.IJSONFormSample"
+      class=".browser.SampleForm"
+      provides="z3c.website.interfaces.ISamplePagelet"
+      layer="z3c.website.layer.IWebSiteBrowserLayer"
+      permission="zope.Public"
+      />
+
+  <z3c:template
+      template="index.pt"
+      for=".browser.SampleForm"
+      layer="z3c.website.layer.IWebSiteBrowserLayer"
+      />
+
+  <!-- json validator -->
+  <configure package="jquery.jsonform">
+    <resource
+        name="jsonform.validate.js"
+        file="jsonform.validate.js"
+        layer="z3c.website.layer.IWebSiteBrowserLayer"
+        />
+
+    <viewlet
+        name="jsonform.validate.js"
+        for="*"
+        manager="z3c.website.layer.IJavaScript"
+        class=".browser.JSONFormValidateJavaScriptViewlet"
+        permission="zope.Public"
+        layer="z3c.website.layer.IWebSiteBrowserLayer"
+        weight="100"
+        />
+
+    <resource
+        name="jsonform.validate.css"
+        file="jsonform.validate.css"
+        layer="z3c.website.layer.IWebSiteBrowserLayer"
+        />
+
+    <viewlet
+        name="validator.css"
+        for="*"
+        manager="z3c.website.layer.ICSS"
+        class=".browser.JSONFormValidateCSSViewlet"
+        permission="zope.Public"
+        layer="z3c.website.layer.IWebSiteBrowserLayer"
+        weight="100"
+        />
+  </configure>
+
+</configure>

Added: jquery.demo/trunk/src/jquery/demo/jsonform/configure.zcml
===================================================================
--- jquery.demo/trunk/src/jquery/demo/jsonform/configure.zcml	                        (rev 0)
+++ jquery.demo/trunk/src/jquery/demo/jsonform/configure.zcml	2007-05-24 10:30:08 UTC (rev 75926)
@@ -0,0 +1,29 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    i18n_domain="jquery.demo">
+
+  <class class=".app.JSONFormSample">
+    <require
+        permission="zope.Public"
+        interface=".interfaces.IJSONFormSample"
+        />
+    <require
+        permission="z3c.website.ManageContent"
+        set_schema=".interfaces.IJSONFormSample"
+        />
+  </class>
+
+  <class class=".app.AnotherSessionData">
+    <require
+        permission="zope.Public"
+        interface=".interfaces.IAnotherSessionData"
+        />
+    <require
+        permission="zope.Public"
+        set_schema=".interfaces.IAnotherSessionData"
+        />
+  </class>
+
+  <include file="browser.zcml" />
+
+</configure>

Added: jquery.demo/trunk/src/jquery/demo/jsonform/index.pt
===================================================================
--- jquery.demo/trunk/src/jquery/demo/jsonform/index.pt	                        (rev 0)
+++ jquery.demo/trunk/src/jquery/demo/jsonform/index.pt	2007-05-24 10:30:08 UTC (rev 75926)
@@ -0,0 +1 @@
+<div metal:use-macro="macro:form" />

Added: jquery.demo/trunk/src/jquery/demo/jsonform/interfaces.py
===================================================================
--- jquery.demo/trunk/src/jquery/demo/jsonform/interfaces.py	                        (rev 0)
+++ jquery.demo/trunk/src/jquery/demo/jsonform/interfaces.py	2007-05-24 10:30:08 UTC (rev 75926)
@@ -0,0 +1,71 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id: layer.py 197 2007-04-13 05:03:32Z rineichen $
+"""
+
+import datetime
+import decimal
+import zope.interface
+import zope.schema
+from z3c.website import interfaces
+
+
+class IJSONFormSample(interfaces.ISample):
+    """JSON form sample."""
+
+
+class IAnotherSessionData(zope.interface.Interface):
+    """Simple data object which offers a field called content."""
+
+    asciiField = zope.schema.ASCII(
+        title=u'ASCII',
+        description=u'This is an ASCII field.',
+        default='This is\n ASCII.')
+
+    asciiLineField = zope.schema.ASCIILine(
+        title=u'ASCII Line',
+        description=u'This is an ASCII-Line field.',
+        default='An ASCII line.')
+
+    dateField = zope.schema.Date(
+        title=u'Date',
+        description=u'This is a Date field.',
+        default=datetime.date(2007, 4, 1))
+
+    datetimeField = zope.schema.Datetime(
+        title=u'Date/Time',
+        description=u'This is a Datetime field.',
+        default=datetime.datetime(2007, 4, 1, 12))
+
+    decimalField = zope.schema.Decimal(
+        title=u'Decimal',
+        description=u'This is a Decimal field.',
+        default=decimal.Decimal('12.87'))
+
+    dottedNameField = zope.schema.DottedName(
+        title=u'Dotted Name',
+        description=u'This is a DottedName field.',
+        default='z3c.form')
+
+    floatField = zope.schema.Float(
+        title=u'Float',
+        description=u'This is a Float field.',
+        default=12.8)
+
+    idField = zope.schema.Id(
+        title=u'Id',
+        description=u'This is a Id field.',
+        default='z3c.form')
+

Added: jquery.demo/trunk/src/jquery/demo/resteditor/__init__.py
===================================================================
--- jquery.demo/trunk/src/jquery/demo/resteditor/__init__.py	                        (rev 0)
+++ jquery.demo/trunk/src/jquery/demo/resteditor/__init__.py	2007-05-24 10:30:08 UTC (rev 75926)
@@ -0,0 +1,16 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id: layer.py 197 2007-04-13 05:03:32Z rineichen $
+"""

Added: jquery.demo/trunk/src/jquery/demo/resteditor/app.py
===================================================================
--- jquery.demo/trunk/src/jquery/demo/resteditor/app.py	                        (rev 0)
+++ jquery.demo/trunk/src/jquery/demo/resteditor/app.py	2007-05-24 10:30:08 UTC (rev 75926)
@@ -0,0 +1,27 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id: layer.py 197 2007-04-13 05:03:32Z rineichen $
+"""
+
+import zope.interface
+from zope.schema.fieldproperty import FieldProperty
+from z3c.website import sample
+from jquery.demo.resteditor import interfaces
+
+
+class RESTEditorSample(sample.Sample):
+    """JSON form sample."""
+
+    zope.interface.implements(interfaces.IRESTEditorSample)

Added: jquery.demo/trunk/src/jquery/demo/resteditor/browser.py
===================================================================
--- jquery.demo/trunk/src/jquery/demo/resteditor/browser.py	                        (rev 0)
+++ jquery.demo/trunk/src/jquery/demo/resteditor/browser.py	2007-05-24 10:30:08 UTC (rev 75926)
@@ -0,0 +1,67 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id: layer.py 197 2007-04-13 05:03:32Z rineichen $
+"""
+
+import zope.interface
+import zope.component
+from zope.viewlet.viewlet import CSSViewlet
+from z3c.website.browser.page import PageAddForm
+from z3c.form.interfaces import IWidgets
+from z3c.form import form, field
+from z3c.pagelet import browser
+from z3c.template.interfaces import ILayoutTemplate
+
+from z3c.website.interfaces import IContent
+from z3c.website.interfaces import ISessionData
+from z3c.website.browser.sample import SampleAddForm
+from z3c.website.browser.sample import SessionDataEditForm
+from jquery.demo.i18n import MessageFactory as _
+from jquery.widget.resteditor.browser import RESTEditorFieldWidget
+from jquery.demo.resteditor import app
+
+
+class AddForm(SampleAddForm):
+
+    label = _('Add REST Editor sample')
+    factory = app.RESTEditorSample
+
+
+class SamplePage(SessionDataEditForm):
+    """Sample edit page"""
+
+    name = u'RestEditorSample'
+
+    fields = field.Fields(ISessionData).select('content')
+    fields['content'].widgetFactory = RESTEditorFieldWidget
+
+
+# This is the enhanced content edit form for ISample
+
+RestEditorCSS = CSSViewlet('resteditor.css')
+
+
+class ContentEditPagelet(form.EditForm):
+    """Content edit page."""
+
+    fields = field.Fields(IContent).select('body')
+
+    fields['body'].widgetFactory = RESTEditorFieldWidget
+
+    def __call__(self):
+        self.update()
+        layout = zope.component.getMultiAdapter((self, self.request),
+            ILayoutTemplate)
+        return layout(self)

Added: jquery.demo/trunk/src/jquery/demo/resteditor/browser.zcml
===================================================================
--- jquery.demo/trunk/src/jquery/demo/resteditor/browser.zcml	                        (rev 0)
+++ jquery.demo/trunk/src/jquery/demo/resteditor/browser.zcml	2007-05-24 10:30:08 UTC (rev 75926)
@@ -0,0 +1,114 @@
+<configure
+    xmlns:zope="http://namespaces.zope.org/zope"
+    xmlns="http://namespaces.zope.org/browser"
+    xmlns:z3c="http://namespaces.zope.org/z3c"
+    i18n_domain="jquery.demo">
+
+  <!-- content edit form for website content -->
+  <z3c:pagelet
+      name="edit.html"
+      for="z3c.website.interfaces.IWebSite"
+      class=".browser.ContentEditPagelet"
+      layer="z3c.website.layer.IWebSiteBrowserLayer"
+      permission="z3c.website.ManageSite"
+      />
+  <z3c:pagelet
+      name="edit.html"
+      for="z3c.website.interfaces.IPage"
+      class=".browser.ContentEditPagelet"
+      layer="z3c.website.layer.IWebSiteBrowserLayer"
+      permission="z3c.website.ManageSite"
+      />
+  <z3c:pagelet
+      name="edit.html"
+      for="z3c.website.interfaces.ISample"
+      class=".browser.ContentEditPagelet"
+      layer="z3c.website.layer.IWebSiteBrowserLayer"
+      permission="z3c.website.ManageSite"
+      />
+  <zrt-resource
+      name="resteditor.css"
+      file="resteditor.css"
+      layer="z3c.website.layer.IWebSiteBrowserLayer"
+      />
+
+
+  <!-- sample configuration -->
+  <z3c:pagelet
+      name="addJQueryRESTEditor.html"
+      for="z3c.website.interfaces.ISamples"
+      provides="z3c.website.interfaces.ISampleAddForm"
+      class=".browser.AddForm"
+      layer="z3c.website.layer.IWebSiteBrowserLayer"
+      permission="z3c.website.ManageSite"
+      />
+
+  <z3c:pagelet
+      name="index.html"
+      for="jquery.demo.resteditor.interfaces.IRESTEditorSample"
+      class=".browser.SamplePage"
+      provides="z3c.website.interfaces.ISamplePagelet"
+      layer="z3c.website.layer.IWebSiteBrowserLayer"
+      permission="zope.Public"
+      />
+
+  <z3c:template
+      template="index.pt"
+      for=".browser.SamplePage"
+      layer="z3c.website.layer.IWebSiteBrowserLayer"
+      />
+  <viewlet
+      name="resteditor.css"
+      for="*"
+      class=".browser.RestEditorCSS"
+      manager="z3c.website.layer.ICSS"
+      layer="z3c.website.layer.IWebSiteBrowserLayer"
+      permission="zope.Public"
+      weight="1000"
+      />
+
+  <!-- register additional JavaScipts for JSON support -->
+
+  <configure package="jquery.widget.resteditor">
+    <resourceDirectory
+        name="jqueryRestEditorIMG"
+        directory="img"
+        layer="z3c.website.layer.IWebSiteBrowserLayer"
+        />
+
+    <zrt-resource
+        name="jquery.resteditor.js"
+        file="jquery.resteditor.js"
+        layer="z3c.website.layer.IWebSiteBrowserLayer"
+        />
+
+    <zrt-resource
+        name="jquery.resteditor.css"
+        file="jquery.resteditor.css"
+        layer="z3c.website.layer.IWebSiteBrowserLayer"
+        />
+
+    <!-- override resteditor.css with a higher weight for SamplePage --> 
+    <viewlet
+        name="jquery.resteditor.css"
+        for="*"
+        view="jquery.demo.resteditor.browser.SamplePage"
+        class=".browser.JQueryRestEditorCSS"
+        manager="z3c.website.layer.ICSS"
+        layer="z3c.website.layer.IWebSiteBrowserLayer"
+        permission="zope.Public"
+        weight="1001"
+        />
+
+    <viewlet
+        name="jquery.resteditor.js"
+        for="*"
+        class=".browser.JQueryRestEditorJavaScript"
+        manager="z3c.website.layer.IJavaScript"
+        layer="z3c.website.layer.IWebSiteBrowserLayer"
+        permission="zope.Public"
+        weight="1000"
+        />
+  </configure>
+
+</configure>

Added: jquery.demo/trunk/src/jquery/demo/resteditor/configure.zcml
===================================================================
--- jquery.demo/trunk/src/jquery/demo/resteditor/configure.zcml	                        (rev 0)
+++ jquery.demo/trunk/src/jquery/demo/resteditor/configure.zcml	2007-05-24 10:30:08 UTC (rev 75926)
@@ -0,0 +1,18 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    i18n_domain="jquery.demo">
+
+  <class class=".app.RESTEditorSample">
+    <require
+        permission="zope.Public"
+        interface=".interfaces.IRESTEditorSample"
+        />
+    <require
+        permission="z3c.website.ManageContent"
+        set_schema=".interfaces.IRESTEditorSample"
+        />
+  </class>
+
+  <include file="browser.zcml" />
+
+</configure>

Added: jquery.demo/trunk/src/jquery/demo/resteditor/index.pt
===================================================================
--- jquery.demo/trunk/src/jquery/demo/resteditor/index.pt	                        (rev 0)
+++ jquery.demo/trunk/src/jquery/demo/resteditor/index.pt	2007-05-24 10:30:08 UTC (rev 75926)
@@ -0,0 +1 @@
+<div metal:use-macro="macro:form" />

Added: jquery.demo/trunk/src/jquery/demo/resteditor/interfaces.py
===================================================================
--- jquery.demo/trunk/src/jquery/demo/resteditor/interfaces.py	                        (rev 0)
+++ jquery.demo/trunk/src/jquery/demo/resteditor/interfaces.py	2007-05-24 10:30:08 UTC (rev 75926)
@@ -0,0 +1,22 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id: layer.py 197 2007-04-13 05:03:32Z rineichen $
+"""
+
+from z3c.website import interfaces
+
+
+class IRESTEditorSample(interfaces.ISample):
+    """REST editor sample."""

Added: jquery.demo/trunk/src/jquery/demo/resteditor/resteditor.css
===================================================================
--- jquery.demo/trunk/src/jquery/demo/resteditor/resteditor.css	                        (rev 0)
+++ jquery.demo/trunk/src/jquery/demo/resteditor/resteditor.css	2007-05-24 10:30:08 UTC (rev 75926)
@@ -0,0 +1,18 @@
+/* zrt-replace: "./img" tal"string:${context/++resource++jqueryRestEditorIMG}" */
+
+div.RESTEditorToolBar {
+    width: 600px;
+    background: white url("./img/restEditorBackground.gif"); background-repeat: repeat-x;
+}
+
+textarea.restEditorWidget {
+    width: 600px;
+    height: 600px;
+}
+
+div.RESTEditorToolBar img {
+    height: 22px;
+    width: 22px;
+    padding-right: 5px;
+    border: 0;
+}



More information about the Checkins mailing list