about summary refs log tree commit diff stats
path: root/app/views/blogs
diff options
context:
space:
mode:
Diffstat (limited to 'app/views/blogs')
-rw-r--r--app/views/blogs/_blog.html.haml4
-rw-r--r--app/views/blogs/voted.js.erb12
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);