Browse Source

Merge pull request #27 from robertjwhitney/config_to_env

Config to env
Andrew Cantino 12 years ago
parent
commit
a6aa81900e

+ 6 - 0
.env.example

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

+ 1 - 0
.gitignore

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

+ 2 - 0
Gemfile

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

+ 3 - 0
Gemfile.lock

@@ -94,6 +94,8 @@ GEM
     font-awesome-sass-rails (3.0.2.2)
       railties (>= 3.1.1)
       sass-rails (>= 3.1.1)
+    foreman (0.62.0)
+      thor (>= 0.13.6)
     geokit (1.6.5)
       multi_json
     geokit-rails3 (0.1.5)
@@ -277,6 +279,7 @@ DEPENDENCIES
   devise
   em-http-request
   fastercsv
+  foreman
   geokit-rails3
   jquery-rails
   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
 
 If you just want to play around, you can simply clone this repository, then perform the following steps:
 
-* Edit `config/initializers/secret_token.rb` and replace `REPLACE_ME_NOW!` with the output of `rake secret`.
-* 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`.
+* Copy .env.example to .env `cp .env.example .env`
+* Edit the configuration options in .env
+* Edit the APP_SECRET_TOKEN environment variable and replace `REPLACE_ME_NOW!` with the output of `rake secret`.
+* Run `rake db:create`, `rake db:migrate`, and then `rake db:seed` to create a development MySQL database with some example seed data.
+* Run `foreman start`, visit `http://localhost:5000`, and login with the username of `admin` and the password of `password`.
 * 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.
 * Setup some Agents!
 

+ 1 - 1
app/mailers/system_mailer.rb

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

+ 6 - 8
config/environments/development.rb

@@ -32,20 +32,18 @@ Huginn::Application.configure do
   # Expands the lines which load the assets
   config.assets.debug = true
 
-  DOMAIN = "localhost:3000"
-
-  config.action_mailer.default_url_options = { :host => DOMAIN }
-  config.action_mailer.asset_host = DOMAIN
+  config.action_mailer.default_url_options = { :host => ENV['DOMAIN'] }
+  config.action_mailer.asset_host = ENV['DOMAIN']
   config.action_mailer.perform_deliveries = false # Enable when testing!
   config.action_mailer.raise_delivery_errors = true
   config.action_mailer.delivery_method = :smtp
   config.action_mailer.smtp_settings = {
       address: "smtp.gmail.com",
       port: 587,
-      domain: "your-google-apps-domain.com",
+      domain: ENV['GOOGLE_APPS_DOMAIN'],
       authentication: "plain",
       enable_starttls_auto: true,
-      user_name: "huginn@your-google-apps-domain.com",
-      password: "your-password"
+      user_name: ENV['GMAIL_USERNAME'],
+      password: ENV['GMAIL_PASSWORD']
   }
-end
+end

+ 6 - 8
config/environments/production.rb

@@ -62,20 +62,18 @@ Huginn::Application.configure do
   # with SQLite, MySQL, and PostgreSQL)
   # config.active_record.auto_explain_threshold_in_seconds = 0.5
 
-  DOMAIN = 'www.yourdomain.com'
-
-  config.action_mailer.default_url_options = { :host => DOMAIN }
-  config.action_mailer.asset_host = DOMAIN
+  config.action_mailer.default_url_options = { :host => ENV['DOMAIN'] }
+  config.action_mailer.asset_host = ENV['DOMAIN']
   config.action_mailer.perform_deliveries = true
   config.action_mailer.raise_delivery_errors = true
   config.action_mailer.delivery_method = :smtp
   config.action_mailer.smtp_settings = {
       address: "smtp.gmail.com",
       port: 587,
-      domain: "your-google-apps-domain.com",
+      domain: ENV['GOOGLE_APPS_DOMAIN'],
       authentication: "plain",
       enable_starttls_auto: true,
-      user_name: "huginn@your-google-apps-domain.com",
-      password: "your-password"
+      user_name: ENV['GMAIL_USERNAME'],
+      password: ENV['GMAIL_PASSWORD']
   }
-end
+end

+ 2 - 4
config/environments/test.rb

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

+ 1 - 1
config/initializers/secret_token.rb

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