Ticket #4329 (closed Bug: fixed)

Opened 7 years ago

Last modified 3 years ago

LiveSearch results title and desc need truncating

Reported by: jeffk Owned by:
Priority: minor Milestone: 2.1
Component: Templates/CSS Version:
Severity: Keywords:
Cc:

Description

LiveSearch results are a fantastic addition to Plone. I'm doing some tests with ATCT reST documents and finding that long descriptions and titles can make the results somewhat awkward to view. I typically put a sentence or two from the body text into the description, if I don't have time to write a more terse synopsis myself.

See the attached screenshot:

Titles: "SQLObject Compared to Other Database Wrappers" should read something like "SQLObject Compared to Other ...", or the CSS style should support linebreaking of long titles.

Descriptions: I wouldn't have expected it, but even two sentences of moderate length make the results stretch too far down the screen. See the wareweb result. I recommend configuring a truncation to a certain number of characters, stopping on the next whitespace if possible, or a hard character limit if whitespace is not found.

Limiting LiveSearch Results? I won't know until the two suggested truncations are in effect, but I can envision searching for 'python' with my test corpus of 3,500 articles will yeild hundreds of results, too many for the user to appreciate in a CSS construct.

If a LiveSearch configlet is under consideration, it would be very helpful to provide a configurable limit on LiveSearch results, as well as perhaps the truncation parameters above.. In the interim, a constant hardcoded in the source in time for 2.1 would be fine.

Attachments

livesearchtruncated.4.png Download (114 bytes) - added by jeffk 7 years ago.
livesearchtruncated.png

Change History

comment:1 Changed 7 years ago by jok2

There is a variable MAX_DESC in the livescript_reply.py script (set to 55), but it is not used to truncate the description part of the search result.

The search results are limited (10), if more is found then there is a link to the normal search result page.

Changed 7 years ago by jeffk

livesearchtruncated.png

comment:2 Changed 7 years ago by jeffk

I changed livesearch_results.py to implement the changes, if someone wants to check them in. See the attached screenshot for typical results. This is much easier to read than unwrapped titles and full-length descriptions.

A smart algorithm for linebreaking long titles and truncating long descriptions at a word boundary would be nice in a future revision.

Index: skins/plone_scripts/livesearch_reply.py =================================================================== --- skins/plone_scripts/livesearch_reply.py (revision 7592) +++ skins/plone_scripts/livesearch_reply.py (working copy) @@ -21,7 +21,8 @@

# SIMPLE CONFIGURATION USE_ICON = True USE_RANKING = False

-MAX_DESC = 55 +MAX_TITLE = 29 +MAX_DESCRIPTION = 93

# generate a result set for the query

catalog = context.portal_catalog

@@ -69,10 +70,19 @@

print <li class="LSRow">,

print <img src="/%s"/> % result.getIcon,

  • print <a href="%s">%s</a> % (itemUrl, pretty_title_or_id(result))

+ full_title = pretty_title_or_id(result) + if len(full_title) >= MAX_TITLE: + display_title = .join((full_title[:MAX_TITLE],'...')) + else: + display_title = full_title + print <a href="%s" title="%s">%s</a> % (itemUrl, full_title, display_title)

print <span class="discreet">[%s%%]</span> % result.data_record_normalized_score_

  • print <div class="discreet" style="margin-left: 2.5em;">%s</div> % (result.Description)

+ display_description = result.Description + if len(display_description) >= MAX_DESCRIPTION: + display_description = .join((display_description[:MAX_DESCRIPTION],'...')) + print <div class="discreet" style="margin-left: 2.5em;">%s</div> % (display_description)

print </li>

+ full_title, display_title, display_description = None, None, None

if len(results)>limit:

# add a more... row print <li class="LSRow">

comment:3 Changed 7 years ago by optilude

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in svn. Thanks for the patch!

comment:4 Changed 3 years ago by hannosch

  • Component changed from Usability to Templates/CSS
Note: See TracTickets for help on using tickets.