Browse Source

Fix no white space for article body

Carlos Hernandez 3 years ago
parent
commit
dfe7206d24
2 changed files with 11 additions and 4 deletions
  1. 5
    0
      app_template/www/css/main.css
  2. 6
    4
      app_template/www/fetch_articles.js

+ 5
- 0
app_template/www/css/main.css View File

@@ -52,3 +52,8 @@ button.article-content {
52 52
 .modal button.close {
53 53
     color: rgb(255, 0, 0) !important;
54 54
 }
55
+
56
+.modal-body,
57
+button.article-content {
58
+    white-space: pre-wrap
59
+}

+ 6
- 4
app_template/www/fetch_articles.js View File

@@ -5,6 +5,7 @@ function get_articles(single = false) {
5 5
             articles = response.data;
6 6
             if (single) {
7 7
                 let artName = articles[articles.length - 1];
8
+                let artNameNoExt = artName.substr(0, artName.lastIndexOf()) || artName;
8 9
                 axios.get(`http://136.145.231.32:8080/${artName}`)
9 10
                     .then(response => {
10 11
                         let homeArticleParent = document.querySelector("#home-article")
@@ -25,13 +26,13 @@ function get_articles(single = false) {
25 26
                             <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-lg">
26 27
                                 <div class="modal-content">
27 28
                                     <div class="modal-header">
28
-                                        <h5 class="modal-title" id="homeArticleModal">${artName}</h5>
29
+                                        <h5 class="modal-title" id="homeArticleModal">${artNameNoExt}</h5>
29 30
                                         <button type="button" class="close" data-dismiss="modal" aria-label="Close">
30 31
                                             <span aria-hidden="true">&times;</span>
31 32
                                         </button>
32 33
                                     </div>
33 34
                                     <div class="modal-body">
34
-                                        ${response.data}
35
+                                        <p>${response.data}</p>
35 36
                                     </div>
36 37
                                     <div class="modal-footer">
37 38
                                         <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
@@ -46,6 +47,7 @@ function get_articles(single = false) {
46 47
             else {
47 48
                 for (let i = 0; i < articles.length; i++) {
48 49
                     let element = articles[i];
50
+                    let elementNoExt = element.substr(0, element.lastIndexOf('.')) || element;
49 51
                     axios.get(`http://136.145.231.32:8080/${element}`)
50 52
                         .then(response => {
51 53
                             let articlesHeading = document.querySelector("#articles-heading").parentElement;
@@ -66,13 +68,13 @@ function get_articles(single = false) {
66 68
                                 <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-lg">
67 69
                                     <div class="modal-content">
68 70
                                         <div class="modal-header">
69
-                                            <h5 class="modal-title" id="articleModalLabel${i}">${element}</h5>
71
+                                            <h5 class="modal-title" id="articleModalLabel${i}">${elementNoExt}</h5>
70 72
                                             <button type="button" class="close" data-dismiss="modal" aria-label="Close">
71 73
                                                 <span aria-hidden="true">&times;</span>
72 74
                                             </button>
73 75
                                         </div>
74 76
                                         <div class="modal-body">
75
-                                            ${response.data}
77
+                                            <p>${response.data}</p>
76 78
                                         </div>
77 79
                                         <div class="modal-footer">
78 80
                                             <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>