Sat, 05 Dec 2020 13:05:00 +0100
enables markdown support in issue descriptions and comments - fixes #10
1.1 --- a/build.gradle.kts Wed Nov 25 11:17:39 2020 +0100 1.2 +++ b/build.gradle.kts Sat Dec 05 13:05:00 2020 +0100 1.3 @@ -32,6 +32,7 @@ 1.4 implementation("org.slf4j:slf4j-api:${slf4jVersion}") 1.5 implementation("org.apache.logging.log4j:log4j-core:${log4jVersion}") 1.6 implementation("org.apache.logging.log4j:log4j-slf4j-impl:${log4jVersion}") 1.7 + implementation("com.vladsch.flexmark:flexmark-all:0.62.2") 1.8 } 1.9 } 1.10 }
2.1 --- a/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java Wed Nov 25 11:17:39 2020 +0100 2.2 +++ b/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java Sat Dec 05 13:05:00 2020 +0100 2.3 @@ -72,7 +72,7 @@ 2.4 } 2.5 } 2.6 2.7 - private void populate(ProjectView viewModel, PathParameters pathParameters, DaoProvider dao) throws SQLException { 2.8 + private void populate(ProjectView viewModel, PathParameters pathParameters, DaoProvider dao) { 2.9 final var projectDao = dao.getProjectDao(); 2.10 final var versionDao = dao.getVersionDao(); 2.11 final var componentDao = dao.getComponentDao(); 2.12 @@ -480,6 +480,8 @@ 2.13 viewModel.setIssue(issue); 2.14 viewModel.setComments(issueDao.listComments(issue)); 2.15 2.16 + viewModel.processMarkdown(); 2.17 + 2.18 forwardView(req, resp, viewModel, "issue-view"); 2.19 } 2.20
3.1 --- a/src/main/java/de/uapcore/lightpit/viewmodel/IssueDetailView.java Wed Nov 25 11:17:39 2020 +0100 3.2 +++ b/src/main/java/de/uapcore/lightpit/viewmodel/IssueDetailView.java Sat Dec 05 13:05:00 2020 +0100 3.3 @@ -1,8 +1,14 @@ 3.4 package de.uapcore.lightpit.viewmodel; 3.5 3.6 +import com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughExtension; 3.7 +import com.vladsch.flexmark.ext.tables.TablesExtension; 3.8 +import com.vladsch.flexmark.html.HtmlRenderer; 3.9 +import com.vladsch.flexmark.parser.Parser; 3.10 +import com.vladsch.flexmark.util.data.MutableDataSet; 3.11 import de.uapcore.lightpit.entities.Issue; 3.12 import de.uapcore.lightpit.entities.IssueComment; 3.13 3.14 +import java.util.Arrays; 3.15 import java.util.List; 3.16 3.17 public class IssueDetailView extends ProjectView { 3.18 @@ -25,4 +31,17 @@ 3.19 public void setComments(List<IssueComment> comments) { 3.20 this.comments = comments; 3.21 } 3.22 + 3.23 + public void processMarkdown() { 3.24 + final var options = new MutableDataSet() 3.25 + .set(Parser.EXTENSIONS, Arrays.asList(TablesExtension.create(), StrikethroughExtension.create())) 3.26 + .toImmutable(); 3.27 + final var parser = Parser.builder(options).build(); 3.28 + final var renderer = HtmlRenderer.builder(options).build(); 3.29 + 3.30 + issue.setDescription(renderer.render(parser.parse(issue.getDescription()))); 3.31 + for (var comment : comments) { 3.32 + comment.setComment(renderer.render(parser.parse(comment.getComment()))); 3.33 + } 3.34 + } 3.35 }
4.1 --- a/src/main/webapp/WEB-INF/jsp/issue-view.jsp Wed Nov 25 11:17:39 2020 +0100 4.2 +++ b/src/main/webapp/WEB-INF/jsp/issue-view.jsp Sat Dec 05 13:05:00 2020 +0100 4.3 @@ -97,7 +97,9 @@ 4.4 <tr> 4.5 <th class="vtop"><fmt:message key="issue.description"/></th> 4.6 <td> 4.7 - <textarea readonly rows="10"><c:out value="${issue.description}"/></textarea> 4.8 + <div class="markdown-styled"> 4.9 + ${issue.description} 4.10 + </div> 4.11 </td> 4.12 </tr> 4.13 <tr> 4.14 @@ -183,8 +185,8 @@ 4.15 <!-- TODO: update count --> 4.16 </c:if> 4.17 </div> 4.18 - <div class="medskip"> 4.19 - <c:out value="${comment.comment}"/> 4.20 + <div class="medskip markdown-styled"> 4.21 + ${comment.comment} 4.22 </div> 4.23 </div> 4.24 </c:forEach>
5.1 --- a/src/main/webapp/lightpit.css Wed Nov 25 11:17:39 2020 +0100 5.2 +++ b/src/main/webapp/lightpit.css Sat Dec 05 13:05:00 2020 +0100 5.3 @@ -269,3 +269,21 @@ 5.4 .row > div { 5.5 display: table-cell; 5.6 } 5.7 + 5.8 +/* MARKDOWN STYLES */ 5.9 + 5.10 +div.markdown-styled p:first-child { 5.11 + margin-top: 0; 5.12 +} 5.13 + 5.14 +div.markdown-styled table { 5.15 + border-collapse: collapse; 5.16 +} 5.17 + 5.18 +div.markdown-styled td, 5.19 +div.markdown-styled th { 5.20 + padding: 0.25em; 5.21 + border-style: solid; 5.22 + border-color: darkgray; 5.23 + border-width: 1pt; 5.24 +}