diff --git a/app/controllers/tag_followings_controller.rb b/app/controllers/tag_followings_controller.rb index 589b68079fdaff822ff2186f8aa3a371c17d6398..4a82166b4c9de14613ce80615c340fe7e2558a3b 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 f3a51c08b2cb93c594c97d16e5914a742d44636c..ff19f21d94017a3ce5fc4273e4e09d3e6b5664de 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 84f8200dca6988df3f2a017faa0c265cd5702e99..cf75adc4c8959bbbea25c7ec0fba6ebab33dbc11 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 24f99531622bac501d40d678e7735b651ab8d5e2..c46f2cf8eba8b09bbdb19a0f768c233fab53f718 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 49a0a1b25fe7b6a06d44bf43a8375385f7e4739e..332e3b75bc83c93d1ac3efd0c1f87670b202d372 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 c778d25db3ffa905009b28bfa202d161066195e0..8165e0409f47ca6ab88c7b3cb8a991e233ef4c75 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 b9436c724572d2fdc613d0c194306f9fdf2fd85e..5250321839f97ccf7988c1b7bbf3972d4d2abcf5 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 f3a9609f3f16b57c708d450fe31bddb0c455dba1..03960a708f0b65629a430d734f8fda030ab396f7 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"