Rewrote comment form controllers and templates in FreeMarker.
This commit is contained in:
parent
ae01a03122
commit
f88a77d307
24 changed files with 723 additions and 208 deletions
|
@ -46,7 +46,7 @@
|
|||
|
||||
<form name = "contact_form" action="sendmail" method="post" onsubmit="return ValidateForm('contact_form');">
|
||||
<input type="hidden" name="home" value="${portalId}"/>
|
||||
<input type="hidden" name="RequiredFields" value="webusername,webuseremail,comments"/>
|
||||
<input type="hidden" name="RequiredFields" value="webusername,webuseremail,s34gfd88p9x1"/>
|
||||
<input type="hidden" name="RequiredFieldsNames" value="Name,Email address,Comments"/>
|
||||
<input type="hidden" name="EmailFields" value="webuseremail"/>
|
||||
<input type="hidden" name="EmailFieldsNames" value="emailaddress"/>
|
||||
|
|
75
webapp/web/js/commentForm.js
Normal file
75
webapp/web/js/commentForm.js
Normal file
|
@ -0,0 +1,75 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
function ValidateForm(formName) {
|
||||
var x = 0; // counts form elements - used as array index
|
||||
var y = 0; // counts required fields - used as array index
|
||||
errors = false;
|
||||
var errorList;
|
||||
|
||||
if (document.forms[formName].RequiredFields) {
|
||||
errorList = 'Please fill out the following required fields:\n';
|
||||
// build array of required fields
|
||||
reqStr = document.forms[formName].RequiredFields.value;
|
||||
requiredFields = reqStr.split(',');
|
||||
// build array holding the names of required fields as
|
||||
// displayed in error box
|
||||
if (document.forms[formName].RequiredFieldsNames) {
|
||||
reqNameStr = document.forms[formName].RequiredFieldsNames.value;
|
||||
} else {
|
||||
reqNameStr = document.forms[formName].RequiredFields.value;
|
||||
}
|
||||
requiredNames = reqNameStr.split(',');
|
||||
// Loop through form elements, checking for required fields
|
||||
while ((x < document.forms[formName].elements.length)) {
|
||||
if (document.forms[formName].elements[x].name == requiredFields[y]) {
|
||||
if (document.forms[formName].elements[x].value == '') {
|
||||
errorList += requiredNames[y] + '\n';
|
||||
errors = true;
|
||||
}
|
||||
y++;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
if (errors) {
|
||||
alert(errorList);
|
||||
return false;
|
||||
}
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
|
||||
// Check for Email formatting
|
||||
if (document.forms[formName].EmailFields) {
|
||||
errorList = 'Please format your e-mail address as: \"userid@institution.edu\" or enter another complete email address';
|
||||
// build array of required fields
|
||||
emailStr = document.forms[formName].EmailFields.value;
|
||||
emailFields = emailStr.split(',');
|
||||
// build array holding the names of required fields as
|
||||
// displayed in error box
|
||||
if (document.forms[formName].EmailFieldsNames) {
|
||||
emailNameStr = document.forms[formName].EmailFieldsNames.value;
|
||||
} else {
|
||||
emailNameStr = document.forms[formName].EmailFields.value;
|
||||
}
|
||||
emailNames = emailNameStr.split(',');
|
||||
// Loop through form elements, checking for required fields
|
||||
while ((x < document.forms[formName].elements.length)) {
|
||||
if (document.forms[formName].elements[x].name == emailFields[y]) {
|
||||
if ((document.forms[formName].elements[x].value.indexOf('@') < 1)
|
||||
|| (document.forms[formName].elements[x].value.lastIndexOf('.') < document.forms[formName].elements[x].value.indexOf('@')+1)) {
|
||||
errors = true;
|
||||
}
|
||||
y++;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
if (errors) {
|
||||
alert(errorList);
|
||||
return false;
|
||||
}
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
<!-- /* $This file is distributed under the terms of the license in /doc/license.txt$ */ -->
|
||||
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
<!--
|
||||
function ValidateForm(formName) {
|
||||
var x = 0; // counts form elements - used as array index
|
||||
var y = 0; // counts required fields - used as array index
|
||||
errors = false;
|
||||
var errorList;
|
||||
|
||||
if (document.forms[formName].RequiredFields) {
|
||||
errorList = 'Please fill out the following required fields:\n';
|
||||
// build array of required fields
|
||||
reqStr = document.forms[formName].RequiredFields.value;
|
||||
requiredFields = reqStr.split(',');
|
||||
// build array holding the names of required fields as
|
||||
// displayed in error box
|
||||
if (document.forms[formName].RequiredFieldsNames) {
|
||||
reqNameStr = document.forms[formName].RequiredFieldsNames.value;
|
||||
} else {
|
||||
reqNameStr = document.forms[formName].RequiredFields.value;
|
||||
}
|
||||
requiredNames = reqNameStr.split(',');
|
||||
// Loop through form elements, checking for required fields
|
||||
while ((x < document.forms[formName].elements.length)) {
|
||||
if (document.forms[formName].elements[x].name == requiredFields[y]) {
|
||||
if (document.forms[formName].elements[x].value == '') {
|
||||
errorList += requiredNames[y] + '\n';
|
||||
errors = true;
|
||||
}
|
||||
y++;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
if (errors) {
|
||||
alert(errorList);
|
||||
return false;
|
||||
}
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
|
||||
// Check for Email formatting
|
||||
if (document.forms[formName].EmailFields) {
|
||||
errorList = 'Please format your e-mail address as: \"userid@institution.edu\" or enter another complete email address';
|
||||
// build array of required fields
|
||||
emailStr = document.forms[formName].EmailFields.value;
|
||||
emailFields = emailStr.split(',');
|
||||
// build array holding the names of required fields as
|
||||
// displayed in error box
|
||||
if (document.forms[formName].EmailFieldsNames) {
|
||||
emailNameStr = document.forms[formName].EmailFieldsNames.value;
|
||||
} else {
|
||||
emailNameStr = document.forms[formName].EmailFields.value;
|
||||
}
|
||||
emailNames = emailNameStr.split(',');
|
||||
// Loop through form elements, checking for required fields
|
||||
while ((x < document.forms[formName].elements.length)) {
|
||||
if (document.forms[formName].elements[x].name == emailFields[y]) {
|
||||
if ((document.forms[formName].elements[x].value.indexOf('@') < 1)
|
||||
|| (document.forms[formName].elements[x].value.lastIndexOf('.') < document.forms[formName].elements[x].value.indexOf('@')+1)) {
|
||||
errors = true;
|
||||
}
|
||||
y++;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
if (errors) {
|
||||
alert(errorList);
|
||||
return false;
|
||||
}
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
-->
|
||||
</script>
|
7
webapp/web/js/commentsForm.jsp
Normal file
7
webapp/web/js/commentsForm.jsp
Normal file
|
@ -0,0 +1,7 @@
|
|||
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
||||
|
||||
<%
|
||||
String contextPath = request.getContextPath();
|
||||
%>
|
||||
|
||||
<script language="JavaScript" type="text/javascript" src="<%= contextPath %>/js/commentForm.js"></script>
|
|
@ -5,12 +5,14 @@
|
|||
<#if message??>
|
||||
<p>${message}</p>
|
||||
<#else>
|
||||
<#list classGroups as classGroup>
|
||||
<h2>${classGroup.publicName}</h2>
|
||||
<ul>
|
||||
<#list classGroup.classes as class>
|
||||
<li><a href="${class.url}">${class.name}</a> (${class.entityCount})</li>
|
||||
</#list>
|
||||
</ul>
|
||||
</#list>
|
||||
</#if>
|
||||
<div class="siteMap">
|
||||
<#list classGroups as classGroup>
|
||||
<h2>${classGroup.publicName}</h2>
|
||||
<ul>
|
||||
<#list classGroup.classes as class>
|
||||
<li><a href="${class.url}">${class.name}</a> (${class.entityCount})</li>
|
||||
</#list>
|
||||
</ul>
|
||||
</#list>
|
||||
</div>
|
||||
</#if>
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- Confirmation page for comment form -->
|
||||
|
||||
<h2>Thank you for your feedback</h2>
|
||||
<img src="${siteIconDir}/mail.gif" alt="mailbox"/><br/>
|
||||
|
||||
<p>Thank you for contacting our curation and development team. We will respond to your inquiry as soon as possible.</p>
|
||||
<p>Return to the <a href="${urls.home}">home page</a>.</p>
|
|
@ -0,0 +1,3 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- Comment form email response -->
|
13
webapp/web/templates/freemarker/body/commentForm/error.ftl
Normal file
13
webapp/web/templates/freemarker/body/commentForm/error.ftl
Normal file
|
@ -0,0 +1,13 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<img src="${siteIconDir}/bomb.gif" alt="email error"/>
|
||||
|
||||
|
||||
<p class="normal">An error occurred during the processing of your request.<br />
|
||||
<#if errorMessage?has_content>
|
||||
<strong>${errorMessage}</strong>
|
||||
</#if>
|
||||
</p>
|
||||
|
||||
|
||||
<p>Return to the <a href="${urls.home}">home page</a>.</p>
|
59
webapp/web/templates/freemarker/body/commentForm/form.ftl
Normal file
59
webapp/web/templates/freemarker/body/commentForm/form.ftl
Normal file
|
@ -0,0 +1,59 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- Comment form -->
|
||||
|
||||
<div class="staticPageBackground feedbackForm">
|
||||
|
||||
<h2>${title}</h2>
|
||||
|
||||
<p>Thank you for your interest in
|
||||
<#compress>
|
||||
<#if portalType == "CALSResearch">
|
||||
the Cornell University College of Agriculture and Life Sciences Research Portal
|
||||
<#elseif portalType == "VIVO">
|
||||
VIVO
|
||||
<#else>
|
||||
the ${siteName} portal
|
||||
</#if>
|
||||
</#compress>.
|
||||
Please submit this form with questions, comments, or feedback about the content of this site.
|
||||
</p>
|
||||
|
||||
<#if siteName == "CALSResearch" || siteName == "CALSImpact">
|
||||
<p>
|
||||
${siteName} is a service that depends on regular updates and feedback.
|
||||
Please help us out by providing comments and suggestions for additional content (people, departments, courses, research services, etc.)
|
||||
that you would like to see represented. The reference librarians at Albert R. Mann Library will be in touch with you soon.
|
||||
</p>
|
||||
</#if>
|
||||
|
||||
<form name="contact_form" action="sendMail" method="post" onsubmit="return ValidateForm('contact_form');">
|
||||
<input type="hidden" name="home" value="${portalId}"/>
|
||||
<input type="hidden" name="RequiredFields" value="webusername,webuseremail,s34gfd88p9x1"/>
|
||||
<input type="hidden" name="RequiredFieldsNames" value="Name,Email address,Comments"/>
|
||||
<input type="hidden" name="EmailFields" value="webuseremail"/>
|
||||
<input type="hidden" name="EmailFieldsNames" value="emailaddress"/>
|
||||
<input type="hidden" name="DeliveryType" value="comment"/>
|
||||
|
||||
<label for="webusername">Full name</label>
|
||||
<p><input style="width:33%;" type="text" name="webusername" maxlength="255"/></p>
|
||||
<label for="webuseremail">Email address</label>
|
||||
<p><input style="width:25%;" type="text" name="webuseremail" maxlength="255"/></p>
|
||||
|
||||
|
||||
<label>Your comments, questions, or suggestions</label>
|
||||
|
||||
<textarea name="s34gfd88p9x1" rows="10" cols="90"></textarea>
|
||||
|
||||
<div>
|
||||
<input type="submit" value="Send Mail" class="yellowbutton"/>
|
||||
<input type="reset" value="Clear Form" class="plainbutton"/>
|
||||
</div
|
||||
|
||||
<p style="font-weight: bold; margin-top: 1em">Thank you!</p>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<#-- RY This is temporary. -->
|
||||
<script src="${contextPath}/js/commentForm.js"></script>
|
|
@ -17,10 +17,10 @@
|
|||
<p class="normal">${copyrightAnchor} makes no warranty, expressed or implied, including the warranties of merchantability
|
||||
and fitness for a particular purpose, or assumes any legal liability or responsibility for the accuracy,
|
||||
completeness, currency or usefulness of any material displayed or distributed through the
|
||||
${appName} website or represents that its use would not infringe privately owned rights.
|
||||
${siteName} website or represents that its use would not infringe privately owned rights.
|
||||
${copyrightAnchor} disclaims all warranties with regard to the information provided. Any reliance upon such information
|
||||
is at your own risk. In no event will ${copyrightAnchor} be liable to you for any damages or losses whatsoever resulting
|
||||
from or caused by the ${appName} website or its contents.</p>
|
||||
from or caused by the ${siteName} website or its contents.</p>
|
||||
|
||||
<h3>Disclaimer of Endorsement</h3>
|
||||
<p class="normal">Reference herein to any specific commercial product, process, or service by trade name,
|
||||
|
|
|
@ -24,5 +24,3 @@
|
|||
All Rights Reserved. <a href="${urls.termsOfUse}">Terms of Use</a>
|
||||
|
||||
</div>
|
||||
|
||||
<#-- SCRIPT TAGS SHOULD GO HERE -->
|
|
@ -0,0 +1,21 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- NOTICE: This is SAMPLE Google Analytics code. You must replace it with your institution's code. -->
|
||||
|
||||
<#--
|
||||
<script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
try {
|
||||
var pageTracker = _gat._getTracker("UA-5164622-5");
|
||||
pageTracker._setDomainName("vivo.cornell.edu");
|
||||
pageTracker._setAllowLinker(true);
|
||||
pageTracker._trackPageview();
|
||||
var rollupTracker = _gat._getTracker("UA-12531954-1");
|
||||
rollupTracker._setDomainName("none");
|
||||
rollupTracker._setAllowLinker(true);
|
||||
rollupTracker._trackPageview(location.host+location.pathname);
|
||||
}
|
||||
catch(err) {}
|
||||
</script>
|
||||
-->
|
|
@ -1 +1,5 @@
|
|||
<#-- $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$ -->
|
||||
|
||||
<#include "googleAnalytics.ftl">
|
||||
|
||||
<#-- OTHER SCRIPT TAGS HERE -->
|
|
@ -3,6 +3,8 @@
|
|||
<link rel="stylesheet" type="text/css" href="${stylesheetDir}screen.css" media="screen"/>
|
||||
<link rel="stylesheet" type="text/css" href="${stylesheetDir}print.css" media="print"/>
|
||||
|
||||
<#list stylesheets as stylesheet>
|
||||
${stylesheet}
|
||||
</#list>
|
||||
<#if stylesheeets??>
|
||||
<#list stylesheets as stylesheet>
|
||||
${stylesheet}
|
||||
</#list>
|
||||
</#if>
|
|
@ -22,7 +22,7 @@
|
|||
<hr class="hidden" />
|
||||
|
||||
<div id="contentwrap">
|
||||
<div id="content" <#if contentClass??> class="${contentClass}" </#if>>
|
||||
<div id="content">
|
||||
<#-- We don't do title here because some pages don't get a title, or it may not be the same as the <title> text.
|
||||
<h2>${title}</h2> -->
|
||||
${body}
|
||||
|
@ -31,6 +31,8 @@
|
|||
|
||||
<#include "/components/footer.ftl">
|
||||
|
||||
</div> <!-- wrap -->
|
||||
</div> <!-- wrap -->
|
||||
|
||||
<#include "/components/scripts.ftl">
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue