Fix formatting issue
Showing
2 changed files
with
41 additions
and
5 deletions
... | @@ -24,6 +24,40 @@ along with this software (see the LICENSE.md file). If not, see | ... | @@ -24,6 +24,40 @@ along with this software (see the LICENSE.md file). If not, see |
24 | <if condition="dataPre == null"> | 24 | <if condition="dataPre == null"> |
25 | <return error="true" message="Email Template does not exist at ${emailTemplate.htmlLocation} with version ${emailTemplate.htmlPublishedVersionName}"/> | 25 | <return error="true" message="Email Template does not exist at ${emailTemplate.htmlLocation} with version ${emailTemplate.htmlPublishedVersionName}"/> |
26 | </if> | 26 | </if> |
27 | <set field="doc" from="org.jsoup.Jsoup.parse(dataPre)"/> | ||
28 | <script><![CDATA[ | ||
29 | doc.outputSettings().escapeMode(org.jsoup.nodes.Entities.EscapeMode.xhtml).prettyPrint(false); | ||
30 | |||
31 | doc.traverse(new org.jsoup.select.NodeVisitor() { | ||
32 | public void head(org.jsoup.nodes.Node node, int depth) { | ||
33 | if (node instanceof org.jsoup.nodes.TextNode) { | ||
34 | def text = node.getWholeText(); | ||
35 | if(text.trim().length() > 0) { | ||
36 | def newText = ""; | ||
37 | def lines = text.split("\n"); | ||
38 | for (line in lines) { | ||
39 | if (line.startsWith("<br>")) { | ||
40 | line = line.replaceFirst(/^<br>/, ""); | ||
41 | } | ||
42 | if (line.endsWith("<br>")) { | ||
43 | newText += line; | ||
44 | } else { | ||
45 | newText += line + "<br>"; | ||
46 | } | ||
47 | } | ||
48 | if (newText.startsWith("<br>")) { | ||
49 | newText = newText.replaceFirst(/^<br>/, ""); | ||
50 | } | ||
51 | node = org.jsoup.nodes.TextNode.createFromEncoded(newText); | ||
52 | } | ||
53 | } | ||
54 | } | ||
55 | public void tail(org.jsoup.nodes.Node node, int depth) { | ||
56 | // No action needed on tail | ||
57 | } | ||
58 | }); | ||
59 | ]]></script> | ||
60 | <set field="dataPre" from="doc.html()"/> | ||
27 | <script><![CDATA[ | 61 | <script><![CDATA[ |
28 | String location = emailTemplate?.htmlLocation ?: "template.ftl"; | 62 | String location = emailTemplate?.htmlLocation ?: "template.ftl"; |
29 | 63 | ... | ... |
... | @@ -385,13 +385,15 @@ along with this software (see the LICENSE.md file). If not, see | ... | @@ -385,13 +385,15 @@ along with this software (see the LICENSE.md file). If not, see |
385 | <entity-find-one entity-name="moqui.resource.DbResourceFileHistory" value-field="usedResourceHistory" auto-field-map="[resourceId:resource.resourceId,previousVersionName:resourceHistory.versionName]" for-update="true"> | 385 | <entity-find-one entity-name="moqui.resource.DbResourceFileHistory" value-field="usedResourceHistory" auto-field-map="[resourceId:resource.resourceId,previousVersionName:resourceHistory.versionName]" for-update="true"> |
386 | <select-field field-name="resourceId,versionName,versionDate,previousVersionName,userId"/></entity-find-one> | 386 | <select-field field-name="resourceId,versionName,versionDate,previousVersionName,userId"/></entity-find-one> |
387 | <!-- <log level="warn" message="set versionName ${usedResourceHistory.versionName} of previousVersionName ${usedResourceHistory.previousVersionName} to ${resourceHistory.previousVersionName}"/>--> | 387 | <!-- <log level="warn" message="set versionName ${usedResourceHistory.versionName} of previousVersionName ${usedResourceHistory.previousVersionName} to ${resourceHistory.previousVersionName}"/>--> |
388 | <set field="usedResourceHistory.previousVersionName" from="resourceHistory.previousVersionName"/> | 388 | <if condition="usedResourceHistory"> |
389 | <set field="usedResourceHistory.previousVersionName" from="resourceHistory?.previousVersionName"/> | ||
389 | 390 | ||
390 | <log level="info" message="Removed resource history ${resourceHistory.resourceId} version ${resourceHistory.versionName}"/> | 391 | <log level="info" message="Removed resource history ${resourceHistory.resourceId} version ${resourceHistory.versionName}"/> |
391 | <set field="removedHistoryList" from="removedHistoryList + [resourceId:resource.resourceId, versionName:resourceHistory.versionName,versionDate:resourceHistory.versionDate,userId:resourceHistory.userId]"/> | 392 | <set field="removedHistoryList" from="removedHistoryList + [resourceId:resource.resourceId, versionName:resourceHistory.versionName,versionDate:resourceHistory.versionDate,userId:resourceHistory.userId]"/> |
392 | 393 | ||
393 | <entity-update value-field="usedResourceHistory"/> | 394 | <entity-update value-field="usedResourceHistory"/> |
394 | <entity-delete value-field="resourceHistory"/> | 395 | <entity-delete value-field="resourceHistory"/> |
396 | </if> | ||
395 | </iterate> | 397 | </iterate> |
396 | </iterate> | 398 | </iterate> |
397 | 399 | ... | ... |
-
Please register or sign in to post a comment