thredded_create_app 0.1.14 → 0.1.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '0192d6123fe66987a3b0523882845a74a0379d69'
4
- data.tar.gz: e1316bc7fa77e70e737c32b7b3cfa185468e8816
3
+ metadata.gz: a0516299291ce7b4cfd720cadd5f34ad94893402
4
+ data.tar.gz: 5c4f3936a075560f5df3b1c6a2c754bacd9ef729
5
5
  SHA512:
6
- metadata.gz: e5f9e0f3e35da8d736e87fa27b0db927b1aa9744b22cdda52ffe086fcc82e894da22638d007fee06147d1fb66137394111fd9fe63cc955c19e9d8533975a8a64
7
- data.tar.gz: 8455840cf1f18b09036f4b160d54a43768e2ce262350acc6b6ff5a07d403d5a361fe09badc454a612aa5eac6b35045a04af8ff4631929d61a8157911bca2c143
6
+ metadata.gz: 7cebe5537c3c942aa0704b5e55351e922b3b19502b0f3486ce6a8762ed9ffe67156370b710dedac8fe2004f578e8dceb3b19a5b5307f1089dc9cdbf415043e3b
7
+ data.tar.gz: bc6209c773afd635ff952185dfa275b951ade1aa6711521a94707610e9702dd47854be51fef1f8f317373ba0aab4ebba60cae66d1729fb9a96b627c7254682b8
data/README.md CHANGED
@@ -189,20 +189,27 @@ The app is now deployed, but you'll also need to set up emailing.
189
189
 
190
190
  The easiest way to do this is via the Mailgun Heroku add-on.
191
191
 
192
- 1. Enable the Mailgun add-on:
192
+ 1. Set the `APP_HOST` environment variable on Heroku so that the app knows its
193
+ domain.
194
+
195
+ ```bash
196
+ heroku config:set APP_HOST='e.g. myapp.herokuapp.com'
197
+ ```
198
+
199
+ 2. Enable the Mailgun add-on:
193
200
 
194
201
  ```bash
195
202
  heroku addons:create mailgun:starter # Enable Mailgun with the free plan
196
203
  ```
197
204
 
198
- 2. Copy the following snippet into `config/environments/production.rb`:
205
+ 3. Copy the following snippet into `config/environments/production.rb`:
199
206
 
