Tweaks to: adding stylesheets from freemarker templates; contact form styles. Add sender's name to sender address on contact form email notification.
This commit is contained in:
parent
bda278e59b
commit
197aa2f4f9
6 changed files with 22 additions and 22 deletions
|
@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -30,8 +31,6 @@ public class ContactMailController extends FreeMarkerHttpServlet {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static final Logger LOG = Logger.getLogger(ContactMailController.class);
|
private static final Logger LOG = Logger.getLogger(ContactMailController.class);
|
||||||
|
|
||||||
private final static String CONFIRM_PAGE = "/thankyou.jsp";
|
|
||||||
private final static String ERR_PAGE = "/contact_err.jsp";
|
|
||||||
private final static String SPAM_MESSAGE = "Your message was flagged as spam.";
|
private final static String SPAM_MESSAGE = "Your message was flagged as spam.";
|
||||||
private final static String EMAIL_BACKUP_FILE_PATH = "/WEB-INF/LatestMessage.html";
|
private final static String EMAIL_BACKUP_FILE_PATH = "/WEB-INF/LatestMessage.html";
|
||||||
|
|
||||||
|
@ -185,7 +184,7 @@ public class ContactMailController extends FreeMarkerHttpServlet {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (spamReason == null) {
|
if (spamReason == null) {
|
||||||
sendMessage(s, webuseremail, deliverToArray, deliveryfrom,
|
sendMessage(s, webuseremail, webusername, deliverToArray, deliveryfrom,
|
||||||
recipientCount, msgText);
|
recipientCount, msgText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +271,7 @@ public class ContactMailController extends FreeMarkerHttpServlet {
|
||||||
// outFile.close();
|
// outFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMessage(Session s, String webuseremail,
|
private void sendMessage(Session s, String webuseremail, String webusername,
|
||||||
String[] deliverToArray, String deliveryfrom, int recipientCount,
|
String[] deliverToArray, String deliveryfrom, int recipientCount,
|
||||||
String msgText)
|
String msgText)
|
||||||
throws AddressException, SendFailedException, MessagingException {
|
throws AddressException, SendFailedException, MessagingException {
|
||||||
|
@ -281,7 +280,12 @@ public class ContactMailController extends FreeMarkerHttpServlet {
|
||||||
//System.out.println("trying to send message from servlet");
|
//System.out.println("trying to send message from servlet");
|
||||||
|
|
||||||
// Set the from address
|
// Set the from address
|
||||||
msg.setFrom( new InternetAddress( webuseremail ));
|
try {
|
||||||
|
msg.setFrom( new InternetAddress( webuseremail, webusername ));
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
LOG.error("Can't set message sender with personal name " + webusername + " due to UnsupportedEncodingException");
|
||||||
|
msg.setFrom( new InternetAddress( webuseremail ) );
|
||||||
|
}
|
||||||
|
|
||||||
// Set the recipient address
|
// Set the recipient address
|
||||||
|
|
||||||
|
|
|
@ -291,14 +291,17 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
|
||||||
|
|
||||||
private final void setThemeInfo(String themeDir) {
|
private final void setThemeInfo(String themeDir) {
|
||||||
|
|
||||||
themeDir = getUrl(themeDir);
|
// This value will be available to any template as a path for adding a new stylesheet.
|
||||||
setSharedVariable("themeDir", themeDir);
|
// It does not contain the context path, because the methods to generate the href
|
||||||
|
// attribute from the string passed in by the template automatically add the context path.
|
||||||
// We'll need to separate theme-general and theme-specific stylesheet
|
|
||||||
// dirs, so we need either two attributes or a list.
|
|
||||||
setSharedVariable("stylesheetDir", themeDir + "/css");
|
setSharedVariable("stylesheetDir", themeDir + "/css");
|
||||||
|
|
||||||
setSharedVariable("siteIconDir", themeDir + "/site_icons");
|
String themeDirWithContext = getUrl(themeDir);
|
||||||
|
|
||||||
|
// This value is used only in stylesheets.ftl and already contains the context path.
|
||||||
|
root.put("stylesheetPath", themeDirWithContext + "/css");
|
||||||
|
|
||||||
|
setSharedVariable("siteIconPath", themeDirWithContext + "/site_icons");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<#-- Confirmation page for comment form -->
|
<#-- Confirmation page for comment form -->
|
||||||
|
|
||||||
<h2>Thank you for your feedback</h2>
|
<h2>Thank you for your feedback</h2>
|
||||||
<img src="${siteIconDir}/mail.gif" alt="mailbox"/><br/>
|
<img src="${siteIconPath}/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>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>
|
<p>Return to the <a href="${urls.home}">home page</a>.</p>
|
|
@ -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$ -->
|
||||||
|
|
||||||
<img src="${siteIconDir}/bomb.gif" alt="email error"/>
|
<img src="${siteIconPath}/bomb.gif" alt="email error"/>
|
||||||
|
|
||||||
|
|
||||||
<p class="normal">An error occurred during the processing of your request.<br />
|
<p class="normal">An error occurred during the processing of your request.<br />
|
||||||
|
|
|
@ -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$ -->
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="${stylesheetDir}/screen.css" media="screen"/>
|
<link rel="stylesheet" type="text/css" href="${stylesheetPath}/screen.css" media="screen"/>
|
||||||
<link rel="stylesheet" type="text/css" href="${stylesheetDir}/print.css" media="print"/>
|
<link rel="stylesheet" type="text/css" href="${stylesheetPath}/print.css" media="print"/>
|
||||||
|
|
||||||
${stylesheets.tags}
|
${stylesheets.tags}
|
|
@ -36,10 +36,3 @@
|
||||||
<#include "/components/scripts.ftl">
|
<#include "/components/scripts.ftl">
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
<#-- How to add a stylesheet:
|
|
||||||
${stylesheets.addFromTheme("/sample.css");
|
|
||||||
${stylesheets.add("/themes/vivo-basic/css/sample.css"}
|
|
||||||
NOT (gets contextPath added twice):
|
|
||||||
${stylesheets.add(stylesheetDir + "/sample.css")}
|
|
||||||
-->
|
|
Loading…
Add table
Reference in a new issue