From 2f1118f95fb6dbe833c80c1ac9870ed61c46d08d Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg Date: Mon, 4 Jul 2011 13:53:41 -0700 Subject: [PATCH] refactor AppConfig to guess what services are configured, and clean up the services view for a user. also, add a box so people can realize what they can connect --- app/models/app_config.rb | 14 ++++++++++++++ app/views/aspects/index.html.haml | 12 ++++++++++++ app/views/shared/_add_remove_services.haml | 11 +++-------- ...{_load_services.rb => _before_load_services.rb} | 0 config/locales/diaspora/en.yml | 6 ++++-- 5 files changed, 33 insertions(+), 10 deletions(-) rename config/initializers/{_load_services.rb => _before_load_services.rb} (100%) diff --git a/app/models/app_config.rb b/app/models/app_config.rb index f874d340d..41327327c 100644 --- a/app/models/app_config.rb +++ b/app/models/app_config.rb @@ -60,6 +60,7 @@ HELP normalize_pod_url normalize_admins + normalize_pod_services end def self.config_file_is_old_style? @@ -92,6 +93,19 @@ HELP self[:admins].collect! { |username| username.downcase } end + def self.normalize_pod_services + if defined?(SERVICES) + puts "in here" + connected_services = [] + SERVICES.keys.each do |service| + unless SERVICES[service].keys.any?{|service_key| SERVICES[service][service_key].blank?} + connected_services << service + end + end + self['configured_services'] = connected_services + end + end + load! def self.[] (key) diff --git a/app/views/aspects/index.html.haml b/app/views/aspects/index.html.haml index 85ded3816..0df73cd20 100644 --- a/app/views/aspects/index.html.haml +++ b/app/views/aspects/index.html.haml @@ -54,6 +54,18 @@ = t('.cubbies.explanation') = link_to t('.cubbies.learn_more'), token_path + .section + .title + = image_tag('/images/icons/monotone_wrench_settings.png') + %h5 + = t('.services.heading') + .content + = t('.services.content') + - AppConfig.configured_services.each do |service| + - unless current_user.services.any?{|x| x.provider == service} + %br= link_to service.titleize, "/auth/#{service}" + + - if @invites > 0 .section .title diff --git a/app/views/shared/_add_remove_services.haml b/app/views/shared/_add_remove_services.haml index 10e98a1d8..b3bc6285a 100644 --- a/app/views/shared/_add_remove_services.haml +++ b/app/views/shared/_add_remove_services.haml @@ -14,11 +14,6 @@ - else You haven't connected any services yet. -- unless @services.any?{|x| x.provider == 'twitter'} - %h4= link_to t('services.index.connect_to_twitter'), "/auth/twitter" if SERVICES['twitter'] && SERVICES['twitter']['consumer_key']!= "" - -- unless @services.any?{|x| x.provider == 'facebook'} - %h4= link_to t('services.index.connect_to_facebook'), "/auth/facebook" if SERVICES['facebook'] && SERVICES['facebook']['app_id'] !="" - -- unless @services.any?{|x| x.provider == 'tumblr'} - %h4= link_to t('services.index.connect_to_tumblr'), "/auth/tumblr" if SERVICES['tumblr'] && SERVICES['tumblr']['consumer_key'] !="" +- AppConfig.configured_services.each do |service| + - unless @services.any?{|x| x.provider == service} + %h4= link_to t("services.index.connect_to_#{service}"), "/auth/#{service}" diff --git a/config/initializers/_load_services.rb b/config/initializers/_before_load_services.rb similarity index 100% rename from config/initializers/_load_services.rb rename to config/initializers/_before_load_services.rb diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index b8b5076e9..9d4322d55 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -143,7 +143,7 @@ en: seed: family: "Family" work: "Work" - index: + index: your_aspects: "Your Aspects" handle_explanation: "This is your diaspora id. Like an email address, you can give this to people to reach you." no_contacts: "No contacts" @@ -157,7 +157,9 @@ en: heading: "Diaspora ID" content_1: "Your Diaspora ID is:" content_2: "Give it to anyone and they'll be able to find you on Diaspora." - + services: + heading: "Connect Services" + content: "You can connect the following services to Diaspora:" aspect_memberships: destroy: success: "Successfully removed person from aspect"