-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_post.ejs
More file actions
41 lines (41 loc) · 1.82 KB
/
_post.ejs
File metadata and controls
41 lines (41 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<li id="post-<%=post._id%>">
<%if(locals.user&& locals.user.id==post.user.id){%>
<a class="delete-post-button" href="posts/destroy/<%=post.id%>">X</a>
<%}%>
<h4><%=post.content%></h4>
<p><%=post.user.name%></p>
<p class="post-likes-display" id="pld-<%=post._id%>">
<%if(post.likes){%>
<%=post.likes.length%>
<%}
</p>
<button class="post-like" id="pl-<%=post._id%>">Like</button>
<div id="post-comments">
<%if(locals.user){%>
<form action="/comment/create" method="post" class="new-comment-form">
<input type="text" name="content" placeholder="write your comment here...">
<input type="hidden" name="post_id" value="<%=post._id%>" >
<input type="submit" value="post commment">
</form>
<%}%>
<div id="post-comments-list">
<ul id="post-comments-<%=post._id%>">
<%for(comment of post.comments){%>
<li id="comment-<%=comment._id%>">
<%if(locals.user&& (locals.user.id==post.user.id||locals.user.id==comment.user.id)){%>
<p class="comment-likes-display" id="cld-<%=comment.id%>">
<%if(comment.likes){%>
<%=comment.likes.length%>
<%}%>
</p>
<button class="comment-like" id="cl-<%=comment.id%>">Like</button>
<a class="com-del" href="comment/destroy/<%=comment.id%>">X</a>
<%}%>
<p><%=comment.content%></p>
<small><%=comment.user.name%></small>
</li>
<%}%>
</ul>
</div>
</div>
</li>