Skip to content

Commit

Permalink
SAK-49165 Portal site header should include links to parent sites (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
ottenhoff authored Feb 11, 2025
1 parent 6948d02 commit 49e8fc5
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 205 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,15 @@
}

.portal-header-breadcrumb-separator, .portal-header-breadcrumb-item > a {
font-size: 16px;
color: var(--sakai-text-color-inverted) !important;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
.portal-header-breadcrumb-separator {
font-size: 14px;
}

#header-site-title {
.portal-header-site-title {
padding-bottom: 2px;

> a {
font-size: 20px;
}
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public interface PortalSiteHelper
*/
SitePage lookupSitePage(String pageId, Site site);

List<Map<String, String>> getParentSites(Site s);

/**
* Produce a page and/or a tool list by iterating through the pages in a site.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ public void doSite(HttpServletRequest req, HttpServletResponse res, Session sess

// Does the tool allow us to buffer?
allowBuffer = allowBufferContent(req, site, siteTool);
log.debug("allowBuffer="+allowBuffer+" url="+req.getRequestURL());
log.debug("allowBuffer={} url={}", allowBuffer, req.getRequestURL());

if ( allowBuffer ) {
TCP = req.getContextPath() + req.getServletPath() + Web.makePath(parts, 1, 5);
Expand Down Expand Up @@ -590,7 +590,7 @@ public void doSite(HttpServletRequest req, HttpServletResponse res, Session sess
}

rcontext.put("siteId", siteId);
boolean showShortDescription = Boolean.valueOf(serverConfigurationService.getBoolean("portal.title.shortdescription.show", false));
boolean showShortDescription = serverConfigurationService.getBoolean("portal.title.shortdescription.show", false);

if (showShortDescription) {
rcontext.put("shortDescription", Web.escapeHtml(site.getShortDescription()));
Expand All @@ -604,6 +604,7 @@ public void doSite(HttpServletRequest req, HttpServletResponse res, Session sess
}else{
rcontext.put("siteTitle", portal.getSiteHelper().getUserSpecificSiteTitle(site, false, true, providers));
rcontext.put("siteUrl", site.getUrl());
rcontext.put("siteParents", portal.getSiteHelper().getParentSites(site));
rcontext.put("siteTitleTruncated", Validator.escapeHtml(portal.getSiteHelper().getUserSpecificSiteTitle(site, true, false, providers)));
rcontext.put("isUserSite", false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,62 +641,50 @@ public Map<String, Object> convertSiteToMap(HttpServletRequest req, Site s, Stri
m.put("siteType", s.getType());
m.put("siteId", s.getId());

// TODO: This should come from the site neighbourhood.
if (includeSummary)
{
summarizeTool(m, s, "sakai.announce");
}
if (expandSite)
{
Map<String, Object> pageMap = pageListToMap(req, loggedIn, s, null, toolContextPath, prefix, doPages, resetTools, includeSummary);
m.put("sitePages", pageMap);
}

return m;
}

@Override
public List<Map<String, String>> getParentSites(Site s) {
ResourceProperties rp = s.getProperties();
String ourParent = rp.getProperty(PROP_PARENT_ID);
// We are not really a child unless the parent exists
// And we have a valid pwd
boolean isChild = false;

// Get the current site hierarchy
if (ourParent != null && isCurrentSite)
{
if (ourParent != null) {
List<Site> pwd = getPwd(s, ourParent);
if (pwd != null)
{
List<Map> l = new ArrayList<>();
// SAK-30477
// Skip current site size - 1
for (int i = 0; i < pwd.size() - 1; i++)
{
Site site = pwd.get(i);
log.debug("PWD[{}]={}{}", i, site.getId(), site.getTitle());
Map<String, Object> pm = new HashMap<>();
if (pwd != null && pwd.size() > 1) { // Ensure we have at least 2 sites
List<Map<String, String>> siteBreadcrumbs = new ArrayList<>();
// SAK-30477: Skip current site size - 1
for (Site site : pwd.subList(0, pwd.size() - 1)) {
log.debug("PWD: {}{}", site.getId(), site.getTitle());
Map<String, String> siteData = new HashMap<>();
List<String> providers = getProviderIDsForSite(site);

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

l.add(pm);
isChild = true;
siteData.put("siteTitle", parentSiteTitle);
siteData.put("siteTitleTrunc", parentSiteTitleTruncated);
siteData.put("siteUrl", "/portal/site/" + formattedText.escapeUrl(getSiteEffectiveId(site)));
siteBreadcrumbs.add(siteData);
}
if (!siteBreadcrumbs.isEmpty()) {
return siteBreadcrumbs;
}
if ( l.size() > 0 ) m.put("pwd", l);
}
}

// If we are a child and have a non-zero length, pwd
// show breadcrumbs
if ( isChild ) {
m.put("isChild", Boolean.valueOf(isChild));
m.put("parentSite", ourParent);
}

if (includeSummary)
{
summarizeTool(m, s, "sakai.announce");
}
if (expandSite)
{
Map<String, Object> pageMap = pageListToMap(req, loggedIn, s, null, toolContextPath, prefix, doPages, resetTools, includeSummary);
m.put("sitePages", pageMap);
}

return m;
return null;
}

/**
* Gets the path of sites back to the root of the tree.
* @param s
Expand Down Expand Up @@ -974,13 +962,6 @@ else if ("always".equals(showHelpGlobal))

}

if ( addMoreToolsUrl != null ) {
theMap.put("pageNavAddMoreToolsUrl", addMoreToolsUrl);
theMap.put("pageNavCanAddMoreTools", true);
} else {
theMap.put("pageNavCanAddMoreTools", false);
}

if(manageOverviewUrl != null){
theMap.put("manageOverviewUrl", manageOverviewUrl);
theMap.put("canManageOverview", true);
Expand All @@ -999,17 +980,6 @@ else if ("always".equals(showHelpGlobal))
}

theMap.put("pageNavTools", l);
theMap.put("pageMaxIfSingle", serverConfigurationService.getBoolean("portal.experimental.maximizesinglepage", false));
theMap.put("pageNavToolsCount", Integer.valueOf(l.size()));

String helpUrl = serverConfigurationService.getHelpUrl(null);
theMap.put("pageNavShowHelp", Boolean.valueOf(showHelp));
theMap.put("pageNavHelpUrl", helpUrl);
theMap.put("helpMenuClass", ICON_SAKAI + "help");
theMap.put("subsiteClass", ICON_SAKAI + "subsite");

// theMap.put("pageNavSitContentshead",
// Web.escapeHtml(rb.getString("sit_contentshead")));

// Display presence? Global property display.users.present may be always / never / true / false
// If true or false, the value may be overriden by the site property display-users-present
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ protected void includePageNav(Map rcontext) throws IOException
rcontext.put("pageNavPublished", Boolean.valueOf(true));
rcontext.put("pageNavType", "type");
rcontext.put("pageNavIconUrl", "iconUrl");
rcontext.put("helpMenuClass", "HelpMenuClass");
// rcontext.put("pageNavSitToolsHead", "sit_toolshead");

List l = new ArrayList();
Expand Down Expand Up @@ -335,11 +334,6 @@ protected void includePageNav(Map rcontext) throws IOException
l.add(m);
rcontext.put("pageNavTools", l);

rcontext.put("pageNavShowHelp", Boolean.valueOf(true));
rcontext.put("pageNavHelpUrl", "helpUrl");
// rcontext.put("pageNavSitHelp", "sit_help");

rcontext.put("pageNavToolsCount", l.size());
rcontext.put("pageNavShowPresenceLoggedIn", Boolean.valueOf(true));
rcontext.put("pageNavPresenceUrl", "presenceUrl");
rcontext.put("sakaiPresenceTimeDelay", Integer.valueOf(3000));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div class="portal-main-container container-fluid mt-2 d-flex flex-column">
<main id="$pageWrapperClass" class="portal-main-content #if( $numberTools > 1 || $homePage)Mrphs-multipleTools #end" role="main">
<h1 class="skip visually-hidden" tabindex="-1" id="tocontent">${rloader.sit_contentshead}</h1>
#parse("/vm/morpheus/includeSiteHierarchy.vm")
#parse("/vm/morpheus/snippets/roleSwitch-snippet.vm")
#parse("/vm/morpheus/snippets/siteStatus-snippet.vm")
#if ($pageTwoColumn)
<div class="row">
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,29 @@
</button>
</div>
#if (${userIsLoggedIn})
<div class="align-items-center portal-header-breadcrumb d-none d-md-flex">
<div id="header-site-title" class="ms-3 portal-header-breadcrumb-item">
## Define font size class based on number of parents
#set($fontSizeClass = "fs-4")
#if($!siteParents && $siteParents.size() > 2)
#set($fontSizeClass = "small")
#elseif($!siteParents && $siteParents.size() > 1)
#set($fontSizeClass = "fs-6")
#end
<div class="align-items-center portal-header-breadcrumb d-none d-md-flex ms-3 ${fontSizeClass}">

#if ($!siteParents)
#foreach ($parent in $siteParents)
<div class="portal-header-breadcrumb-item portal-header-site-title">
<a href="$!{parent.siteUrl}" title="$!{parent.siteTitle}">$!{parent.siteTitle}</a>
</div>
<div class="mx-2 bi bi-chevron-right portal-header-breadcrumb-separator d-none d-md-block fs-6"></div>
#end
#end
<div id="header-site-title" class="portal-header-breadcrumb-item portal-header-site-title ${fontSizeClass}">
<a href="$!{siteUrl}">$!{siteTitle}</a>
</div>
#foreach( $page in $sitePages.pageNavTools )
#if ($page.current)
<div class="mx-2 bi bi-chevron-right portal-header-breadcrumb-separator d-none d-md-block"></div>
<div class="mx-2 bi bi-chevron-right portal-header-breadcrumb-separator d-none d-md-block fs-6"></div>
<div class="portal-header-breadcrumb-item header-tool-title">
<a href="${page.pageResetUrl}" title="$rloader.sit_reset">${page.pageTitle}</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## Adds $viewAsStudentLink options
## Only display this if we're in view as student mode and it's not the home page
#if ($viewAsStudentLink)
<div id="roleSwitch" class="role-switcher me-1">
<ol class="breadcrumb mb-2">
<li id="roleSwitch" class="role-switcher me-1">
#if ($roleSwitchState)
<span>$rloader.getFormattedMessage("rs_roleSwapAdvice", $roleUrlValue)</span>
<a href="$switchRoleUrl" id="roleSwitchAnchor" class="Mrphs-roleSwitch__anchor Mrphs-roleSwitch__exit">
Expand All @@ -25,5 +26,6 @@
#end ## END OF IF ($roleswapdropdown)
</div>
#end ## END of IF ($roleSwitchState)
</div>
</li>
</ol>
#end ## END of if ($viewAsStudentLink)

0 comments on commit 49e8fc5

Please sign in to comment.