Commit 8b1c6cfd authored by Benjamin Meichsner's avatar Benjamin Meichsner Committed by Mario Manno

add dotenv, replaces settings.yml

parent d5f9a1b9
FRAB_HOST=localhost
FRAB_PROTOCOL=http
FROM_EMAIL=frab@localhost
FRAB_HOST=frab.test
FRAB_PROTOCOL=http
FROM_EMAIL=frab@frab.test
.bundle
.env.local
.env.production
.ruby-version
config/database.yml
config/settings.yml
db/*.sqlite3
log/*.log
tmp/*
......
......@@ -5,7 +5,6 @@ rvm:
bundler_args: --without mysql postgresql
before_install:
- cp config/database.yml.template config/database.yml
- cp config/settings.yml.template config/settings.yml
script:
- bundle exec rake db:setup
- bundle exec rake
......@@ -28,6 +28,7 @@ gem 'acts_as_commentable'
gem 'bcrypt-ruby'
gem 'cancancan'
gem 'cocoon'
gem "dotenv-rails"
gem 'haml'
gem 'localized_language_select', github: "frab/localized_language_select", branch: 'master'
gem 'nokogiri'
......@@ -39,7 +40,6 @@ gem 'ransack'
gem 'ri_cal'
gem 'simple_form'
gem 'sucker_punch'
gem 'settingslogic'
gem 'transitions', :require => ["transitions", "active_record/transitions"]
gem 'will_paginate'
......
......@@ -72,6 +72,10 @@ GEM
execjs
coffee-script-source (1.9.1.1)
columnize (0.9.0)
dotenv (2.0.2)
dotenv-rails (2.0.2)
dotenv (= 2.0.2)
railties (~> 4.0)
erubis (2.7.0)
execjs (2.5.2)
factory_girl (4.5.0)
......@@ -184,7 +188,6 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (~> 1.1)
settingslogic (2.0.9)
simple_form (3.1.0)
actionpack (~> 4.0)
activemodel (~> 4.0)
......@@ -224,6 +227,7 @@ DEPENDENCIES
cancancan
cocoon
coffee-rails (~> 4.1.0)
dotenv-rails
factory_girl_rails (~> 4.0)
github-markdown
haml
......@@ -247,7 +251,6 @@ DEPENDENCIES
redcarpet
ri_cal
sass-rails (~> 5.0)
settingslogic
simple_form
sqlite3
sucker_punch
......
......@@ -48,7 +48,7 @@ and follow these steps:
bundle install
Hint. To avoid installing database drivers you don't wanna use, exclude
Hint. To avoid installing database drivers you don't want to use, exclude
drivers with `bundle install --without="postgresql mysql"`.
4) Install nodejs:
......@@ -70,13 +70,11 @@ preferred package manager (apt-get, yum, brew etc.).
cp config/database.yml.template config/database.yml
frab bundles all three built-in rails database drivers.
And it should work with all three, although it is best tested
with MySQL and SQLite3 (for development).
7) Modify settings:
7) Create and modify settings:
cp config/settings.yml.template config/settings.yml
Settings are defined via environment variables. Frab uses dotenv files to
set these variables. The variables for development mode are set in `.env.development`.
You can also use .env.local for local overrides.
8) Create and setup the database
......@@ -86,26 +84,12 @@ with MySQL and SQLite3 (for development).
rake assets:precompile
10) Generate secret token and export it for production servers
export SECRET_KEY_BASE=`rake secret`
11) Start the server
10) Start the server
To start frab in the development environment simply run
rails server
To start frab in the production environment make sure you
did not skip step 8 and run:
rails server -e production
(Note that for a "real" production environment you
probably do not want to use this script, but rather something
like unicorn or passenger. Note that under Apache 2.x
mod_header is needed.)
Navigate to http://localhost:3000/ and login as
"admin@example.org" with password "test123".
......@@ -114,11 +98,18 @@ Navigate to http://localhost:3000/ and login as
If you are running frab in a production environment you have to
take additional steps to build a secure and stable site.
0. Change the password of the inital admin account
1. Change the initial secret token
2. Add a content disposition header, so attachments get downloaded and
* Change the password of the inital admin account
* Change the initial secret token
* Add a content disposition header, so attachments get downloaded and
are not displayed in the browser. See `./public/system/attachments/.htaccess` for an example.
3. Add a gem like `exception_notification` to get emails in case of errors.
* Add a gem like `exception_notification` to get emails in case of errors.
In Production make sure the config variables are set, copy and edit the file
`env.example` to `.env`.
To start frab in the production environment run
RACK_ENV=production bundle rails s
## Ticket Server
......
class SelectionNotification < ActionMailer::Base
default from: Settings['from_email']
default from: ENV.fetch('FROM_EMAIL')
def acceptance_notification(event_person)
@person = event_person.person
......
class UserMailer < ActionMailer::Base
default from: Settings['from_email']
default from: ENV.fetch('FROM_EMAIL')
def password_reset_instructions(user, conference)
@user = user
......
class Settings < Settingslogic
source "#{Rails.root}/config/settings.yml"
namespace Rails.env
load!
end
......@@ -96,7 +96,7 @@ class User < ActiveRecord::Base
end
def authenticate(password_entered)
if super(password_entered) or (Settings['devise_pepper'] and super(password_entered + Settings['devise_pepper']))
if super(password_entered) or (ENV["DEVISE_PEPPER"] and super(password_entered + ENV["DEVISE_PEPPER"]))
self
else
false
......
cal.event do |e|
e.dtstamp = @event.updated_at
e.organizer = @conference.acronym
e.uid = "#{@event.guid}@#{Settings.host}"
e.uid = "#{@event.guid}@#{ENV.fetch('FRAB_HOST')}"
e.dtstart = @event.start_time
e.dtend = @event.end_time
e.summary = @event.title
......
......@@ -2,7 +2,7 @@
next if event.start_time.nil?
cal.event do |e|
e.dtstamp = event.updated_at
e.uid = "#{event.guid}@#{Settings.host}"
e.uid = "#{event.guid}@#{ENV.fetch('FRAB_HOST')}"
e.organizer = @conference.acronym
e.dtstart = event.start_time
e.dtend = event.end_time
......
......@@ -16,9 +16,6 @@ Dir.chdir APP_ROOT do
unless File.exist?("config/database.yml")
system "cp config/database.yml.template config/database.yml"
end
unless File.exist?("config/settings.yml")
system "cp config/settings.yml.template config/settings.yml"
end
puts "\n== Preparing database =="
system "bin/rake db:setup"
......
ActionMailer::Base.default_url_options = { host: Settings.host, protocol: Settings.protocol }
if Settings['smtp_settings']
smtp_settings = Hash.new
Settings.smtp_settings.each {|k, v| smtp_settings[k.to_sym] = v }
ActionMailer::Base.default_url_options = {
host: ENV.fetch('FRAB_HOST'),
protocol: ENV.fetch('FRAB_PROTOCOL')
}
if ENV["SMTP_ADDRESS"]
smtp_settings = {}
%w(ADDRESS PORT DOMAIN USER_NAME PASSWORD).each do |setting|
next unless ENV["SMTP_#{setting}"]
smtp_settings[setting.downcase] = ENV["SMTP_#{setting}"]
end
ActionMailer::Base.smtp_settings = smtp_settings
end
development:
# Host configuration used to generate links in emails
host: localhost
port: 3000
protocol: http
# Default 'From' address, used when sending emails
from_email: frab@localhost
test:
host: frab.test
protocol: http
from_email: frab@frab.test
production:
# no need to specify port, when default (80) is used
host: frab.example.com
protocol: https
from_email: noreply@frab.example.com
# smtp server settings. see
# http://api.rubyonrails.org/classes/ActionMailer/Base.html
# for all available options
smtp_settings:
address: localhost
SECRET_KEY_BASE=asdkjf3245jsjfakjq435jadsgjlkq4j5jwj45jasdjvlj
FRAB_HOST=localhost
FRAB_PROTOCOL=http
FROM_EMAIL=frab@localhost
SMTP_ADDRESS=localhost
SMTP_PORT=587
SMTP_USER_NAME
SMTP_PASSWORD
......@@ -34,8 +34,8 @@ class StaticProgramExport
@original_schedule_public = @conference.schedule_public
@session = ActionDispatch::Integration::Session.new(Frab::Application)
@session.host = Settings.host
@session.https! if Settings['protocol'] == "https"
@session.host = ENV.fetch('FRAB_HOST')
@session.https! if ENV.fetch('FRAB_PROTOCOL') == "https"
ActiveRecord::Base.transaction do
unlock_schedule unless @original_schedule_public
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment