diff options
author | BakedSnake <gilferrandm@gmail.com> | 2021-03-17 12:58:53 +0100 |
---|---|---|
committer | BakedSnake <gilferrandm@gmail.com> | 2021-03-17 12:58:53 +0100 |
commit | 188527c6b55a2d64d5f76c5d3e094da45c69b0c9 (patch) | |
tree | 8c6c41a2ffe04af81483ec36f72d328c3c76780a /views/blog/show.ejs |
Diffstat (limited to 'views/blog/show.ejs')
-rw-r--r-- | views/blog/show.ejs | 53 |
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') %> |