Skip to content
Browse files

New configuration system

* Throw away old system
* Add new system
* Add new example files
* Replace all calls
* add the most important docs
* Add Specs
* rename disable_ssl_requirement to require_ssl
* cloudfiles isn't used/called in our code
* since community_spotlight.list is only used as enable flag replace it with such one and remove all legacy and irelevant codepaths around it
* die if session secret is unset and on heroku
* First basic infrastructure for version information
  • Loading branch information...
1 parent 5bea630 commit 2a4db54db97e259de4711d3e25326ee1a4822727 @jhass jhass committed Sep 16, 2012
Showing with 1,574 additions and 1,244 deletions.
  1. +2 −6 .gitignore
  2. +24 −0 Changelog.md
  3. +0 −1 Gemfile
  4. +0 −7 Gemfile.lock
  5. +8 −4 app/controllers/application_controller.rb
  6. +1 −1 app/controllers/invitations_controller.rb
  7. +0 −6 app/controllers/publics_controller.rb
  8. +2 −2 app/controllers/registrations_controller.rb
  9. +4 −4 app/helpers/analytics_helper.rb
  10. +4 −4 app/helpers/application_helper.rb
  11. +2 −2 app/helpers/open_graph_helper.rb
  12. +1 −1 app/helpers/people_helper.rb
  13. +1 −1 app/helpers/posts_helper.rb
  14. +1 −1 app/helpers/sessions_helper.rb
  15. +1 −1 app/mailers/diaspora_devise_mailer.rb
  16. +1 −1 app/mailers/notification_mailers/also_commented.rb
  17. +3 −3 app/mailers/notification_mailers/base.rb
  18. +1 −1 app/mailers/notification_mailers/comment_on_post.rb
  19. +1 −1 app/mailers/notification_mailers/private_message.rb
  20. +5 −5 app/mailers/notifier.rb
  21. +0 −194 app/models/app_config.rb
  22. +3 −3 app/models/invitation_code.rb
  23. +1 −1 app/models/jobs/publish_to_hub.rb
  24. +2 −2 app/models/photo.rb
  25. +2 −2 app/models/profile.rb
  26. +0 −16 app/models/role.rb
  27. +1 −1 app/models/service.rb
  28. +2 −2 app/models/services/facebook.rb
  29. +2 −2 app/models/services/tumblr.rb
  30. +2 −2 app/models/services/twitter.rb
  31. +2 −2 app/models/user.rb
  32. +2 −2 app/presenters/o_embed_presenter.rb
  33. +1 −1 app/views/admins/_admin_bar.haml
  34. +2 −2 app/views/contacts/spotlight.haml
  35. +1 −1 app/views/devise/shared/_links.haml
  36. +1 −1 app/views/layouts/notifier.html.erb
  37. +1 −1 app/views/publics/host_meta.erb
  38. +2 −2 app/views/sessions/new.html.erb
  39. +1 −1 app/views/shared/_contact_sidebar.html.haml
  40. +1 −1 app/views/shared/_donatepod.html.haml
  41. +3 −3 app/views/shared/_right_sections.html.haml
  42. +2 −2 app/views/users/public.atom.builder
  43. +0 −280 config/application.yml.example
  44. +121 −0 config/defaults.yml
  45. +1 −2 config/deploy.rb
  46. +283 −0 config/diaspora.yml.example
  47. +4 −1 config/environment.rb
  48. +1 −1 config/heroku.yml.example
  49. +0 −5 config/initializers/1_intialize_app_config.rb
  50. +0 −18 config/initializers/2_before_load_services.rb
  51. +0 −1 config/initializers/3_setup_app_config.rb
  52. +2 −2 config/initializers/airbrake.rb
  53. +7 −7 config/initializers/carrierwave.rb
  54. +6 −1 config/initializers/check_session_secret.rb
  55. +3 −3 config/initializers/devise.rb
  56. +1 −1 config/initializers/enforce_ssl.rb
  57. +1 −1 config/initializers/faraday.rb
  58. +0 −15 config/initializers/fetch_featured_users.rb
  59. +1 −1 config/initializers/ignore_ssl_in_development.rb
  60. +5 −4 config/initializers/load_analyitics.rb
  61. +31 −33 config/initializers/mailer_config.rb
  62. +1 −1 config/initializers/newrelic.rb
  63. +8 −7 config/initializers/omniauth.rb
  64. +6 −6 config/initializers/resque.rb
  65. +4 −4 config/initializers/set_up_image_redirects.rb
  66. +1 −1 config/initializers/static_assets.rb
  67. +1 −9 config/initializers/version_header.rb
  68. +41 −0 config/load_config.rb
  69. +2 −2 config/newrelic.yml
  70. +0 −9 config/oauth_keys.yml.example
  71. +1 −1 config/routes.rb
  72. +1 −1 config/unicorn.rb
  73. +0 −7 features/step_definitions/uri-step.rb
  74. +0 −8 features/support/env.rb
  75. +69 −0 lib/configuration.rb
  76. +65 −0 lib/configuration/lookup_chain.rb
  77. +115 −0 lib/configuration/methods.rb
  78. +19 −0 lib/configuration/provider.rb
  79. +24 −0 lib/configuration/provider/dynamic.rb
  80. +14 −0 lib/configuration/provider/env.rb
  81. +52 −0 lib/configuration/provider/yaml.rb
  82. +76 −0 lib/configuration/proxy.rb
  83. +0 −54 lib/environment_configuration.rb
  84. +1 −1 lib/messagebus/mailer.rb
  85. +2 −2 lib/rake_helpers.rb
  86. +0 −4 lib/stream/base.rb
  87. +1 −1 lib/stream/multi.rb
  88. +1 −1 lib/tasks/db.rake
  89. +5 −7 lib/tasks/heroku.rake
  90. +3 −3 lib/tasks/migrations.rake
  91. +8 −11 script/get_config.rb
  92. +6 −6 script/server
  93. +10 −4 spec/controllers/application_controller_spec.rb
  94. +4 −4 spec/controllers/invitations_controller_spec.rb
  95. +3 −3 spec/controllers/registrations_controller_spec.rb
  96. +0 −16 spec/controllers/streams_controller_spec.rb
  97. +2 −2 spec/factories.rb
  98. +0 −108 spec/fixtures/config/old_style_app.yml
  99. +12 −7 spec/helpers/application_helper_spec.rb
  100. +1 −1 spec/helpers/people_helper_spec.rb
  101. +67 −0 spec/lib/configuration/lookup_chain_spec.rb
  102. +141 −0 spec/lib/configuration/methods_spec.rb
  103. +23 −0 spec/lib/configuration/provider/dynamic_spec.rb
  104. +32 −0 spec/lib/configuration/provider/env_spec.rb
  105. +72 −0 spec/lib/configuration/provider/yaml_spec.rb
  106. +18 −0 spec/lib/configuration/provider_spec.rb
  107. +56 −0 spec/lib/configuration/proxy_spec.rb
  108. +25 −0 spec/lib/configuration_spec.rb
  109. +3 −3 spec/lib/rake_helper_spec.rb
  110. +1 −1 spec/lib/webfinger_spec.rb
  111. +3 −3 spec/mailers/notifier_spec.rb
  112. +0 −257 spec/models/app_config_spec.rb
  113. +4 −4 spec/models/invitation_code_spec.rb
  114. +1 −1 spec/models/jobs/publish_to_hub_spec.rb
  115. +4 −4 spec/models/person_spec.rb
  116. +1 −1 spec/models/profile_spec.rb
  117. +0 −6 spec/spec_helper.rb
  118. +1 −1 spec/support/user_methods.rb
