Browse Source

Misc. fixes:

- Comments in .rbenv-vars-sample
- Setting for serving static files in staging
- Gem babel-transpiler for jsx file
- Make mailgun work in production
- Make js compression work in production
- Fix db seeding
Maarten van den Berg 8 years ago
parent
commit
0085669d7f

+ 8 - 1
.rbenv-vars-sample

1
+# Parameters for sending mail
1
 MAILGUN_DOMAIN=
2
 MAILGUN_DOMAIN=
2
 MAILGUN_API_KEY=
3
 MAILGUN_API_KEY=
3
-
4
 MAIL_FROM_ADDRESS=
4
 MAIL_FROM_ADDRESS=
5
 
5
 
6
+# To be used in link construction
6
 AARDBEI_HOSTNAME=
7
 AARDBEI_HOSTNAME=
7
 
8
 
9
+SECRET_KEY_BASE=
10
+# ['production', 'development']
8
 RAILS_ENV=
11
 RAILS_ENV=
9
 
12
 
13
+# Set to '1' if in staging and/or not running a 'real' server or assets won't work
14
+RAILS_SERVE_STATIC_FILES=
15
+
16
+# Database credentials
10
 DB_NAME=
17
 DB_NAME=
11
 DB_USER=
18
 DB_USER=
12
 DB_PASS=
19
 DB_PASS=

+ 2 - 1
Gemfile

7
 gem 'puma', '~> 3.0'
7
 gem 'puma', '~> 3.0'
8
 # Use SCSS for stylesheets
8
 # Use SCSS for stylesheets
9
 gem 'sass-rails', '~> 5.0'
9
 gem 'sass-rails', '~> 5.0'
10
-# Use Uglifier as compressor for JavaScript assets
10
+# Use Uglifier as compressor for JavaScript assets, babel for ES6
11
+gem 'babel-transpiler'
11
 gem 'uglifier', '>= 1.3.0'
12
 gem 'uglifier', '>= 1.3.0'
12
 # Use CoffeeScript for .coffee assets and views
13
 # Use CoffeeScript for .coffee assets and views
13
 gem 'coffee-rails', '~> 4.2'
14
 gem 'coffee-rails', '~> 4.2'

+ 5 - 0
Gemfile.lock

41
     arel (7.1.4)
41
     arel (7.1.4)
42
     autoprefixer-rails (6.7.7.2)
42
     autoprefixer-rails (6.7.7.2)
43
       execjs
43
       execjs
44
+    babel-source (5.8.35)
45
+    babel-transpiler (0.7.0)
46
+      babel-source (>= 4.0, < 6)
47
+      execjs (~> 2.0)
44
     bcrypt (3.1.11)
48
     bcrypt (3.1.11)
45
     bindex (0.5.0)
49
     bindex (0.5.0)
46
     bootstrap-sass (3.3.7)
50
     bootstrap-sass (3.3.7)
188
 
192
 
189
 DEPENDENCIES
193
 DEPENDENCIES
190
   autoprefixer-rails
194
   autoprefixer-rails
195
+  babel-transpiler
191
   bcrypt (~> 3.1.7)
196
   bcrypt (~> 3.1.7)
192
   bootstrap-sass (~> 3.3.6)
197
   bootstrap-sass (~> 3.3.6)
193
   byebug
198
   byebug

+ 1 - 1
app/assets/javascripts/application.js

17
 //= require editable/bootstrap-editable
17
 //= require editable/bootstrap-editable
18
 //= require editable/rails
18
 //= require editable/rails
19
 //= require_tree .
19
 //= require_tree .
20
-
20
+//= require_self

app/assets/javascripts/buttonhandlers.js → app/assets/javascripts/buttonhandlers.jsx.js


+ 7 - 1
config/environments/production.rb

19
   config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
19
   config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
20
 
20
 
21
   # Compress JavaScripts and CSS.
21
   # Compress JavaScripts and CSS.
22
-  config.assets.js_compressor = :uglifier
22
+  config.assets.js_compressor = Uglifier.new({harmony: true})
23
   # config.assets.css_compressor = :sass
23
   # config.assets.css_compressor = :sass
24
 
24
 
25
   # Do not fallback to assets pipeline if a precompiled asset is missed.
25
   # Do not fallback to assets pipeline if a precompiled asset is missed.
83
 
83
 
