From 67c3e6787e13e2da45f1590508f93b5c25053d0d Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Thu, 9 Mar 2017 09:04:11 +0100 Subject: [PATCH 1/2] fix #1811: Remove last legacy Javascript highlight-searchterms.js and its skins folder. ref #1801 --- CHANGES.rst | 178 ++++++++++++++ Products/CMFPlone/profiles/default/skins.xml | 3 - .../profiles/dependencies/registry.xml | 11 +- .../jquery.highlightsearchterms.js | 218 ------------------ .../CMFPlone/tests/testCSSandJSRegistry.py | 1 - 5 files changed, 180 insertions(+), 231 deletions(-) delete mode 100644 Products/CMFPlone/skins/plone_ecmascript/jquery.highlightsearchterms.js diff --git a/CHANGES.rst b/CHANGES.rst index 18c9158e88..5850cbbd77 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -13,6 +13,184 @@ Breaking changes: - Remove all dependencies on plone.app.controlpanel. Third party code need either to depend on plone.app.controlpanel 4.0, which is a backward compatibilit package only, or also update to not depend on it anymore. +- *add item here* + +New features: + +- Adapt code and tests to the new indexing operations queueing. + Part of PLIP 1343: https://github.com/plone/Products.CMFPlone/issues/1343 + [gforcada] + +Bug fixes: + +- Show version of products in Add-ons control panel configlet. + This fixes https://github.com/plone/Products.CMFPlone/issues/1472. + [hvelarde] + +- Resource registry legacy bundle cooking: Exit early with a warning, if preconditions to build are not given (no compilation paths). + Allow cooking CSS, even if no JS is defined. + Log all important steps of the cooking process. + [thet] + +- Remove unused ``plone.css`` from static repository. + [thet] + +- Check for ``AccessInactivePortalContent`` for each path in a catalog query. + This solves a problem, where Editors couldn't see inactive content, even though they had the required permission on a subpath of the portal (e.g. a subsite). + [thet] + +- Remove last legacy Javascript ``highlight-searchterms.js``. + Removes also the skins folder ``plone_ecmascript``. + It was broken for all (Google, other search engines, own live search); + JS worked only when coming from Plone detailed search. + [jensens] + + +5.1b2 (2017-02-20) +------------------ + +Bug fixes: + +- Fix packaging error. + [esteele] + +5.1b1 (2017-02-20) +------------------ + +Breaking changes: + +- Add helper method to get all catalog entries from a given catalog: ``Products.CMFPlone.CatalogTool.catalog_get_all``. + In Products.ZCatalog before 4.0 a catalog call without a query returned all catalog brains. + This can be used as a replacement where it is needed, for exampe in tests. + [thet, gogobd] + +- Remove ``query_request`` from CatalogTool's search method, as it isn't supported in Products.ZCatalog 4 anymore. + [thet] + +- Removed our patch that added ``secureSend`` to the ``MailHost``. + This was originally scheduled for removal in Plone 5.0. See `issue + 965 `_. + [maurits] + +- The related items widget has changed a lot. + See the Mockup changelog for 2.4.0 here: https://github.com/plone/mockup/blob/master/CHANGES.rst + +- All css classes named ``enableUnloadProtection`` were changed to ``pat-formunloadalert`` to trigger that pattern. + Templates using ``enableUnloadProtection`` should change to ``pat-formunloadalert`` too. + This change shouldn't impact too much, because the form unload protection didn't work at all in Plone 5 until now. + [thet] + +- MimetypesRegistry icons are now a browser resource directory instead of skins folder. + [jensens] + +- Remove unused ``plone_scripts`` (not used nor tested anywhere in coredev) [jensens, davisagli] + + - ``add_ext_editor.py`` + - ``author_find_content.py`` + - ``canSelectDefaultPage.py`` with tests + - ``create_query_string.py`` + - ``createMultiColumnList.py`` + - ``displayContentsTab.py`` + - ``formatColumns.py`` with tests + - ``getAllowedTypes.py`` + - ``getGlobalPortalRoles.py`` + - ``getNotAddableTypes.py`` + - ``getPopupScript.py`` + - ``getPortalTypeList.py`` and metadata + - ``getPortalTypes.py`` + - ``getSelectableViews.py`` with tests + - ``hasIndexHtml.py`` with tests + - ``navigationParent.py`` with test + - ``plone_log.py`` + - ``plone.css.py`` + - ``returnNone.py`` with occurence refactored + - ``reverseList.py`` with test + - ``sort_modified_ascending.py`` + +- Move scripts ``datecomponents.py`` and ``show_id.py`` to Archetypes + [jensens, davisagli] + +- Remove methods of the ``@@plone`` view that were marked for deprecation: + - ``showEditableBorder`` (use ``@@plone/showToolbar``) + - ``mark_view`` (use ``@@plone_layout/mark_view``) + - ``hide_columns`` (use ``@@plone_layout/hide_columns``) + - ``icons_visible`` (use ``@@plone_layout/icons_visible``) + - ``getIcon`` (use ``@@plone_layout/getIcon``) + - ``have_portlets`` (use ``@@plone_layout/have_portlets``) + - ``bodyClass`` (use ``@@plone_layout/bodyClass``) + [davisagli] + +- Move plone_content skin templates into Products.ATContentTypes as browser views. + [gforcada] + +New features: + +- Added ``ok`` view. This is useful for automated checks, for example + httpok, to see if the site is still available. It returns the text + ``OK`` and sets headers to avoid caching. + [maurits] + +- Make contact form extensible. This fixes https://github.com/plone/Products.CMFPlone/issues/1879. + [timo] + +- Don't minify CSS or JavaScript resources if they end with ``.min.css`` resp. ``.min.js``. + [thet] + +- Add ``safe_encode`` utility function to ``utils`` to safely encode unicode to a specified encoding. + The encoding defaults to ``utf-8``. + [thet] + +- The password reset templates were changed to make use of ``content-core`` macros. + [thet] + +- Add utility method to retrieve the top most parent request from a sub request. + [thet] + +- Add ``mockup-patterns-relateditems-upload`` resource, which can be used in custom bundles to add the upload feature in the related items widget. + [thet] + +- Move ``get_top_site_from_url`` from plone.app.content to ``utils.py`` and make it robust against unicode paths. + This function allows in virtual hosting environments to acquire the top most visible portal object to operate on. + It is used for example to calculate the correct virtual root objects for Mockup's related items and structure pattern. + [thet] + +- Add sort_on field to search controlpanel. + [rodfersou] + +- PLIP 1340: Deprecate portal_quickinstaller. + You should no longer use CMFQuickInstallerTool methods, but GenericSetup profiles. + See https://github.com/plone/Products.CMFPlone/issues/1340 + [maurits] + +- Include mockup 2.4.0. + [thet] + +- PasswordResetTool moved from its own package to here (includes cleanup and removal of ``getStats``). + [tomgross] + +- Prevent workflow menu overflowing in toolbar [MatthewWilkes] + +- Add default icon for top-level contentview and contentmenu toolbar entries [alecm] + +- Toolbar: Make menu hover background fit whole menu width. [thet] + +- Toolbar: Don't force scoll buttons to be left, when toolbar is right. [thet] + +- Toolbar: Make first level list items exand the whole toolbar width - also when scroll buttons are shown. [thet] + +- Toolbar: Make scroll buttons exand whole toolbar width. [thet] + +- Toolbar: Let the toolbar submenus be as wide as they need to be and do not break entries into multiple lines. [thet] + +- Resource Registry: + In ``debug-mode`` (zope.conf, buildout) do not load cache the production bundle. + [jensens] + +- Resource Registry: + In ``debug-mode`` (zope.conf, buildout) do not ignore development mode for anonymous users. + [jensens] + +- Resource Registry: If file system version is newer than ``last_compilation`` date of a bundle, use this as ``last_compilation`` date. [jensens] - New browser view based login code - merged from plone.login (credits to esteele, pbauer, agitator, jensens, et al). diff --git a/Products/CMFPlone/profiles/default/skins.xml b/Products/CMFPlone/profiles/default/skins.xml index 5ac4748c4c..b8be444eff 100644 --- a/Products/CMFPlone/profiles/default/skins.xml +++ b/Products/CMFPlone/profiles/default/skins.xml @@ -3,8 +3,6 @@ cookie_persistence="False" default_skin="Plone Default" request_varname="plone_skin"> - - diff --git a/Products/CMFPlone/profiles/dependencies/registry.xml b/Products/CMFPlone/profiles/dependencies/registry.xml index 24fe2aa660..92f0f21287 100644 --- a/Products/CMFPlone/profiles/dependencies/registry.xml +++ b/Products/CMFPlone/profiles/dependencies/registry.xml @@ -1071,14 +1071,8 @@ ++plone++static/components/jquery.recurrenceinput.js/lib/jquery.tmpl.js jquery - - - - - jquery.highlightsearchterms.js - - + + Last legacy js/css import date @@ -1230,7 +1224,6 @@ interface='Products.CMFPlone.interfaces.IBundleRegistry'> default - jquery-highlightsearchterms plone ++plone++static/plone-legacy-compiled.js diff --git a/Products/CMFPlone/skins/plone_ecmascript/jquery.highlightsearchterms.js b/Products/CMFPlone/skins/plone_ecmascript/jquery.highlightsearchterms.js deleted file mode 100644 index e0ba2c36a2..0000000000 --- a/Products/CMFPlone/skins/plone_ecmascript/jquery.highlightsearchterms.js +++ /dev/null @@ -1,218 +0,0 @@ -/* - Provides $.fn.highlightSearchTerms - - applies it to $('#region-content,#content') on page load, - but ignore referrals from our own domain -*/ - -/*jslint nomen:false */ - - -(function($) { - var Highlighter, - makeSearchKey, - makeAddress, - defaults; - - Highlighter = function (options) { - $.extend(this, options); - this.terms = this.cleanTerms(this.terms.length ? this.terms : this.getSearchTerms()); - }; - Highlighter.prototype = { - highlight: function(startnode) { - // Starting at startnode, highlight the terms in the tree - if (!this.terms.length || !startnode.length) {return;} - - var self = this; - $.each(this.terms, function(i, term) { - startnode.find('*:not(textarea)').andSelf().contents().each(function() { - if (this.nodeType === 3) { - self.highlightTermInNode(this, term); - } - }); - }); - }, - - highlightTermInNode: function(node, word) { - // wrap every occurance of word within node in a span with - // options className. - // word is a String, node a DOM TextNode - var c = node.nodeValue, - self = this, - highlight, - ci, - index, - next; - - if ($(node).parent().hasClass(self.highlightClass)) {return;} - - // Internet Explorer cannot create simple tags without content - // otherwise it'd be $('').addClass(...).text(content) - highlight = function(content) { - return $(' ').text(content); - }; - - ci = self.caseInsensitive; - while (c && (index = (ci ? c.toLowerCase() : c).indexOf(word)) > -1) { - // replace the node with [before]word[after] - $(node) - .before(document.createTextNode(c.substr(0, index))) - .before(highlight(c.substr(index, word.length))) - .before(document.createTextNode(c.substr(index+word.length))); - next = node.previousSibling; // text after the span - $(node).remove(); - // wash, rinse and repeat - node = next; c = node.nodeValue; - } - }, - - queryStringValue: function(uri, regexp) { - // Return the decoded value of the key=value pair in the query string - // uri is the full URI including qs, regexp is a /key=(.*)/ pattern - var match, pair; - - if (uri.indexOf('?') < 0) {return '';} - uri = uri.substr(uri.indexOf('?') + 1); - while (uri.indexOf('=') >= 0) { - uri = uri.replace(/^\&*/, ''); - pair = uri.split('&', 1)[0]; - uri = uri.substr(pair.length); - match = pair.match(regexp); - if (match) { - return decodeURIComponent( - match[match.length-1].replace(/\+/g, ' ')); - } - } - return ''; - }, - - termsFromReferrer: function() { - // Find search terms from the referrer, if a recognized search engine - var ref, i, se; - - ref = $.fn.highlightSearchTerms._test_referrer !== null ? - $.fn.highlightSearchTerms._test_referrer : - document.referrer; - if (!ref) {return '';} - - for (i = 0; i < this.referrers.length; i+=1) { - se = this.referrers[i]; - if (ref.match(se.address)) {return this.queryStringValue(ref, se.key);} - } - return ''; - }, - - cleanTerms: function(terms) { - var self = this; - return $.unique($.map(terms, function(term) { - term = $.trim(self.caseInsensitive ? term.toLowerCase() : term); - return (!term || self.filterTerms.test(term)) ? null : term; - })); - }, - - getSearchTerms: function() { - var terms = [], - uri = $.fn.highlightSearchTerms._test_location !== null ? - $.fn.highlightSearchTerms._test_location : - location.href; - if (this.useReferrer) { - $.merge(terms, this.termsFromReferrer().split(/\s+/)); - } - if (this.useLocation) { - $.merge(terms, this.queryStringValue(uri, this.searchKey).split(/\s+/)); - } - return terms; - } - }; - - makeSearchKey = function(key) { - return (typeof key === 'string') ? new RegExp('^' + key + '=(.*)$', 'i') : key; - }; - makeAddress = function(addr) { - return (typeof addr === 'string') ? new RegExp('^https?://(www\\.)?' + addr, 'i') : addr; - }; - - $.fn.highlightSearchTerms = function(options) { - // Wrap terms in a span with class highlightedSearchTerm. - // See defaults for options - options = $.extend({}, defaults, options); - options = $.extend(options, { - searchKey: makeSearchKey(options.searchKey), - referrers: $.map(options.referrers, function(se) { - return { - address: makeAddress(se.address), - key: makeSearchKey(se.key) - }; - }) - }); - if (options.includeOwnDomain) { - var hostname = $.fn.highlightSearchTerms._test_location !== null ? - $.fn.highlightSearchTerms._test_location : location.hostname; - options.referrers.push({ - address: makeAddress(hostname.replace(/\./g, '\\.')), - key: options.searchKey - }); - } - new Highlighter(options).highlight(this); - - return this; - }; - - // defaults referrers is public for easy copying (for extending the - // list) or even inplace alteration if you are so inclined. - $.fn.highlightSearchTerms.referrers = [ // List based on http://fucoder.com/code/se-hilite/ - { address: 'google\\.', key: 'q' }, // Google - { address: 'search\\.yahoo\\.', key: 'p' }, // Yahoo - { address: 'search\\.msn\\.', key: 'q' }, // MSN - { address: 'search\\.live\\.', key: 'query' }, // MSN - { address: 'search\\.aol\\.', key: 'userQuery' }, // AOL - { address: 'ask\\.com', key: 'q' }, // AOL - { address: 'altavista\\.', key: 'q' }, // AltaVista - { address: 'feedster\\.', key: 'q' } // Feedster - ]; - - defaults = { - // array of terms to highlight; if empty we'll look up terms from the - // location and referrer - terms: [], - - // Use the current location query string? If so, use searchKey to find - // what query parameter to use; it's either a string or a regexp, the - // former will be turned into a regexp matching /^[searchKey]=(.*)$/i. - // Note that the last group in a match *must* contain the terms. - useLocation: true, - searchKey: '(searchterm|SearchableText)', - - // Use the referrer to detect search engine queries? If so, use - // referrers to detect these and their search keys. Is an - // array of {address, key} entries; key is treated as searchKey - // above, with address turned into '^https?://(www\.)?[address]' - // regular expressions, if not already a regexp. - useReferrer: true, - referrers: $.fn.highlightSearchTerms.referrers, - - // Should the current domain name and searchKey be included in - // the referrers? - includeOwnDomain: true, - - // Are terms matched case insensitive? - caseInsensitive: true, - // what terms are never to be highlighted (regexp)? - filterTerms: /(not|and|or)/i, - // What class is used to mark highlighted search terms? - highlightClass: 'highlightedSearchTerm' - }; - - // Internal use only, test framework hooks. - $.fn.highlightSearchTerms._test_location = null; - $.fn.highlightSearchTerms._test_referrer = null; - $.fn.highlightSearchTerms._highlighter = Highlighter; -}(jQuery)); - -jQuery(function($) { - // Highlight search results, but ignore referrals from our own domain - // when displaying search results. - $('#region-content,#content').highlightSearchTerms({ - includeOwnDomain: $('dl.searchResults').length === 0 - }); -}); diff --git a/Products/CMFPlone/tests/testCSSandJSRegistry.py b/Products/CMFPlone/tests/testCSSandJSRegistry.py index 11843cc8f6..cfb8d4c553 100644 --- a/Products/CMFPlone/tests/testCSSandJSRegistry.py +++ b/Products/CMFPlone/tests/testCSSandJSRegistry.py @@ -62,7 +62,6 @@ def testDefaultJSIsInstalled(self): ) expected = [ '++resource++plone.js', - 'jquery.highlightsearchterms.js' ] js_files = {x.js for x in installedResources.values()} for e in expected: From e261d98f5f95c46c30ed6e296d8f5694dbaedf7c Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Tue, 7 Aug 2018 19:37:34 +0200 Subject: [PATCH 2/2] fix merge mistake --- CHANGES.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 5850cbbd77..f6f162c0ad 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -25,6 +25,13 @@ Bug fixes: - Show version of products in Add-ons control panel configlet. This fixes https://github.com/plone/Products.CMFPlone/issues/1472. +- Remove last legacy Javascript ``highlight-searchterms.js``. + Removes also the skins folder ``plone_ecmascript``. + It was broken for almost all use cases (Google, other search engines, own live search); + JS worked only when coming from Plone detailed search page. + [jensens] + +- Get rid of obsolete ``X-UA-Compatible`` header. [hvelarde] - Resource registry legacy bundle cooking: Exit early with a warning, if preconditions to build are not given (no compilation paths).