NIHVIVO-1230 NIHVIVO-1231 Example implementation of the Freemarker templates to show revision info.
This commit is contained in:
parent
b8fefaee00
commit
a7a083c7b3
5 changed files with 84 additions and 8 deletions
|
@ -377,6 +377,15 @@
|
||||||
<url-pattern>/siteAdmin.jsp</url-pattern>
|
<url-pattern>/siteAdmin.jsp</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>RevisionInfoController</servlet-name>
|
||||||
|
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.freemarker.RevisionInfoController</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>RevisionInfoController</servlet-name>
|
||||||
|
<url-pattern>/revisionInfo</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>ImageUploadController</servlet-name>
|
<servlet-name>ImageUploadController</servlet-name>
|
||||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.freemarker.ImageUploadController</servlet-class>
|
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.freemarker.ImageUploadController</servlet-class>
|
||||||
|
|
|
@ -25,6 +25,7 @@ import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
|
||||||
import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties;
|
import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
|
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.config.RevisionInfoBean;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.ContactMailServlet;
|
import edu.cornell.mannlib.vitro.webapp.controller.ContactMailServlet;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
@ -435,7 +436,7 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
||||||
map.put("bannerImage", UrlBuilder.getUrl(themeDir + "site_icons/" + bannerImage));
|
map.put("bannerImage", UrlBuilder.getUrl(themeDir + "site_icons/" + bannerImage));
|
||||||
}
|
}
|
||||||
|
|
||||||
map.put("version", getVersionInfo());
|
map.put("version", getVersionInfo(urlBuilder));
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
@ -479,11 +480,12 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
||||||
return copyright;
|
return copyright;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Map<String, Object> getVersionInfo() {
|
private final Map<String, Object> getVersionInfo(UrlBuilder urlBuilder) {
|
||||||
Map<String, Object> version = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
// Add revision info here
|
map.put("label", RevisionInfoBean.getBean(getServletContext())
|
||||||
version.put("number", "1.2"); // test code - to be removed
|
.getReleaseLabel());
|
||||||
return version;
|
map.put("moreInfoUrl", urlBuilder.getPortalUrl("/revisionInfo"));
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Subclasses may override. This serves as a default.
|
// Subclasses may override. This serves as a default.
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.config.RevisionInfoBean;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the detailed revision information.
|
||||||
|
*/
|
||||||
|
public class RevisionInfoController extends FreemarkerHttpServlet {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private static final Log log = LogFactory.getLog(RevisionInfoController.class);
|
||||||
|
private static final String TEMPLATE_DEFAULT = "revisionInfo.ftl";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||||
|
Map<String, Object> body = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
body.put("revisionInfoBean", RevisionInfoBean.getBean(getServletContext()));
|
||||||
|
|
||||||
|
return new TemplateResponseValues(TEMPLATE_DEFAULT, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getTitle(String siteName) {
|
||||||
|
return "Revision Information for " + siteName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
28
webapp/web/templates/freemarker/body/revisionInfo.ftl
Normal file
28
webapp/web/templates/freemarker/body/revisionInfo.ftl
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
|
<#-- Template for the Revision Information page. -->
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h1>Revision Information</h1>
|
||||||
|
|
||||||
|
<h2>Build date:</h2>
|
||||||
|
<div>
|
||||||
|
${revisionInfoBean.buildDate?datetime?string.full}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h2>Levels:</h2>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>name</th>
|
||||||
|
<th>release</th>
|
||||||
|
<th>revision</th>
|
||||||
|
</tr>
|
||||||
|
<#list revisionInfoBean.levelInfos as level>
|
||||||
|
<tr>
|
||||||
|
<td>${level.name}</td>
|
||||||
|
<td>${level.release}</td>
|
||||||
|
<td>${level.revision}</td>
|
||||||
|
</tr>
|
||||||
|
</#list>
|
||||||
|
</table>
|
||||||
|
</div>
|
|
@ -5,6 +5,6 @@
|
||||||
<#-- Only show version info if user is logged in -->
|
<#-- Only show version info if user is logged in -->
|
||||||
<#if loginName??>
|
<#if loginName??>
|
||||||
<div id="version">
|
<div id="version">
|
||||||
Version ${version.number}
|
Version <a href="${version.moreInfoUrl}">${version.label}</a>
|
||||||
</div>
|
</div>
|
||||||
</#if>
|
</#if>
|
Loading…
Add table
Add a link
Reference in a new issue