[SAK-23567] Flexible way to customize cut method for site title in tabs. Created: 01-May-2013  Updated: 29-Nov-2016  Resolved: 13-Jun-2013

Status: CLOSED
Project: Sakai
Component/s: Portal
Affects Version/s: 2.9.2
Fix Version/s: 10.0

Type: Feature Request Priority: Major
Reporter: Juan José Meroño Sánchez Assignee: Aaron Zeckoski (Inactive)
Resolution: Fixed Votes: 3
Labels: PATCH_ADDED

Attachments: JPEG File ###0.100.jpg     JPEG File 50.50 ....jpg     JPEG File 50.50.jpg     JPEG File Default.jpg     JPEG File MoreSites View.jpg     JPEG File PDA View.jpg     Text File SAK-23567.moresites.patch     Text File SAK-23567.patch     Text File SAK-23567.pda.patch     Text File portal_SAK-23567.patch.txt    
Issue Links:
Relate
relates to SAK-23795 Cut site titles in preferences in the... CLOSED
relates to SAK-23725 Include new site property to store cu... CLOSED
is related to SAK-31985 New property needed to control the si... CLOSED
Property addition/change required:
Yes

 Description   

The property site.title.maxlength allow long site titles fix the UI by cutting the end of the title in tabs.

We've got many long site titles and very similar, for example, "This is the subject part I", "This is the subject part II". In these cases both cutted titles appears to be the same "This is the subj...".

We want a more flexible way to do it. With 2 new properties:

site.title.cut.method = customize the cut method. Default 100:0.
site.title.cut.separator = separator string. Default ...

The value has the format X:Y, wich means X percent of maxlength at the beginning and Y percent of maxlength at the end. Now if you choose 50:50 and [...], the above example, will get something like "This is[...]part I" and "This is[...]part II".

  1. Max length for site title display
  2. Default 25 characters
    #site.title.maxlength=25
  1. Cut method for site title display
  2. Default 100:0 display the first site.title.maxlength characters and the separator string at the end
  3. Other values:
  4. 0:100 display the last site.title.maxlength characters and the separator string at the beginning
  5. 50:50 display first site.title.maxlength*50% characters the separator string and the last site.title.maxlength*50%
    #site.title.cut.method=100:0
  1. Separator string used to separate characters in cut method
  2. Default ...
    #site.title.cut.separator= ...


 Comments   
Comment by Juan José Meroño Sánchez [ 01-May-2013 ]

I've added screenshots with different methods to cut site title.

Comment by Aaron Zeckoski (Inactive) [ 09-May-2013 ]

From a technical perspective, this should:
a) Not change the current mechanism by default
b) Move the processing logic to a single method (rather than putting it in the middle of the existing method)
c) Add some unit tests to verify the functionality - especially cases with odd sized titles (1-2 chars, 5 chars, etc.)

Will be happy to review after

Comment by Juan José Meroño Sánchez [ 17-May-2013 ]

Processing logic moved to single method, and unit testing.

Comment by Juan José Meroño Sánchez [ 17-May-2013 ]

I don't know if percentage values are too tricky for this purposes, maybe I can use number of characters instead of percentage:

site.title.maxlength=25
site.title.cut.method=13:12

Comment by Juan José Meroño Sánchez [ 23-May-2013 ]

In addition to that, I uploaded a patch for neoskin 'More Sites' view, to use the siteTitle instead of fullTitle. Right now, it is using css ellipsis to truncate titles and I thing it should use the same method. I don't know if this shoud be a different jira related to this one, but I want to add to it to the discussion.

Comment by Juan José Meroño Sánchez [ 24-May-2013 ]

In the pda view you see the brief titles, but you aren't able to see the full title because hover doesn't work in mobiles. So I add a patch to show fullTitles os sites all across the pda view. See screenshot.

Comment by Megan May [ 30-May-2013 ]

From CLE Team meeting. Let's float this feature to the dev list . . . Anthony Whyte has offered to review a draft.

Comment by Aaron Zeckoski (Inactive) [ 30-May-2013 ]

Leave out the "SAK-23567.pda.patch" part for now since it uses the full site title instead of the truncated one (which is inconsistent and also seems to be the reverse of the desired mechanism when there is limited screen space)

Comment by Jose Mariano Lujan [ 31-May-2013 ]

Steve Swingsburg comment on sakai-dev:

It probably too configurable, I would just use the current site length and code it to use stringutils abbreviateMiddle. Maybe a property to control either the abbreviateMiddle or the normal abbreviate method, but percentages is a bit overkill when it's a fixed property.

Comment by Jose Mariano Lujan [ 31-May-2013 ]

What you describe seems like a reasonable simplification that will make configuration much easier, and also could be totally open.
If we could add a property value with an Interface, something like:

site.title.cut.method=org.sakaiproject.util.Abbreviator
site.title.maxlength=25
#site.title.cut.separator= (Not needed, ... by default in both provided implementations)

