summaryrefslogtreecommitdiff
path: root/views/blog/show.ejs
diff options
context:
space:
mode:
Diffstat (limited to 'views/blog/show.ejs')
-rw-r--r--views/blog/show.ejs53
1 files changed, 53 insertions, 0 deletions
diff --git a/views/blog/show.ejs b/views/blog/show.ejs
new file mode 100644
index 0000000..0133499
--- /dev/null
+++ b/views/blog/show.ejs
@@ -0,0 +1,53 @@
+<%- include('../partials/header') %>
+
+<div class='content'>
+ <div class='leftie'>
+ <ul>
+ <% if(!currentUser) { %>
+ <li><a href='/search/all'>Search for blog posts</a></li>
+ <li><a href='/'>About</a></li>
+ <li><a href='/browsers'>Minimal browsers</a></li>
+ <% } else { %>
+ <li><a href='/blog/<%= currentUser.username %>'>My Blog</a></li>
+ <li><a href='/blog/<%= currentUser.username %>/new'>Create a blog post</a></li>
+ <li><a href='/search/all'>Search for blog posts</a></li>
+ <li><a href='/'>About</a></li>
+ <li><a href='/browsers'>Minimal browsers</a></li>
+ <% } %>
+ </ul>
+ </div>
+ <div class='rightie'>
+ <h3><a id='pbname' href="/blog/<%= account %>"><%= account.toUpperCase() %></a></h3>
+ <div class='showPost'>
+ <h4><%= post.title %></h4>
+ <img src="<%= post.image %>" alt="...">
+ <span><button><%= post.tag %></button></span>
+ <p><%- post.body %></p>
+ <% if(currentUser && post.author.id.equals(currentUser._id)) { %>
+ <a id='edit' href="/blog/<%= currentUser.username %>/<%= post._id %>/edit">Edit</a>
+ <form id="deleteForm" action="/blog/<%= currentUser.username %>/<%= post._id %>?_method=DELETE" method="POST">
+ <button class='deleteBtn' type='submit'>Delete</button>
+ </form>
+ <% } %>
+ <% post.comments.map((comment) => { %>
+ <div class='comment'>
+ <h5><%= comment.author.username.toUpperCase() %>: </h5>
+ <p><%- comment.text %></p>
+ <% if(currentUser && comment.author.id.equals(currentUser._id)) { %>
+ <div class='cmmntOps'>
+ <a id="edCmmnt" href="/blog/<%= account %>/<%= post._id %>/comments/<%= comment._id %>/edit">
+ Edit
+ </a>
+ <form id="deleteForm" action='/blog/<%= account %>/<%= post._id %>/comments/<%= comment._id %>?_method=DELETE' method="POST">
+ <button class='deleteBtn' type='submit'>Delete</button>
+ </form>
+ </div>
+ <% } %>
+ </div>
+ <% }) %>
+ <a id='edit' href="/blog/<%= account %>/<%= post._id %>/comments/new">Add a comment</a>
+ </div>
+ </div>
+</div>
+
+<%- include('../partials/footer') %>