Merge pull request #27 from robertjwhitney/config_to_env

Config to env

Andrew Cantino 11 ans auparavant
Parent
Commettre
a6aa81900e

+ 6 - 0
.env.example

@@ -0,0 +1,6 @@
1
+APP_SECRET_TOKEN=REPLACE_ME_NOW!
2
+DOMAIN=localhost:3000
3
+GOOGLE_APPS_DOMAIN=your-domain-here.com
4
+GMAIL_USERNAME=you@gmail.com
5
+GMAIL_PASSWORD=somepassword
6
+EMAIL_FROM_ADDRESS=from_address@gmail.com

+ 1 - 0
.gitignore

@@ -16,3 +16,4 @@ rerun.txt
16 16
 pickle-email-*.html
17 17
 .idea/
18 18
 .DS_Store
19
+.env

+ 2 - 0
Gemfile

@@ -15,6 +15,8 @@ gem 'delayed_job_active_record', "~> 0.3.3" # newer was giving a strange MySQL e
15 15
 gem "daemons"
16 16
 # gem "delayed_job_web"
17 17
 
18
+gem 'foreman'
19
+
18 20
 group :assets do
19 21
   gem 'sass-rails',   '~> 3.2.3'
20 22
   gem 'coffee-rails', '~> 3.2.1'

+ 3 - 0
Gemfile.lock

@@ -94,6 +94,8 @@ GEM
94 94
     font-awesome-sass-rails (3.0.2.2)
95 95
       railties (>= 3.1.1)
96 96
       sass-rails (>= 3.1.1)
97
+    foreman (0.62.0)
98
+      thor (>= 0.13.6)
97 99
     geokit (1.6.5)
98 100
       multi_json
99 101
     geokit-rails3 (0.1.5)
@@ -277,6 +279,7 @@ DEPENDENCIES
277 279
   devise
278 280
   em-http-request
279 281
   fastercsv
282
+  foreman
280 283
   geokit-rails3
281 284
   jquery-rails
282 285
   json (>= 1.7.7)

+ 5 - 2
README.md

@@ -39,8 +39,11 @@ And now, some example screenshots.  Below them are instructions to get you start
39 39
 
40 40
 If you just want to play around, you can simply clone this repository, then perform the following steps:
41 41
 
42
-* Edit `config/initializers/secret_token.rb` and replace `REPLACE_ME_NOW!` with the output of `rake secret`.
43
-* Run `rake db:create`, `rake db:migrate`, and then `rake db:seed` to create a development MySQL database with some example seed data.  Run `rails s`, visit `http://localhost:3000`, and login with the username of `admin` and the password of `password`.
42
+* Copy .env.example to .env `cp .env.example .env`
43
+* Edit the configuration options in .env
44
+* Edit the APP_SECRET_TOKEN environment variable and replace `REPLACE_ME_NOW!` with the output of `rake secret`.
45
+* Run `rake db:create`, `rake db:migrate`, and then `rake db:seed` to create a development MySQL database with some example seed data.
46
+* Run `foreman start`, visit `http://localhost:5000`, and login with the username of `admin` and the password of `password`.
44 47
 * Make some extra Terminal windows and run `bundle exec rails runner bin/schedule.rb`, `bundle exec rails runner bin/twitter_stream.rb`, and `script/delayed_job run` in separate windows.
45 48
 * Setup some Agents!
46 49
 

+ 1 - 1
app/mailers/system_mailer.rb

@@ -1,5 +1,5 @@
1 1
 class SystemMailer < ActionMailer::Base
2
-  default from: "huginn@your-google-apps-domain.com"
2
+  default from: ENV['EMAIL_FROM_ADDRESS']
3 3
 
4 4
   def send_message(options)
5 5
     @lines = options[:lines]

+ 6 - 8
config/environments/development.rb

@@ -32,20 +32,18 @@ Huginn::Application.configure do
32 32
   # Expands the lines which load the assets
33 33
   config.assets.debug = true
34 34
 
35
-  DOMAIN = "localhost:3000"
36
-
37
-  config.action_mailer.default_url_options = { :host => DOMAIN }
38
-  config.action_mailer.asset_host = DOMAIN
35
+  config.action_mailer.default_url_options = { :host => ENV['DOMAIN'] }
36
+  config.action_mailer.asset_host = ENV['DOMAIN']
39 37
   config.action_mailer.perform_deliveries = false # Enable when testing!
40 38
   config.action_mailer.raise_delivery_errors = true
41 39
   config.action_mailer.delivery_method = :smtp
42 40
   config.action_mailer.smtp_settings = {
43 41
       address: "smtp.gmail.com",
44 42
       port: 587,
45
-      domain: "your-google-apps-domain.com",
43
+      domain: ENV['GOOGLE_APPS_DOMAIN'],
46 44
       authentication: "plain",
47 45
       enable_starttls_auto: true,
48
-      user_name: "huginn@your-google-apps-domain.com",
49
-      password: "your-password"
46
+      user_name: ENV['GMAIL_USERNAME'],
47
+      password: ENV['GMAIL_PASSWORD']
50 48
   }
51
-end
49
+end

+ 6 - 8
config/environments/production.rb

@@ -62,20 +62,18 @@ Huginn::Application.configure do
62 62
   # with SQLite, MySQL, and PostgreSQL)
63 63
   # config.active_record.auto_explain_threshold_in_seconds = 0.5
64 64
 
65
-  DOMAIN = 'www.yourdomain.com'
66
-
67
-  config.action_mailer.default_url_options = { :host => DOMAIN }
68
-  config.action_mailer.asset_host = DOMAIN
65
+  config.action_mailer.default_url_options = { :host => ENV['DOMAIN'] }
66
+  config.action_mailer.asset_host = ENV['DOMAIN']
69 67
   config.action_mailer.perform_deliveries = true
70 68
   config.action_mailer.raise_delivery_errors = true
71 69
   config.action_mailer.delivery_method = :smtp
72 70
   config.action_mailer.smtp_settings = {
73 71
       address: "smtp.gmail.com",
74 72
       port: 587,
75
-      domain: "your-google-apps-domain.com",
73
+      domain: ENV['GOOGLE_APPS_DOMAIN'],
76 74
       authentication: "plain",
77 75
       enable_starttls_auto: true,
78
-      user_name: "huginn@your-google-apps-domain.com",
79
-      password: "your-password"
76
+      user_name: ENV['GMAIL_USERNAME'],
77
+      password: ENV['GMAIL_PASSWORD']
80 78
   }
81
-end
79
+end

+ 2 - 4
config/environments/test.rb

@@ -37,8 +37,6 @@ Huginn::Application.configure do
37 37
   # Print deprecation notices to the stderr
38 38
   config.active_support.deprecation = :stderr
39 39
 
40
-  DOMAIN = 'test.host'
41
-
42
-  config.action_mailer.default_url_options = { :host => DOMAIN }
40
+  config.action_mailer.default_url_options = { :host => ENV['DOMAIN'] }
43 41
   config.action_mailer.perform_deliveries = true
44
-end
42
+end

+ 1 - 1
config/initializers/secret_token.rb

@@ -4,4 +4,4 @@
4 4
 # If you change this key, all old signed cookies will become invalid!
5 5
 # Make sure the secret is at least 30 characters and all random,
6 6
 # no regular words or you'll be exposed to dictionary attacks.
7
-Huginn::Application.config.secret_token = 'REPLACE_ME_NOW!'
7
+Huginn::Application.config.secret_token = ENV['APP_SECRET_TOKEN']