environment.rb 2.09 KB
Newer Older
danielgrippi's avatar
danielgrippi committed
1
#   Copyright (c) 2010-2011, Diaspora Inc.  This file is
Raphael's avatar
Raphael committed
2
#   licensed under the Affero General Public License version 3 or later.  See
Raphael's avatar
Raphael committed
3
#   the COPYRIGHT file.
4

Raphael Sofaer's avatar
Raphael Sofaer committed
5 6 7 8 9
# check what database you have
def postgres?
  @using_postgres ||= defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) && ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
end

10 11 12 13
def sqlite?
  @using_sqlite ||= defined?(ActiveRecord::ConnectionAdapters::SQLite3Adapter) && ActiveRecord::Base.connection.class == ActiveRecord::ConnectionAdapters::SQLite3Adapter
end

14 15
# Load the rails application
require File.expand_path('../application', __FILE__)
maxwell's avatar
maxwell committed
16
Haml::Template.options[:format] = :html5
17
Haml::Template.options[:escape_html] = true
danielvincent's avatar
danielvincent committed
18

19 20 21 22 23 24
if File.exists?(File.expand_path("./config/locale_settings.yml"))
  locale_settings = YAML::load(File.open(File.expand_path("./config/locale_settings.yml")))
  AVAILABLE_LANGUAGES = (locale_settings['available'].length > 0) ? locale_settings['available'] : { :en => 'English' }
  DEFAULT_LANGUAGE = (AVAILABLE_LANGUAGES.include?(locale_settings['default'])) ? locale_settings['default'] : AVAILABLE_LANGUAGES.keys[0].to_s
  AVAILABLE_LANGUAGE_CODES = locale_settings['available'].keys.map { |v| v.to_s }
  LANGUAGE_CODES_MAP = locale_settings['fallbacks']
MrZYX's avatar
MrZYX committed
25
  RTL_LANGUAGES = locale_settings['rtl']
26 27
else
  AVAILABLE_LANGUAGES = { :en => 'English' }
28
  DEFAULT_LANGUAGE = 'en'
29
  AVAILABLE_LANGUAGE_CODES = ['en']
MrZYX's avatar
MrZYX committed
30
  LANGUAGE_CODES_MAP = {}
MrZYX's avatar
MrZYX committed
31
  RTL_LANGUAGES = []
MrZYX's avatar
MrZYX committed
32 33
end

Paul Spieker's avatar
Paul Spieker committed
34 35
# Blacklist of usernames
USERNAME_BLACKLIST = ['admin', 'administrator', 'hostmaster', 'info', 'postmaster', 'root', 'ssladmin', 
36
  'ssladministrator', 'sslwebmaster', 'sysadmin', 'webmaster', 'support', 'contact', 'example_user1dsioaioedfhgoiesajdigtoearogjaidofgjo']
Paul Spieker's avatar
Paul Spieker committed
37

38 39
# Initialize the rails application
Diaspora::Application.initialize!
40 41 42 43 44 45 46 47 48 49 50 51

# allow token auth only for posting activitystream photos
module Devise
  module Strategies
    class TokenAuthenticatable < Authenticatable
      private
      def valid_request?
        params[:controller] == "activity_streams/photos" && params[:action] == "create"
      end
    end
  end
end