Skip to content

Commit

Permalink
SAK-33662: abbreviated site title missing in Sakai 11.5+ (sakaiprojec…
Browse files Browse the repository at this point in the history
…t#5048)

* SAK-33662: abbreviated site title missing in Sakai 11.5+

* SAK-33662: add full site title to tooltip in preferences > sites

* SAK-33662: re-add reference to local JIRA...
  • Loading branch information
bjones86 authored and ottenhoff committed Dec 1, 2017
1 parent a60622f commit cde5b41
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,9 @@ public Map convertSiteToMap(HttpServletRequest req, Site s, String prefix,
.equals(myWorkspaceSiteId))));

String siteTitle = getUserSpecificSiteTitle(s, false, true, siteProviders);
String siteTitleTruncated = FormattedText.makeShortenedText(siteTitle, null, null, null);
m.put("siteTitle", siteTitle);
m.put("siteTitleTrunc", siteTitleTruncated);
m.put("fullTitle", siteTitle);

m.put("siteDescription", s.getHtmlDescription());
Expand Down Expand Up @@ -500,7 +502,11 @@ public Map convertSiteToMap(HttpServletRequest req, Site s, String prefix,
log.debug("PWD[{}]={}{}", i, site.getId(), site.getTitle());
Map<String, Object> pm = new HashMap<>();
List<String> providers = getProviderIDsForSite(site);
pm.put("siteTitle", getUserSpecificSiteTitle(site, false, true, providers));

String parentSiteTitle = getUserSpecificSiteTitle(site, false, true, providers);
String parentSiteTitleTruncated = FormattedText.makeShortenedText(parentSiteTitle, null, null, null);
pm.put("siteTitle", parentSiteTitle);
pm.put("siteTitleTrunc", parentSiteTitleTruncated);
pm.put("siteUrl", siteUrl + Web.escapeUrl(getSiteEffectiveId(site)));

l.add(pm);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#if (!${site.isMyWorkspace} && (${site.favorite} == "true" || ${site.isCurrentSite} || !${userIsLoggedIn}))
<li class="Mrphs-sitesNav__menuitem #if (${site.isCurrentSite}) is-selected #end">
<a class="link-container" href="${site.siteUrl}" title="${site.fullTitle}">
<span>#if ( ( ${tabDisplayLabel} == 2 ) && ( ${site.shortDescription} ) )${site.shortDescription}#else${site.siteTitle}#end</span>
<span>#if ( ( ${tabDisplayLabel} == 2 ) && ( ${site.shortDescription} ) )${site.shortDescription}#else${site.siteTitleTrunc}#end</span>
</a>
<a class="Mrphs-sitesNav__dropdown" href="#" data-site-id="${site.siteId}" role="separator"></a>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@
#end

<div class="fav-title #if (${site.isMyWorkspace}) fav-title-myworkspace #end">
<a href="${site.siteUrl}" title="${site.siteUrl}">
<a href="${site.siteUrl}" title="${site.siteTitle}">
#if (${site.isMyWorkspace})
<i class="fa fa-home" aria-hidden="true"></i><span class="fullTitle">${rloader.sit_mywor}</span>
#elseif ( ( ${tabDisplayLabel} == 2 ) && ( ${site.shortDescription} ) )
<span class="fullTitle">${site.shortDescription}</span>
#else
<span class="fullTitle">${site.siteTitle}</span>
<span class="fullTitle">${site.siteTitleTrunc}</span>
#end
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -809,12 +809,20 @@ public String getTabTitle()
* title (default behaviour)
*
* @param site the site in question
* @param truncate whether or not to truncate the site title for display purposes
* @return the site or section title
*/
public static String getUserSpecificSiteTitle( Site site )
public static String getUserSpecificSiteTitle( Site site, boolean truncate )
{
String retVal = SiteService.getUserSpecificSiteTitle( site, UserDirectoryService.getCurrentUser().getId() );
return Web.escapeHtml( FormattedText.makeShortenedText( retVal, null, null, null ) );
if (truncate)
{
return Web.escapeHtml( FormattedText.makeShortenedText( retVal, null, null, null ) );
}
else
{
return Web.escapeHtml( retVal );
}
}

/**
Expand Down Expand Up @@ -2303,7 +2311,7 @@ public SiteOverrideBean(String siteId, String option) {

try {
Site site = SiteService.getSite(siteId);
this.siteTitle = getUserSpecificSiteTitle(site);
this.siteTitle = getUserSpecificSiteTitle(site, true);
} catch (IdUnusedException e) {
LOG.warn("Unable to get Site object for id: " + siteId, e);
}
Expand Down Expand Up @@ -2358,7 +2366,7 @@ public DecoratedSiteTypeBean(String typeKey, String typeText, List<DecoratedSite
this.defaultOpen = defaultOpen;

for (DecoratedSiteBean dsb : sites) {
sitesAsSelects.add(new SelectItem(dsb.getSite().getId(), getUserSpecificSiteTitle(dsb.getSite())));
sitesAsSelects.add(new SelectItem(dsb.getSite().getId(), getUserSpecificSiteTitle(dsb.getSite(), true)));
}
}

Expand Down Expand Up @@ -2617,7 +2625,15 @@ public TermSites(List<Site> sites) {
termsToSites.put(term, new ArrayList<Site>(1));
}

site.setTitle(getUserSpecificSiteTitle(site));
// This is being used to display the full site title in the tool tip.
// It's necessary to pack this into some random/unused field of the Site object
// because the tool is using an old JSF version, which does not support calling
// methods with parameters in a JSP file to a backing bean. So, as a hack, we stuff
// the untruncated site title into the 'infoUrl' String to accomplish this.
// The site object is never saved, so we don't have to worry about overwriting the 'infoUrl' value
site.setInfoUrl(getUserSpecificSiteTitle(site, false));

site.setTitle(getUserSpecificSiteTitle(site, true));
termsToSites.get(term).add(site);
}

Expand Down
17 changes: 9 additions & 8 deletions user/user-tool-prefs/tool/src/webapp/js/manage-hidden-sites.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ $(function () {
return {
siteid: $(this).find('.site-id').text(),
title: $(this).find('.site-title').text(),
description: $(this).find('.site-short-description').text()
description: $(this).find('.site-short-description').text(),
tooltip: $(this).find('.site-titleFull').text()
};
}).toArray();

Expand All @@ -31,10 +32,10 @@ $(function () {
var item = $('<div class="manage-hidden-entry site-entry" />');
item.append($('<i class="fa site-entry-star" />'));

if ($('#selectedTabLabelValue').text().trim() == '2' && site.description) {
item.append($('<span class="title" />').text(site.description));
if ($('#selectedTabLabelValue').text().trim() === '2' && site.description) {
item.append($('<span class="title" title="' + site.tooltip + '" />').text(site.description));
} else {
item.append($('<span class="title" />').text(site.title));
item.append($('<span class="title" title="' + site.tooltip + '" />').text(site.title));
}

item.append($('<input type="checkbox" class="site-hidden hidden-checkbox">').data('site-id', site.siteid));
Expand All @@ -61,14 +62,14 @@ $(function () {

var update_term_state = function (term) {
// If an entire section's sites are checked, check the title too
var checks = $('.site-hidden', term).map(function () { return $(this).prop('checked') }).toArray();
var checks = $('.site-hidden', term).map(function () { return $(this).prop('checked'); }).toArray();
var allTermSitesChecked = (checks.indexOf(false) < 0);
$('.term-hidden', term).prop('checked', allTermSitesChecked);

// Apply our 'entry-hidden' styles to anything checked
$('.entry-hidden', term).removeClass('entry-hidden');
$('.hidden-checkbox:checked', term).closest('.manage-hidden-entry').addClass('entry-hidden');
}
};

// Set the initial state upon load
$('.term-section', target).each(function (i, term) {
Expand Down Expand Up @@ -126,7 +127,7 @@ $(function () {
}

var siteList = $('.site-hidden:checked').map(function (i, checkbox) {
return $(checkbox).data('site-id')
return $(checkbox).data('site-id');
}).toArray().join(",");

$('#hidden_sites_form\\:hiddenSites').val(siteList);
Expand All @@ -141,7 +142,7 @@ $(function () {
method: 'GET',
success: function (data) {
favoritesList = data.split(';').filter(function (e, i) {
return e != '';
return e !== '';
});

callback(favoritesList);
Expand Down
4 changes: 4 additions & 0 deletions user/user-tool-prefs/tool/src/webapp/prefs/hidden.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@
<h:outputText value="#{site.title}" />
<f:verbatim></span></f:verbatim>

<f:verbatim><span class="site-titleFull"></f:verbatim>
<h:outputText value="#{site.infoUrl}" />
<f:verbatim></span></f:verbatim>

<f:verbatim><span class="site-short-description"></f:verbatim>
<h:outputText value="#{site.shortDescription}" />
<f:verbatim></span></f:verbatim>
Expand Down

0 comments on commit cde5b41

Please sign in to comment.