Skip to content

Commit

Permalink
Fix for like's messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Azisaka Maciel committed Oct 17, 2010
1 parent 2ac1bf8 commit f5ff173
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
4 changes: 3 additions & 1 deletion app/controllers/likes_controller.rb
@@ -1,12 +1,14 @@
class LikesController < ApplicationController
include ActionView::Helpers::TextHelper
include TemplatesHelper

before_filter :authenticate_githubber!

def create
template = Template.find(params[:template_id])
like = current_githubber.like_it template
if like.persisted?
render :json => { :status => pluralize(template.likes.count, "person like it", "people like it") }
render :json => { :status => like_counter(template) }
else
render :json => {}, :status => 406
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/templates/_like_status.html.haml
Expand Up @@ -3,7 +3,7 @@
%p= like_counter(template)
- if githubber_signed_in? && !current_githubber.liked?(template)
.link-default.rounded-all
= link_to 'I like it', template_likes_path(template), :method => :POST, :id => 'like_button', :remote => true
= link_to 'I like it', template_likes_path(template), :method => :post, :id => 'like_button', :remote => true, "data-type" => "html"

- if !githubber_signed_in?
.link-default.rounded-all
Expand Down
11 changes: 6 additions & 5 deletions app/views/templates/show.html.haml
Expand Up @@ -66,11 +66,12 @@

#commentaries
%h3 Comments
- if @template.commentaries.size > 0
- @template.commentaries.reverse.each do |commentary|
.commentary= render :partial => "commentary", :object => commentary
- else
%p.notice Be the first to comment about this template!
.comments-list
- if @template.commentaries.size > 0
- @template.commentaries.reverse.each do |commentary|
.commentary= render :partial => "commentary", :object => commentary
- else
%p.notice Be the first to comment about this template!

- if current_githubber
- semantic_form_for @commentary, :url => template_commentaries_path(@template), :remote => true, :html => { "data-type" => "html" } do |form|
Expand Down
7 changes: 5 additions & 2 deletions public/javascripts/application.js
Expand Up @@ -15,6 +15,7 @@ var Application = {
});
}
});

$(".delete-template")
.bind('ajax:success', onSuccess);
$('.unlike-template').bind('ajax:success', function() {
Expand All @@ -32,17 +33,19 @@ var Application = {
}
});
});
$(".delete-template").bind('ajax:success', onSuccess);

$(".delete-template").bind('ajax:success', onSuccess);
}
},
commentaryCreation: function(){
$("#new_commentary")
.bind('ajax:loading', function(rawResponse, msg) {
$("#commentaries .notice").fadeOut('fast');
$("#commentaries").parent().find('.error').remove();
})
.bind('ajax:success', function(rawResponse,msg) {
var div = $("<div />").addClass('commentary').css("display", "none").html(msg);
$('#commentaries').prepend(div);
$('.comments-list').prepend(div);
$('#commentary_commentary').val('');
div.slideDown();
}).bind('ajax:failure', function(rawResponse, msg){
Expand Down

0 comments on commit f5ff173

Please sign in to comment.