From 8f50c622fada4cf864f432c5c3866624c50a801e Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Mon, 11 Jul 2011 16:17:11 -0700 Subject: [PATCH] Fix contentUpdater spec, adjust migration and fix a couple of the js viwes --- app/controllers/sessions_controller.rb | 2 +- app/views/comments/_comments.haml | 4 ++-- app/views/likes/_likes_container.haml | 5 ++++- app/views/post_visibilities/update.js.erb | 2 +- app/views/posts/destroy.js.erb | 2 +- app/views/shared/_stream_element.html.haml | 4 ++-- db/migrate/20110707234802_likes_on_comments.rb | 2 +- db/schema.rb | 4 ++-- public/javascripts/content-updater.js | 4 ++-- public/stylesheets/sass/application.sass | 10 ++++++---- 10 files changed, 22 insertions(+), 17 deletions(-) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 1b29378c9..79545b5cc 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -4,7 +4,7 @@ class SessionsController < Devise::SessionsController - after_filter :enqueue_update, :only => :create + #after_filter :enqueue_update, :only => :create protected def enqueue_update diff --git a/app/views/comments/_comments.haml b/app/views/comments/_comments.haml index 304550afc..85254bb51 100644 --- a/app/views/comments/_comments.haml +++ b/app/views/comments/_comments.haml @@ -5,7 +5,7 @@ - unless comments_expanded %ul.show_comments{:class => ("hidden" if post.comments.size <= 3)} %li - %b= comment_toggle( post) + = comment_toggle( post) %ul.comments{:id => post.id, :class => ('loaded' if post.comments.size <= 3)} -if post.comments.size > 3 && !comments_expanded @@ -14,5 +14,5 @@ = render :partial => 'comments/comment', :collection => post.comments, :locals => {:post => post} - unless @commenting_disabled - .new_comment_form_wrapper{:class => ( 'hidden' if post.comments.size == 0)} + .new_comment_form_wrapper{:class => ('hidden' if post.comments.size == 0)} = new_comment_form(post.id, current_user) diff --git a/app/views/likes/_likes_container.haml b/app/views/likes/_likes_container.haml index bb43ed49d..0a8ea4de0 100644 --- a/app/views/likes/_likes_container.haml +++ b/app/views/likes/_likes_container.haml @@ -5,7 +5,10 @@ .likes_container - if likes_count > 0 = image_tag('icons/heart.svg') - = link_to t('likes.likes.people_like_this', :count => likes_count), post_likes_path(target_id), :class => "expand_likes" + - if defined?(likes_index_link) && likes_index_link + = link_to t('likes.likes.people_like_this', :count => likes_count), post_likes_path(target_id), :class => "expand_likes" + - else + = t('likes.likes.people_like_this', :count => likes_count) %span.hidden.likes_list /= render 'likes/likes', :likes => likes diff --git a/app/views/post_visibilities/update.js.erb b/app/views/post_visibilities/update.js.erb index 010c13a6b..b7c4a701a 100644 --- a/app/views/post_visibilities/update.js.erb +++ b/app/views/post_visibilities/update.js.erb @@ -1,3 +1,3 @@ -var target = $(".stream_element[data-guid=<%= escape_javascript(@post.id.to_s) %>]") +var target = $("#<%= @post.guid %>") target.find(".sm_body").toggleClass("hidden"); target.find(".undo_text").toggleClass("hidden"); diff --git a/app/views/posts/destroy.js.erb b/app/views/posts/destroy.js.erb index e873e96c7..5a0c3dd83 100644 --- a/app/views/posts/destroy.js.erb +++ b/app/views/posts/destroy.js.erb @@ -1,2 +1,2 @@ -var target = $(".stream_element[data-guid=<%= escape_javascript(@post.id.to_s) %>]") +var target = $("#<%= @post.guid %>") target.hide('blind', { direction: 'vertical' }, 300, function(){ target.remove() }); diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml index 415a96811..0c1d4769a 100644 --- a/app/views/shared/_stream_element.html.haml +++ b/app/views/shared/_stream_element.html.haml @@ -55,7 +55,7 @@ ยท = link_to t('comments.new_comment.comment'), '#', :class => 'focus_comment_textarea' - .likes - = render "likes/likes_container", :target_id => post.id, :likes_count => post.likes_count, :current_user => current_user + .likes.on_post + = render "likes/likes_container", :target_id => post.id, :likes_count => post.likes_count, :current_user => current_user, :likes_index_link => true = render "comments/comments", :post => post, :current_user => current_user, :commenting_disabled => (defined?(@commenting_disabled) && @commenting_disabled) diff --git a/db/migrate/20110707234802_likes_on_comments.rb b/db/migrate/20110707234802_likes_on_comments.rb index 9a65d66c4..7b3e80e75 100644 --- a/db/migrate/20110707234802_likes_on_comments.rb +++ b/db/migrate/20110707234802_likes_on_comments.rb @@ -3,7 +3,7 @@ class LikesOnComments < ActiveRecord::Migration def self.up remove_foreign_key :likes, :posts - add_column :likes, :target_type, :string, :null => false + add_column :likes, :target_type, :string, :limit => 60, :null => false rename_column :likes, :post_id, :target_id add_column :comments, :likes_count, :integer, :default => 0, :null => false diff --git a/db/schema.rb b/db/schema.rb index 4c3cbf3b4..da2eb61fc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -110,7 +110,7 @@ ActiveRecord::Schema.define(:version => 20110707234802) do add_index "invitations", ["sender_id"], :name => "index_invitations_on_sender_id" create_table "likes", :force => true do |t| - t.boolean "positive", :default => true + t.boolean "positive", :default => true t.integer "target_id" t.integer "author_id" t.string "guid" @@ -118,7 +118,7 @@ ActiveRecord::Schema.define(:version => 20110707234802) do t.text "parent_author_signature" t.datetime "created_at" t.datetime "updated_at" - t.string "target_type", :null => false + t.string "target_type", :limit => 60, :null => false end add_index "likes", ["author_id"], :name => "likes_author_id_fk" diff --git a/public/javascripts/content-updater.js b/public/javascripts/content-updater.js index 028670c65..a3c0c7dd0 100644 --- a/public/javascripts/content-updater.js +++ b/public/javascripts/content-updater.js @@ -6,7 +6,7 @@ var ContentUpdater = { addPostToStream: function(html) { var streamElement = $(html); - var postGUID = streamElement.id; + var postGUID = $(streamElement).attr('id'); if($("#"+postGUID).length === 0) { if($("#no_posts").length) { @@ -31,5 +31,5 @@ var ContentUpdater = { .html(html) .fadeIn("fast"); } - + }; diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 0275ce0ad..56b25dad5 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -667,6 +667,7 @@ form.new_comment :display inline-block +.comment .likes, .likes_container :display inline @@ -2221,6 +2222,11 @@ ul.show_comments :border :top 1px dotted #aaa +ul.show_comments, +.likes_container + a + :color #999 + .likes_container :margin :bottom -4px @@ -2228,10 +2234,6 @@ ul.show_comments ul.show_comments, .likes_container - a - :font - :weight bold - img :position relative :top 2px