200
207
  ```ruby
201
208
  config.action_mailer.perform_deliveries = true
202
209
  config.action_mailer.raise_delivery_errors = true
203
210
  config.action_mailer.delivery_method = :smtp
204
211
  config.action_mailer.smtp_settings = {
205
- domain: '[SET ME] myapp.herokuapp.com',
212
+ domain: Settings.hostname,
206
213
  port: ENV['MAILGUN_SMTP_PORT'],
207
214
  address: ENV['MAILGUN_SMTP_SERVER'],
208
215
  user_name: ENV['MAILGUN_SMTP_LOGIN'],
@@ -213,7 +220,10 @@ The easiest way to do this is via the Mailgun Heroku add-on.
213
220
 
214
221
  Set the `domain` in the snippet above to your domain.
215
222
 
216
- 3. Commit and push to Heroku.
223
+ 4. Commit and push to Heroku.
224
+
225
+ By default, emails are send from `no-reply@`. You can configure this in
226
+ `config/settings.yml`.
217
227
 
218
228
  ### Performance
219
229
 
@@ -4,6 +4,7 @@ require 'fileutils'
4
4
  require 'shellwords'
5
5
  require 'thredded_create_app/tasks/base'
6
6
  require 'thredded_create_app/tasks/create_rails_app'
7
+ require 'thredded_create_app/tasks/add_rails_config'
7
8
  require 'thredded_create_app/tasks/add_simple_form'
8
9
  require 'thredded_create_app/tasks/add_devise'
9
10
  require 'thredded_create_app/tasks/add_roadie'
@@ -63,6 +64,7 @@ module ThreddedCreateApp
63
64
  def tasks
64
65
  @tasks ||= [
65
66
  Tasks::CreateRailsApp,
67
+ Tasks::AddRailsConfig,
66
68
  (Tasks::AddSimpleForm if @options[:simple_form]),
67
69
  Tasks::AddDevise,
68
70
  Tasks::AddRailsEmailPreview,
@@ -20,6 +20,7 @@ module ThreddedCreateApp
20
20
  run_generator 'devise:install'
21
21
  run_generator 'devise User'
22
22
  setup_views
23
+ setup_emails
23
24
  setup_after_sign_in_behaviour
24
25
  git_commit 'Setup Devise'
25
26
  end
@@ -65,6 +66,19 @@ module ThreddedCreateApp
65
66
  optional: true
66
67
  end
67
68
  end
69
+
70
+ def setup_emails
71
+ replace 'config/initializers/devise.rb',
72
+ /# config\.parent_mailer = .*/,
73
+ <<~'RUBY'.chomp
74
+ config.parent_mailer = 'ApplicationMailer'
75
+ RUBY
76
+ replace 'config/initializers/devise.rb',
77
+ /( *)config\.mailer_sender = .*/,
78
+ '\1' + <<~'RUBY'.chomp
79
+ config.mailer_sender = %("#{I18n.t('brand.name')}" <#{Settings.email_sender}>)
80
+ RUBY
81
+ end
68
82
  end
69
83
  end
70
84
  end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thredded_create_app/tasks/base'
4
+ module ThreddedCreateApp
5
+ module Tasks
6
+ class AddRailsConfig < Base
7
+ def summary
8
+ 'Add the config gem'
9
+ end
10
+
11
+ def before_bundle
12
+ add_gem 'config'
13
+ end
14
+
15
+ def after_bundle
16
+ run_generator 'config:install'
17
+ git_commit 'Add Rails Config configuration (rails g config:install)'
18
+ inject_into_file 'config/initializers/config.rb',
19
+ before: /\A/,
20
+ content: config_initializer_header
21
+ end
22
+
23
+ private
24
+
25
+ def config_initializer_header
26
+ <<~'RUBY'
27
+ # frozen_string_literal: true
28
+
29
+ # This file *must* be named "config.rb". It is loaded manually by the config
30
+ # gem before everything else, so you can use the Settings constant even in
31
+ # config/application.rb and config/environments/*.
32
+ RUBY
33
+ end
34
+ end
35
+ end
36
+ end
@@ -13,7 +13,7 @@ module ThreddedCreateApp
13
13
  add_gem 'plain-david' # for plain text email generation
14
14
  end
15
15
 
16
- def after_bundle
16
+ def after_bundle # rubocop:disable Metrics/AbcSize
17
17
  inject_into_file 'app/mailers/application_mailer.rb',
18
18
  after: "ActionMailer::Base\n",
19
19
  content: " include Roadie::Rails::Automatic\n"
@@ -56,7 +56,7 @@ module ThreddedCreateApp
56
56
  <<~'RUBY'
57
57
  # Set the default URL options for both Roadie and ActionMailer:
58
58
  config.roadie.url_options = config.action_mailer.default_url_options = {
59
- host: ENV['APP_HOST'] || '[SET ME] myapp.herokuapp.com',
59
+ host: Settings.hostname,
60
60
  protocol: 'https',
61
61
  }
62
62
  RUBY
@@ -26,8 +26,8 @@ module ThreddedCreateApp
26
26
  git_commit 'Configure Thredded (routes, assets, behaviour, tests)'
27
27
  add_admin_column_to_users
28
28
  git_commit 'Add the admin column to users'
29
- add_thredded_email_styles
30
- git_commit 'Configure Thredded email styles with Roadie'
29
+ setup_thredded_emails
30
+ git_commit 'Configure Thredded emails and email styles with Roadie'
31
31
  configure_rails_email_preview
32
32
  git_commit 'Configure RailsEmailPreview with Thredded and Roadie'
33
33
  run 'bundle exec rails thredded:install:emoji'
@@ -79,7 +79,7 @@ module ThreddedCreateApp
79
79
  Dir['db/migrate/*_add_admin_to_users.rb'][0]
80
80
  end
81
81
 
82
- def add_thredded_email_styles
82
+ def setup_thredded_emails
83
83
  File.write 'app/assets/stylesheets/email.scss', <<~'SCSS', mode: 'a'
84
84
  @import "variables";
85
85
  @import "thredded-variables";
@@ -87,8 +87,13 @@ module ThreddedCreateApp
87
87
  SCSS
88
88
 
89
89
  replace 'config/initializers/thredded.rb',
90
- "# Thredded.parent_mailer = 'ActionMailer::Base'",
90
+ /# Thredded\.parent_mailer = .*/,
91
91
  "Thredded.parent_mailer = 'ApplicationMailer'"
92
+ replace 'config/initializers/thredded.rb',
93
+ /# Thredded\.email_from = .*/,
94
+ <<~'RUBY'.chomp
95
+ Thredded.email_from = %("#{I18n.t('brand.name')}" <#{Settings.email_sender}>)
96
+ RUBY
92
97
 
93
98
  add_precompile_asset 'email.css'
94
99
 
@@ -11,13 +11,14 @@ module ThreddedCreateApp
11
11
  class Base
12
12
  include ThreddedCreateApp::Logging
13
13
 
14
- attr_reader :app_name, :app_path, :gems
14
+ attr_reader :app_name, :app_hostname, :app_path, :gems
15
15
 
16
16
  def initialize(app_path:, verbose: false, **_args)
17
17
  @app_path = app_path
18
18
  @app_name = File.basename(File.expand_path(app_path))
19
- @verbose = verbose
20
- @gems = []
19
+ @app_hostname = "#{@app_name.tr(' ', '_').downcase}.com"
20
+ @verbose = verbose
21
+ @gems = []
21
22
  end
22
23
 
23
24
  def summary
@@ -0,0 +1,3 @@
1
+ <%% hostname = ENV['APP_HOST'] || '<%= app_hostname %>' %>
2
+ hostname: <%%= hostname.inspect %>
3
+ email_sender: <%%= (ENV['SMTP_USER'] || "no-reply@#{hostname}").inspect %>
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Manually initialize i18n so that it can be used in the initializers
4
+ I18n::Railtie.initialize_i18n(Rails.application)
5
+ I18n.backend.send(:init_translations) unless I18n.backend.initialized?
@@ -24,16 +24,17 @@ module ThreddedCreateApp
24
24
  end
25
25
 
26
26
  def after_bundle
27
+ add_config_vars
28
+ add_i18n
29
+ add_seeds
27
30
  add_favicon_and_touch_icons
28
31
  add_javascripts
29
32
  add_styles
30
33
  add_user_page
31
34
  add_home_page
32
- add_i18n
33
35
  add_app_layout
34
36
  copy 'setup_app_skeleton/spec/features/homepage_spec.rb',
35
37
  'spec/features/homepage_spec.rb'
36
- add_seeds
37
38
  git_commit 'Set up basic app navigation and styles'
38
39
  end
39
40
 
@@ -94,9 +95,19 @@ module ThreddedCreateApp
94
95
  add_precompile_asset 'night.css'
95
96
  end
96
97
 
98
+ def add_config_vars
99
+ copy_template 'setup_app_skeleton/config/settings.yml.erb',
100
+ 'config/settings.yml'
101
+ replace 'app/mailers/application_mailer.rb',
102
+ /default from: .*/,
103
+ 'default from: Settings.email_sender'
104
+ end
105
+
97
106
  def add_i18n
98
- copy_template 'setup_app_skeleton/en.yml.erb',
107
+ copy_template 'setup_app_skeleton/config/locales/en.yml.erb',
99
108
  'config/locales/en.yml'
109
+ copy_template 'setup_app_skeleton/initializers/02_i18n.rb',
110
+ 'config/initializers/02_i18n.rb'
100
111
  inject_into_file'config/application.rb',
101
112
  before: / *end\nend\n\z/,
102
113
  content: indent(4, <<~'RUBY')
@@ -186,7 +197,7 @@ module ThreddedCreateApp
186
197
  end
187
198
 
188
199
  def admin_email
189
- "admin@#{app_name.tr(' ', '_').downcase}.com"
200
+ "admin@#{app_hostname}"
190
201
  end
191
202
 
192
203
  def admin_password
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ThreddedCreateApp
4
- VERSION = '0.1.14'
4
+ VERSION = '0.1.15'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thredded_create_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Mazovetskiy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-26 00:00:00.000000000 Z
11
+ date: 2017-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: term-ansicolor
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.44'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: Generates a Rails app with Thredded installed.
98
112
  email:
99
113
  - glex.spb@gmail.com
@@ -114,6 +128,7 @@ files:
114
128
  - lib/thredded_create_app/tasks/add_display_name_to_users.rb
115
129
  - lib/thredded_create_app/tasks/add_display_name_to_users/add_display_name_to_users.rb
116
130
  - lib/thredded_create_app/tasks/add_memcached_support.rb
131
+ - lib/thredded_create_app/tasks/add_rails_config.rb
117
132
  - lib/thredded_create_app/tasks/add_rails_email_preview.rb
118
133
  - lib/thredded_create_app/tasks/add_rails_email_preview/_rails_email_preview-custom.scss
119
134
  - lib/thredded_create_app/tasks/add_roadie.rb
@@ -140,9 +155,11 @@ files:
140
155
  - lib/thredded_create_app/tasks/setup_app_skeleton/_header.html.erb
141
156
  - lib/thredded_create_app/tasks/setup_app_skeleton/application.body.html.erb
142
157
  - lib/thredded_create_app/tasks/setup_app_skeleton/application_helper_methods.rb
143
- - lib/thredded_create_app/tasks/setup_app_skeleton/en.yml.erb
158
+ - lib/thredded_create_app/tasks/setup_app_skeleton/config/locales/en.yml.erb
159
+ - lib/thredded_create_app/tasks/setup_app_skeleton/config/settings.yml.erb
144
160
  - lib/thredded_create_app/tasks/setup_app_skeleton/home_show.html.erb.erb
145
161
  - lib/thredded_create_app/tasks/setup_app_skeleton/images/brightness.svg
162
+ - lib/thredded_create_app/tasks/setup_app_skeleton/initializers/02_i18n.rb
146
163
  - lib/thredded_create_app/tasks/setup_app_skeleton/javascripts/app.js
147
164
  - lib/thredded_create_app/tasks/setup_app_skeleton/javascripts/app/monkey-patch-turbolinks.js
148
165
  - lib/thredded_create_app/tasks/setup_app_skeleton/javascripts/app/theme.js