diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-10-20 21:27:06 -0400 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-10-20 21:27:06 -0400 |
| commit | 2a7a19c93ee0e0d77e4e388d43f36a721c7ab715 (patch) | |
| tree | c5e775bca4600d111d01d1bd7998d3b6252462e6 /app/views | |
| parent | 74b1612e49ebd9cb29efb85f3afeb07f0e8d608a (diff) | |
| download | thoughts-2a7a19c93ee0e0d77e4e388d43f36a721c7ab715.tar.gz thoughts-2a7a19c93ee0e0d77e4e388d43f36a721c7ab715.tar.bz2 thoughts-2a7a19c93ee0e0d77e4e388d43f36a721c7ab715.zip | |
Added post voting
Diffstat (limited to 'app/views')
| -rw-r--r-- | app/views/blogs/_blog.html.haml | 4 | ||||
| -rw-r--r-- | app/views/blogs/voted.js.erb | 12 |
2 files changed, 16 insertions, 0 deletions
| diff --git a/app/views/blogs/_blog.html.haml b/app/views/blogs/_blog.html.haml index ec61bb5..1f86ae8 100644 --- a/app/views/blogs/_blog.html.haml +++ b/app/views/blogs/_blog.html.haml | |||
| @@ -19,3 +19,7 @@ | |||
| 19 | %strong= blog.user.login.capitalize | 19 | %strong= blog.user.login.capitalize |
| 20 | on | 20 | on |
| 21 | = blog.visible_date.strftime("%B #{blog.visible_date.day.ordinalize}, %Y at %-I:%M:%S%P") | 21 | = blog.visible_date.strftime("%B #{blog.visible_date.day.ordinalize}, %Y at %-I:%M:%S%P") |
| 22 | .post-vote{ id: "blog-vote-section-#{blog.id}" } | ||
| 23 | %span.vote-link{ id: "blog-upvote-link-#{blog.id}" }= link_to_unless (not blog.published or blog.already_upvoted?(request.remote_ip)), "👍", upvote_blog_path(blog), remote: true, rel: "nofollow", class: "blog-upvote-link", method: :post | ||
| 24 | %span.post-rating{ id: "blog-rating-#{blog.id}" }= blog.upvotes - blog.downvotes | ||
| 25 | %span.vote-link{ id: "blog-downvote-link-#{blog.id}" }= link_to_unless (not blog.published or blog.already_downvoted?(request.remote_ip)), "👎", downvote_blog_path(blog), remote: true, rel: "nofollow", class: "blog-downvote-link", method: :post | ||
| diff --git a/app/views/blogs/voted.js.erb b/app/views/blogs/voted.js.erb new file mode 100644 index 0000000..951c740 --- /dev/null +++ b/app/views/blogs/voted.js.erb | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | $("#blog-rating-<%= @blog.id %>").html('<%= escape_javascript("#{@blog.upvotes - @blog.downvotes}") %>'); | ||
| 2 | |||
| 3 | <% if @blog.already_upvoted? request.remote_ip %> | ||
| 4 | $("#blog-upvote-link-<%= @blog.id %>").html("👍"); | ||
| 5 | <% elsif @blog.already_downvoted? request.remote_ip %> | ||
| 6 | $("#blog-downvote-link-<%= @blog.id %>").html("👎"); | ||
| 7 | <% else %> | ||
| 8 | $("#blog-upvote-link-<%= @blog.id %>").html('<%= escape_javascript(link_to("👍", upvote_blog_path(@blog), remote: true, rel: "nofollow", class: "blog-upvote-link", method: :post)) %>'); | ||
| 9 | $("#blog-downvote-link-<%= @blog.id %>").html('<%= escape_javascript(link_to("👎", downvote_blog_path(@blog), remote: true, rel: "nofollow", class: "blog-downvote-link", method: :post)) %>'); | ||
| 10 | <% end %> | ||
| 11 | |||
| 12 | $("#blog-vote-section-<%= @blog.id %>").effect('highlight', {}, 2000); | ||
