Skip to content

Commit

Permalink
Do not install ck_ruid_to_url anymore
Browse files Browse the repository at this point in the history
Related upgrade step
  • Loading branch information
gotcha committed Dec 14, 2023
1 parent e000813 commit bde38f4
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 439 deletions.
4 changes: 4 additions & 0 deletions docs/HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ Changelog
5.0.0b4 (unreleased)
--------------------

- Unregister ck_ruid_to_url as plone.outputfilters come with the same feature.
[gotcha]

- Include CKeditor resources only when user is logged in.
[gotcha]


5.0.0b3 (2023-11-13)
Expand Down
2 changes: 1 addition & 1 deletion src/collective/ckeditor/browser/ckeditorsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class ICKEditorBrowserSchema(Interface):
title=_(u"Allow link objects by UID"),
description=_(u"Check if you want url with Unique ID "
"(no more 404 errors when moving objects). "
"Notice that portal_transforms in standard "
"Notice that plone.outputfilters in standard "
"configuration transforms uid links in absolute urls "
"in view displays."),
default=True,
Expand Down
5 changes: 0 additions & 5 deletions src/collective/ckeditor/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@
'Link', 'Unlink','-','About']
]"""

# quintagroup.com (from qPloneResolveUID product)
DOCUMENT_DEFAULT_OUTPUT_TYPE = "text/x-html-safe"
REQUIRED_TRANSFORM = "ck_ruid_to_url"

# taken from collective/ckeditor/_src/ckeditor/_source/plugins/scayt/plugin.js
# XXX warning order language correctly because if several values for the same
# main language, the first defined language will be used as fallback when
# trying to find SCAYT language to use when enableScaytOnStartup is True
Expand Down
2 changes: 1 addition & 1 deletion src/collective/ckeditor/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<metadata>
<version>5000</version>
<version>5010</version>
<dependencies>
<dependency>profile-collective.plonefinder:default</dependency>
<dependency>profile-collective.quickupload:default</dependency>
Expand Down
12 changes: 12 additions & 0 deletions src/collective/ckeditor/profiles/to5010/registry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<registry>
<records prefix="plone.bundles/collective.ckeditor.ckeditor_vars" interface="Products.CMFPlone.interfaces.IBundleRegistry">
<value key="expression">python: member is not None</value>
</records>
<records prefix="plone.bundles/collective.ckeditor.ckeditor_js" interface="Products.CMFPlone.interfaces.IBundleRegistry">
<value key="expression">python: member is not None</value>
</records>
<records prefix="plone.bundles/collective.ckeditor.ckeditor_plone" interface="Products.CMFPlone.interfaces.IBundleRegistry">
<value key="expression">python: member is not None</value>
</records>
</registry>
38 changes: 1 addition & 37 deletions src/collective/ckeditor/setuphandlers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from collective.ckeditor import LOG
from collective.ckeditor.config import DOCUMENT_DEFAULT_OUTPUT_TYPE, \
REQUIRED_TRANSFORM
from Products.CMFPlone.utils import getToolByName
from Products.CMFPlone.interfaces import INonInstallable
from plone.registry.interfaces import IRegistry
Expand All @@ -15,10 +13,6 @@ def importFinalSteps(context):
if context.readDataFile('collective.ckeditor.txt') is None:
return
site = context.getSite()
registerTransform(site, 'ck_ruid_to_url',
'collective.ckeditor.transforms.ck_ruid_to_url')
registerTransformPolicy(site, DOCUMENT_DEFAULT_OUTPUT_TYPE,
REQUIRED_TRANSFORM)
LOG.info('CKEditor for Plone installed')


Expand All @@ -29,40 +23,9 @@ def uninstallSteps(context):
uninstallControlPanel(site)
uninstallFromRegistry(site)
uninstallMemberProperties(site)
unregisterTransform(site, 'ck_ruid_to_url')
unregisterTransformPolicy(site, DOCUMENT_DEFAULT_OUTPUT_TYPE,
REQUIRED_TRANSFORM)
LOG.info('CKEditor for Plone uninstalled')


def registerTransform(context, name, module):
transforms = getToolByName(context, 'portal_transforms')
if name not in transforms.objectIds():
transforms.manage_addTransform(name, module)
LOG.info("Registered transform '%s'" % name)
else:
LOG.info("Transform '%s' always registered" % name)


def registerTransformPolicy(context, output_mimetype, required_transform):
transforms = getToolByName(context, 'portal_transforms')
tpolicies = transforms.listPolicies()
mimetype_registered = False
for p in tpolicies:
out_type = p[0]
if out_type == output_mimetype:
policies = list(p[1])
if required_transform not in policies:
policies.append(required_transform)
transforms.manage_delPolicies([output_mimetype])
transforms.manage_addPolicy(output_mimetype, policies)
mimetype_registered = True
break
if not mimetype_registered:
transforms.manage_addPolicy(output_mimetype, [required_transform])
LOG.info("Registered policy for '%s' mimetype" % output_mimetype)


def uninstallControlPanel(context):
"""
Uninstall CKeditor control panel
Expand Down Expand Up @@ -164,4 +127,5 @@ def getNonInstallableProfiles(self):
"collective.ckeditor:uninstall",
"collective.ckeditor:to4350",
"collective.ckeditor:to4330",
"collective.ckeditor:to5010",
]
25 changes: 0 additions & 25 deletions src/collective/ckeditor/tests/installation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,3 @@ Control resource bundles in registry
>>> ckbundles = [name for name in bundles if name.startswith("collective.ckeditor")]
>>> len(ckbundles) == 3
True

Control portal_transforms installation
--------------------------------------

>>> transforms = getToolByName(portal, 'portal_transforms')
>>> output_mimetype = 'text/x-html-safe'
>>> cke_transform = 'ck_ruid_to_url'

Control if cke_transform is here

>>> cke_transform in transforms.objectIds()
True

Control if ckeditor policies are registered
>>> tpolicies = transforms.listPolicies()
>>> mimetype_registered = False
>>> for p in tpolicies :
... out_type = p[0]
... if out_type == output_mimetype :
... policies = p[1]
... if cke_transform in policies :
... mimetype_registered = True
... break
>>> mimetype_registered
True
1 change: 0 additions & 1 deletion src/collective/ckeditor/tests/test_doctests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
'ckeditor_jsconfig.txt',
'uninstall.txt',
'widget.txt',
'transform_uids.txt',
]


Expand Down
207 changes: 0 additions & 207 deletions src/collective/ckeditor/tests/test_transform.py

This file was deleted.

Loading

0 comments on commit bde38f4

Please sign in to comment.