Permalink
Browse files

Adjusted vote icon display.

  • Loading branch information...
1 parent 489627a commit 100ec351fcabbadfd45238775f78964a3c2858e7 @lvterry committed Apr 18, 2012
Showing with 15 additions and 5 deletions.
  1. +3 −0 app/assets/stylesheets/application.css
  2. +10 −1 app/helpers/articles_helper.rb
  3. +2 −4 app/views/articles/_article.html.erb
View
3 app/assets/stylesheets/application.css
@@ -142,6 +142,9 @@ h2 {
.meta .icon:hover {
opacity: 1;
}
+.meta .icon.voted {
+ opacity: 1;
+}
footer {
font-size: 80%;
padding: 25px 0;
View
11 app/helpers/articles_helper.rb
@@ -1,2 +1,11 @@
-module ArticlesHelper
+module ArticlesHelper
+ def vote_icon(article)
+ if current_user && current_user.voted_article?(article)
+ raw %Q(<i class="icon icon-heart voted"></i>)
+ else
+ link_to article_votes_path(article), :method => :post, :class => 'vote' do
+ raw %Q(<i class="icon icon-heart"></i>)
+ end
+ end
+ end
end
View
6 app/views/articles/_article.html.erb
@@ -1,10 +1,8 @@
<div class="article">
<p class="title"><a href="<%= article.url %>" target="_blank"><%= article.title %></a></p>
<div class="meta">
- <%= link_to article_votes_path(article), :method => :post, :class => 'vote' do %>
- <i class="icon icon-heart"></i>
- <% end %>
- <%= article.votes_count %> likes, <i class="icon icon-comment"></i><%= link_to pluralize(article.comments.size, 'comment'), article_path(article) %>&nbsp;&nbsp;|&nbsp;&nbsp;Submitted by <i class="icon icon-user"></i><%= article.user && article.user.name || '' %> <%= time_ago_in_words article.created_at %> ago
+ <%= vote_icon article %><%= article.votes_count %> likes,
+ <i class="icon icon-comment"></i><%= link_to pluralize(article.comments.size, 'comment'), article_path(article) %>&nbsp;&nbsp;|&nbsp;&nbsp;Submitted by <i class="icon icon-user"></i><%= article.user && article.user.name || '' %> <%= time_ago_in_words article.created_at %> ago
<% if current_user %>
| <%= link_to 'Edit', edit_article_path(article) %>&nbsp;<%= link_to 'Delete', article_path(article), :method => 'DELETE', :confirm => 'Sure?' %>
<% end %>

0 comments on commit 100ec35

Please sign in to comment.