From 0def71d74f9b172ad5ffe76c834c32b5510b15f3 Mon Sep 17 00:00:00 2001 From: danielgrippi <danielgrippi@gmail.com> Date: Thu, 27 Oct 2011 19:57:00 -0700 Subject: [PATCH] add some feedback text & animation; added spec for collapsing tags --- app/controllers/tag_followings_controller.rb | 11 ++++++++--- app/views/tags/_followed_tags_listings.haml | 2 +- app/views/tags/update.js.erb | 4 +++- config/locales/diaspora/en.yml | 4 ++-- config/locales/javascript/javascript.en.yml | 2 ++ public/javascripts/view.js | 2 -- public/stylesheets/sass/application.sass | 3 ++- spec/controllers/tag_followings_controller_spec.rb | 5 +++++ 8 files changed, 23 insertions(+), 10 deletions(-) diff --git a/app/controllers/tag_followings_controller.rb b/app/controllers/tag_followings_controller.rb index 589b68079f..4a82166b4c 100644 --- a/app/controllers/tag_followings_controller.rb +++ b/app/controllers/tag_followings_controller.rb @@ -14,13 +14,13 @@ class TagFollowingsController < ApplicationController # POST /tag_followings # POST /tag_followings.xml def create - @tag = ActsAsTaggableOn::Tag.find_or_create_by_name(params[:name]) + @tag = ActsAsTaggableOn::Tag.find_or_create_by_name(tag_name) @tag_following = current_user.tag_followings.new(:tag_id => @tag.id) if @tag_following.save - flash[:notice] = I18n.t('tag_followings.create.success', :name => params[:name]) + flash[:notice] = I18n.t('tag_followings.create.success', :name => tag_name) else - flash[:error] = I18n.t('tag_followings.create.failure', :name => params[:name]) + flash[:error] = I18n.t('tag_followings.create.failure', :name => tag_name) end redirect_to :back @@ -63,4 +63,9 @@ class TagFollowingsController < ApplicationController redirect_to multi_path end + + private + def tag_name + @tag_name ||= params[:name].gsub(/\s/,'') if params[:name] + end end diff --git a/app/views/tags/_followed_tags_listings.haml b/app/views/tags/_followed_tags_listings.haml index f3a51c08b2..ff19f21d94 100644 --- a/app/views/tags/_followed_tags_listings.haml +++ b/app/views/tags/_followed_tags_listings.haml @@ -10,7 +10,7 @@ %ul.sub_nav - if tags.size > 0 - for tg in tags - %li.unfollow{:id => tg.name} + %li.unfollow{:id => "tag-following-#{tg.name}"} .unfollow_icon.hidden = link_to image_tag("icons/monotone_close_exit_delete.png", :height => 16, :title => t('aspects.index.unfollow_tag', :tag => tg.name)), tag_tag_followings_path(:name => tg.name, :remote => true), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :id => "unfollow_" + tg.name = link_to "##{tg.name}", tag_path(:name => tg.name), :class => "tag_selector" diff --git a/app/views/tags/update.js.erb b/app/views/tags/update.js.erb index 84f8200dca..cf75adc4c8 100644 --- a/app/views/tags/update.js.erb +++ b/app/views/tags/update.js.erb @@ -1 +1,3 @@ -$("#followed_tags_listing").first().html("<%= escape_javascript(render('tags/followed_tags_listings')) =%>"); +var tagName = "<%= escape_javascript(@tag.name) %>" +$("#followed_tags_listing").find("#tag-following-"+tagName).slideUp(100); +Diaspora.page.flashMessages.render({success: true, notice: Diaspora.I18n.t("tags.wasnt_that_interesting", {tagName: tagName})}); diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 24f9953162..c46f2cf8eb 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -819,8 +819,8 @@ en: followed_by: 'followed by' tag_followings: create: - success: "Successfully following: #%{name}" - failure: "Failed to follow: #%{name}" + success: "Horray! You're now following #%{name}." + failure: "Failed to follow #%{name}. Are you already following it?" destroy: success: "Successfully stopped following: #%{name}" failure: "Failed to stop following: #%{name}" diff --git a/config/locales/javascript/javascript.en.yml b/config/locales/javascript/javascript.en.yml index 49a0a1b25f..332e3b75bc 100644 --- a/config/locales/javascript/javascript.en.yml +++ b/config/locales/javascript/javascript.en.yml @@ -66,3 +66,5 @@ en: preparing_your_stream: "Preparing your personialized stream..." photo_uploader: looking_good: "OMG, you look awesome!" + tags: + wasnt_that_interesting: "OK, I suppose #{{tagName}} wasn't all that interesting..." diff --git a/public/javascripts/view.js b/public/javascripts/view.js index c778d25db3..8165e0409f 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -49,8 +49,6 @@ var View = { /* tag following */ $("#new_tag_following .tag_input").bind('focus', function(evt){ $(this).siblings("#tag_following_submit").removeClass('hidden'); - }).bind('blur', function(evt){ - $(this).siblings("#tag_following_submit").addClass('hidden'); }); /* Autoexpand textareas */ diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index b9436c7245..5250321839 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -91,7 +91,8 @@ form @include border-radius(6px) @include box-shadow(0, 1px, 5px, rgba(0,0,0,0.4)) :display inline-block - :width 400px + :min-width 400px + :max-width 800px :padding :top 45px :bottom 8px diff --git a/spec/controllers/tag_followings_controller_spec.rb b/spec/controllers/tag_followings_controller_spec.rb index f3a9609f3f..03960a708f 100644 --- a/spec/controllers/tag_followings_controller_spec.rb +++ b/spec/controllers/tag_followings_controller_spec.rb @@ -66,6 +66,11 @@ describe TagFollowingsController do flash[:error].should == "Failed to follow: ##{valid_attributes[:name]}" end + it 'squashes the tag' do + post :create, :name => "some stuff" + assigns[:tag].name.should == "somestuff" + end + it 'downcases the tag name' do pending "THIS CAUSES A 500 WE NEED TO FIX IT" post "tags/#{valid_attributes[:name].upcase}/tag_followings" -- GitLab