articleDetails.jsp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  2. <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
  3. <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
  4. <%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
  5. <%@ taglib uri = "http://java.sun.com/jsp/jstl/functions" prefix = "fn" %>
  6. <%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
  7. <jsp:include page="/WEB-INF/jsp/include/head.jsp"></jsp:include>
  8. <script>
  9. function favorite() {
  10. const favArticleBtn = document.querySelectorAll('.favorite-btn');
  11. if("${ssIsLogin}" === "true"){
  12. favArticleBtn.forEach(value =>
  13. value.classList.toggle('active')
  14. )
  15. } else {
  16. location.href = "/user/signin"
  17. }
  18. }
  19. function follow() {
  20. const followBtn = document.querySelectorAll('.follow-btn');
  21. if("${ssIsLogin}" === "true"){
  22. followBtn.forEach(value =>
  23. value.classList.toggle('active')
  24. )
  25. } else {
  26. location.href = "/user/signin"
  27. }
  28. }
  29. window.onload = () => {
  30. const tags = document.querySelector('.tag-list');
  31. const tagString = "${articleDetail.tags}"
  32. const tagList = tagString.split(',');
  33. if(tagString !== ''){
  34. tags.innerHTML = tagList.map(tag =>
  35. `<li class="tag">\${tag}</li>`
  36. ).join('');
  37. }
  38. const date = "${articleDetail.created}"
  39. document.querySelectorAll('.date').forEach(value =>
  40. value.textContent = new Date(date).toLocaleString()
  41. )
  42. }
  43. fet
  44. </script>
  45. </head>
  46. <body>
  47. <jsp:include page="/WEB-INF/jsp/include/header.jsp"></jsp:include>
  48. <div class="article-page">
  49. <!-- Article Banner -->
  50. <section class="banner">
  51. <div class="container">
  52. <h1 class="article-banner-title">
  53. <c:out value="${articleDetail.title}"></c:out>
  54. </h1>
  55. <div class="article-meta">
  56. <div class="metadata">
  57. <a href="userpage-my.html" class="profile-link">
  58. <img src="img/avatar.jpg" alt="">
  59. </a>
  60. <div class="article-info">
  61. <a href="userpage-my.html" class="name">
  62. <c:out value="${articleDetail.writerName}"></c:out>
  63. </a>
  64. <span class="date">
  65. </span>
  66. </div>
  67. <c:choose>
  68. <c:when test="${articleDetail.writerId eq ssId}">
  69. <div class="buttons">
  70. <a href="editor.html" class="edit-article btn-sm">
  71. <i class="fas fa-pencil-alt"> Edit Article</i>
  72. </a>
  73. <button class="delete-article btn-sm">
  74. <i class="fas fa-trash-alt"> Delete Article</i>
  75. </button>
  76. </div>
  77. </c:when>
  78. <c:otherwise>
  79. <div class="buttons">
  80. <button class="follow-btn btn-sm" onclick="follow()">
  81. <i class="fas fa-plus"></i>&nbsp;Follow Gerome
  82. </button>
  83. <button class="favorite-btn btn-sm" onclick="favorite()">
  84. <i class="fas fa-heart"></i>&nbsp;Favorite Article (564)
  85. </button>
  86. </div>
  87. </c:otherwise>
  88. </c:choose>
  89. </div>
  90. </div>
  91. </div>
  92. </section>
  93. <div class="container main">
  94. <div class="article-content">
  95. <div class="col-12">
  96. <pre>
  97. <c:out value="${articleDetail.content}"></c:out>
  98. </pre>
  99. <ul class="tag-list">
  100. </ul>
  101. </div>
  102. </div>
  103. <hr>
  104. <div class="article-actions">
  105. <div class="article-meta">
  106. <div class="metadata">
  107. <a href="userpage-my.html" class="profile-link">
  108. <img src="img/avatar.jpg" alt="">
  109. </a>
  110. <div class="article-info">
  111. <a href="userpage-my.html" class="name">
  112. <c:out value="${articleDetail.writerName}"></c:out>
  113. </a>
  114. <span class=date>
  115. <c:out value="${articleDetail.created}"></c:out>
  116. </span>
  117. </div>
  118. <c:choose>
  119. <c:when test="${articleDetail.writerId eq ssId}">
  120. <div class="buttons">
  121. <a href="editor.html" class="edit-article btn-sm">
  122. <i class="fas fa-pencil-alt"> Edit Article</i>
  123. </a>
  124. <button class="delete-article btn-sm">
  125. <i class="fas fa-trash-alt"> Delete Article</i>
  126. </button>
  127. </div>
  128. </c:when>
  129. <c:otherwise>
  130. <div class="buttons">
  131. <button class="follow-btn btn-sm" onclick="follow()">
  132. <i class="fas fa-plus"></i>&nbsp;Follow Gerome
  133. </button>
  134. <button class="favorite-btn btn-sm" onclick="favorite()">
  135. <i class="fas fa-heart"></i>&nbsp;Favorite Article (564)
  136. </button>
  137. </div>
  138. </c:otherwise>
  139. </c:choose>
  140. </div>
  141. </div>
  142. </div>
  143. <!-- comment -->
  144. <div class="row">
  145. <div class="col-8">
  146. <div class="card comment-form">
  147. <div class="card-block">
  148. -- articleDetail: <c:out value="${articleDetail}"></c:out> <br>
  149. -- title: <c:out value="${articleDetail.title}"></c:out> <br>
  150. -- subtitle: <c:out value="${articleDetail.subtitle}"></c:out> <br>
  151. -- content: <c:out value="${articleDetail.content}"></c:out> <br>
  152. -- tags: <c:out value="${articleDetail.tags}"></c:out> <br>
  153. -- created: <c:out value="${articleDetail.created}"></c:out> <br>
  154. -- writerId: <c:out value="${articleDetail.writerId}"></c:out> <br>
  155. -- writerName: <c:out value="${articleDetail.writerName}"></c:out> <br>
  156. -- writerEmail: <c:out value="${articleDetail.writerEmail}"></c:out> <br>
  157. <textarea class="form-control" placeholder="Write a comment..." rows="3"></textarea>
  158. </div>
  159. <div class="card-footer">
  160. <img class="comment-img" src="img/avatar.jpg" alt="">
  161. <button class="btn btn-card btn-sm">Post Comment</button>
  162. </div>
  163. </div>
  164. <div class="card">
  165. <div class="card-block">
  166. <p class="card-text">
  167. While most "todo" demos provide an excellent cursory glance at a framework's capabilities,
  168. they typically don't convey the knowledge & perspective required to actually build real
  169. applications with it.
  170. </p>
  171. </div>
  172. <div class="card-footer">
  173. <div class="user-info">
  174. <a href="userpage-others.html" class="comment-author">
  175. <img class="comment-img" src="img/avatar.jpg" alt="">
  176. </a>
  177. <a href="userpage-others.html" class="comment-author">Gerome</a>
  178. <span class="date-posted">November 24, 2021</span>
  179. </div>
  180. <i style="display: none" class="fas fa-trash-alt"></i>
  181. </div>
  182. </div>
  183. <div class="card">
  184. <div class="card-block">
  185. <p class="card-text">
  186. RealWorld solves this by allowing you to choose any frontend (React, Angular, & more) and
  187. any backend (Node, Django, & more) and see how they power a real-world, beautifully designed
  188. full-stack app called Conduit.
  189. </p>
  190. </div>
  191. <div class="card-footer">
  192. <div class="user-info">
  193. <a href="userpage-my.html" class="comment-author">
  194. <img class="comment-img " src="img/avatar.jpg" alt="">
  195. </a>
  196. <a href="userpage-my.html" class="comment-author">username</a>
  197. <span class="date-posted">posting date</span>
  198. </div>
  199. <i class="fas fa-trash-alt"></i>
  200. </div>
  201. </div>
  202. </div>
  203. </div>
  204. </div>
  205. </div>
  206. </body>
  207. </html>