NHIVIVO-2051 Fix values of currentServlet (was currentPage) and urls.currentPage
This commit is contained in:
parent
afa25c7f2a
commit
1f16791d2a
5 changed files with 24 additions and 19 deletions
|
@ -263,14 +263,22 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
|||
urls.put("themeImages", urlBuilder.getPortalUrl(themeDir + "/images"));
|
||||
urls.put("images", UrlBuilder.getUrl("/images"));
|
||||
urls.put("theme", UrlBuilder.getUrl(themeDir));
|
||||
urls.put("index", UrlBuilder.getUrl("/browse"));
|
||||
|
||||
//urls.put("currentPage", vreq.getRequestURI());
|
||||
urls.put("currentPage", getCurrentPageValue(vreq));
|
||||
urls.put("index", UrlBuilder.getUrl("/browse"));
|
||||
urls.put("currentPage", getCurrentPageUrl(vreq));
|
||||
|
||||
return urls;
|
||||
}
|
||||
|
||||
private String getCurrentPageUrl(HttpServletRequest request) {
|
||||
String path = request.getServletPath().replaceFirst("/", "");
|
||||
String pathInfo = request.getPathInfo();
|
||||
if (pathInfo != null) {
|
||||
path += pathInfo;
|
||||
}
|
||||
path = normalizeServletName(path);
|
||||
return UrlBuilder.getUrl(path);
|
||||
}
|
||||
|
||||
protected BeansWrapper getNonDefaultBeansWrapper(int exposureLevel) {
|
||||
BeansWrapper wrapper = new DefaultObjectWrapper();
|
||||
// Too bad exposure levels are ints instead of enum values; what happens if
|
||||
|
@ -392,23 +400,20 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
|||
map.put("flash", flashMessage);
|
||||
}
|
||||
|
||||
// Let the page template know which page it's processing.
|
||||
String currentPage = getCurrentPageValue(vreq).replaceFirst(vreq.getContextPath() + "/", "");
|
||||
map.put("currentPage", currentPage);
|
||||
// Let the page template know which page it's processing.
|
||||
map.put("currentServlet", normalizeServletName(vreq.getServletPath().replaceFirst("/", "")));
|
||||
|
||||
// Allow template to send domain name to JavaScript (needed for AJAX calls)
|
||||
map.put("requestedPage", vreq.getRequestURL().toString());
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
private String getCurrentPageValue(HttpServletRequest request) {
|
||||
String currentPage = request.getRequestURI();
|
||||
// Return a uniform value for the home page
|
||||
if (currentPage.equals("") || currentPage.equals("index.jsp")) {
|
||||
currentPage = "home";
|
||||
}
|
||||
return currentPage;
|
||||
private String normalizeServletName(String name) {
|
||||
// Return a uniform value for the home page.
|
||||
// Note that if servletName is "index.jsp", it must be the home page,
|
||||
// since we don't get here on other tabs.
|
||||
return (name.length() == 0 || name.equals("index.jsp")) ? "home" : name;
|
||||
}
|
||||
|
||||
private TabMenu getTabMenu(VitroRequest vreq) {
|
||||
|
|
|
@ -98,7 +98,7 @@ public class BrowseWidget extends Widget {
|
|||
values.putAll(FreemarkerHttpServlet.getDirectives());
|
||||
try {
|
||||
values.put("urls",env.getDataModel().get("urls"));
|
||||
values.put("currentPage", env.getDataModel().get("currentPage"));
|
||||
values.put("currentServlet", env.getDataModel().get("currentServlet"));
|
||||
} catch (TemplateModelException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -101,7 +101,7 @@ public class LoginWidget extends Widget {
|
|||
}
|
||||
|
||||
values.put("urls", dataModel.get("urls"));
|
||||
values.put("currentPage", dataModel.get("currentPage"));
|
||||
values.put("currentServlet", dataModel.get("currentServlet"));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> dm = (Map<String, Object>) DeepUnwrap.permissiveUnwrap(dataModel);
|
||||
|
|
|
@ -7,7 +7,7 @@ the domain of the controllers. -->
|
|||
<#assign bodyClasses>
|
||||
<#-- The compress directives and formatting here resolve whitespace issues in output; please do not alter them. -->
|
||||
<#compress>
|
||||
<#assign bodyClassList = [currentPage!]>
|
||||
<#assign bodyClassList = [currentServlet!]>
|
||||
|
||||
<#if user.loggedIn>
|
||||
<#assign bodyClassList = bodyClassList + ["loggedIn"]/>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
<#macro loginForm>
|
||||
<#-- Don't display the JavaScript required to edit message on the home page even if JavaScript is unavailable -->
|
||||
<#if ( currentPage != 'home' && currentPage != 'index.jsp')>
|
||||
<#if currentServlet != 'home'>
|
||||
<noscript>
|
||||
<section id="error-alert">
|
||||
<img src="${urls.images}/iconAlertBig.png" alt="Alert Icon"/>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue