NIHVIVO-1389 NIHVIVO-1407 NIHVIVO-1437 Significant refactoring of templates both in vitro core and vivo themes to ensure consistent markup with 3 different base templates at play (page.ftl, basicPage.jsp and formPrefix/formSuffix.jsp) Resulted in creating smaller component freemarker templates that could be included by all of the base templates, whether ftl or jsp. This is a temporary compromise while we continue our conversion to Freemarker. The goal was to keep jsp files outside of the theme and working behind the scenes.

This commit is contained in:
nac26 2010-12-08 14:05:16 +00:00
parent 1126d6f75d
commit 9892846244
7 changed files with 212 additions and 144 deletions

View file

@ -36,10 +36,11 @@ public class FreemarkerComponentGenerator extends FreemarkerHttpServlet {
Map<String, Object> root = getSharedVariables(vreq, new HashMap<String, Object>()); Map<String, Object> root = getSharedVariables(vreq, new HashMap<String, Object>());
root.putAll(getPageTemplateValues(vreq)); root.putAll(getPageTemplateValues(vreq));
request.setAttribute("ftl_head", get("head", root, config, vreq));
request.setAttribute("ftl_identity", get("identity", root, config, vreq)); request.setAttribute("ftl_identity", get("identity", root, config, vreq));
request.setAttribute("ftl_menu", get("menu", root, config, vreq));
request.setAttribute("ftl_stylesheets", get("stylesheets", root, config, vreq)); request.setAttribute("ftl_stylesheets", get("stylesheets", root, config, vreq));
request.setAttribute("ftl_headScripts", get("headScripts", root, config, vreq)); request.setAttribute("ftl_headScripts", get("headScripts", root, config, vreq));
request.setAttribute("ftl_menu", get("menu", root, config, vreq));
request.setAttribute("ftl_search", get("search", root, config, vreq)); request.setAttribute("ftl_search", get("search", root, config, vreq));
request.setAttribute("ftl_footer", get("footer", root, config, vreq)); request.setAttribute("ftl_footer", get("footer", root, config, vreq));
request.setAttribute("ftl_googleAnalytics", get("googleAnalytics", root, config, vreq)); request.setAttribute("ftl_googleAnalytics", get("googleAnalytics", root, config, vreq));

View file

@ -1,17 +1,55 @@
<%-- $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$ --%>
<%@ page import="java.util.List" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.web.*" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.filters.VitroRequestPrep"%> <%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ page errorPage="/error.jsp"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.filters.VitroRequestPrep" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Portal"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<c:set var='themeDir'><c:out value='${portalBean.themeDir}'/></c:set>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <!-- formPrefix.jsp -->
<% <%
FreemarkerHttpServlet.getFreemarkerComponentsForJsp(request);
%>
<%
VitroRequest vreq = new VitroRequest(request);
Portal portal = vreq.getPortal();
String contextRoot = vreq.getContextPath();
String themeDir = portal != null ? portal.getThemeDir() : Portal.DEFAULT_THEME_DIR_FROM_CONTEXT;
themeDir = contextRoot + '/' + themeDir;
%>
<c:set var="portal" value="${requestScope.portalBean}"/>
<c:set var="themeDir"><c:out value="${themeDir}" /></c:set>
<c:set var="bodyJsp"><c:out value="${requestScope.bodyJsp}" default="/debug.jsp"/></c:set>
<c:set var="title"><c:out value="${requestScope.title}" /></c:set>
<!DOCTYPE html>
<html lang="en">
<head> <!-- formPrefix.jsp -->
<% String useAutoComplete = (useAutoComplete=request.getParameter("useAutoComplete")) != null && !(useAutoComplete.equals("")) ? useAutoComplete : "false";
if (useAutoComplete.equalsIgnoreCase("true")) { %>
<link rel="stylesheet" type="text/css" href="<c:url value="/js/jquery_plugins/jquery-autocomplete/jquery.autocomplete.css"/>" />
<% } %>
<c:forEach var="cssFile" items="${customCss}">
<link rel="stylesheet" type="text/css" href="<c:url value="${cssFile}"/>" media="screen"/>
</c:forEach>
<link rel="stylesheet" type="text/css" href="<c:url value="/js/jquery_plugins/thickbox/thickbox.css"/>" />
${ftl_head}
<c:if test="${!empty scripts}"><jsp:include page="${scripts}"/></c:if>
<%
String useTinyMCE = (useTinyMCE=request.getParameter("useTinyMCE")) != null && !(useTinyMCE.equals("")) ? useTinyMCE : "false"; String useTinyMCE = (useTinyMCE=request.getParameter("useTinyMCE")) != null && !(useTinyMCE.equals("")) ? useTinyMCE : "false";
if (useTinyMCE.equalsIgnoreCase("true")) { if (useTinyMCE.equalsIgnoreCase("true")) {
String height = (height=request.getParameter("height")) != null && !(height.equals("")) ? height : "200"; String height = (height=request.getParameter("height")) != null && !(height.equals("")) ? height : "200";
@ -19,7 +57,7 @@
String defaultButtons="bold,italic,underline,separator,link,bullist,numlist,separator,sub,sup,charmap,separator,undo,redo,separator,code"; String defaultButtons="bold,italic,underline,separator,link,bullist,numlist,separator,sub,sup,charmap,separator,undo,redo,separator,code";
String buttons = (buttons=request.getParameter("buttons")) != null && !(buttons.equals("")) ? buttons : defaultButtons; String buttons = (buttons=request.getParameter("buttons")) != null && !(buttons.equals("")) ? buttons : defaultButtons;
String tbLocation = (tbLocation=request.getParameter("toolbarLocation")) != null && !(tbLocation.equals("")) ? tbLocation : "top"; String tbLocation = (tbLocation=request.getParameter("toolbarLocation")) != null && !(tbLocation.equals("")) ? tbLocation : "top";
%> %>
<script language="javascript" type="text/javascript" src="../js/tiny_mce/tiny_mce.js"></script> <script language="javascript" type="text/javascript" src="../js/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
tinyMCE.init({ tinyMCE.init({
@ -58,29 +96,10 @@
// theme_advanced_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Row=tableRow1", // Theme specific setting CSS classes // theme_advanced_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Row=tableRow1", // Theme specific setting CSS classes
}); });
</script> </script>
<% } %> <% } %>
<% String useAutoComplete = (useAutoComplete=request.getParameter("useAutoComplete")) != null && !(useAutoComplete.equals("")) ? useAutoComplete : "false";
if (useAutoComplete.equalsIgnoreCase("true")) { %>
<link rel="stylesheet" type="text/css" href="<c:url value="/js/jquery_plugins/jquery-autocomplete/jquery.autocomplete.css"/>" />
<% } %>
<c:forEach var="cssFile" items="${customCss}">
<link rel="stylesheet" type="text/css" href="<c:url value="${cssFile}"/>" media="screen"/>
</c:forEach>
<link rel="stylesheet" type="text/css" href="<c:url value="/js/jquery_plugins/thickbox/thickbox.css"/>" />
<link rel="stylesheet" type="text/css" href="<c:url value="/${themeDir}css/screen.css"/>" media="screen"/>
<link rel="stylesheet" type="text/css" href="<c:url value="/${themeDir}css/formedit.css" />" media="screen"/>
<title>Edit</title>
</head> </head>
<body class="formsEdit"> <body class="formsEdit">
<div id="wrap" class="container"> ${ftl_identity}
<jsp:include page="/templates/page/freemarkerTransition/identity.jsp" flush="true"/>
<jsp:include page="/templates/page/freemarkerTransition/menu.jsp" flush="true"/> ${ftl_menu}
<div id="contentwrap">
<div id="content" class="form">
<!-- end of formPrefix.jsp --> <!-- end of formPrefix.jsp -->

View file

@ -1,32 +1,51 @@
<%-- $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$ --%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%> <%@ page import="edu.cornell.mannlib.vitro.webapp.web.*" %>
<%@page import="edu.cornell.mannlib.vitro.webapp.filters.VitroRequestPrep"%> <%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ page errorPage="/error.jsp"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.filters.VitroRequestPrep" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Portal"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet" %>
<c:set var='themeDir'><c:out value='${portalBean.themeDir}' /></c:set> <% /* Prepare Freemarker components to allow .ftl templates to be included from jsp */
</div> <!-- #content.form --> FreemarkerHttpServlet.getFreemarkerComponentsForJsp(request);
%>
</div> <%
<div class="push"></div> VitroRequest vreq = new VitroRequest(request);
Portal portal = vreq.getPortal();
<jsp:include page="/templates/page/freemarkerTransition/footer.jsp" flush="true"/> String contextRoot = vreq.getContextPath();
</div><!-- end wrap --> String themeDir = portal != null ? portal.getThemeDir() : Portal.DEFAULT_THEME_DIR_FROM_CONTEXT;
themeDir = contextRoot + '/' + themeDir;
%>
<script type="text/javascript" src="<c:url value="/js/extensions/String.js"/>"></script></script>
<script type="text/javascript" src="<c:url value="/js/jquery.js"/>"></script> <c:set var="portal" value="${requestScope.portalBean}"/>
<c:set var="themeDir"><c:out value="${themeDir}" /></c:set>
<c:set var="bodyJsp"><c:out value="${requestScope.bodyJsp}" default="/debug.jsp"/></c:set>
<c:set var="title"><c:out value="${requestScope.title}" /></c:set>
${ftl_footer}
<script type="text/javascript" src="<c:url value="/js/extensions/String.js"/>"></script>
<script type="text/javascript" src="<c:url value="/js/jquery_plugins/jquery.bgiframe.pack.js"/>"></script> <script type="text/javascript" src="<c:url value="/js/jquery_plugins/jquery.bgiframe.pack.js"/>"></script>
<script type="text/javascript" src="<c:url value="/js/jquery_plugins/thickbox/thickbox-compressed.js"/>"></script> <script type="text/javascript" src="<c:url value="/js/jquery_plugins/thickbox/thickbox-compressed.js"/>"></script>
<!-- <script type="text/javascript" src="<c:url value="/js/jquery_plugins/ui.datepicker.js"/>"></script> --> <!-- <script type="text/javascript" src="<c:url value="/js/jquery_plugins/ui.datepicker.js"/>"></script> -->
<% String useAutoComplete = (useAutoComplete=request.getParameter("useAutoComplete")) != null && !(useAutoComplete.equals("")) ? useAutoComplete : "false"; <% String useAutoComplete = (useAutoComplete=request.getParameter("useAutoComplete")) != null && !(useAutoComplete.equals("")) ? useAutoComplete : "false";
if (useAutoComplete.equalsIgnoreCase("true")) { %> if (useAutoComplete.equalsIgnoreCase("true")) { %>
<script type="text/javascript" src="<c:url value="/js/jquery_plugins/jquery-autocomplete/jquery.autocomplete.pack.js"/>"></script> <script type="text/javascript" src="<c:url value="/js/jquery_plugins/jquery-autocomplete/jquery.autocomplete.pack.js"/>"></script>
<% } %> <% } %>
<c:forEach var="jsFile" items="${customJs}"> <c:forEach var="jsFile" items="${customJs}">
<script type="text/javascript" src="<c:url value="${jsFile}"/>"></script> <script type="text/javascript" src="<c:url value="${jsFile}"/>"></script>
</c:forEach> </c:forEach>
</body> </body>
</html> </html>

View file

@ -1,7 +1,11 @@
<#-- $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$ -->
<head> <meta charset="utf-8" />
<!-- Google Chrome Frame open source plug-in brings Google Chrome's open web technologies and speedy JavaScript engine to Internet Explorer-->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<#include "title.ftl"> <#include "title.ftl">
<#include "stylesheets.ftl"> <#include "stylesheets.ftl">
<#include "headScripts.ftl"> <#include "headScripts.ftl">
</head>

View file

@ -1,29 +1,52 @@
<#-- $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$ -->
<#import "lib-list.ftl" as l> <header id="branding" role="banner">
<h1 class="vivo-logo"><a href="${urls.home}"><span class="displace">${siteName}</span></a></h1>
<div id="identity">
<h1><a title="Home" href="${urls.home}">${siteName}</a></h1>
<#if siteTagline?has_content> <#if siteTagline?has_content>
<em>${siteTagline}</em> <em>${siteTagline}</em>
</#if> </#if>
<ul id="otherMenu"> <nav role="navigation">
<@l.firstLastList> <ul id="header-nav" role="list">
<#if user.loggedIn> <#if user.loggedIn>
<li> <li role="listitem">${user.loginName}</li>
Logged in as <strong>${user.loginName}</strong> (<a href="${urls.logout}">Log out</a>) <li role="listitem"><a href="${urls.logout}" title="End your session">Log out</a></li>
</li>
<#if user.hasSiteAdminAccess> <#if user.hasSiteAdminAccess>
<li><a href="${urls.siteAdmin}">Site Admin</a></li> <li role="listitem"><a href="${urls.siteAdmin}" title="Manage this site">Site Admin</a></li>
</#if> </#if>
<#else> <#else>
<li><a title="log in to manage this site" href="${urls.login}">Log in</a></li> <li role="listitem"><a href="${urls.login}" title="Log in to manage this site" >Log in</a></li>
</#if>
<#-- List of links that appear in submenus, like the header and footer. -->
<li role="listitem"><a href="${urls.about}" title="More details about this site">About</a></li>
<#if urls.contact??>
<li role="listitem"><a href="${urls.contact}" title="Send us your feedback or ask a question">Contact Us</a></li>
</#if>
<li role="listitem"><a href="http://www.vivoweb.org/support" title="Visit the national project web site" target="blank">Support</a></li>
<li role="listitem"><a href="${urls.index}" title="View an outline of the content in this site">Index</a></li>
</ul>
</nav>
<section id="search" role="region">
<fieldset>
<legend>Search form</legend>
<form id="search-form" action="${urls.search}" name="search" role="search">
<#if user.showFlag1SearchField>
<select id="search-form-modifier" name="flag1" class="form-item" >
<option value="nofiltering" selected="selected">entire database (${user.loginName})</option>
<option value="${portalId}">${siteTagline!}</option>
</select>
<#else>
<input type="hidden" name="flag1" value="${portalId}" />
</#if> </#if>
<#include "subMenuLinks.ftl"> <div id="search-field">
</@l.firstLastList> <input type="text" name="querytext" class="search-vivo" value="${querytext!}" />
</ul> <input type="submit" value="Search" class="submit">
</div> </div>
</form>
</fieldset>
</section>
</header>

View file

@ -1,13 +1,16 @@
<#-- $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$ -->
<div id="primaryAndOther"> <nav role="navigation">
<ul id="primary"> <ul id="main-nav" role="list">
<#list tabMenu.items as item> <#list menu.items as item>
<li> <li role="listitem"><a href="${item.url}" <#if item.active> class="selected" </#if>>${item.linkText}</a></li>
<a href="${item.url}" <#if item.active> class="activeTab" </#if>>
${item.linkText}
</a>
</li>
</#list> </#list>
</ul> </ul>
</div> </nav>
<div id="wrapper-content" role="main">
<#if flash?has_content>
<section id="flash-message" role="alert">
${flash}
</section>
</#if>

View file

@ -7,6 +7,8 @@
<%@ page errorPage="/error.jsp"%> <%@ page errorPage="/error.jsp"%>
<%@ page contentType="text/html; charset=UTF-8"%> <%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.filters.VitroRequestPrep" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.filters.VitroRequestPrep" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Portal"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet" %>
<% /*********************************************** <% /***********************************************
Display a single Page in the most basic fashion. Display a single Page in the most basic fashion.
@ -51,25 +53,22 @@
%> %>
<c:set var="portal" value="${requestScope.portalBean}"/> <% /* Prepare Freemarker components to allow .ftl templates to be included from jsp */
<c:set var="themeDir"><c:out value="${portal.themeDir}" /></c:set> FreemarkerHttpServlet.getFreemarkerComponentsForJsp(request);
<c:set var="bodyJsp"><c:out value="${requestScope.bodyJsp}" default="/debug.jsp"/></c:set> %>
<!DOCTYPE html>
<html lang="en">
${ftl_head}
<jsp:include page="doctype.jsp"/>
<head>
<jsp:include page="headContent.jsp"/>
</head>
<body ${requestScope.bodyAttr}> <body ${requestScope.bodyAttr}>
<div id="wrap" class="container"> ${ftl_identity}
<div id="header">
<jsp:include page="/templates/page/freemarkerTransition/identity.jsp" flush="true"/> ${ftl_menu}
<jsp:include page="/templates/page/freemarkerTransition/menu.jsp" flush="true"/>
</div><!-- #header -->
<hr class="hidden" />
<div id="contentwrap">
<c:import url="${bodyJsp}"/> <c:import url="${bodyJsp}"/>
</div> <!-- #contentwrap -->
<jsp:include page="/templates/page/freemarkerTransition/footer.jsp" flush="true"/> ${ftl_footer}
</div> <!-- #wrap -->
</body> </body>
</html> </html>