From 461cb221091f2080ea1301e7657345f9b002f87e Mon Sep 17 00:00:00 2001 From: Ilya Zhitomirskiy Date: Fri, 23 Sep 2011 17:06:21 -0700 Subject: [PATCH] in the getting started featured tags are now followable --- app/controllers/application_controller.rb | 15 ++++++++++++++ app/controllers/aspects_controller.rb | 14 ------------- app/controllers/tag_followings_controller.rb | 2 +- app/helpers/getting_started_helper.rb | 12 +++++++++++ app/views/tags/_followed_tags_listings.haml | 4 ++-- app/views/users/getting_started.haml | 10 +++------- config/locales/diaspora/en.yml | 2 +- public/stylesheets/sass/application.sass | 21 ++++++++++++++++++++ 8 files changed, 55 insertions(+), 25 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index dc3e864b4..21ee8d15b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -16,6 +16,7 @@ class ApplicationController < ActionController::Base inflection_method :grammatical_gender => :gender helper_method :all_aspects, :all_contacts_count, :my_contacts_count, :only_sharing_count + helper_method :tags, :tag_followings def ensure_http_referer_is_set request.env['HTTP_REFERER'] ||= '/aspects' @@ -117,4 +118,18 @@ class ApplicationController < ActionController::Base def after_sign_in_path_for(resource) stored_location_for(:user) || (current_user.getting_started? ? getting_started_path : aspects_path) end + + def tag_followings + if current_user + if @tag_followings == nil + @tag_followings = current_user.tag_followings + end + @tag_followings + end + end + + def tags + @tags ||= current_user.followed_tags + end + end diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index fc2a4804d..4572e2048 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -12,7 +12,6 @@ class AspectsController < ApplicationController respond_to :html, :js respond_to :json, :only => [:show, :create] - helper_method :tags, :tag_followings helper_method :selected_people def index @@ -138,19 +137,6 @@ class AspectsController < ApplicationController params[:max_time] ||= Time.now + 1 end - def tag_followings - if current_user - if @tag_followings == nil - @tag_followings = current_user.tag_followings - end - @tag_followings - end - end - - def tags - @tags ||= current_user.followed_tags - end - private def save_sort_order if params[:sort_order].present? diff --git a/app/controllers/tag_followings_controller.rb b/app/controllers/tag_followings_controller.rb index f28f02486..327c7c541 100644 --- a/app/controllers/tag_followings_controller.rb +++ b/app/controllers/tag_followings_controller.rb @@ -19,7 +19,7 @@ class TagFollowingsController < ApplicationController flash[:error] = I18n.t('tag_followings.create.failure', :name => params[:name]) end - redirect_to tag_path(:name => params[:name]) + redirect_to :back end # DELETE /tag_followings/1 diff --git a/app/helpers/getting_started_helper.rb b/app/helpers/getting_started_helper.rb index 2a9a73d76..5bd271be4 100644 --- a/app/helpers/getting_started_helper.rb +++ b/app/helpers/getting_started_helper.rb @@ -48,4 +48,16 @@ module GettingStartedHelper t('users.getting_started.welcome') end end + + def tag_link(tag_name) + if tag_followed?(tag_name) + link_to "##{tag_name}", tag_followings_path(tag_name), :method => :delete, :class => "featured_tag followed" + else + link_to "##{tag_name}", tag_tag_followings_path(tag_name), :method => :post, :class => "featured_tag" + end + end + + def tag_followed?(tag_name) + tags.detect{|t| t.name == tag_name} + end end diff --git a/app/views/tags/_followed_tags_listings.haml b/app/views/tags/_followed_tags_listings.haml index 3ec41beb4..0b9703666 100644 --- a/app/views/tags/_followed_tags_listings.haml +++ b/app/views/tags/_followed_tags_listings.haml @@ -9,8 +9,8 @@ = t('aspects.index.tags_following') %ul.sub_nav - - if current_user.followed_tags.size > 0 - - for tg in current_user.followed_tags + - if tags.size > 0 + - for tg in tags %li.unfollow{:id => 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 diff --git a/app/views/users/getting_started.haml b/app/views/users/getting_started.haml index abd508b09..ee42fdc35 100644 --- a/app/views/users/getting_started.haml +++ b/app/views/users/getting_started.haml @@ -139,13 +139,9 @@ %h4{:style => "margin-top:7px;"} = t('.featured_tags') %p - = link_to "#diaspora", tag_path('diaspora'), :target => "_blank" - %br - = link_to "#art", tag_path('art'), :target => "_blank" - %br - = link_to "#gif", tag_path('gif'), :target => "_blank" - %br - = link_to "#french", tag_path('french'), :target => "_blank" + - ["diaspora", "art", "gif", "french"].each do |tag_name| + = tag_link(tag_name) + %br .clearfix %br %br diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 272a3f689..ed138b60b 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -871,7 +871,7 @@ en: connect_to: "Connect to" find_friends_from_facebook: "find friends from Facebook" - featured_tags: "Featured tags" + featured_tags: "Follow featured tags" find_friends: "Find friends" see_all_featured_users: "See all featured users" get_updates_from_core: "Get updates about the project from the core team." diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 93f290532..056caa20a 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -3296,6 +3296,27 @@ ul#getting_started :background :image url('/images/icons/check_yes_ok.png') !important +.featured_tag + :background + //:image url('/images/icons/check_yes_ok.png') + :position center left + :repeat no-repeat + :display none + + :padding + :left 20px + + &.followed + :background + :image url('/images/icons/check_yes_ok.png') + + &:hover, + :background + :image url('/images/icons/check_yes_ok_lighter.png') + + + + #featured_users_pane :padding 10px 0