Skip to content
This repository has been archived by the owner on Apr 10, 2023. It is now read-only.

Change default search method and results order used when searching for content on internal links #129

Closed
wants to merge 3 commits into from
Closed
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
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ HISTORY
1.4.4 (unreleased)
------------------

- Change default search method and results order used when searching for content on internal links.
Now we search by ``Title`` (as it is faster than ``SearchableText``) and return results sorted by relevance instead of ``sortable_title``.
[hvelarde]

- Update basque translation
[erral]

Expand Down
11 changes: 2 additions & 9 deletions Products/TinyMCE/adapters/JSONSearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,14 @@ def getSearchResults(self, filter_portal_types, searchtext):
query = self.listing_base_query.copy()
query.update({
'portal_type': filter_portal_types,
'sort_on': 'sortable_title',
'path': '/'.join(self.context.getPhysicalPath()),
'SearchableText': searchtext,
'Title': searchtext,
})
if searchtext:
plone_layout = self.context.restrictedTraverse('@@plone_layout',
None)
if plone_layout is None:
# Plone 3
plone_view = self.context.restrictedTraverse('@@plone')
getIcon = lambda brain: plone_view.getIcon(brain).html_tag()
else:
# Plone >= 4
getIcon = lambda brain: plone_layout.getIcon(brain)()

getIcon = lambda brain: plone_layout.getIcon(brain)()
brains = self.context.portal_catalog.searchResults(**query)

catalog_results = [
Expand Down
2 changes: 2 additions & 0 deletions Products/TinyMCE/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def setUpZope(self, app, configurationContext):
import Products.TinyMCE.tests
self.loadZCML(package=Products.TinyMCE.tests,
name='skins.zcml')
z2.installProduct(app, 'Products.DateRecurringIndex')
z2.installProduct(app, 'Products.TinyMCE')
if HAS_DX:
self.loadZCML(package=plone.app.contenttypes)
Expand All @@ -65,6 +66,7 @@ def setUpPloneSite(self, portal):

def tearDownZope(self, app):
"""Tear down Zope."""
z2.uninstallProduct(app, 'Products.DateRecurringIndex')
z2.uninstallProduct(app, 'Products.TinyMCE')


Expand Down
4 changes: 2 additions & 2 deletions Products/TinyMCE/tests/test_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def test_json_search(self):
self.assertRegexpMatches(results, '"id": "events", "icon": null}')

def test_json_search_icon(self):
self.portal.invokeFactory('File', id='somefile.bin')
self.portal.invokeFactory('File', id='somefile.bin', title='Somefile')
linkable_portal_types = self.utility.linkable.split('\n')
linkable_portal_types.extend(self.utility.containsobjects.split('\n'))

Expand All @@ -168,7 +168,7 @@ def test_json_search_icon(self):
r'"id": "somefile.bin", "icon": "<img width=\\"16\\" height=\\"16\\" src=\\"http://nohost/plone/application.png\\" alt=\\"File.*?\\" />"')

def test_json_search_wildcard_whitespace(self):
self.portal.invokeFactory('File', id='somefile bin')
self.portal.invokeFactory('File', id='somefile bin', title='Somefile bin')
linkable_portal_types = self.utility.linkable.split('\n')
linkable_portal_types.extend(self.utility.containsobjects.split('\n'))

Expand Down
4 changes: 2 additions & 2 deletions Products/TinyMCE/tests/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class BrowserTestCase(FunctionalTestCase):

def setUp(self):
super(BrowserTestCase, self).setUp()
self.image = self.portal.invokeFactory('Image', id='image')
self.document = self.portal.invokeFactory('Document', id='document')
self.image = self.portal.invokeFactory('Image', id='image', title='Image')
self.document = self.portal.invokeFactory('Document', id='document', title='Document')

def test_url(self):
# We get the url by specifying the uid of the document.
Expand Down