Merge pull request #158 from plone/register_js_in_legacy_bundle

Register old js in legacy bundle to fix missing js
This commit is contained in:
Philip Bauer 2019-06-27 22:24:58 +02:00 committed by GitHub
commit 6cedcc4df6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 38 additions and 45 deletions

View File

@ -135,36 +135,4 @@ comments.py file with our custom version of the comments viewlet::
return "%s/memberhome/%s" % (self.context.portal_url(), username)
To override the comments viewlet template, we create a comment.pt file in the
same directory and copy the contents from::
...
Override the comments viewlet Javascript
----------------------------------------
Overriding the comments viewlet javascript works just like overriding the
comments viewlet. We register the javascript file for our custom browser
layer and remove the existing javascript file in
profiles/default/jsregistry.xml::
<?xml version="1.0"?>
<object name="portal_javascripts">
<!-- Remove plone.app.discussion comments javascript -->
<javascript
id="++resource++plone.app.discussion.javascripts/comments.js"
remove="True"
/>
<!-- Register a custom version of the plone.app.discussion javascript -->
<javascript
id="++resource++example.myaddonproduct.javascripts/comments.js" />
</object>
browser/configure.zcml::
<!-- Resource directory for javascripts -->
<browser:resourceDirectory
name="example.myaddonproduct.javascripts"
directory="javascripts"
layer="example.myaddonprocuts.interfaces.IBrowserLayer"
/>
same directory and copy the contents from the original.

2
news/157.bugfix Normal file
View File

@ -0,0 +1,2 @@
Fix reply to comment by adding old-school js-resources to legacy-bundle. Fix #157
[pbauer]

View File

@ -1,6 +1,7 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:plone="http://namespaces.plone.org/plone"
xmlns:zcml="http://namespaces.zope.org/zcml"
i18n_domain="plone">
@ -129,10 +130,10 @@
/>
<!-- Resource directory for javascripts -->
<browser:resourceDirectory
<plone:static
name="plone.app.discussion.javascripts"
type="plone"
directory="javascripts"
layer="..interfaces.IDiscussionLayer"
/>
<!-- Control panel -->

View File

@ -70,7 +70,7 @@
</div>
<script type="text/javascript"
tal:attributes="src string:${portal_url}/++resource++plone.app.discussion.javascripts/controlpanel.js">
tal:attributes="src string:${portal_url}/++plone++plone.app.discussion.javascripts/controlpanel.js">
</script>
</article>

View File

@ -18,7 +18,7 @@
b_start request/b_start | b_start;
moderation_enabled view/moderation_enabled;">
<script type="text/javascript"
tal:attributes="src string:${context/portal_url}/++resource++plone.app.discussion.javascripts/moderation.js">
tal:attributes="src string:${context/portal_url}/++plone++plone.app.discussion.javascripts/moderation.js">
</script>
<h1 class="documentFirstHeading" i18n:translate="heading_moderate_comments">

View File

@ -1,7 +0,0 @@
<?xml version="1.0"?>
<object name="portal_javascripts">
<javascript
id="++resource++plone.app.discussion.javascripts/comments.js"
insert-after="collapsibleformfields.js"
/>
</object>

View File

@ -1,6 +1,7 @@
<metadata>
<version>1000</version>
<version>1001</version>
<dependencies>
<dependency>profile-plone.resource:default</dependency>
<dependency>profile-plone.app.registry:default</dependency>
</dependencies>
</metadata>

View File

@ -4,4 +4,17 @@
<value key="edit_comment_enabled">False</value>
<value key="delete_own_comment_enabled">False</value>
</records>
<records prefix="plone.resources/plone-app-discussion"
interface='Products.CMFPlone.interfaces.IResourceRegistry'>
<value key="js">++plone++plone.app.discussion.javascripts/comments.js</value>
</records>
<records prefix="plone.bundles/plone-legacy"
interface='Products.CMFPlone.interfaces.IBundleRegistry'>
<value key="resources" purge="false">
<element>plone-app-discussion</element>
</value>
<value key="last_compilation"></value>
</records>
</registry>

View File

@ -61,3 +61,7 @@ def upgrade_comment_workflows(context):
comment.reindexObjectSecurity()
except (AttributeError, KeyError):
logger.info('Could not reindex comment {0}'.format(brain.getURL()))
def add_js_to_plone_legacy(context):
context.runImportStepFromProfile(default_profile, 'plone.app.registry')

View File

@ -51,4 +51,15 @@
/>
</genericsetup:upgradeSteps>
<genericsetup:upgradeSteps
source="1000"
destination="1001"
profile="plone.app.discussion:default">
<genericsetup:upgradeStep
title="Move comment.js into plone-legacy bundle"
description=""
handler=".upgrades.add_js_to_plone_legacy"
/>
</genericsetup:upgradeSteps>
</configure>