From 197aa2f4f9ef4eeef1ebe7da449b89fe6dfb3e50 Mon Sep 17 00:00:00 2001 From: rjy7 Date: Fri, 21 May 2010 16:39:32 +0000 Subject: [PATCH] Tweaks to: adding stylesheets from freemarker templates; contact form styles. Add sender's name to sender address on contact form email notification. --- .../freemarker/ContactMailController.java | 14 +++++++++----- .../freemarker/FreeMarkerHttpServlet.java | 15 +++++++++------ .../freemarker/body/commentForm/confirmation.ftl | 2 +- .../freemarker/body/commentForm/error.ftl | 2 +- .../freemarker/components/stylesheets.ftl | 4 ++-- webapp/web/templates/freemarker/page/default.ftl | 7 ------- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactMailController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactMailController.java index b98c85aa0..050a32f5f 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactMailController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ContactMailController.java @@ -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 diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreeMarkerHttpServlet.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreeMarkerHttpServlet.java index 67d9a4cb1..3e632e1e5 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreeMarkerHttpServlet.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreeMarkerHttpServlet.java @@ -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"); } diff --git a/webapp/web/templates/freemarker/body/commentForm/confirmation.ftl b/webapp/web/templates/freemarker/body/commentForm/confirmation.ftl index a442fc2e1..2d1dee289 100644 --- a/webapp/web/templates/freemarker/body/commentForm/confirmation.ftl +++ b/webapp/web/templates/freemarker/body/commentForm/confirmation.ftl @@ -3,7 +3,7 @@ <#-- Confirmation page for comment form -->

Thank you for your feedback

-mailbox
+mailbox

Thank you for contacting our curation and development team. We will respond to your inquiry as soon as possible.

Return to the home page.

\ No newline at end of file diff --git a/webapp/web/templates/freemarker/body/commentForm/error.ftl b/webapp/web/templates/freemarker/body/commentForm/error.ftl index d17ecab07..2c3bf367f 100644 --- a/webapp/web/templates/freemarker/body/commentForm/error.ftl +++ b/webapp/web/templates/freemarker/body/commentForm/error.ftl @@ -1,6 +1,6 @@ <#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> -email error +email error

An error occurred during the processing of your request.
diff --git a/webapp/web/templates/freemarker/components/stylesheets.ftl b/webapp/web/templates/freemarker/components/stylesheets.ftl index 087ac9ee1..234e781f6 100644 --- a/webapp/web/templates/freemarker/components/stylesheets.ftl +++ b/webapp/web/templates/freemarker/components/stylesheets.ftl @@ -1,6 +1,6 @@ <#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> - - + + ${stylesheets.tags} \ No newline at end of file diff --git a/webapp/web/templates/freemarker/page/default.ftl b/webapp/web/templates/freemarker/page/default.ftl index 79e4e25fa..70da460f2 100644 --- a/webapp/web/templates/freemarker/page/default.ftl +++ b/webapp/web/templates/freemarker/page/default.ftl @@ -36,10 +36,3 @@ <#include "/components/scripts.ftl"> - -<#-- 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")} ---> \ No newline at end of file