From b5730561199906afe5af6946814722edd3953cc2 Mon Sep 17 00:00:00 2001 From: tudtianus <tudtianus@gmail.com> Date: Fri, 15 Jun 2018 14:23:05 +0200 Subject: [PATCH] fix: added grid layout to createJournal.html, moved markdown to html conversion to server --- gemeinsamforschen/pom.xml | 5 ++ .../journal/service/DummyJournalService.java | 18 ++++- .../src/main/webapp/assets/css/journal.css | 42 ++++++++++ .../src/main/webapp/pages/createJournal.html | 77 +++++++++++++------ 4 files changed, 116 insertions(+), 26 deletions(-) create mode 100644 gemeinsamforschen/src/main/webapp/assets/css/journal.css diff --git a/gemeinsamforschen/pom.xml b/gemeinsamforschen/pom.xml index 860b8d5e..81951f47 100644 --- a/gemeinsamforschen/pom.xml +++ b/gemeinsamforschen/pom.xml @@ -147,6 +147,11 @@ <scope>provided</scope> </dependency> + <dependency> + <groupId>com.atlassian.commonmark</groupId> + <artifactId>commonmark</artifactId> + <version>0.11.0</version> + </dependency> </dependencies> </project> \ No newline at end of file diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/DummyJournalService.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/DummyJournalService.java index f5a48326..eef3702d 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/DummyJournalService.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/DummyJournalService.java @@ -1,12 +1,14 @@ package unipotsdam.gf.modules.journal.service; +import org.commonmark.renderer.html.HtmlRenderer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import unipotsdam.gf.modules.assessment.controller.StudentIdentifier; import unipotsdam.gf.modules.journal.model.Journal; import unipotsdam.gf.modules.journal.model.JournalFilter; import unipotsdam.gf.modules.journal.model.Visibility; - +import org.commonmark.node.*; +import org.commonmark.parser.Parser; import java.util.ArrayList; import java.util.Calendar; @@ -83,7 +85,7 @@ public class DummyJournalService implements JournalService { if (Long.valueOf(id) == -1){ StudentIdentifier studentId = new StudentIdentifier(student,project); - journals.add(new Journal(this.id++, studentId, text , cal.getTimeInMillis(), stringToVisibility(visibility) , category)); + journals.add(new Journal(this.id++, studentId, convertMarkdownToHtml(text) , cal.getTimeInMillis(), stringToVisibility(visibility) , category)); } else { for (Journal j : journals){ @@ -142,4 +144,16 @@ public class DummyJournalService implements JournalService { return journals; } + /** + * Converts a markdown text to html + * @param markdown markdown text + * @return html text + */ + private String convertMarkdownToHtml (String markdown){ + Parser parser = Parser.builder().build(); + Node document = parser.parse("This is *Sparta*"); + HtmlRenderer renderer = HtmlRenderer.builder().build(); + return renderer.render(document); + } + } diff --git a/gemeinsamforschen/src/main/webapp/assets/css/journal.css b/gemeinsamforschen/src/main/webapp/assets/css/journal.css new file mode 100644 index 00000000..43418240 --- /dev/null +++ b/gemeinsamforschen/src/main/webapp/assets/css/journal.css @@ -0,0 +1,42 @@ +.jounral-form-container { + height:90vh; + display: grid; + grid-template-rows: 5% 90% 5%; + grid-template-columns: 40% 40% 20%; +} + +.visibility{ + grid-column-start:1; + grid-column-end:1; + grid-row-start:1; + grid-row-end:1; +} + +.category{ + grid-column-start:2; + grid-column-end:2; + grid-row-start:1; + grid-row-end:1; +} + +.editor{ + grid-column-start:1; + grid-column-end:3; + grid-row-start:2; + grid-row-end:2; +} + +.save{ + grid-column-start:1; + grid-column-end:1; + grid-row-start:3; + grid-row-end:3; +} + +.back{ + grid-column-start:2; + grid-column-end:2; + grid-row-start:3; + grid-row-end:3; +} + diff --git a/gemeinsamforschen/src/main/webapp/pages/createJournal.html b/gemeinsamforschen/src/main/webapp/pages/createJournal.html index bdee04a6..dc71b6ac 100644 --- a/gemeinsamforschen/src/main/webapp/pages/createJournal.html +++ b/gemeinsamforschen/src/main/webapp/pages/createJournal.html @@ -1,35 +1,64 @@ <!DOCTYPE html> <html> +<head> + <script src="https://cdn.jsdelivr.net/npm/inscrybmde@1.11.3/dist/inscrybmde.min.js"></script> + + <link rel="stylesheet" type="text/css" href="../assets/css/journal.css"> + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/inscrybmde@1.11.3/dist/inscrybmde.min.css"> + +</head> <body> - <form id="journalform" class="form-journal" method="POST" action="../rest/journal/save"> - - <input type="hidden" name="student" value="0"> - <input type="hidden" name="project" value="0"> - - <div> - <textarea name="text" form="journalform"> - </textarea> +<h1> Tagebucheintrag erstellen </h1> + +<form id="journalform" class="form-journal" method="POST" action="../rest/journal/save"> + + <input type="hidden" name="student" value="0"> + <input type="hidden" name="project" value="0"> + + <div class="jounral-form-container"> + + <div class = "visibility"> + Sichtbarkeit: + <select name="visibility" form="journalform"> + <option value="ALL"> Alle </option> + <option value="GROUP"> Gruppe </option> + <option value="DOZENT"> Dozent </option> + <option value="NONE"> Niemand </option> + </select> </div> - - <div> - <select name="visibility" form="journalform"> - <option value="ALL"> Alle </option> - <option value="GROUP"> Gruppe </option> - <option value="DOZENT"> Dozent </option> - <option value="NONE"> Niemand </option> - </select> + + <div class = "category"> + Kategorie: + <select name="category" form="journalform"> + <option value="A"> A </option> + <option value="B"> B </option> + </select> </div> - <div> - <select name="category" form="journalform"> - <option value="A"> A </option> - <option value="B"> B </option> - </select> + + + <div class ="editor"> + <textarea id = "editor" name="text" form="journalform" > + </textarea> + </div> + + <div class="save"> + <input type="submit"> + </div> + + <div class="back"> + <button> Zurück </button> </div> - <input type="submit"> - </form> + </div> +</form> - +<script> + var editor = new InscrybMDE({ + element: document.getElementById("editor"), + spellChecker: false, + forceSync: true, + }); +</script> </body> </html> -- GitLab