Skip to content

Commit

Permalink
#9: Check sling redirect target, deleted html-context of navbar links
Browse files Browse the repository at this point in the history
  • Loading branch information
drere committed Jan 5, 2016
1 parent a18aa22 commit de1fe84
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Expand Up @@ -24,11 +24,13 @@ public class LinkUtil {
public static final String EXT_HTML = ".html";

public static final String PROP_TARGET = "sling:target";
public static final String PROP_REDIRECT = "sling:redirect";

public static final Pattern URL_PATTERN = Pattern.compile("^(https?)://([^/]+)(:\\d+)?(/.*)?$");

public static final Pattern SELECTOR_PATTERN = Pattern.compile("^(.*/[^/]+)(\\.[^.]+)$");


/**
* Builds a mapped link to a path (resource path) without selectors and a determined extension.
* @param request the request context for path mapping (the result is always mapped)
Expand Down Expand Up @@ -88,7 +90,7 @@ public static String getUrl(SlingHttpServletRequest request, String url,

// check for a necessary extension and determine it if not specified
extension = getExtension(resource, extension);
}
}

// map the path (the url) with the resource resolver (encodes the url)
url = resolver.map(request, url);
Expand Down Expand Up @@ -173,6 +175,9 @@ protected static String getFinalTarget(ResourceHandle resource, List<String> tra
throw new RedirectLoopException(trace, path);
}
String redirect = resource.getProperty(PROP_TARGET);
if (StringUtils.isBlank(redirect)) {
redirect = resource.getProperty(PROP_REDIRECT);
}
if (StringUtils.isNotBlank(redirect)) {
trace.add(path);
finalTarget = redirect;
Expand Down
Expand Up @@ -11,15 +11,15 @@
<span class="icon-bar"></span>
</button>
<div id="composum-logo" class="navbar-brand">
<a href="${cpn:url(slingRequest,'/libs/composum/sling/console/content.html')}">
<a href="${cpn:url(slingRequest,'/libs/composum/sling/console/content')}">
<img src="${cpn:url(slingRequest,'/libs/composum/sling/console/page/images/composum-nodes-logo-on-black.png')}" />
</a>
</div>
</div>
<nav class="collapse navbar-collapse bs-navbar-collapse" role="navigation">
<ul class="nav navbar-nav">
<c:forEach items="${status.consoles}" var="console">
<li class="nav-item ${console.name} link"><a href="${console.path}.html">${console.label}</a></li>
<li class="nav-item ${console.name} link"><cpn:link href="${console.path}">${console.label}</cpn:link></li>
</c:forEach>
</ul>
<ul class="system nav navbar-nav navbar-right">
Expand Down

0 comments on commit de1fe84

Please sign in to comment.