|
static final String | MAIL_CSS = "/WEB-INF/elephant/templates-mail/css" |
|
◆ inline()
String org.turro.mail.impl.MailFormat.inline |
( |
String |
html | ) |
|
Definition at line 56 of file MailFormat.java.
57 if(Strings.isBlank(html)) {
65 File rootCSS =
new File(ElephantContext.getRealPath(
MAIL_CSS));
66 if (rootCSS.exists()) {
67 for (File css : rootCSS.listFiles(
new FilenameFilter() {
69 public boolean accept(File dir, String name) {
70 return name.endsWith(
".css");
74 html = inlineCSS(css, html);
75 }
catch (IOException ex) {
76 Logger.getLogger(MailFormat.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(
null), ex);
80 return HTMLEntities.escape(html);
◆ inlineStyles()
String org.turro.mail.impl.MailFormat.inlineStyles |
( |
String |
html | ) |
throws IOException |
Definition at line 132 of file MailFormat.java.
133 final Document doc = Jsoup.parse(html);
134 String style =
"style";
135 Elements els = doc.select(style);
136 for (Element e : els) {
137 String styleRules = e.getAllElements().get(0).data().replaceAll(
"\n",
"").trim(), delims
139 StringTokenizer st =
new StringTokenizer(styleRules, delims);
140 while (st.countTokens() > 1) {
141 String selector = st.nextToken(), properties = st.nextToken();
142 if (selector.indexOf(
":") > 0) {
143 selector = selector.substring(0, selector.indexOf(
":"));
145 if (Strings.isBlank(selector)) {
148 Elements selectedElements = doc.select(selector);
149 for (Element selElem : selectedElements) {
150 String oldProperties = selElem.attr(style);
153 oldProperties.length() > 0 ? concatenateProperties(oldProperties,
154 properties) : properties);
◆ MAIL_CSS
final String org.turro.mail.impl.MailFormat.MAIL_CSS = "/WEB-INF/elephant/templates-mail/css" |
|
static |
The documentation for this class was generated from the following file: