Permalink
Browse files

Initial import

  • Loading branch information...
0 parents commit f2aa2dd0d6e417f8138ed16123905d12e15c00be @miohtama miohtama committed Nov 21, 2012
@@ -0,0 +1,37 @@
+*.pyc
+*.pyo
+*.mo
+*.egg-info
+*.egg
+*.EGG
+*.EGG-INFO
+build
+downloads/*
+eggs/*
+fake-eggs/*
+parts/*
+develop-eggs
+dist
+.installed.cfg
+.mr.developer.cfg
+.hg
+.bzr
+.svn
+*.pyc
+*.pyo
+*.LCK
+*.lck
+*~
+*.bak
+.coverage
+*.pyd
+*.so
+*.orig
+*.rej
+__minitage__*
+.metadata
+.secret.cfg
+.settings
+.project
+.pydevproject
+.DS_Store
@@ -0,0 +1,25 @@
+Introduction
+============
+
+Allow "alias" portlets from other locations to show in the current folder in `Plone CMS <http://plone.org>`_.
+This is useful if you need to have the same portlet to pop-up in different unrelated locations
+and you want to have only one copy for the site editors to maintain the portlet content.
+
+* Go to Manage portlets
+
+* Choose Add new portlet... Alias
+
+* Enter the path to the source folder
+
+* Enter the portlet id of the source portlet. This add-on provides @@portlet-data view which dumps
+ out the folder portlet info and related its.
+
+Installation
+============
+
+* http://plone.org/documentation/kb/installing-add-ons-quick-how-to/
+
+Author
+========
+
+`Mikko Ohtamaa <http://opensourcehacker.com>`_
@@ -0,0 +1,6 @@
+# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+ from pkgutil import extend_path
+ __path__ = extend_path(__path__, __name__)
@@ -0,0 +1,8 @@
+# -*- extra stuff goes here -*-
+from zope.i18nmessageid import MessageFactory
+
+portletaliasMessageFactory = MessageFactory('collective.portletalias')
+
+
+def initialize(context):
+ """Initializer called when used as a Zope 2 product."""
@@ -0,0 +1,31 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:five="http://namespaces.zope.org/five"
+ xmlns:i18n="http://namespaces.zope.org/i18n"
+ xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ i18n_domain="collective.portletalias">
+
+ <five:registerPackage package="." initialize=".initialize" />
+
+ <genericsetup:registerProfile
+ name="default"
+ title="collective.portletalias"
+ directory="profiles/default"
+ description="Installs the collective.portletalias package"
+ provides="Products.GenericSetup.interfaces.EXTENSION"
+ />
+ <!-- -*- extra stuff goes here -*- -->
+
+ <include package=".portlets" />
+
+ <browser:page
+ for="*"
+ name="portlet-data"
+ class=".views.PortletData"
+ template="portlet-data.pt"
+ permission="cmf.ManagePortal"
+ />
+
+
+</configure>
@@ -0,0 +1,22 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:metal="http://xml.zope.org/namespaces/metal"
+ xmlns:tal="http://xml.zope.org/namespaces/tal"
+ xmlns:i18n="http://xml.zope.org/namespaces/i18n"
+ metal:use-macro="context/main_template/macros/master">
+
+ <metal:block fill-slot="content-core">
+ <div class="manager" tal:repeat="manager view/getPortletData">
+ <h2 tal:content="manager/name" />
+
+ <p>Assignments in this portlet manager</p>
+
+ <div class="portlet-info" tal:repeat="assignment python:manager['items']">
+ <h3 tal:content="assignment/name" />
+
+ <pre tal:content="python:unicode(assignment['data'])" />
+
+ </div>
+ </div>
+ </metal:block>
+
+</html>
No changes.
@@ -0,0 +1,24 @@
+<dl class="portlet portletAliasPortlet"
+ i18n:domain="collective.portletalias">
+
+ <dt class="portletHeader">
+ <span class="portletTopLeft"></span>
+ <span>
+ Header
+ </span>
+ <span class="portletTopRight"></span>
+ </dt>
+
+ <dd class="portletItem odd">
+ Body text
+ </dd>
+
+ <dd class="portletFooter">
+ <span class="portletBottomLeft"></span>
+ <span>
+ Footer
+ </span>
+ <span class="portletBottomRight"></span>
+ </dd>
+
+</dl>
@@ -0,0 +1,108 @@
+from zope.interface import Interface
+from zope.interface import implements
+
+from plone.app.portlets.portlets import base
+from plone.portlets.interfaces import IPortletDataProvider
+
+from zope import schema
+from zope.formlib import form
+from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
+
+from collective.portletalias import portletaliasMessageFactory as _
+
+from zope.i18nmessageid import MessageFactory
+__ = MessageFactory("plone")
+
+
+class IAliasPortlet(IPortletDataProvider):
+ """A portlet
+
+ It inherits from IPortletDataProvider because for this portlet, the
+ data that is being rendered and the portlet assignment itself are the
+ same.
+ """
+
+ # TODO: Add any zope.schema fields here to capture portlet configuration
+ # information. Alternatively, if there are no settings, leave this as an
+ # empty interface - see also notes around the add form and edit form
+ # below.
+
+ path = schema.TextLine(title=_(u"Path"),
+ description=_(u"Site root relative path where the other portlet is assigned"),
+ required=True)
+
+ provider = schema.TextLine(title=_(u"Provider"),
+ description=_(u"Portlet provider id. E.g. plone.leftcolumn or plone.rightcolumn"),
+ required=True)
+
+ assignmentId = schema.TextLine(title=_(u"Portlet id"),
+ description=_(u"What's the portlet id of the assignment. Use @@portlet-info view to show out"),
+ required=True)
+
+
+class Assignment(base.Assignment):
+ """Portlet assignment.
+
+ This is what is actually managed through the portlets UI and associated
+ with columns.
+ """
+
+ implements(IAliasPortlet)
+
+ # TODO: Set default values for the configurable parameters here
+
+ # some_field = u""
+
+ # TODO: Add keyword parameters for configurable parameters here
+ # def __init__(self, some_field=u''):
+ # self.some_field = some_field
+
+ def __init__(self):
+ pass
+
+ @property
+ def title(self):
+ """This property is used to give the title of the portlet in the
+ "manage portlets" screen.
+ """
+ return __(u"Alias Portlet")
+
+
+class Renderer(base.Renderer):
+ """Portlet renderer.
+
+ This is registered in configure.zcml. The referenced page template is
+ rendered, and the implicit variable 'view' will refer to an instance
+ of this class. Other methods can be added and referenced in the template.
+ """
+
+ render = ViewPageTemplateFile('aliasportlet.pt')
+
+
+# NOTE: If this portlet does not have any configurable parameters, you can
+# inherit from NullAddForm and remove the form_fields variable.
+
+class AddForm(base.AddForm):
+ """Portlet add form.
+
+ This is registered in configure.zcml. The form_fields variable tells
+ zope.formlib which fields to display. The create() method actually
+ constructs the assignment that is being added.
+ """
+ form_fields = form.Fields(IAliasPortlet)
+
+ def create(self, data):
+ return Assignment(**data)
+
+
+# NOTE: IF this portlet does not have any configurable parameters, you can
+# remove this class definition and delete the editview attribute from the
+# <plone:portlet /> registration in configure.zcml
+
+class EditForm(base.EditForm):
+ """Portlet edit form.
+
+ This is registered with configure.zcml. The form_fields variable tells
+ zope.formlib which fields to display.
+ """
+ form_fields = form.Fields(IAliasPortlet)
@@ -0,0 +1,22 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:plone="http://namespaces.plone.org/plone"
+ i18n_domain="collective.portletalias">
+ <!-- Ensure Plone's portlets ZCML has already been processed; without
+ this, we may get a permission lookup error
+ -->
+ <include package="plone.app.portlets" />
+ <!-- -*- extra stuff goes here -*- -->
+
+ <plone:portlet
+ name="collective.portletalias.portlets.AliasPortlet"
+ interface=".aliasportlet.IAliasPortlet"
+ assignment=".aliasportlet.Assignment"
+ view_permission="zope2.View"
+ edit_permission="cmf.ManagePortal"
+ renderer=".aliasportlet.Renderer"
+ addview=".aliasportlet.AddForm"
+ editview=".aliasportlet.EditForm"
+ />
+
+</configure>
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<metadata>
+ <version>1000</version>
+</metadata>
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<!-- This file is used to register new types of portlets. It can also
+ be used to register completely new column types. See CMFPlone's version
+ of this file for more information.
+ -->
+<portlets
+ xmlns:i18n="http://xml.zope.org/namespaces/i18n"
+ i18n:domain="plone">
+ <!-- -*- extra stuff goes here -*- -->
+
+ <!-- to have your portlet's title and description translated in
+ @@manage-portlets, provide the messageids for the i18n:domain plone
+ (see http://dev.plone.org/plone/ticket/9631 or
+ http://dev.plone.org/plone/ticket/9090) for more information on
+ internationalization with portlets or in plone in general -->
+ <portlet
+ addview="collective.portletalias.portlets.AliasPortlet"
+ title="Alias Portlet"
+ description="Show portlet from other location"
+ i18n:attributes="title; description"
+ />
+
+</portlets>
@@ -0,0 +1,55 @@
+import unittest
+
+#from zope.testing import doctestunit
+#from zope.component import testing
+from Testing import ZopeTestCase as ztc
+
+from Products.Five import fiveconfigure
+from Products.PloneTestCase import PloneTestCase as ptc
+from Products.PloneTestCase.layer import PloneSite
+ptc.setupPloneSite()
+
+import collective.portletalias
+
+
+class TestCase(ptc.PloneTestCase):
+
+ class layer(PloneSite):
+
+ @classmethod
+ def setUp(cls):
+ fiveconfigure.debug_mode = True
+ ztc.installPackage(collective.portletalias)
+ fiveconfigure.debug_mode = False
+
+ @classmethod
+ def tearDown(cls):
+ pass
+
+
+def test_suite():
+ return unittest.TestSuite([
+
+ # Unit tests
+ #doctestunit.DocFileSuite(
+ # 'README.txt', package='collective.portletalias',
+ # setUp=testing.setUp, tearDown=testing.tearDown),
+
+ #doctestunit.DocTestSuite(
+ # module='collective.portletalias.mymodule',
+ # setUp=testing.setUp, tearDown=testing.tearDown),
+
+
+ # Integration tests that use PloneTestCase
+ #ztc.ZopeDocFileSuite(
+ # 'README.txt', package='collective.portletalias',
+ # test_class=TestCase),
+
+ #ztc.FunctionalDocFileSuite(
+ # 'browser.txt', package='collective.portletalias',
+ # test_class=TestCase),
+
+ ])
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
No changes.
Oops, something went wrong.

0 comments on commit f2aa2dd

Please sign in to comment.