View
8 .gitignore
@@ -4,13 +4,9 @@ app/assets/images/custom/*
# Configuration files
-config/app_config.yml
-config/app.yml
-config/application.yml
+config/diaspora.yml
config/heroku.yml
-config/script_server*.yml
-config/fb_config.yml
-config/oauth_keys.yml
+config/script_server.yml
config/initializers/secret_token.rb
config/redis.conf
config/deploy_config.yml
View
24 Changelog.md
@@ -0,0 +1,24 @@
+# 0.0.1.0pre
+
+## New configuration system!
+
+Copy over config/diaspora.yml.example to config/diaspora.yml and migrate your settings! An updated Heroku guide including basic hints on howto migrate is [here](https://github.com/diaspora/diaspora/wiki/Installing-on-heroku).
+
+The new configuration system allows all possible settings to be overriden by environment variables. This makes it possible to deploy heroku without checking any credentials into git. Read the top of `config/diaspora.yml.example` for an explanation on how to convert the setting names to environment variables.
+
+### Environment variable changes:
+
+#### deprectated
+
+* REDISTOGO_URL in favour of REDIS_URL or ENVIRONMENT_REDIS
+
+#### removed
+
+* application_yml - Obsolete, all settings are settable via environment variables now
+
+#### renamed
+
+* SINGLE_PROCESS_MODE -> ENVIRONMENT_SINGLE_PROCESS_MODE
+* SINGLE_PROCESS -> ENVIRONMENT_SINGLE_PROCESS_MODE
+* NO_SSL -> ENVIRONMENT_REQUIRE_SSL
+* ASSET_HOST -> ENVIRONMENT_ASSETS_HOST
View
1 Gemfile
@@ -53,7 +53,6 @@ group :heroku do
gem 'unicorn', '4.3.1', :require => false
end
-gem 'settingslogic', :git => 'https://github.com/binarylogic/settingslogic.git'
# database
gem "activerecord-import", "0.2.11"
View
7 Gemfile.lock
@@ -8,12 +8,6 @@ GIT
nokogiri (>= 1.3.3)
GIT
- remote: https://github.com/binarylogic/settingslogic.git
- revision: 4884d455bf18d92723cb8190cfd2dbf87f3aafd5
- specs:
- settingslogic (2.0.8)
-
-GIT
remote: https://github.com/plataformatec/markerb.git
revision: 93b1e8bea9b8fa89ef930f78ba562f596c022198
specs:
@@ -519,7 +513,6 @@ DEPENDENCIES
ruby-oembed (= 0.8.7)
sass-rails (= 3.2.5)
selenium-webdriver (= 2.25.0)
- settingslogic!
spork (= 1.0.0rc3)
thin (= 1.4.1)
timecop (= 0.5.1)
View
12 app/controllers/application_controller.rb
@@ -8,7 +8,7 @@ class ApplicationController < ActionController::Base
before_filter :ensure_http_referer_is_set
before_filter :set_locale
- before_filter :set_git_header if (AppConfig[:git_update] && AppConfig[:git_revision])
+ before_filter :set_diaspora_header
before_filter :set_grammatical_gender
before_filter :mobile_switch
@@ -61,9 +61,13 @@ def ensure_page
params[:page] = params[:page] ? params[:page].to_i : 1
end
- def set_git_header
- headers['X-Git-Update'] = AppConfig[:git_update] if AppConfig[:git_update].present?
- headers['X-Git-Revision'] = AppConfig[:git_revision] if AppConfig[:git_revision].present?
+ def set_diaspora_header
+ headers['X-Diaspora-Version'] = AppConfig.version_string
+
+ if AppConfig.git_available?
+ headers['X-Git-Update'] = AppConfig.git_update if AppConfig.git_update.present?
+ headers['X-Git-Revision'] = AppConfig.git_revision if AppConfig.git_revision.present?
+ end
end
def set_locale
View
2 app/controllers/invitations_controller.rb
@@ -55,7 +55,7 @@ def create
end
def check_if_invites_open
- unless AppConfig[:open_invitations]
+ unless AppConfig.settings.invitations.open?
flash[:error] = I18n.t 'invitations.create.no_more'
redirect_to :back
View
6 app/controllers/publics_controller.rb
@@ -9,12 +9,6 @@ class PublicsController < ApplicationController
require Rails.root.join('lib', 'postzord', 'receiver', 'private')
include Diaspora::Parser
- # We use newrelic_ignore to prevent artifical RPM bloat; however,
- # I am commenting this line out for the time being to debug some apparent
- # issues on Heroku.
- #
- # newrelic_ignore if EnvironmentConfiguration.using_new_relic?
-
skip_before_filter :set_header_data
skip_before_filter :set_grammatical_gender
before_filter :check_for_xml, :only => [:receive, :receive_public]
View
4 app/controllers/registrations_controller.rb
@@ -31,15 +31,15 @@ def new
private
def check_valid_invite!
- return true unless AppConfig[:registrations_closed] #this sucks
+ return true if AppConfig.settings.enable_registrations? #this sucks
return true if invite && invite.can_be_used?
flash[:error] = t('registrations.invalid_invite')
redirect_to new_user_session_path
end
def check_registrations_open_or_vaild_invite!
return true if invite.present?
- if AppConfig[:registrations_closed]
+ unless AppConfig.settings.enable_registrations?
flash[:error] = t('registrations.closed')
redirect_to new_user_session_path
end
View
8 app/helpers/analytics_helper.rb
@@ -9,7 +9,7 @@ def include_mixpanel
<<-JS.html_safe
(function(d,c){var a,b,g,e;a=d.createElement('script');a.type='text/javascript';a.async=!0;a.src=('https:'===d.location.protocol?'https:':'http:')+'//api.mixpanel.com/site_media/js/api/mixpanel.2.js';b=d.getElementsByTagName('script')[0];b.parentNode.insertBefore(a,b);c._i=[];c.init=function(a,d,f){var b=c;'undefined'!==typeof f?b=c[f]=[]:f='mixpanel';g='disable track track_pageview track_links track_forms register register_once unregister identify name_tag set_config'.split(' ');
for(e=0;e<g.length;e++)(function(a){b[a]=function(){b.push([a].concat(Array.prototype.slice.call(arguments,0)))}})(g[e]);c._i.push([a,d,f])};window.mixpanel=c})(document,[]);
- mixpanel.init("#{AppConfig[:mixpanel_uid]}");
+ mixpanel.init("#{AppConfig.privacy.mixpanel_uid}");
JS
end
end
@@ -35,7 +35,7 @@ def include_chartbeat
include_analytics "chartbeat" do
javascript_tag do
<<-JS.html_safe
- var _sf_async_config = { uid: #{AppConfig[:chartbeat_uid]}, domain: "#{AppConfig[:pod_uri].host}" };
+ var _sf_async_config = { uid: #{AppConfig.privacy.chartbeat_uid}, domain: "#{AppConfig.pod_uri.host}" };
(function() {
function loadChartbeat() {
window._sf_endpt = (new Date()).getTime();
@@ -64,6 +64,6 @@ def include_analytics(service, &block)
end
def configured?(service)
- AppConfig["#{service}_uid".to_sym].present?
+ AppConfig.privacy.send("#{service}_uid").present?
end
-end
+end
View
8 app/helpers/application_helper.rb
@@ -4,7 +4,7 @@
module ApplicationHelper
def pod_name
- AppConfig[:pod_name].present? ? AppConfig[:pod_name] : "DIASPORA*"
+ AppConfig.settings.pod_name.present? ? AppConfig.settings.pod_name : "DIASPORA*"
end
def how_long_ago(obj)
@@ -21,7 +21,7 @@ def bookmarklet
end
def raw_bookmarklet( height = 250, width = 620)
- "javascript:(function(){f='#{AppConfig[:pod_url]}bookmarklet?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'&notes='+encodeURIComponent(''+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text))+'&v=1&';a=function(){if(!window.open(f+'noui=1&jump=doclose','diasporav1','location=yes,links=no,scrollbars=no,toolbar=no,width=#{width},height=#{height}'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()"
+ "javascript:(function(){f='#{AppConfig.environment.url}bookmarklet?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'&notes='+encodeURIComponent(''+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text))+'&v=1&';a=function(){if(!window.open(f+'noui=1&jump=doclose','diasporav1','location=yes,links=no,scrollbars=no,toolbar=no,width=#{width},height=#{height}'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()"
end
def magic_bookmarklet_link
@@ -37,7 +37,7 @@ def contacts_link
end
def all_services_connected?
- current_user.services.size == AppConfig[:configured_services].size
+ current_user.services.size == AppConfig.configured_services.size
end
def popover_with_close_html(without_close_html)
@@ -56,7 +56,7 @@ def modernizer_responsive_tag
# vendored jquery_ujs
def jquery_include_tag
buf = []
- if AppConfig[:jquery_cdn]
+ if AppConfig.privacy.jquery_cdn?
version = Jquery::Rails::JQUERY_VERSION
buf << [ javascript_include_tag("//ajax.googleapis.com/ajax/libs/jquery/#{version}/jquery.min.js") ]
buf << [ javascript_tag("!window.jQuery && document.write(unescape('#{j javascript_include_tag("jquery")}'));") ]
View
4 app/helpers/open_graph_helper.rb
@@ -30,7 +30,7 @@ def og_type
end
def og_namespace(object)
- namespace = AppConfig[:open_graph_namespace].present? ? AppConfig[:open_graph_namespace] : 'joindiaspora'
+ namespace = AppConfig.services.facebook.open_graph_namespace.present? ? AppConfig.services.facebook.open_graph_namespace : 'joindiaspora'
"#{namespace}:frame"
end
@@ -54,4 +54,4 @@ def default_image_url
"#{root_url.chop}#{image_path('asterisk.png')}"
end
end
-end
+end
View
2 app/helpers/people_helper.rb
@@ -73,7 +73,7 @@ def person_href(person, opts={})
# Rails.application.routes.url_helpers is needed since this is indirectly called from a model
def local_or_remote_person_path(person, opts={})
- opts.merge!(:protocol => AppConfig[:pod_uri].scheme, :host => AppConfig[:pod_uri].authority)
+ opts.merge!(:protocol => AppConfig.pod_uri.scheme, :host => AppConfig.pod_uri.authority)
absolute = opts.delete(:absolute)
if person.local?
View
2 app/helpers/posts_helper.rb
@@ -20,7 +20,7 @@ def post_page_title(post, opts={})
def post_iframe_url(post_id, opts={})
opts[:width] ||= 516
opts[:height] ||= 315
- host = AppConfig[:pod_uri].site
+ host = AppConfig.pod_uri.site
"<iframe src='#{Rails.application.routes.url_helpers.post_url(post_id, :host => host)}' width='#{opts[:width]}px' height='#{opts[:height]}px' frameBorder='0'></iframe>".html_safe
end
end
View
2 app/helpers/sessions_helper.rb
@@ -9,7 +9,7 @@ def prefilled_username
end
def display_registration_link?
- !AppConfig[:registrations_closed] && devise_mapping.registerable? && controller_name != 'registrations'
+ !AppConfig.settings.enable_registrations? && devise_mapping.registerable? && controller_name != 'registrations'
end
def display_password_reset_link?
View
2 app/mailers/diaspora_devise_mailer.rb
@@ -1,5 +1,5 @@
class DiasporaDeviseMailer < Devise::Mailer
- default :from => AppConfig[:smtp_sender_address]
+ default :from => AppConfig.mail.sender_address
def self.mailer_name
"devise/mailer"
View
2 app/mailers/notification_mailers/also_commented.rb
@@ -9,7 +9,7 @@ def set_headers(comment_id)
@comment = Comment.find_by_id(comment_id)
if mail?
- @headers[:from] = "\"#{@comment.author_name} (Diaspora*)\" <#{AppConfig[:smtp_sender_address]}>"
+ @headers[:from] = "\"#{@comment.author_name} (Diaspora*)\" <#{AppConfig.mail.sender_address}>"
@headers[:subject] = truncate(@comment.comment_email_subject, :length => TRUNCATION_LEN)
@headers[:subject] = "Re: #{@headers[:subject]}"
end
View
6 app/mailers/notification_mailers/base.rb
@@ -33,12 +33,12 @@ def name_and_address(name, email)
private
def default_headers
headers = {
- :from => AppConfig[:smtp_sender_address],
- :host => "#{AppConfig[:pod_uri]}",
+ :from => AppConfig.mail.sender_address.get,
+ :host => "#{AppConfig.pod_uri.host}",
:to => name_and_address(@recipient.name, @recipient.email)
}
- headers[:from] = "\"#{@sender.name} (Diaspora*)\" <#{AppConfig[:smtp_sender_address]}>" if @sender.present?
+ headers[:from] = "\"#{@sender.name} (Diaspora*)\" <#{AppConfig.mail.sender_address}>" if @sender.present?
headers
end
View
2 app/mailers/notification_mailers/comment_on_post.rb
@@ -7,7 +7,7 @@ class CommentOnPost < NotificationMailers::Base
def set_headers(comment_id)
@comment = Comment.find(comment_id)
- @headers[:from] = "\"#{@comment.author_name} (Diaspora*)\" <#{AppConfig[:smtp_sender_address]}>"
+ @headers[:from] = "\"#{@comment.author_name} (Diaspora*)\" <#{AppConfig.mail.sender_address}>"
@headers[:subject] = truncate(@comment.comment_email_subject, :length => TRUNCATION_LEN)
@headers[:subject] = "Re: #{@headers[:subject]}"
end
View
2 app/mailers/notification_mailers/private_message.rb
@@ -7,7 +7,7 @@ def set_headers(message_id)
@conversation = @message.conversation
@participants = @conversation.participants
- @headers[:from] = "\"#{@message.author_name} (Diaspora*)\" <#{AppConfig[:smtp_sender_address]}>"
+ @headers[:from] = "\"#{@message.author_name} (Diaspora*)\" <#{AppConfig.mail.sender_address}>"
@headers[:subject] = @conversation.subject.strip
@headers[:subject] = "Re: #{@headers[:subject]}" if @conversation.messages.size > 1
end
View
10 app/mailers/notifier.rb
@@ -24,8 +24,8 @@ def single_admin(string, recipient, opts={})
end
default_opts = {:to => @receiver.email,
- :from => AppConfig[:smtp_sender_address],
- :subject => I18n.t('notifier.single_admin.subject'), :host => AppConfig[:pod_uri].host}
+ :from => AppConfig.mail.sender_address,
+ :subject => I18n.t('notifier.single_admin.subject'), :host => AppConfig.pod_uri.host}
default_opts.merge!(opts)
@@ -42,9 +42,9 @@ def invite(email, message, inviter, invitation_code, locale)
@locale = locale
@invitation_code = invitation_code
- mail_opts = {:to => email, :from => AppConfig[:smtp_sender_address],
- :subject => I18n.t('notifier.invited_you', :name => @inviter.name),
- :host => AppConfig[:pod_uri].host}
+ mail_opts = {:to => email, :from => AppConfig.mail.sender_address,
+ :subject => I18n.t('notifier.invited_you', :name => @inviter.name),
+ :host => AppConfig.pod_uri.host}
I18n.with_locale(locale) do
mail(mail_opts) do |format|
View
194 app/models/app_config.rb
@@ -1,194 +0,0 @@
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
-
-require 'uri'
-require Rails.root.join('lib', 'environment_configuration')
-
-class AppConfig < Settingslogic
- def self.source_file_name
- if ENV['application_yml'].present?
- puts "using remote application.yml"
- return ENV['application_yml']
- end
- config_file = Rails.root.join("config", "application.yml")
- if !File.exists?(config_file) && (Rails.env == 'test' || Rails.env.include?("integration") || EnvironmentConfiguration.heroku?)
- config_file = Rails.root.join("config", "application.yml.example")
- end
- config_file
- end
- source source_file_name
- namespace Rails.env
-
- def self.load!
- unless EnvironmentConfiguration.heroku?
- if no_config_file? && !have_old_config_file?
- $stderr.puts <<-HELP
-******** You haven't set up your Diaspora settings file. **********
-Please do the following:
-1. Copy config/application.yml.example to config/application.yml.
-2. Have a look at the settings in that file. It has sensible defaults for development, which (we hope)
-work without modification. However, it's always good to know what's available to change later.
-3. Restart Diaspora!
-******** Thanks for being an alpha tester! **********
- HELP
- Process.exit(1)
- end
-
- if ((no_config_file? && have_old_config_file?) || config_file_is_old_style?)
- $stderr.puts <<-HELP
-******** The Diaspora configuration file format has changed. **********
-Please do the following:
-1. Copy config/application.yml.example to config/application.yml.
-2. Make any changes in config/application.yml that you previously made in config/app.yml or config/app_config.yml.
-3. Delete config/app.yml and config/app_config.yml. Don't worry if they don't exist, though.
-4. Restart Diaspora!
-******** Thanks for being an alpha tester! **********
- HELP
- Process.exit(1)
- end
- end
-
- begin
- super
- rescue TypeError
- puts "Couldn't find section ''#{self.namespace}' in config/application.yml."
- puts "Double check it's there and that you haven't set RAILS_ENV to something weired (check it for typos)"
- Process.exit(1)
- end
-
- if !EnvironmentConfiguration.heroku? && no_cert_file_in_prod?
- $stderr.puts <<-HELP
-******** Diaspora does not know where your SSL-CA-Certificates file is. **********
- Please add the root certificate bundle (this is operating system specific) to application.yml. Defaults:
- CentOS: '/etc/pki/tls/certs/ca-bundle.crt'
- Debian: '/etc/ssl/certs/ca-certificates.crt'
-
- Example:
- ca_file: '/etc/ssl/certs/ca-certificates.crt'
-******** Thanks for being secure! **********
-HELP
- Process.exit(1)
- end
- end
-
- def self.setup!
- normalize_pod_url
- normalize_admins
- normalize_pod_services
- deprecate_hoptoad_api_key
- self[:to_ary] = []
- end
-
- def self.configured_services
- self['configured_services'] || []
- end
-
- def self.config_file_is_old_style?
- !(File.read(@source) =~ /^defaults: &defaults/)
- end
-
- def self.no_config_file?
- !File.exists?(@source)
- end
-
- def self.no_cert_file_in_prod?
- (Rails.env == "production") && (self[:ca_file].blank? || !File.exists?(self[:ca_file]))
- end
-
- def self.have_old_config_file?
- File.exists?(Rails.root.join("config", "app.yml")) || (File.exists?(Rails.root.join("config", "app_config.yml")))
- end
-
- def self.new_relic_app_name
- self[:new_relic_app_name] || self[:pod_uri].host
- end
-
- def self.normalize_pod_url
- unless self[:pod_url] =~ /^(https?:\/\/)/ # starts with http:// or https://
- self[:pod_url] = "http://#{self[:pod_url]}"
- end
- unless self[:pod_url] =~ /\/$/ # ends with slash
- self[:pod_url] = "#{self[:pod_url]}/"
- end
- end
-
- def self.bare_pod_uri
- self[:pod_uri].authority.gsub('www.', '')
- end
-
- def self.normalize_admins
- self[:admins] ||= []
- self[:admins].collect! { |username| username.downcase }
- end
-
- def self.normalize_pod_services
- self['configured_services'] = []
- if defined?(SERVICES)
- SERVICES.keys.each do |service|
- unless SERVICES[service].keys.any?{|service_key| SERVICES[service][service_key].blank?}
- self['configured_services'] << service
- end
- end
- end
- end
-
- def deprecate_hoptoad_api_key
- if self[:hoptoad_api_key].present?
- $stderr.puts "WARNING: Please change hoptoad_api_key to airbrake_api_key in your application.yml"
- self[:airbrake_api_key] = self[:hoptoad_api_key]
- end
- end
-
- load!
-
- def self.[] (key)
- return self.pod_uri if key == :pod_uri
- super
- end
-
- def self.[]= (key, value)
- super
- if key.to_sym == :pod_url
- @@pod_uri = nil
- normalize_pod_url
- end
- end
-
- cattr_accessor :pod_uri
-
- def self.pod_uri
- if @@pod_uri.nil?
- begin
- @@pod_uri = Addressable::URI.parse(self[:pod_url])
- rescue
- puts "WARNING: pod url " + self[:pod_url] + " is not a legal URI"
- end
- end
- return @@pod_uri
- end
-
- def self.single_process_mode?
- (ENV['SINGLE_PROCESS'] == "true" || ENV['SINGLE_PROCESS_MODE'] == "true" || self[:single_process_mode]) ? true : false
- end
-
- def self.get_redis_instance
- if ENV["REDISTOGO_URL"].present?
- puts "WARNING: using the REDISTOGO_URL environment variable is deprecated, please use REDIS_URL now."
- ENV['REDIS_URL'] = ENV["REDISTOGO_URL"]
- end
-
- redis_options = {}
-
- if ENV['REDIS_URL'].present?
- redis_options = { :url => ENV['REDIS_URL'] }
- elsif ENV['RAILS_ENV']== 'integration2'
- redis_options = { :host => 'localhost', :port => 6380 }
- elsif self[:redis_url].present?
- puts "WARNING: You're redis_url doesn't start with redis://" unless self[:redis_url].start_with?("redis://")
- redis_options = { :url => self[:redis_url] }
- end
-
- Redis.new(redis_options.merge(:thread_safe => true))
- end
-end
View
6 app/models/invitation_code.rb
@@ -30,14 +30,14 @@ def generate_token
end
def self.default_inviter_or(user)
- if AppConfig[:admin_account].present?
- inviter = User.find_by_username(AppConfig[:admin_account])
+ if AppConfig.admins.account.present?
+ inviter = User.find_by_username(AppConfig.admins.account.get)
end
inviter ||= user
inviter
end
def set_default_invite_count
- self.count = AppConfig[:invite_count] || 25
+ self.count = AppConfig['settings.invitations.count'] || 25
end
end
View
2 app/models/jobs/publish_to_hub.rb
@@ -9,7 +9,7 @@ class PublishToHub < Base
def self.perform(sender_public_url)
require Rails.root.join('lib', 'pubsubhubbub')
atom_url = sender_public_url + '.atom'
- Pubsubhubbub.new(AppConfig[:pubsub_server]).publish(atom_url)
+ Pubsubhubbub.new(AppConfig.environment.pubsub_server.get).publish(atom_url)
end
end
end
View
4 app/models/photo.rb
@@ -99,8 +99,8 @@ def processed?
def update_remote_path
unless self.unprocessed_image.url.match(/^https?:\/\//)
- pod_url = AppConfig[:pod_url].dup
- pod_url.chop! if AppConfig[:pod_url][-1,1] == '/'
+ pod_url = AppConfig.environment.url.get.dup
+ pod_url.chop! if pod_url[-1,1] == '/'
remote_path = "#{pod_url}#{self.unprocessed_image.url}"
else
remote_path = self.unprocessed_image.url
View
4 app/models/profile.rb
@@ -185,8 +185,8 @@ def clearable_fields
end
def absolutify_local_url url
- pod_url = AppConfig[:pod_url].dup
- pod_url.chop! if AppConfig[:pod_url][-1,1] == '/'
+ pod_url = AppConfig.environment.url.get
+ pod_url.chop! if pod_url[-1,1] == '/'
"#{pod_url}#{url}"
end
end
View
16 app/models/role.rb
@@ -13,20 +13,4 @@ def self.add_admin(person)
def self.add_spotlight(person)
find_or_create_by_person_id_and_name(person.id, 'spotlight')
end
-
- def self.load_admins
- admins = AppConfig[:admins] || []
- admins.each do |username|
- u = User.find_by_username(username)
- find_or_create_by_person_id_and_name(u.person.id, 'admin')
- end
- end
-
- def self.load_spotlight
- spotlighters = AppConfig[:community_spotlight] || []
- spotlighters.each do |diaspora_handle|
- person = Person.find_by_diaspora_handle(diaspora_handle)
- find_or_create_by_person_id_and_name(person.id, 'spotlight')
- end
- end
end
View
2 app/models/service.rb
@@ -14,7 +14,7 @@ def self.titles(service_strings)
def public_message(post, length, url = "")
Rails.logger.info("Posting out to #{self.class}")
- url = Rails.application.routes.url_helpers.short_post_url(post, :protocol => AppConfig[:pod_uri].scheme, :host => AppConfig[:pod_uri].authority)
+ url = Rails.application.routes.url_helpers.short_post_url(post, :protocol => AppConfig.pod_uri.scheme, :host => AppConfig.pod_uri.authority)
space_for_url = 21 + 1
truncated = truncate(post.text(:plain_text => true), :length => (length - space_for_url))
truncated = "#{truncated} #{url}"
View
4 app/models/services/facebook.rb
@@ -23,7 +23,7 @@ def post_to_facebook(url, body)
end
def create_open_graph_params(post)
- {:post => "#{AppConfig[:pod_url]}#{short_post_path(post)}", :access_token => self.access_token}
+ {:post => "#{AppConfig.environment.url}#{short_post_path(post)}", :access_token => self.access_token}
end
def create_post_params(post)
@@ -38,4 +38,4 @@ def public_message(post, url)
def profile_photo_url
"https://graph.facebook.com/#{self.uid}/picture?type=large&access_token=#{URI.escape(self.access_token)}"
end
-end
+end
View
4 app/models/services/tumblr.rb
@@ -9,11 +9,11 @@ def provider
end
def consumer_key
- SERVICES['tumblr']['consumer_key']
+ AppConfig.services.tumblr.key
end
def consumer_secret
- SERVICES['tumblr']['consumer_secret']
+ AppConfig.services.tumblr.secret
end
def post(post, url='')
View
4 app/models/services/twitter.rb
@@ -35,8 +35,8 @@ def profile_photo_url
private
def configure_twitter
- twitter_key = SERVICES['twitter']['consumer_key']
- twitter_consumer_secret = SERVICES['twitter']['consumer_secret']
+ twitter_key = AppConfig.services.twitter.key
+ twitter_consumer_secret = AppConfig.services.twitter.secret
if twitter_key.blank? || twitter_consumer_secret.blank?
Rails.logger.info "you have a blank twitter key or secret.... you should look into that"
View
4 app/models/user.rb
@@ -395,7 +395,7 @@ def setup(opts)
end
def set_person(person)
- person.url = AppConfig[:pod_url]
+ person.url = AppConfig.environment.url
person.diaspora_handle = "#{self.username}#{User.diaspora_id_host}"
self.person = person
end
@@ -410,7 +410,7 @@ def seed_aspects
self.aspects.create(:name => I18n.t('aspects.seed.work'))
aq = self.aspects.create(:name => I18n.t('aspects.seed.acquaintances'))
- unless AppConfig[:no_follow_diasporahq]
+ unless AppConfig.settings.follow_diasporahq
default_account = Webfinger.new('diasporahq@joindiaspora.com').fetch
self.share_with(default_account, aq) if default_account
end
View
4 app/presenters/o_embed_presenter.rb
@@ -15,7 +15,7 @@ def to_json(opts={})
def as_json(opts={})
{
:provider_name => "Diaspora",
- :provider_hurl => AppConfig[:pod_url],
+ :provider_url => AppConfig.environment.url,
:type => 'rich',
:version => '1.0',
:title => post_title,
@@ -40,7 +40,7 @@ def post_author
end
def post_author_url
- Rails.application.routes.url_helpers.person_url(@post.author, :host => AppConfig[:pod_uri].host)
+ Rails.application.routes.url_helpers.person_url(@post.author, :host => AppConfig.pod_uri.host)
end
def iframe_html
View
2 app/views/admins/_admin_bar.haml
@@ -6,6 +6,6 @@
%li= link_to t('.weekly_user_stats'), weekly_user_stats_path
%li= link_to t('.pod_stats'), pod_stats_path
%li= link_to t('.correlations'), correlations_path
- - if AppConfig[:mount_resque_web]
+ - if AppConfig.admins.inline_resque_web?
%li= link_to t('.resque_overview'), resque_web_path
View
4 app/views/contacts/spotlight.haml
@@ -16,9 +16,9 @@
.span-18.last{:style => "position:relative;"}
- - if AppConfig[:spotlight_suggest_email].present?
+ - if AppConfig.settings.community_spotlight.suggest_email.present?
.right
- = link_to "Suggest a member", "mailto:#{AppConfig[:spotlight_suggest_email]}", :class => "button"
+ = link_to "Suggest a member", "mailto:#{AppConfig.settings.community_spotlight.suggest_email}", :class => "button"
%h3
= t('contacts.spotlight.community_spotlight')
View
2 app/views/devise/shared/_links.haml
@@ -1,7 +1,7 @@
- if controller_name != 'sessions'
= link_to t('.sign_in'), new_session_path(resource_name)
%br/
-- if !AppConfig[:registrations_closed] && devise_mapping.registerable? && controller_name != 'registrations'
+- if AppConfig.settings.enable_registrations? && devise_mapping.registerable? && controller_name != 'registrations'
= link_to t('.sign_up'), new_registration_path(resource_name)
%br/
- else
View
2 app/views/layouts/notifier.html.erb
@@ -28,7 +28,7 @@
<table cellspacing="0" cellpadding="0" border="0" align="center" width="100%" style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:14px;color:#333;">
<tr>
<td style="text-align:center;padding:30px;">
- <img src="<%=AppConfig[:pod_url]%>assets/branding/logo_caps.png" alt="DIASPORA*" width="95px" height="14px"/>
+ <img src="<%=AppConfig.environment.url %>assets/branding/logo_caps.png" alt="DIASPORA*" width="95px" height="14px"/>
</td>
</tr>
</table>
View
2 app/views/publics/host_meta.erb
@@ -5,6 +5,6 @@
<Link rel='lrdd'
type='application/xrd+xml'
- template='<%= AppConfig[:pod_url] %>webfinger?q={uri}' />
+ template='<%= AppConfig.environment.url %>webfinger?q={uri}' />
</XRD>
View
4 app/views/sessions/new.html.erb
@@ -1,10 +1,10 @@
<% content_for :page_title do %>
- <%= "#{AppConfig[:pod_name]} / #{t('devise.sessions.new.sign_in')}" %>
+ <%= "#{AppConfig.settings.pod_name} / #{t('devise.sessions.new.sign_in')}" %>
<% end %>
<div id="login">
<h1 id="huge-text">
- <%= AppConfig[:pod_name] %>
+ <%= AppConfig.settings.pod_name %>
</h1>
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => {:class => "form-horizontal block-form"}, :autocomplete => 'off') do |f| %>
View
2 app/views/shared/_contact_sidebar.html.haml
@@ -8,6 +8,6 @@
%hr
%ul.left_nav
- - if AppConfig[:community_spotlight]
+ - if AppConfig.settings.community_spotlight.enable?
%li{:class => ("active" if @spotlight)}
= link_to t('contacts.spotlight.community_spotlight'), community_spotlight_path, :class => "element_selector"
View
2 app/views/shared/_donatepod.html.haml
@@ -1,6 +1,6 @@
%form{:action => "https://www.paypal.com/cgi-bin/webscr", :method => "post"}
%input{:name => "cmd", :type => "hidden", :value => "_s-xclick"}
- %input{:name => "hosted_button_id", :type => "hidden", :value => AppConfig[:paypal_hosted_button_id]}
+ %input{:name => "hosted_button_id", :type => "hidden", :value => AppConfig.settings.paypal_hosted_button_id}
%input{:name => "on0", :type => "hidden", :value => "Type"}
%input{:name => "modify", :type => "hidden", :value => "2"}
%select{:name => "os0"}
View
6 app/views/shared/_right_sections.html.haml
@@ -3,7 +3,7 @@
-# the COPYRIGHT file.
-- if AppConfig[:open_invitations]
+- if AppConfig.settings.invitations.open?
.section
.title
= image_tag('icons/plus.png')
@@ -73,8 +73,8 @@
%h5
= t('aspects.index.donate')
.content
- - if AppConfig[:paypal_hosted_button_id].present?
- = t('aspects.index.keep_pod_running', :pod => URI.parse(AppConfig[:pod_url]).host)
+ - if AppConfig.settings.paypal_hosted_button_id.present?
+ = t('aspects.index.keep_pod_running', :pod => URI.parse(AppConfig.environment.url).host)
%br
= render 'shared/donatepod'
- else
View
4 app/views/users/public.atom.builder
@@ -8,14 +8,14 @@ atom_feed({'xmlns:thr' => 'http://purl.org/syndication/thread/1.0',
:id => "#{@user.public_url}.atom",
:root_url => "#{@user.public_url}"}) do |feed|
- feed.tag! :generator, 'Diaspora', :uri => "#{AppConfig[:pod_url]}"
+ feed.tag! :generator, 'Diaspora', :uri => "#{AppConfig.environment.url}"
feed.title "#{@user.name}'s Public Feed"
feed.subtitle "Updates from #{@user.name} on Diaspora"
feed.logo "#{@user.image_url(:thumb_small)}"
feed.updated @posts[0].created_at if @posts.length > 0
feed.tag! :link, :rel => 'avatar', :type => 'image/jpeg', 'media:width' => '100',
'media:height' => '100', :href => "#{@user.image_url}"
- feed.tag! :link, :href => "#{AppConfig[:pubsub_server]}", :rel => 'hub'
+ feed.tag! :link, :href => "#{AppConfig.environment.pubsub_server}", :rel => 'hub'
feed.author do |author|
author.name @user.name
View
280 config/application.yml.example
@@ -1,280 +0,0 @@
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
-
-defaults: &defaults
-
- ######################################################
- # Environment Configuration
- ######################################################
-
- ## Set the hostname of the machine you're running Diaspora on, as seen
- ## from the internet. This should be the URL you want to use to
- ## access the pod. So if you plan to reverse proxy it, it should be
- ## the URL the proxy listens on.
- ## DO NOT CHNANGE THIS AFTER INITIAL SETUP
- ## UNLESS YOU KNOW WHAT YOU'RE DOING!
- ## However changing http to https is okay and has no consquences.
- ## If you do change it you have to start over as it's hardcoded into
- ## the database.
- pod_url: "http://localhost:3000/"
-
- ## Setting the bundle of certificate authorities (CA) certificates.
- ## This is operating system specific.
- ## Examples, uncomment one or add your own:
- ca_file: '/etc/pki/tls/certs/ca-bundle.crt'
-
- ## Redis URL for a remote redis.
- ## Don't forget to restrict IP access!
- ## Leave it empty for the default ('redis://localhost:6379/0')
- ## You can specify a username and password in it, for example
- ## redis://user:password@remote_host:6379/0
- ## You can also specify a unix socket URL like unix://tmp/redis.sock
- redis_url:
-
- ## Serve static assets via the appserver.
- ## This is highly not recommended for production use,
- ## let your reverse proxy/webserver do it by serving the files
- ## under public/ directly.
- serve_static_assets: false
-
- ## Disable SSL requirement
- #when set, your pod will not force you to use https in production
- #NOTE: not all features of Diaspora work without SSL, and you may have trouble federating
- # with other pods
- circumvent_ssl_requirement: false
-
- # If set to true Diaspora will work with just the appserver, thin by default,
- # running, however this makes it quite slow as all the time intensive jobs
- # must be run inside the request cycle. Also the live updates from the Websocket
- # will be disabled.
- single_process_mode: true
-
- ## Use Amazon S3 instead of your local filesystem
- ## to handle uploaded pictures.
- # s3 config - if set, carrierwave will store your photos on s3. Otherwise they're on the filesystem.
- #s3_key: 'key'
- #s3_secret: 'secret'
- #s3_bucket: 'my_photos'
- s3_region: 'us-east-1'
-
- ## Related to S3 you can set a url to redirect all requests to uploaded
- ## images to another host. If you for example set
- ## https://images.example.org here, all requests made to
- ## pictures under /uploads/images will be redirected to
- ## https://images.example.org/uploads/images/...
- image_redirect_url: ''
-
- ## Diaspora is only tested against this default pubsub server.
- ## You probably don't want to change this.
- pubsub_server: 'https://pubsubhubbub.appspot.com/'
-
- ## Include jQuery from Google's CDN
- ## This potentially saves you some traffic and speeds up
- ## load time since most clients already have this one cached
- jquery_cdn: false
-
- ## Provide a key to enable tracking by Google Analytics
- google_a_site: false
-
- ## Piwik Tracking
- ## Provide a site ID and the host piwik is running on to enable
- ## tracking through Piwik.
- # piwik integration - if not set, no javascript included
- piwik_id:
- # the site url in raw format (e.g. pikwik.examplehost.com)
- piwik_url:
-
- ## Chartbeat tracking
- chartbeat_uid:
-
- ## Mixpanel event tracking
- mixpanel_uid:
-
-
- ######################################################
- # 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).
- registrations_closed: false
-
- ## Set this to true if you don't want your users to follow the
- ## diasporahq@joindiaspora.com account on account creation.
- ## The diasporahq account helps users start with some activity in
- ## their stream and get news about Diaspora, but if you want
- ## your server to contact joindiaspora.com, set this to false:
- no_follow_diasporahq: false
-
- ## the 'admin' account for your pod... ie for jd.com, this is diasporahq.
- ## (This is not about privileges, but e.g. to determine the sender for
- ## emails sent from the admin panel. If you want to configure an actual
- ## admin accout, use roles instead. See
- ## https://github.com/diaspora/diaspora/wiki/FAQ-for-Pod-Maintainers
- ## "What are roles and how do I use them?")
- admin_account: ''
-
- ## Settings about invitations
-
- # Set this to true if you want users to invite as many people as they want
- open_invitations: true
-
- #the default amount of invitiations for an invite link
- invite_count: 25
-
- ## Paypal donations
- ## You can provide the ID of a hosted Paypal button here to kindly ask
- ## your users for donations to run their pod. If you leave this out
- ## we kindly ask your users to donate to the Diaspora Foundation :)
- paypal_hosted_button_id: ""
-
-
- ## Community Spotlight
- ## The community spotlight gives new users a starting point on who
- ## could be interesting Diasporas community.
- ## --------
- ## DEPRECATED - use roles instead, see
- ## https://github.com/diaspora/diaspora/wiki/FAQ-for-Pod-Maintainers
- ## "What are roles and how do I use them?"
- ## --------
- #community_spotlight:
- #list:
- #- 'diasporahq@joindiaspora.com'
- #- 'me@example.org'
-
- ## E-Mail address users can make suggestions about who should be
- ## in the spotlight to.
- spotlight_suggest_email: ''
-
- ######################################################
- # Email Configuration
- ######################################################
-
- ## First you need to enable it ;)
- mailer_on: false
-
- ## Sender address used in mail send by Diaspora
- #sender_address: 'no-reply@example.org'
-
- ## This selects which mailer should be used. Take 'smtp' for a smtp
- ## connection, 'sendmail' to use the sendmail binary or
- ## 'messagebus' to use the messagebus service.
- mailer_method: 'smtp'
-
- # Address/port to smtp server handling outgoing mail.
- smtp_address: 'smtp.example.com'
- smtp_port: '587'
-
- #API key if you are using message bus
- message_bus_api_key: ''
-
- # The path to the sendmail binary. Ignored if mailer_method is not set to sendmail
- sendmail_location: '/usr/sbin/sendmail'
-
- # Set this to true if you want to use exim and sendmail
- sendmail_exim_fix: false
-
- # Authentication required to send mail. Use one of 'plain',
- # 'login' or 'cram_md5'. Use 'none' if server does not support
- # authentication
- smtp_authentication: 'plain'
-
- # Automatically enable TLS? Ignored if smtp_authentication is set to none
- smtp_starttls_auto: true
-
- # OpenSSL verify mode used when connecting to a SMTP server with TLS.
- # Set this to none if you have a self signed certificate, keep it empty (not '') for the default
- # Possible values: none, peer, client_once, fail_if_no_peer_cert
- smtp_openssl_verify_mode:
-
- # Domain of smtp server.
- # This should match the common name of the certificate
- # the SMTP server sends. If he sends one
- smtp_domain: 'example.com'
-
- # Credentials to log in to the SMTP server - may be necessary if
- # smtp_authentication is not 'none'
- smtp_username: 'smtp_username'
- smtp_password: 'secret'
-
- # Sender address in Diaspora's outgoing mail.
- smtp_sender_address: 'no-reply@joindiaspora.com'
-
- ######################################################
- # Social Service Configuration
- ######################################################
-
- ## OAuth credentials for Facebook:
- facebook_app_id: ''
- facebook_app_secret: ''
-
- #this will be the namespace for your object, it should be configured in your FB app
- open_graph_namespace: ''
-
-
- ## OAuth credentials for Twitter:
- twitter_consumer_key: ''
- twitter_consumer_secret: ''
-
- ## OAuth credentials for Tumblr
- tumblr_consumer_key: ''
- tumblr_consumer_secret: ''
-
-
- ######################################################
- # Debugging Service Tool Integration
- ######################################################
-
- ## Resque is the background processing sysem used by Diaspora
- ## Resque web is an admin tool for it. This settings decides wheter
- ## or not to inline it into Diaspora.
- mount_resque_web: true
-
- ## If you use Airbrake provide your API key here:
- airbrake_api_key: ''
-
- ## If you use NewRelic provide your credentials here:
- NEW_RELIC_LICENSE_KEY: ''
- new_relic_app_name: ''
-
-######################################################
-# Overrides
-######################################################
-
-development:
- <<: *defaults
- serve_static_assets: true
- no_follow_diasporahq: true
-
-production:
- <<: *defaults
- jquery_cdn: true
-
-##################################################
-# FEDERATION LOGGER ##############################
-# Do not touch unless you know what you're doing!#
-##################################################
-
-test:
- <<: *defaults
- pod_url: "http://localhost:9887/"
- socket_port: 8081
- open_invitations: true
- no_follow_diasporahq: true
- serve_static_assets: true
- mailer_on: true
-
-integration1:
- <<: *defaults
- pod_url: "http://localhost:3001/"
- serve_static_assets: true
-
-integration2:
- <<: *defaults
- pod_url: "http://localhost:3002/"
- serve_static_assets: true
View
121 config/defaults.yml
@@ -0,0 +1,121 @@
+#######################################################################
+############### DO NOT TOUCH ANYTHING BELOW THIS ######################
+#######################################################################
+
+defaults:
+ version:
+ number: "0.0.1.0"
+ release: false # Do not touch unless in a merge conflict on doing a release, master should have a commit setting this to true which is not backported to the develop branch.
+ heroku: false
+ environment:
+ url: "http://localhost:3000/"
+ certificate_authorities:
+ redis:
+ serve_static_assets: false
+ require_ssl: true
+ single_process_mode: false
+ s3:
+ enable: false
+ key:
+ secret:
+ bucket:
+ region:
+ image_redirect_url:
+ pubsub_server: 'https://pubsubhubbub.appspot.com/'
+ privacy:
+ jquery_cdn: true
+ google_analytics_key:
+ piwik:
+ enable: false
+ host:
+ site_id:
+ mixpanel_uid:
+ chartbeat_uid:
+ settings:
+ pod_name: "Diaspora*"
+ enable_registrations: true
+ follow_diasporahq: true
+ invitations:
+ open: true
+ count: 25
+ paypal_hosted_button_id:
+ community_spotlight:
+ enable: false
+ suggest_email:
+ services:
+ facebook:
+ enable: false
+ app_id:
+ secret:
+ open_graph_namespace: 'joindiaspora'
+ twitter:
+ enable: false
+ key:
+ secret:
+ tumblr:
+ enable: false
+ key:
+ secret:
+ mail:
+ enable: false
+ sender_address: 'no-reply@example.org'
+ method: 'smtp'
+ smtp:
+ host: 'localhost'
+ port: 587
+ authentication: 'plain'
+ username:
+ password:
+ starttls_auto: true
+ openssl_verify_mode:
+ domain:
+ sendmail:
+ location: '/usr/sbin/sendmail'
+ exim_fix: false
+ message_bus_api_key:
+ admins:
+ account:
+ inline_resque_web: true
+ monitoring:
+ airbrake_api_key:
+ new_relic:
+ enable: false
+ app_name:
+ license_key:
+
+development:
+ environment:
+ serve_static_assets: true
+ single_process_mode: true
+ require_ssl: false
+ settings:
+ follow_diasporahq: false
+production:
+ i_am_a_dummy: # Remove if you add an actual override
+test:
+ environment:
+ url: "http://localhost:9887/"
+ single_process_mode: true
+ require_ssl: false
+ serve_static_assets: true
+ settings:
+ follow_diasporahq: false
+ invitations:
+ open: true
+ services:
+ facebook:
+ enable: true
+ app_id: 'fake'
+ secret: 'sdoigjosdfijg'
+ mail:
+ enable: true
+integration1:
+ environment:
+ url: "http://localhost:45789/"
+ serve_static_assets: true
+ require_ssl: false
+integration2:
+ environment:
+ url: "http://localhost:34658/"
+ serve_static_assets: true
+ require_ssl: false
View
3 config/deploy.rb
@@ -32,8 +32,7 @@ def current_git_branch
namespace :deploy do
task :symlink_config_files do
run "ln -s -f #{shared_path}/config/database.yml #{current_path}/config/database.yml"
- run "ln -s -f #{shared_path}/config/application.yml #{current_path}/config/application.yml"
- run "ln -s -f #{shared_path}/config/oauth_keys.yml #{current_path}/config/oauth_keys.yml"
+ run "ln -s -f #{shared_path}/config/diaspora.yml #{current_path}/config/diaspora.yml"
end
task :symlink_cookie_secret do
View
283 config/diaspora.yml.example
@@ -0,0 +1,283 @@
+## Some notes about this file:
+## - All comments start with a double #
+## - All settings are by default commented out with a single #
+## You need to uncomment them in order to work.
+## - Take care to keep proper indentation, that is keeping the indentation
+## of the original #, with no additional space before the settings
+## name.
+## - Take care to keep proper quoting. All ' should have a matching ' at
+## the end of the same line. Same goes for "
+## - Lists need the space after the -
+## - true, false and numbers should have no quoting.
+## Single words could have none, but doesn't do any harm to them.
+##
+## You can set and/or override all this settings through environment variables
+## with the following conversion rules:
+## - Strip the top level namespace (configuration, production, etc.)
+## - Build the path to the setting, for example environment.s3.enable
+## - Replace the dots with underscores: environment_s3_enable
+## - Upcase everything: ENVIRONMENT_S3_ENABLE
+## - Specify lists/arrays as comma separated values
+
+configuration:
+
+ ## Settings you need to change or at least review
+ ## in order for your pod to basically work
+ environment:
+
+ ## Set the hostname of the machine you're running Diaspora on, as seen
+ ## from the internet. This should be the URL you want to use to
+ ## access the pod. So if you plan to reverse proxy it, it should be
+ ## the URL the proxy listens on.
+ ## DO NOT CHNANGE THIS AFTER INITIAL SETUP
+ ## UNLESS YOU KNOW WHAT YOU'RE DOING!
+ ## However changing http to https is okay and has no consequences.
+ ## If you do change it you have to start over as it's hardcoded into
+ ## the database.
+ #url: "https://example.org/"
+
+ ## Setting the bundle of certificate authorities (CA) certificates.
+ ## This is operating system specific.
+ ## Examples, uncomment one or add your own:
+ ## Debian, Ubuntu, Archlinux (package ca-certificates)
+ #certificate_authorities: '/etc/ssl/certs/ca-certificates.crt'
+ ## CentOS
+ #certificate_authorities: '/etc/pki/tls/certs/ca-bundle.crt'
+ ## Gentoo
+ #certificate_authorities: '/etc/ssl/certs/ca-certificates.crt'
+
+ ## URL for a remote redis.
+ ## Don't forget to restrict the IP access!
+ ## Leave it commented out for the default (localhost)
+ #redis: 'redis://exmaple_host'
+ #redis: 'redis://username:password@host:6379/0'
+ #redis: 'unix:///tmp/redis.sock'
+
+ ## Require SSL, default true.
+ ## When set, your pod will force you to use https in production.
+ ## Since OAuth2 requires SSL Diasporas future API might not work if you're not
+ ## on SSL. Also no gurantee that posting to services is given if SSL
+ ## is disabled.
+ #require_ssl: true
+
+ ## Single process mode
+ ## If set to true Diaspora will work with just the appserver,
+ ## thin by default, running, however this makes it quite slow as
+ ## all the time intensive jobs must be run inside the request cycle.
+ ## So this is higly unrecommended for production setups.
+ #single_process_mode: true
+
+ ## Use Amazon S3 instead of your local filesystem
+ ## to handle uploaded pictures.
+ s3:
+ #enable: true
+ #key: 'changeme'
+ #secret: 'changeme'
+ #bucket: 'my_photos'
+ #region: 'us-east-1'
+
+ ## Related to S3 you can set a url to redirect all requests to uploaded
+ ## images to another host. If you for example set
+ ## https://images.example.org here, all requests made to
+ ## pictures under /uploads/images will be redirected to
+ ## https://images.example.org/uploads/images/...
+ #image_redirect_url: 'https://images.example.org'
+
+ assets:
+ ## Serve static assets via the appserver.
+ ## This is highly discouraged for production use,
+ ## let your reverse proxy/webserver do it by serving the files
+ ## under public/ directly.
+ #serve: true
+
+ ## Upload your assets to S3
+ #upload: true
+
+ ## Specify an asset host. Ensure it does not have a trailing slash (/).
+ #host: http://cdn.example.org/diaspora
+
+ ## Diaspora is only tested against this default pubsub server.
+ ## You likely don't want to change this.
+ #pubsub_server: 'https://pubsubhubbub.appspot.com/'
+
+
+ ## Settings probably affecting the privacy of your users
+ privacy:
+
+ ## Include jQuery from Google's CDN
+ ## This potentially saves you some traffic and speeds up
+ ## load time since most clients already have this one cached
+ #jquery_cdn: true
+
+ ## Provide a key to enable tracking by Google Analytics
+ #google_analytics_key:
+
+ ## Piwik Tracking
+ ## Provide a site ID and the host piwik is running on to enable
+ ## tracking through Piwik.
+ piwik:
+ #enable: true
+ #host: 'stats.example.org'
+ #site_id: 1
+
+ ## Mixpanel event tracking
+ #mixpanel_uid:
+
+ ## Chartbeat tracking
+ #chartbeat_uid:
+
+ ## General settings
+ settings:
+
+ ## The name of your pod displayed in various locations,
+ ## including the header.
+ #pod_name: "Diaspora*"
+
+ ## Set this to false 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).
+ #enable_registrations: true
+
+ ## Set this to false if you don't want your users to follow the
+ ## diasporahq@joindiaspora.com account on account creation.
+ ## The diasporahq account helps users start with some activity in
+ ## their stream and get news about Diaspora, but if you don't want
+ ## your server to contact joindiaspora.com, set this to false:
+ #follow_diasporahq: false
+
+ ## Settings about invitations
+ invitiations:
+
+ ## Set this to true if you want users to invite as many
+ ## people as they want.
+ #open: true
+
+ ## The default amount of invitiations an invite link has.
+ ## Every user has such a link. Only counts if open is false.
+ #count: 25
+
+ ## Paypal donations
+ ## You can provide the ID of a hosted Paypal button here to kindly ask
+ ## your users for donations to run their pod. If you leave this out
+ ## we kindly ask your users to donate to the Diaspora Foundation :)
+ #paypal_hosted_button_id: ""
+
+ ## Community Spotlight
+ ## The community spotlight gives new users a starting point on who
+ ## could be interesting Diasporas community. To add a person
+ ## to the spotlight add the 'spotlight' role to it.
+ community_spotlight:
+ #enable: false
+ ## E-Mail address users can make suggestions about who should be
+ ## in the spotlight to.
+ #suggest_email: 'admin@example.org'
+
+ ## Setup E-Mail
+ mail:
+
+ ## First you need to enable it ;)
+ #enable: true
+
+ ## Sender address used in mail send by Diaspora
+ #sender_address: 'no-reply@example.org'
+
+ ## This selects which mailer should be used. Take 'smtp' for a smtp
+ ## connection, 'sendmail' to use the sendmail binary or
+ ## 'messagebus' to use the messagebus service.
+ #method: 'smtp'
+
+ ## Ignore if method isn't 'smtp'
+ smtp:
+ ## Host and port of the smtp server handling outgoing mail.
+ ## This should match the common name of the certificate
+ ## the SMTP server sends. If he sends one.
+ #host: 'smtp.example.org'
+ #port: 587
+
+ ## Authentication required to send mail. Use one of 'plain',
+ ## 'login' or 'cram_md5'. Use 'none' if server does not support
+ ## authentication
+ #authentication: 'plain'
+
+ ## Credentials to log in to the SMTP server - may be necessary if
+ ## authentication is not 'none'
+ #username: 'changeme'
+ #password: 'changeme'
+
+ ## Automatically enable TLS? Ignored if authentication is set to none
+ #starttls_auto: true
+
+ ## The domain for the HELO command if needed
+ #domain: 'smtp.example.org'
+
+ ## OpenSSL verify mode used when connecting to a
+ ## SMTP server with TLS. Set this to none if you have
+ ## a self signed certificate. Possible values:
+ ## 'none', 'peer', 'client_once', 'fail_if_no_peer_cert'
+ #openssl_verify_mode: 'none'
+
+ ## Ignore if method isn't 'sendmail'
+ sendmail:
+ ## The path to the sendmail binary.
+ #location: '/usr/sbin/sendmail'
+
+ ## Set this to true if you want to use exim and sendmail
+ #exim_fix: true
+
+ ## Ignore if method isn't 'messagebus'
+ #message_bus_api_key: 'abcdef'
+
+ ## Settings around Diasporas capabilities to post to services
+ services:
+ ## OAuth credentials for Facebook:
+ facebook:
+ #enable: true
+ #app_id: 'abcdef'
+ #secret: 'changeme'
+ ## this will be the namespace for your object,
+ ## it should be configured in your FB app
+ #open_graph_namespace:
+
+ ## OAuth credentials for Twitter:
+ twitter:
+ #enable: true
+ #key: 'abcdef'
+ #secret: 'changeme'
+
+ ## OAuth credentials for Tumblr
+ tumblr:
+ #enable: true
+ #key: 'abcdef'
+ #secret: 'changeme'
+
+ ## Settings relevant to administrators
+ admins:
+
+ ## Set the admin account.
+ ## This doesn't make the user an admin but is used when a generic
+ ## admin contact is neeeded, much like the postmaster role in mail
+ ## systems. Set only the username, NOT the full ID.
+ #account: "podmaster"
+
+ ## Resque is the background processing system used by Diaspora
+ ## Resque web is an admin tool for it. This settings decides whether
+ ## or not to inline it into Diaspora.
+ #inline_resque_web: true
+
+ monitoring:
+ ## If you use Airbrake provide your API key here:
+ #airbrake_api_key: 'abcdef'
+
+ ## If you use NewRelic provide your credentials here:
+ new_relic:
+ #enable: true
+ #app_name: 'foo'
+ #license_key: 'abcdef'
+
+## Here you can make overides to settings defined above if you need
+## to have them different in different environments.
+production:
+
+development:
+ environment:
+ #redis_url: 'redis://production.example.org:6379'
View
5 config/environment.rb
@@ -13,7 +13,10 @@ def sqlite?
# Load the rails application
require File.expand_path('../application', __FILE__)
-require File.join(Rails.root, "lib", "exceptions")
+require Rails.root.join("lib", "exceptions")
+
+# Load configuration system early
+require Rails.root.join("config", "load_config")
Haml::Template.options[:format] = :html5
Haml::Template.options[:escape_html] = true
View
2 config/heroku.yml.example
@@ -1,6 +1,6 @@
defaults: &defaults
HEROKU: true
- application_yml: <%= '../' + '../' +'config/' + 'application.yml.example' %>
+ application_yml: <%= '../' + '../' +'config/' + 'diaspora.yml.example' %>
production:
app: production
stack: cedar
View
5 config/initializers/1_intialize_app_config.rb
@@ -1,5 +0,0 @@
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
-
-require Rails.root.join('app', 'models', 'app_config')
View
18 config/initializers/2_before_load_services.rb
@@ -1,18 +0,0 @@
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
-
-def load_config_yaml filename
- YAML.load(ERB.new(File.read(filename)).result)
-end
-
-oauth_keys_file = Rails.root.join('config', 'oauth_keys.yml').to_s
-
-
-SERVICES = load_config_yaml("#{oauth_keys_file}.example")
-
-#this is to be backwards compatible with current production setups
-if File.exist? oauth_keys_file
- ActiveSupport::Deprecation.warn("01/05/2012 keys in oauth_keys.yml should be moved into application.yml. SEE application.yml.example for updated key names")
- SERVICES.deep_merge!(load_config_yaml(oauth_keys_file))
-end
View
1 config/initializers/3_setup_app_config.rb
@@ -1 +0,0 @@
-AppConfig.setup!
View
4 config/initializers/airbrake.rb
@@ -3,8 +3,8 @@
# the COPYRIGHT file.
Airbrake.configure do |config|
- if AppConfig[:airbrake_api_key].present?
- config.api_key = AppConfig[:airbrake_api_key]
+ if AppConfig.admins.monitoring.airbrake_api_key.present?
+ config.api_key = AppConfig.admins.monitoring.airbrake_api_key
else
# creative way to disable Airbrake, should be replaced once the gem provides a proper way
config.development_environments << Rails.env
View
14 config/initializers/carrierwave.rb
@@ -3,18 +3,18 @@
# the COPYRIGHT file.
#Excon needs to see the CA Cert Bundle file
-ENV["SSL_CERT_FILE"] = AppConfig[:ca_file]
+ENV['SSL_CERT_FILE'] = AppConfig.environment.certificate_authorities.get
CarrierWave.configure do |config|
- if !Rails.env.test? && AppConfig[:s3_key] && AppConfig[:s3_secret] && AppConfig[:s3_bucket] && AppConfig[:s3_region]
+ if !Rails.env.test? && AppConfig.environment.s3.enable?
config.storage = :fog
config.cache_dir = Rails.root.join('tmp', 'uploads').to_s
config.fog_credentials = {
- :provider => 'AWS',
- :aws_access_key_id => AppConfig[:s3_key],
- :aws_secret_access_key => AppConfig[:s3_secret],
- :region => AppConfig[:s3_region]
+ :provider => 'AWS',
+ :aws_access_key_id => AppConfig.environment.s3.key.get,
+ :aws_secret_access_key => AppConfig.environment.s3.secret.get,
+ :region => AppConfig.environment.s3.region.get
}
- config.fog_directory = AppConfig[:s3_bucket]
+ config.fog_directory = AppConfig.environment.s3.bucket.get
else
config.storage = :file
end
View
7 config/initializers/check_session_secret.rb
@@ -1 +1,6 @@
-EnvironmentConfiguration.ensure_secret_token!
+if AppConfig.heroku?
+ Rails.application.config.secret_token = AppConfig.secret_token
+elsif !File.exists?( Rails.root.join('config', 'initializers', 'secret_token.rb'))
+ `bundle exec rake generate:secret_token`
+ require Rails.root.join('config', 'initializers', 'secret_token.rb')
+end
View
6 config/initializers/devise.rb
@@ -21,9 +21,9 @@ def to_mobile
require 'devise/orm/active_record'
#mail setup
- if AppConfig[:smtp_sender_address]
- config.mailer_sender = AppConfig[:smtp_sender_address]
- else
+ if AppConfig.mail.sender_address.present?
+ config.mailer_sender = AppConfig.mail.sender_address
+ elsif AppcConfig.mail.enable?
unless Rails.env == 'test'
Rails.logger.warn("No smtp sender address set, mail may fail.")
puts "WARNING: No smtp sender address set, mail may fail."
View
2 config/initializers/enforce_ssl.rb
@@ -2,7 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
-if EnvironmentConfiguration.enforce_ssl?
+if AppConfig.environment.require_ssl?
Rails.application.config.middleware.insert_before 0, Rack::SSL
puts "Rack::SSL is enabled"
end
View
2 config/initializers/faraday.rb
@@ -3,7 +3,7 @@
# the COPYRIGHT file.
options = {:timeout => 25}
-options[:ssl] = {:ca_file => EnvironmentConfiguration.ca_cert_file_location}
+options[:ssl] = {:ca_file => AppConfig.environment.certificate_authorities}
Faraday.default_connection = Faraday::Connection.new(options) do |b|
b.use FaradayMiddleware::FollowRedirects
b.adapter Faraday.default_adapter
View
15 config/initializers/fetch_featured_users.rb
@@ -1,15 +0,0 @@
-#this breaks seed scripts
-
-if AppConfig[:featured_users].present? && AppConfig[:community_spotlight].blank?
- AppConfig[:community_spotlight] = AppConfig[:featured_users]
- puts "DEPRICATION WARNING (10/21/11): Please change `featured_users` in your application.yml to `community_spotlight`. Thanks!"
-end
-
-unless EnvironmentConfiguration.prevent_fetching_community_spotlight?
- print "Fetching community spotlight users from remote servers"
- AppConfig[:community_spotlight].each do |x|
- Webfinger.new(x).fetch
- print "."
- end
- puts " done!"
-end
View
2 config/initializers/ignore_ssl_in_development.rb
@@ -2,7 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
-if AppConfig[:ca_file].blank? && (Rails.env == "development")
+if AppConfig.environment.certificate_authorities.blank? && (Rails.env == "development")
module OpenSSL
module SSL
remove_const :VERIFY_PEER
View
9 config/initializers/load_analyitics.rb
@@ -5,15 +5,16 @@
if Rails.env == 'production'
Diaspora::Application.configure do
- if AppConfig[:google_a_site].present?
+ if AppConfig.privacy.google_analytics_key.present?
config.gem 'rack-google-analytics', :lib => 'rack/google-analytics'
- config.middleware.use Rack::GoogleAnalytics, :tracker => AppConfig[:google_a_site]
+ config.middleware.use Rack::GoogleAnalytics, :tracker => AppConfig.privacy.google_analytics_key.get
end
- if AppConfig[:piwik_url].present?
+ if AppConfig.privacy.piwik.enable?
require 'rack/piwik'
config.gem 'rack-piwik', :lib => 'rack/piwik'
- config.middleware.use Rack::Piwik, :piwik_url => AppConfig[:piwik_url], :piwik_id => AppConfig[:piwik_id]
+ config.middleware.use Rack::Piwik, :piwik_url => AppConfig.privacy.piwik.host.get,
+ :piwik_id => AppConfig.privacy.piwik.site_id.get
end
end
end
View
64 config/initializers/mailer_config.rb
@@ -4,51 +4,49 @@
require Rails.root.join('lib', 'messagebus', 'mailer')
Diaspora::Application.configure do
- config.action_mailer.default_url_options = {:protocol => AppConfig[:pod_uri].scheme,
- :host => AppConfig[:pod_uri].authority }
- config.action_mailer.asset_host = AppConfig[:pod_uri].to_s
- config.action_mailer.perform_deliveries = AppConfig[:mailer_on]
+ config.action_mailer.default_url_options = {:protocol => AppConfig.pod_uri.scheme,
+ :host => AppConfig.pod_uri.authority }
+ config.action_mailer.asset_host = AppConfig.pod_uri.to_s
+ config.action_mailer.perform_deliveries = AppConfig.mail.enable?
- unless Rails.env == 'test' || AppConfig[:mailer_on] != true
- if AppConfig[:mailer_method] == 'messagebus'
+ unless Rails.env == 'test' || !AppConfig.mail.enable?
+ if AppConfig.mail.method == 'messagebus'
- if AppConfig[:message_bus_api_key].present?
-
- config.action_mailer.delivery_me