Rename Freemarker search result templates. Initial work on moving main site admin page to Freemarker: login form.
This commit is contained in:
parent
dc331e515a
commit
2c6ddaab64
15 changed files with 189 additions and 8 deletions
|
@ -352,6 +352,19 @@
|
||||||
<servlet-name>SiteAdminController</servlet-name>
|
<servlet-name>SiteAdminController</servlet-name>
|
||||||
<url-pattern>/siteAdmin.jsp</url-pattern>
|
<url-pattern>/siteAdmin.jsp</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>FmSiteAdminController</servlet-name>
|
||||||
|
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.edit.FreemarkerSiteAdminController</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>FmSiteAdminController</servlet-name>
|
||||||
|
<url-pattern>/fm-siteAdmin</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>FmSiteAdminController</servlet-name>
|
||||||
|
<url-pattern>/fm-siteAdmin.jsp</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>ImageUploadController</servlet-name>
|
<servlet-name>ImageUploadController</servlet-name>
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.controller.edit;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.collections.map.ListOrderedMap;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vedit.beans.LoginFormBean;
|
||||||
|
import edu.cornell.mannlib.vedit.util.FormUtils;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginTemplateHelper;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
|
import freemarker.template.Configuration;
|
||||||
|
|
||||||
|
public class FreemarkerSiteAdminController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(FreemarkerSiteAdminController.class);
|
||||||
|
|
||||||
|
public static final String VERBOSE = "verbosePropertyListing";
|
||||||
|
|
||||||
|
public String getTitle(String siteName) {
|
||||||
|
return siteName + " Site Administration";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBody(VitroRequest vreq, Map<String, Object> body, Configuration config) {
|
||||||
|
|
||||||
|
String loginStatus = null;
|
||||||
|
|
||||||
|
LoginFormBean loginHandler = (LoginFormBean)vreq.getSession().getAttribute("loginHandler");
|
||||||
|
if (loginHandler != null) {
|
||||||
|
loginStatus = loginHandler.getLoginStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not logged in: just show login form
|
||||||
|
if (loginHandler == null || !"authenticated".equals(loginStatus)) {
|
||||||
|
//return new LoginTemplateHelper(vreq).showLoginPage(vreq, body, config);
|
||||||
|
body.put("loginPanel", new LoginTemplateHelper(vreq).showLoginPage(vreq, body, config));
|
||||||
|
return mergeBodyToTemplate("siteAdmin-main.ftl", body, config);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int securityLevel = Integer.parseInt( loginHandler.getLoginRole() );
|
||||||
|
|
||||||
|
if (securityLevel >= LoginFormBean.CURATOR) {
|
||||||
|
String verbose = vreq.getParameter("verbose");
|
||||||
|
if( "true".equals(verbose)) {
|
||||||
|
vreq.getSession().setAttribute(VERBOSE, Boolean.TRUE);
|
||||||
|
} else if( "false".equals(verbose)) {
|
||||||
|
vreq.getSession().setAttribute(VERBOSE, Boolean.FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
body.put("singlePortal", new Boolean(vreq.getFullWebappDaoFactory().getPortalDao().isSinglePortal()));
|
||||||
|
|
||||||
|
WebappDaoFactory wadf = vreq.getFullWebappDaoFactory();
|
||||||
|
|
||||||
|
// Not used
|
||||||
|
// int languageProfile = wadf.getLanguageProfile();
|
||||||
|
// String languageMode = null;
|
||||||
|
// if ( 200 <= languageProfile && languageProfile < 300 ) {
|
||||||
|
// languageMode = "OWL Mode";
|
||||||
|
// } else if ( 100 == languageProfile ) {
|
||||||
|
// languageMode = "RDF Schema Mode";
|
||||||
|
// }
|
||||||
|
// body.put("languageModeStr", languageMode);
|
||||||
|
|
||||||
|
|
||||||
|
// Create map for data input entry form
|
||||||
|
List classGroups = wadf.getVClassGroupDao().getPublicGroupsWithVClasses(true,true,false); // order by displayRank, include uninstantiated classes, don't get the counts of individuals
|
||||||
|
Iterator classGroupIt = classGroups.iterator();
|
||||||
|
ListOrderedMap optGroupMap = new ListOrderedMap();
|
||||||
|
while (classGroupIt.hasNext()) {
|
||||||
|
VClassGroup group = (VClassGroup)classGroupIt.next();
|
||||||
|
List classes = group.getVitroClassList();
|
||||||
|
optGroupMap.put(group.getPublicName(),FormUtils.makeOptionListFromBeans(classes,"URI","PickListName",null,null,false));
|
||||||
|
}
|
||||||
|
body.put("VClassIdOptions", optGroupMap);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return mergeBodyToTemplate("siteAdmin-main.ftl", body, config);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -58,6 +58,7 @@ public class LoginTemplateHelper extends LoginTemplateHelperBase {
|
||||||
super(req);
|
super(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Version for JSP page */
|
||||||
public String showLoginPage(HttpServletRequest request) {
|
public String showLoginPage(HttpServletRequest request) {
|
||||||
try {
|
try {
|
||||||
VitroRequest vreq = new VitroRequest(request);
|
VitroRequest vreq = new VitroRequest(request);
|
||||||
|
@ -79,6 +80,28 @@ public class LoginTemplateHelper extends LoginTemplateHelperBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Version for Freemarker page */
|
||||||
|
public String showLoginPage(VitroRequest vreq, Map<String, Object> body, Configuration config) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
State state = getCurrentLoginState(vreq);
|
||||||
|
log.debug("State on exit: " + state);
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case LOGGED_IN:
|
||||||
|
return "";
|
||||||
|
case FORCED_PASSWORD_CHANGE:
|
||||||
|
return doTemplate(vreq, showPasswordChangeScreen(vreq), body, config);
|
||||||
|
default:
|
||||||
|
return doTemplate(vreq, showLoginScreen(vreq), body, config);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e);
|
||||||
|
return "<h2>Internal server error:<br/>" + e + "</h2>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User is just starting the login process. Be sure that we have a
|
* User is just starting the login process. Be sure that we have a
|
||||||
* {@link LoginProcessBean} with the correct status. Show them the login
|
* {@link LoginProcessBean} with the correct status. Show them the login
|
||||||
|
@ -131,6 +154,7 @@ public class LoginTemplateHelper extends LoginTemplateHelperBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We processed a response, and want to show a template.
|
* We processed a response, and want to show a template.
|
||||||
|
* Version for JSP page.
|
||||||
*/
|
*/
|
||||||
private String doTemplate(VitroRequest vreq, TemplateResponseValues values) {
|
private String doTemplate(VitroRequest vreq, TemplateResponseValues values) {
|
||||||
// Set it up like FreeMarkerHttpServlet.doGet() would do.
|
// Set it up like FreeMarkerHttpServlet.doGet() would do.
|
||||||
|
@ -144,6 +168,17 @@ public class LoginTemplateHelper extends LoginTemplateHelperBase {
|
||||||
body.putAll(values.getBodyMap());
|
body.putAll(values.getBodyMap());
|
||||||
return mergeBodyToTemplate(values.getTemplateName(), body, config);
|
return mergeBodyToTemplate(values.getTemplateName(), body, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We processed a response, and want to show a template.
|
||||||
|
* Version for Freemarker page.
|
||||||
|
*/
|
||||||
|
private String doTemplate(VitroRequest vreq, TemplateResponseValues values, Map<String, Object> body, Configuration config) {
|
||||||
|
|
||||||
|
// Add the values that we got, and merge to the template.
|
||||||
|
body.putAll(values.getBodyMap());
|
||||||
|
return mergeBodyToTemplate(values.getTemplateName(), body, config);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Where are we in the process? Logged in? Not? Somewhere in between?
|
* Where are we in the process? Logged in? Not? Somewhere in between?
|
||||||
|
|
|
@ -291,7 +291,7 @@ public class FreemarkerPagedSearchController extends FreemarkerHttpServlet imple
|
||||||
return doSearchError(e.getMessage(), config);
|
return doSearchError(e.getMessage(), config);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mergeBodyToTemplate("pagedSearchResults.ftl", body, config);
|
return mergeBodyToTemplate("search-pagedResults.ftl", body, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void alphaSortIndividuals(List<Individual> beans) {
|
private void alphaSortIndividuals(List<Individual> beans) {
|
||||||
|
@ -752,14 +752,14 @@ public class FreemarkerPagedSearchController extends FreemarkerHttpServlet imple
|
||||||
private String doSearchError(String message, Configuration config) {
|
private String doSearchError(String message, Configuration config) {
|
||||||
Map<String, Object> body = new HashMap<String, Object>();
|
Map<String, Object> body = new HashMap<String, Object>();
|
||||||
body.put("message", "Search failed: " + message);
|
body.put("message", "Search failed: " + message);
|
||||||
return mergeBodyToTemplate("searchError.ftl", body, config);
|
return mergeBodyToTemplate("search-error.ftl", body, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String doNoQuery(Configuration config, Portal portal) {
|
private String doNoQuery(Configuration config, Portal portal) {
|
||||||
Map<String, Object> body = new HashMap<String, Object>();
|
Map<String, Object> body = new HashMap<String, Object>();
|
||||||
body.put("title", "Search " + portal.getAppName());
|
body.put("title", "Search " + portal.getAppName());
|
||||||
body.put("message", "No query entered.");
|
body.put("message", "No query entered.");
|
||||||
return mergeBodyToTemplate("searchError.ftl", body, config);
|
return mergeBodyToTemplate("search-error.ftl", body, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String doFailedSearch(String message, String querytext, Configuration config) {
|
private String doFailedSearch(String message, String querytext, Configuration config) {
|
||||||
|
@ -769,14 +769,14 @@ public class FreemarkerPagedSearchController extends FreemarkerHttpServlet imple
|
||||||
message = "Search failed.";
|
message = "Search failed.";
|
||||||
}
|
}
|
||||||
body.put("message", message);
|
body.put("message", message);
|
||||||
return mergeBodyToTemplate("searchError.ftl", body, config);
|
return mergeBodyToTemplate("search-error.ftl", body, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String doNoHits(String querytext, Configuration config) {
|
private String doNoHits(String querytext, Configuration config) {
|
||||||
Map<String, Object> body = new HashMap<String, Object>();
|
Map<String, Object> body = new HashMap<String, Object>();
|
||||||
body.put("title", "Search for '" + querytext + "'");
|
body.put("title", "Search for '" + querytext + "'");
|
||||||
body.put("message", "No matching results.");
|
body.put("message", "No matching results.");
|
||||||
return mergeBodyToTemplate("searchError.ftl", body, config);
|
return mergeBodyToTemplate("search-error.ftl", body, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
<#-- Log in template for accessing site admin -->
|
<#-- Log in template for accessing site admin -->
|
||||||
|
|
||||||
|
|
||||||
<div id="formLogin">
|
<div id="formLogin">
|
||||||
<h2>Create Your New Password</h2>
|
<h2>Create Your New Password</h2>
|
||||||
|
|
||||||
|
@ -20,4 +19,4 @@
|
||||||
<input id="confirmPassword" type="password" name="confirmPassword" />
|
<input id="confirmPassword" type="password" name="confirmPassword" />
|
||||||
<input name="passwordChangeForm" type="submit" class="submit" value="Save Changes"/> <span class="or">or <a class="cancel" href="${cancelUrl}">Cancel</a></span>
|
<input name="passwordChangeForm" type="submit" class="submit" value="Save Changes"/> <span class="or">or <a class="cancel" href="${cancelUrl}">Cancel</a></span>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
<#-- Log in template for accessing site admin -->
|
<#-- Template for login form -->
|
||||||
|
|
||||||
<noscript>
|
<noscript>
|
||||||
<div id="javascriptDisableWrapper">
|
<div id="javascriptDisableWrapper">
|
||||||
|
@ -33,6 +33,8 @@
|
||||||
<input name="loginForm" type="submit" class="submit" value="Log in"/>
|
<input name="loginForm" type="submit" class="submit" value="Log in"/>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
|
<#-- Main template for the login panel -->
|
||||||
|
|
||||||
|
${loginPanel}
|
||||||
|
|
||||||
|
${stylesheets.add("/css/login.css")}
|
||||||
|
${stylesheets.addFromTheme("/css/formedit.css")}
|
||||||
|
${scripts.add("/js/jquery.js", "/js/login/loginUtils.js")}
|
|
@ -0,0 +1,3 @@
|
||||||
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
|
<#-- Template for Site Administration Advanced Data Tools -->
|
|
@ -0,0 +1,3 @@
|
||||||
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
|
<#-- Template for Site Administration Custom Reports -->
|
|
@ -0,0 +1,3 @@
|
||||||
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
|
<#-- Template for Site Administration Data Input -->
|
|
@ -0,0 +1,15 @@
|
||||||
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
|
<#-- Template for the main Site Administration page -->
|
||||||
|
|
||||||
|
<div class="tab">
|
||||||
|
<h2>Site Administration</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="adminDashboard">
|
||||||
|
|
||||||
|
<#if loginPanel??>
|
||||||
|
<#include "login-main.ftl">
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
</div>
|
|
@ -0,0 +1,3 @@
|
||||||
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
|
<#-- Template for Site Administration Ontology Editor -->
|
|
@ -0,0 +1,3 @@
|
||||||
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
|
<#-- Template for Site Administration Site Configuration -->
|
Loading…
Add table
Reference in a new issue