From 82c4e0d577fc1e019b8122e7a419ec5239ab1569 Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg Date: Wed, 30 May 2012 11:17:03 -0700 Subject: [PATCH] add a podname app config var, and use it throughout the app --- app/assets/templates/stream.jst.hbs | 6 ++++-- app/helpers/application_helper.rb | 4 ++++ app/helpers/language_helper.rb | 6 +++--- app/helpers/layout_helper.rb | 4 +++- app/views/home/show.html.haml | 2 +- app/views/layouts/application.mobile.haml | 2 +- app/views/sessions/new.haml | 2 +- config/application.yml.example | 8 +++----- spec/helpers/application_helper_spec.rb | 13 +++++++++++++ spec/helpers/layout_helper_spec.rb | 3 ++- 10 files changed, 35 insertions(+), 15 deletions(-) diff --git a/app/assets/templates/stream.jst.hbs b/app/assets/templates/stream.jst.hbs index 1d8984363..cccb849a1 100644 --- a/app/assets/templates/stream.jst.hbs +++ b/app/assets/templates/stream.jst.hbs @@ -36,7 +36,7 @@ - DIASPORA + {{t "pod_name"}} @@ -44,7 +44,9 @@

- +

diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a62e5f8c2..39111b199 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3,6 +3,10 @@ # the COPYRIGHT file. module ApplicationHelper + def pod_name + AppConfig[:pod_name].present? ? AppConfig[:pod_name] : "DIASPORA*" + end + def how_long_ago(obj) timeago(obj.created_at) end diff --git a/app/helpers/language_helper.rb b/app/helpers/language_helper.rb index 6f976b5a2..fefb8212e 100644 --- a/app/helpers/language_helper.rb +++ b/app/helpers/language_helper.rb @@ -15,8 +15,8 @@ module LanguageHelper defaults.deep_merge!(translations) end - defaults['pluralization_rule'] = I18n.t 'i18n.plural.js_rule', :locale => language - + defaults['pluralization_rule'] = I18n.t('i18n.plural.js_rule', :locale => language) + defaults['pod_name'] = pod_name defaults end @@ -26,6 +26,6 @@ module LanguageHelper end def rtl? - @rtl ||= RTL_LANGUAGES.include? I18n.locale.to_s + @rtl ||= RTL_LANGUAGES.include?(I18n.locale.to_s) end end diff --git a/app/helpers/layout_helper.rb b/app/helpers/layout_helper.rb index 2e64e84be..8eb325fdd 100644 --- a/app/helpers/layout_helper.rb +++ b/app/helpers/layout_helper.rb @@ -7,6 +7,8 @@ # to do so you may need to add this line to your ApplicationController # helper :layout module LayoutHelper + include ApplicationHelper + def title(page_title, show_title = true) content_for(:title) { page_title.to_s } @show_title = show_title @@ -14,7 +16,7 @@ module LayoutHelper def page_title(text=nil) return text unless text.blank? - "Diaspora*" + pod_name end def set_asset_host diff --git a/app/views/home/show.html.haml b/app/views/home/show.html.haml index 0af6b4df3..9d1f21d3d 100644 --- a/app/views/home/show.html.haml +++ b/app/views/home/show.html.haml @@ -4,7 +4,7 @@ - content_for :page_title do - Diaspora* + = pod_name - begin = render :partial => 'home/show' diff --git a/app/views/layouts/application.mobile.haml b/app/views/layouts/application.mobile.haml index bcdaaf398..cb32701ab 100644 --- a/app/views/layouts/application.mobile.haml +++ b/app/views/layouts/application.mobile.haml @@ -6,7 +6,7 @@ %html{:lang => I18n.locale.to_s, :dir => (rtl?) ? 'rtl' : 'ltr'} %head %title - DIASPORA* + = pod_name %meta{:name => "description", :content => "Diaspora* Mobile"} %meta{:name => "author", :content => "Diaspora, Inc."} diff --git a/app/views/sessions/new.haml b/app/views/sessions/new.haml index 1dbdb2a54..978950f28 100644 --- a/app/views/sessions/new.haml +++ b/app/views/sessions/new.haml @@ -3,7 +3,7 @@ -# the COPYRIGHT file. = content_for :page_title do - = "Diaspora* / #{t('devise.sessions.new.sign_in')}" + = "#{pod_name} / #{t('devise.sessions.new.sign_in')}" = content_for :head do = javascript_include_tag :login diff --git a/config/application.yml.example b/config/application.yml.example index 1a6cb53d0..1179aadce 100644 --- a/config/application.yml.example +++ b/config/application.yml.example @@ -89,6 +89,9 @@ defaults: &defaults # General Pod Settings ###################################################### + ## Name of your pod + pod_name: "Diaspora*" + ## Set this to true to prevent people from signing up for your pod ## without an invitation. Note that this needs to be true even for ## the first registration (you). @@ -104,11 +107,6 @@ defaults: &defaults #the 'admin' account for your pod... ie for jd.com, this is diasporahq admin_account: '' - ## Here, you can turn specific users into admins - admins: - #- 'admin' - #- 'me' - ## Settings about invitations # Set this to true if you want users to invite as many people as they want diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 19079a273..1bf7b6989 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -83,4 +83,17 @@ describe ApplicationHelper do jquery_include_tag.should match(/jQuery\.ajaxSetup/) end end + + describe '#pod_name' do + it 'defaults to Diaspora*' do + pod_name.should == 'DIASPORA*' + end + + it 'displays the supplied AppConfig[:pod_name] if it is set' do + old_name = AppConfig[:pod_name] + AppConfig[:pod_name] = "Catspora" + pod_name.should == "Catspora" + AppConfig[:pod_name] = old_name + end + end end diff --git a/spec/helpers/layout_helper_spec.rb b/spec/helpers/layout_helper_spec.rb index 7c312cb1e..0dabf3f2b 100644 --- a/spec/helpers/layout_helper_spec.rb +++ b/spec/helpers/layout_helper_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' describe LayoutHelper do + include ApplicationHelper before do @user = alice end @@ -18,7 +19,7 @@ describe LayoutHelper do context "passed blank text" do it "returns Diaspora*" do - page_title.should == "Diaspora*" + page_title.should == pod_name end end