84
   # Do not dump schema after migrations.
84
   # Do not dump schema after migrations.
85
   config.active_record.dump_schema_after_migration = false
85
   config.active_record.dump_schema_after_migration = false
86
+
87
+  config.action_mailer.delivery_method = :mailgun
88
+  config.action_mailer.mailgun_settings = {
89
+        api_key: ENV['MAILGUN_API_KEY'],
90
+        domain: ENV['MAILGUN_DOMAIN']
91
+  }
86
 end
92
 end

+ 10 - 9
db/seeds.rb

5
 #
5
 #
6
 #   movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
6
 #   movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
7
 #   Character.create(name: 'Luke', movie: movies.first)
7
 #   Character.create(name: 'Luke', movie: movies.first)
8
+require 'byebug'
8
 
9
 
9
 p = Person.create!(
10
 p = Person.create!(
10
   first_name: 'Maarten',
11
   first_name: 'Maarten',
11
   infix: 'van den',
12
   infix: 'van den',
12
   last_name: 'Berg',
13
   last_name: 'Berg',
13
   birth_date: (Faker::Date.between(21.years.ago, Date.today)),
14
   birth_date: (Faker::Date.between(21.years.ago, Date.today)),
14
-  email: 'maarten@maartenberg.nl.eu.org',
15
+  email: 'maarten@maartenberg.nl',
15
   is_admin: true
16
   is_admin: true
16
 )
17
 )
17
 
18
 
18
 u = User.create!(
19
 u = User.create!(
19
-  email: 'maarten@maartenberg.nl.eu.org',
20
+  email: 'maarten@maartenberg.nl',
20
   person: p,
21
   person: p,
21
   password: 'aardbei123',
22
   password: 'aardbei123',
22
   password_confirmation: 'aardbei123'
23
   password_confirmation: 'aardbei123'
26
   first_name: 'Henkie',
27
   first_name: 'Henkie',
27
   last_name: 'Gekke',
28
   last_name: 'Gekke',
28
   birth_date: (Faker::Date.between(21.years.ago, Date.today)),
29
   birth_date: (Faker::Date.between(21.years.ago, Date.today)),
29
-  email: 'gekkehenkie@maartenberg.nl.eu.org'
30
+  email: 'gekkehenkie@maartenberg.nl'
30
 )
31
 )
31
 
32
 
32
 g = Group.create!(
33
 g = Group.create!(
45
     first_name: (Faker::Name.first_name),
46
     first_name: (Faker::Name.first_name),
46
     last_name:  (Faker::Name.last_name),
47
     last_name:  (Faker::Name.last_name),
47
     birth_date: (Faker::Date.between(21.years.ago, Date.today)),
48
     birth_date: (Faker::Date.between(21.years.ago, Date.today)),
48
-    email: "testuser#{i}@maartenberg.nl.eu.org"
49
+    email: "testuser#{i}@maartenberg.nl"
49
   )
50
   )
50
 end
51
 end
51
 
52
 
72
     starttime = Faker::Time.between(DateTime.now, 1.years.since, :morning)
73
     starttime = Faker::Time.between(DateTime.now, 1.years.since, :morning)
73
     endtime   = Faker::Time.between(1.hours.since(starttime), 1.days.since(starttime), :afternoon)
74
     endtime   = Faker::Time.between(1.hours.since(starttime), 1.days.since(starttime), :afternoon)
74
     deadline  = 5.days.ago(starttime)
75
     deadline  = 5.days.ago(starttime)
75
-    puts starttime
76
-    puts endtime
77
-    puts deadline
78
 
76
 
79
     act = Activity.create!(
77
     act = Activity.create!(
80
       public_name: Faker::Hacker.ingverb,
78
       public_name: Faker::Hacker.ingverb,
105
           notes = nil
103
           notes = nil
106
         end
104
         end
107
 
105
 
108
-        part = Participant.create!(
106
+        # Participants are created on adding to group!
107
+        part = Participant.find_by(
109
           activity: a,
108
           activity: a,
110
-          person:   p,
109
+          person: p
110
+        )
111
+        part.update!(
111
           is_organizer: Faker::Boolean.boolean(0.1),
112
           is_organizer: Faker::Boolean.boolean(0.1),
112
           attending: [true, false, nil].sample,
113
           attending: [true, false, nil].sample,
113
           notes:    notes
114
           notes:    notes