We could provide as the default implementation StringUtils.abbreviate, and an alternative implementation StringUtils.abbreviateMiddle, and therefore, anyone could create his own custom implementation by adding other abbreviate functionalities like for example: replace Mister with Mr. or things like that.

Less configuration but more configurable

Comment by Steve Swinsburg [ 31-May-2013 ]

Yes, except the cut method config looks like its a class, when really it just needs to be a simple string config, since it can be done in one line of code for each method.

site.title.cut.method=abbreviate | abbreviateMiddle | truncate

pseudocode, you'll need to check the API:

if(StringUtils.equals(cutMethod, "abbreviate")) {
siteTitle = StringUtils.abbreviate(siteTitle, length);
} else if (StringUtils.equals(cutMethod, "abbreviateMiddle")) {
siteTitle = StringUtils.abbreviateMiddle(siteTitle, length);
} else if (StringUtils.equals(cutMethod, "truncate")) {
siteTitle = StringUtils.substring(siteTitle, 0, length);
}

Comment by Louis Algaze [ 31-May-2013 ]

We have a relatively complicated naming convention similar to yours and would appreciate a feature like this.

Our convention is "siteID: Title (quarter_instructorInitials)" I.e. "GE1000: Introduction to Mathematics (FA13_LA)" with the siteID being a fixed length always followed by a colon and the other important information in parentheses which may vary in length. We also have Project sites which have no structure to the title.

We would love to see the course be shortened to "SiteID (quarter_instructorInitials)" I.e. "GE1000 (FA13_LA)" or similar while leaving the Project site titles alone.

For ultimate flexibility what about have a single property which specifies a regex string? The ability to apply the rules to only a particular type of site would be helpful as well.

----------------------- update
I'd like to change my vote to including an optional site property (possibly available to instructors in the Site Editor > Edit Site Information) which is the short title of the site that is displayed in the quicklinks, if this property is empty, the full title is used. Even with regex there are always exceptions to the rule.

Comment by Juan José Meroño Sánchez [ 01-Jun-2013 ]

Maybe a site property could be the best solution. The code would be like:

private static final String PROP_ABBREVIATED_TITLE = "sakai:abbreviatedTitle";

int siteTitleMaxLength = ServerConfigurationService.getInt("site.title.maxlength", 25);
String cutMethod = ServerConfigurationService.getString("site.title.cut.method", "abbreviate");
String fullTitle = s.getTitle();
String titleStr = s.getProperties().getProperty(PROP_ABBREVIATED_TITLE);
if (StringUtils.isBlank(titleStr)) titleStr = fullTitle;
if (StringUtils.equals(cutMethod,"abbreviateMiddle"))

{ StringUtils.abbreviateMiddle(titleStr,"...",siteTitleMaxLength); }

else if (StringUtils.equals(cutMethod,"abbreviate"))

{ StringUtils.abbreviate(titleStr,siteTitleMaxLength); }

Now you can add in the site property any customized title you want, and this value will also abbreviated (to ensure the maxlength). With this code if you set site.title.cut.method=none (or anything different to abbreviate or abbreviateMiddle), the site title/property won't be abbreviated and could exceed the maxlength.

Comment by Alexandre Ballesté [ 06-Jun-2013 ]

I also add my vote to include it with the option to override the values of sakai.properties if site properties are defined. Cool solution.

Comment by Aaron Zeckoski (Inactive) [ 13-Jun-2013 ]

We are going to go forward with this patch as is (maybe with some minor tweaks). If more flexibility is needed then the CLE team suggests opening a new JIRA for that and linking/referencing this one.

Comment by Aaron Zeckoski (Inactive) [ 13-Jun-2013 ]

Attaching a unified patch of what was applied to trunk

Comment by Aaron Zeckoski (Inactive) [ 13-Jun-2013 ]

Docs added

      1. SAK-23567 Flexible way to shorten site title in tabs
    1. Max length for site title display
  1. Default 25 characters
    #site.title.maxlength=25
    1. Abbreviation method for site title display
  2. Examples:
  3. 0:100 display the last site.title.maxlength characters and the separator string at the beginning
  4. 50:50 display first site.title.maxlength*50% characters the separator string and the last site.title.maxlength*50%
  5. Default: 100:0 (display the first {site.title.maxlength}

    characters and the separator string at the end)
    #site.title.cut.method=100:0

    1. Separator string used to separate characters in cut method
  6. Default "..." (three dots)
    #site.title.cut.separator=***
Comment by Aaron Zeckoski (Inactive) [ 13-Jun-2013 ]

Ready for QA

Comment by Hudson CI Server [ 13-Jun-2013 ]

Integrated in portal trunk #1565 (See http://builds.sakaiproject.org:8080/job/portal%20trunk/1565/)
SAK-23567 Fixing headers and weird duplication in merge (Revision 125740)

Result = SUCCESS

Generated at Sun Sep 22 08:26:40 CDT 2019 using Jira 8.0.3#800011-sha1:073e8b433c2c0e389c609c14a045ffa7abaca10d.