Implement “like” button.
[Sone.git] / src / main / resources / templates / include / viewPost.html
index 8e528ac..1f0020c 100644 (file)
@@ -1,10 +1,25 @@
-<div id="<% post.id|html>" class="post <%if postLoop.last>last<%/if>">
+<div id="<% post.id|html>" class="post <%if loop.last>last<%/if>">
        <div>
                <div class="author profile-link"><a href="viewSone.html?sone=<% post.sone.id|html>"><% post.sone.niceName|html></a></div>
                <div class="text"><% post.text|html></div>
        </div>
        <div class="status-line">
                <div class="time"><a href="viewPost.html?post=<% post.id|html>"><% post.time|date format="MMM d, yyyy, HH:mm:ss"></a></div>
+               <div class="likes"><span>⬆<span class="like-count"><% post.likes.size></span></span></div>
+               <%ifnull ! currentSone>
+                       <form class="like<%if post.liked> hidden<%/if>" action="likePost.html" method="post">
+                               <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+                               <input type="hidden" name="returnPage" value="<% request.uri|html>" />
+                               <input type="hidden" name="post" value="<% post.id|html>" />
+                               <button type="submit" value="1"><%= View.Post.LikeLink|l10n|html></button>
+                       </form>
+                       <form class="unlike<%if ! post.liked> hidden<%/if>" action="unlikePost.html" method="post">
+                               <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+                               <input type="hidden" name="returnPage" value="<% request.uri|html>" />
+                               <input type="hidden" name="post" value="<% post.id|html>" />
+                               <button type="submit" value="1"><%= View.Post.UnlikeLink|l10n|html></button>
+                       </form>
+               <%/if>
                <%if post.sone.current>
                        <form class="delete" action="deletePost.html" method="post">
                                <input type="hidden" name="formPassword" value="<% formPassword|html>" />
@@ -16,7 +31,7 @@
        </div>
        <div class="replies">
                <%foreach post.replies reply>
-                       <div class="reply">
+                       <div id="<% reply.id|html>" class="reply">
                                <div>
                                        <div class="author profile-link"><a href="viewSone.html?sone=<% reply.sone.id|html>"><% reply.sone.niceName|html></a></div>
                                        <div class="text"><% reply.text|html></div>