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:
rjy7 2010-05-21 16:39:32 +00:00
parent bda278e59b
commit 197aa2f4f9
6 changed files with 22 additions and 22 deletions

View file

@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
@ -30,8 +31,6 @@ public class ContactMailController extends FreeMarkerHttpServlet {
private static final long serialVersionUID = 1L;
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 EMAIL_BACKUP_FILE_PATH = "/WEB-INF/LatestMessage.html";
@ -185,7 +184,7 @@ public class ContactMailController extends FreeMarkerHttpServlet {
try {
if (spamReason == null) {
sendMessage(s, webuseremail, deliverToArray, deliveryfrom,
sendMessage(s, webuseremail, webusername, deliverToArray, deliveryfrom,
recipientCount, msgText);
}
@ -272,7 +271,7 @@ public class ContactMailController extends FreeMarkerHttpServlet {
// 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 msgText)
throws AddressException, SendFailedException, MessagingException {
@ -281,7 +280,12 @@ public class ContactMailController extends FreeMarkerHttpServlet {
//System.out.println("trying to send message from servlet");
// 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

View file

@ -291,14 +291,17 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
private final void setThemeInfo(String themeDir) {
themeDir = getUrl(themeDir);
setSharedVariable("themeDir", themeDir);
// We'll need to separate theme-general and theme-specific stylesheet
// dirs, so we need either two attributes or a list.
// This value will be available to any template as a path for adding a new stylesheet.
// 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.
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");
}

View file

@ -3,7 +3,7 @@
<#-- Confirmation page for comment form -->
<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>Return to the <a href="${urls.home}">home page</a>.</p>

View file

@ -1,6 +1,6 @@
<#-- $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 />

View file

@ -1,6 +1,6 @@
<#-- $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="${stylesheetDir}/print.css" media="print"/>
<link rel="stylesheet" type="text/css" href="${stylesheetPath}/screen.css" media="screen"/>
<link rel="stylesheet" type="text/css" href="${stylesheetPath}/print.css" media="print"/>
${stylesheets.tags}

View file

@ -36,10 +36,3 @@
<#include "/components/scripts.ftl">
</body>
</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")}
-->