Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for python3 #40

Merged
merged 4 commits into from
Feb 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ testrelease
include/
lib/

.DS_Store
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ JQueryUI Changelog: http://jqueryui.com/changelog/

Bug fixes:

- Added uninstall profile
[agitator]

- Python 2/3 compatibility
[pbauer]

- Simplify resource registration for Plone 5 the way done in
https://github.com/collective/example.p4p5#cssjs-declaration-in-plone-5
[rnix]
Expand Down
2 changes: 1 addition & 1 deletion collective/js/jqueryui/controlpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def verify_jsregistry(record):
site = getSite()
jsregistry = site.portal_javascripts

keys = JQUERYUI_DEPENDENCIES.keys()
keys = list(JQUERYUI_DEPENDENCIES.keys())
for key in keys:
rkey = key.replace('.', '_')
resource_id = RESOURCE_ID % key
Expand Down
9 changes: 9 additions & 0 deletions collective/js/jqueryui/profiles.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@
description="Install jQuery UI."
provides="Products.GenericSetup.interfaces.EXTENSION" />

<genericsetup:registerProfile
name="uninstall"
title="jQuery UI (uninstall)"
directory="profiles/uninstall"
description="Uninstalls the jQuery UI add-on."
provides="Products.GenericSetup.interfaces.EXTENSION"
/>


<!-- Hide profiles/products from Quick Installer -->
<utility factory=".setuphandlers.HiddenProfiles" name="collective.js.jqueryui" />
<utility factory=".setuphandlers.HiddenProducts" name="collective.js.jqueryui" />
Expand Down
2 changes: 1 addition & 1 deletion collective/js/jqueryui/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<metadata>
<version>3203</version>
<version>3204</version>
<dependencies>
<dependency>profile-collective.js.jqueryui:install-base</dependency>
</dependencies>
Expand Down
6 changes: 6 additions & 0 deletions collective/js/jqueryui/profiles/uninstall/actions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<object name="portal_actions" meta_type="Plone Actions Tool"
xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<object name="jqueryui_panels" meta_type="CMF Action Category" remove="true"/>
<object name="sunburst" meta_type="CMF Action" i18n:domain="collective.js.jqueryui" remove="true"/>
</object>
7 changes: 7 additions & 0 deletions collective/js/jqueryui/profiles/uninstall/browserlayer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<layers>
<layer
name="collective.js.jqueryui"
remove="true"
/>
</layers>
20 changes: 20 additions & 0 deletions collective/js/jqueryui/profiles/uninstall/controlpanel.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<object
name="portal_controlpanel"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
i18n:domain="collective.jqueryuithememanager">

<configlet
title="JQueryUI"
action_id="collective.js.jqueryui"
appId="collective.js.jqueryui"
category="Products"
condition_expr=""
url_expr="string:${portal_url}/@@jqueryui-controlpanel"
icon_expr="string:${portal_url}/++resource++jqueryui_icon.jpg"
visible="True"
i18n:attributes="title"
remove="true">
</configlet>

</object>
7 changes: 7 additions & 0 deletions collective/js/jqueryui/profiles/uninstall/registry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<registry>
<records interface="collective.js.jqueryui.controlpanel.IJQueryUIPlugins" remove="true" />
<records interface="collective.js.jqueryui.controlpanel.IJQueryUICSS" remove="true" />
<records prefix="plone.bundles/jqueryui"
interface='Products.CMFPlone.interfaces.IBundleRegistry' remove="true" />

</registry>
24 changes: 7 additions & 17 deletions collective/js/jqueryui/resources.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
import logging
from copy import copy
from zope import component
from StringIO import StringIO
try:
from zope.component.hooks import getSite
except ImportError:
#BBB
from zope.site.hooks import getSite
from six import StringIO
from plone.registry.interfaces import IRegistry
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import safe_unicode
from Products.Five import BrowserView
from Products.ResourceRegistries.tools.packer import CSSPacker
from Products.ResourceRegistries.tools.packer import JavascriptPacker
from Products.ResourceRegistries.utils import applyPrefix

from collective.js.jqueryui import interfaces, config

from Acquisition import aq_parent
logger = logging.getLogger('collective.js.jqueryui')


Expand Down Expand Up @@ -85,7 +79,7 @@ def get_resources_content(self, resources):
try:
resource = self.context.restrictedTraverse(
resourceid)
except KeyError, e:
except KeyError as e:
logger.error(e)
continue
if not resource:
Expand All @@ -102,13 +96,9 @@ def get_resources_content(self, resources):
fic = open(resource.context.path, 'r')
content = fic.read()
fic.close()
try:
content = unicode(content)

except Exception, e:
content = unicode(content.decode('utf-8'))
content = safe_unicode(content)

#css applyPrefix
# css applyPrefix
if self._css:
upath = upath.rstrip('/')
prefix = '/'.join([upath, resourceid])
Expand All @@ -118,7 +108,7 @@ def get_resources_content(self, resources):
prefix.split('/')[:-1])
content = applyPrefix(content, prefix)

#content is already minified
# content is already minified
data.write(content)
data.write(u"\n")

Expand All @@ -141,7 +131,7 @@ def get_resources(self):
portal_registry"""
settings = self.settings()
deps = config.JQUERYUI_DEPENDENCIES
alljs = deps.keys()
alljs = list(deps.keys())
resources = []
wanted = [] # not ordered list of wanted plugins
tpl = "++resource++jquery-ui/jquery.%s.min.js"
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"Programming Language :: Python",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
],
keywords='plone jqueryui',
author='JeanMichel FRANCOIS aka toutpt',
Expand Down