This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository bow. See http://git.chorem.org/bow.git commit 07d2743f5d8d541284b1f37e853a562e68ee7782 Author: Benjamin POUSSIN <poussin@codelutin.com> Date: Tue Jul 28 16:41:38 2015 +0200 add markdown processor to process bookmark description (in safeMode) --- bow-ui/pom.xml | 6 ++++++ bow-ui/src/main/java/org/chorem/bow/BowUtils.java | 13 +++++++++++++ bow-ui/src/main/webapp/WEB-INF/bowutils.tld | 6 ++++++ bow-ui/src/main/webapp/WEB-INF/jsp/atom.jsp | 2 +- bow-ui/src/main/webapp/WEB-INF/jsp/inc/bookmark.jsp | 6 +++--- bow-ui/src/main/webapp/css/bookmark.css | 13 ++++++++++++- pom.xml | 7 ++++++- 7 files changed, 47 insertions(+), 6 deletions(-) diff --git a/bow-ui/pom.xml b/bow-ui/pom.xml index d15ad9b..a733e8b 100644 --- a/bow-ui/pom.xml +++ b/bow-ui/pom.xml @@ -208,6 +208,12 @@ <groupId>org.jsoup</groupId> <artifactId>jsoup</artifactId> </dependency> + + <dependency> + <groupId>com.github.rjeschke</groupId> + <artifactId>txtmark</artifactId> + </dependency> + </dependencies> <build> diff --git a/bow-ui/src/main/java/org/chorem/bow/BowUtils.java b/bow-ui/src/main/java/org/chorem/bow/BowUtils.java index af80bcd..1e9b0df 100644 --- a/bow-ui/src/main/java/org/chorem/bow/BowUtils.java +++ b/bow-ui/src/main/java/org/chorem/bow/BowUtils.java @@ -20,6 +20,8 @@ */ package org.chorem.bow; +import com.github.rjeschke.txtmark.Configuration; +import com.github.rjeschke.txtmark.Processor; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; @@ -47,6 +49,17 @@ public class BowUtils { public BowUtils() { } + private static final Configuration markdownConf = + Configuration.builder().forceExtentedProfile().enableSafeMode().build(); + + public static String toHtml(String markdown) { + String result = ""; + if (StringUtils.isNotBlank(markdown)) { + result = Processor.process(markdown, markdownConf); + } + return result; + } + public static String toBase64(byte[] b) { return Base64.encodeBase64String(b); } diff --git a/bow-ui/src/main/webapp/WEB-INF/bowutils.tld b/bow-ui/src/main/webapp/WEB-INF/bowutils.tld index ca2d045..612f6c0 100644 --- a/bow-ui/src/main/webapp/WEB-INF/bowutils.tld +++ b/bow-ui/src/main/webapp/WEB-INF/bowutils.tld @@ -19,4 +19,10 @@ <function-class>org.chorem.bow.BowUtils</function-class> <function-signature>boolean isPublicGroup(org.chorem.bow.BowGroup)</function-signature> </function> + + <function> + <name>toHtml</name> + <function-class>org.chorem.bow.BowUtils</function-class> + <function-signature>java.lang.String toHtml(java.lang.String)</function-signature> + </function> </taglib> diff --git a/bow-ui/src/main/webapp/WEB-INF/jsp/atom.jsp b/bow-ui/src/main/webapp/WEB-INF/jsp/atom.jsp index ea53368..42d9509 100644 --- a/bow-ui/src/main/webapp/WEB-INF/jsp/atom.jsp +++ b/bow-ui/src/main/webapp/WEB-INF/jsp/atom.jsp @@ -107,7 +107,7 @@ <p><s:a href="%{config.aliasUrl + #bookmark.wikittyId}.action"><s:property value="%{#bookmark.link}" /></s:a></p> <h3><s:text name="bow.bookmark.description" /> :</h3> - <p><s:property value="%{#bookmark.description}" escapeHtml="false" escapeJavaScript="true"/></p> + ${u:toHtml(bookmark.description)} <p> <strong><s:text name="bow.bookmark.tags" /> :</strong> <s:iterator value="#bookmark.labels" var="tag"> diff --git a/bow-ui/src/main/webapp/WEB-INF/jsp/inc/bookmark.jsp b/bow-ui/src/main/webapp/WEB-INF/jsp/inc/bookmark.jsp index 5e89bde..e5914f4 100644 --- a/bow-ui/src/main/webapp/WEB-INF/jsp/inc/bookmark.jsp +++ b/bow-ui/src/main/webapp/WEB-INF/jsp/inc/bookmark.jsp @@ -108,9 +108,9 @@ <s:a href="alias/%{#bookmark.wikittyId}.action"><s:property value="%{#bookmark.link}"/></s:a> </p> <h3><s:text name="bow.bookmark.description" /> :</h3> - <p> - <s:property value="%{#bookmark.description}"/> - </p> + <div class="markdown"> + ${u:toHtml(bookmark.description)} + </div> <p class="tags"> <strong><s:text name="bow.bookmark.tags" /> :</strong> <s:iterator value="#bookmark.labels" var="tag"> diff --git a/bow-ui/src/main/webapp/css/bookmark.css b/bow-ui/src/main/webapp/css/bookmark.css index e6548df..b4ba97e 100644 --- a/bow-ui/src/main/webapp/css/bookmark.css +++ b/bow-ui/src/main/webapp/css/bookmark.css @@ -181,9 +181,20 @@ left: 100px; } -.bookmark .description h3{ +.bookmark .description h3 { color:#88516c; } +.markdown p { + margin: inherit; +} + +.markdown p, .markdown ul, .markdown ol { + margin-bottom: 5px; +} + +.markdown ul { + margin-left: 20px; +} .bookmark .description .tags{ color:#88516c; diff --git a/pom.xml b/pom.xml index ae86097..bbf36ed 100644 --- a/pom.xml +++ b/pom.xml @@ -128,7 +128,7 @@ <h2Version>1.4.187</h2Version> <crxMavenPluginVersion>1.1.0</crxMavenPluginVersion> <jstlVersion>1.2</jstlVersion> - + <txtmarkVersion>0.13</txtmarkVersion> <!-- license to use --> <license.licenseName>agpl_v3</license.licenseName> @@ -403,6 +403,11 @@ <version>1.7.2</version> </dependency> + <dependency> + <groupId>com.github.rjeschke</groupId> + <artifactId>txtmark</artifactId> + <version>${txtmarkVersion}</version> + </dependency> </dependencies> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.