Truncate titles and author names in carousels

Bug #488470 reported by Lance Arthur
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Open Library
Fix Released
Low
Anand Chitipothu

Bug Description

See: http://upstream.openlibrary.org/subjects/Frozen_fish

When covers are not available, title and author names are sometimes too long to easily fit on the blank covers. The carousel script needs to be altered to include the truncate macro for both titles and authors (70-character limit is standard)

Revision history for this message
George (george-archive) wrote :

70 chars for that amount of space might still be too large. How about 20 for each? Or 30?

We should show the full title and full author in the alt/title so you can read it all if you mouseover.

Changed in openlibrary:
assignee: nobody → Anand Chitipothu (anandology)
milestone: none → upstream
status: New → Confirmed
importance: Undecided → Low
Revision history for this message
Edward Betts (edwardbetts) wrote :

Web.py templates use the same syntax as Python for addressing substrings. To truncate a title to 30 characters write it like this:

page.title[:30]

Or maybe you want to get fancy and add a '…' to the end of truncated strings:

def truncate(s, len):
    if len(s) < len:
        return s
    return s[:len] + "&hellip;"

truncate(page.title, 30)

Revision history for this message
Anand Chitipothu (anandology) wrote :

That is rendered in javascript.
Fixed by adding truncate function to http://upstream.openlibrary.org/js/utils.js and using it in http://upstream.openlibrary.org/templates/lib/covers.tmpl

Changed in openlibrary:
status: Confirmed → Fix Released
Revision history for this message
Anand Chitipothu (anandology) wrote :

forgot to mention, using 40-character limit for truncation.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.