thredded_create_app 0.1.23 → 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/thredded_create_app/cli.rb +1 -1
- data/lib/thredded_create_app/generator.rb +22 -7
- data/lib/thredded_create_app/tasks/add_devise/sessions_controller.rb +17 -0
- data/lib/thredded_create_app/tasks/add_devise.rb +41 -10
- data/lib/thredded_create_app/tasks/add_thredded/thredded_initializer_controller.rb +6 -1
- data/lib/thredded_create_app/tasks/add_thredded.rb +2 -1
- data/lib/thredded_create_app/tasks/setup_app_skeleton/spec/controllers/users_controller_spec.rb +1 -1
- data/lib/thredded_create_app/tasks/setup_app_skeleton/users_show.html.erb +6 -0
- data/lib/thredded_create_app/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f18869fd3be69b970328dea05718efa3e89da02c61692b8b76fe8cb3f65ef9b4
|
|
4
|
+
data.tar.gz: 6a36d2746531f37b7e4f33fc99118cd6661b429e218a7cdd1218cc44461c43c6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 836abf0e71ec67aab2ab51b9859f3670bb1a8f51145e78743e8c15c734a5e53f0fc9c7abaef2872c36b716a370d1a580c4c2139146e0e5284818a38b918acb12
|
|
7
|
+
data.tar.gz: 1962f34cd78eef86a40cf7cc044808150675ba849068208ca08c8e106f4eeec0ca1a2015c1ba01ddf16d1a950235f743d64626aea12241559c9331896ab92874
|
|
@@ -84,24 +84,39 @@ module ThreddedCreateApp
|
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
# @final
|
|
87
|
-
def bundle
|
|
87
|
+
def bundle
|
|
88
88
|
gemfile_contents = File.read('Gemfile')
|
|
89
89
|
gems_to_add = gems.reject do |gem|
|
|
90
90
|
gemfile_contents =~ /^gem\s*['"]#{Regexp.escape(gem[0])}['"]/
|
|
91
91
|
end
|
|
92
|
+
log_info 'Writing gems to Gemfile'
|
|
93
|
+
add_gems_to_gemfile gems_to_add
|
|
94
|
+
log_info 'Installing gems'
|
|
95
|
+
install_gems
|
|
96
|
+
git_commit "Add gems: #{gems_to_add.map { |(name, *)| name } * ', '}"
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def add_gems_to_gemfile(gems)
|
|
92
100
|
File.open('Gemfile', 'a') do |f|
|
|
93
|
-
|
|
94
|
-
gems_to_add.each do |(name, version, groups, path)|
|
|
101
|
+
gems.each do |(name, version, groups, path)|
|
|
95
102
|
f.puts ["gem '#{name}'",
|
|
96
103
|
(version if version),
|
|
97
104
|
("groups: %i(#{groups * ' '})" if groups),
|
|
98
105
|
("path: '#{path}'" if path)].compact.join(', ')
|
|
99
106
|
end
|
|
100
107
|
end
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def install_gems
|
|
111
|
+
cache_path = ENV['THREDDED_CREATE_APP_BUNDLE_CACHE']
|
|
112
|
+
if cache_path
|
|
113
|
+
FileUtils.mkdir_p cache_path
|
|
114
|
+
run 'ln', '-s', cache_path, 'vendor/cache'
|
|
115
|
+
end
|
|
116
|
+
run 'bundle', 'install',
|
|
117
|
+
*('--quiet' unless verbose?),
|
|
118
|
+
*(%w[--path .bundle] unless File.writable?(Gem.dir))
|
|
119
|
+
run 'bundle', 'package', *('--quiet' unless verbose?) if cache_path
|
|
105
120
|
end
|
|
106
121
|
end
|
|
107
122
|
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Users
|
|
4
|
+
class SessionsController < ::Devise::SessionsController
|
|
5
|
+
attr_accessor :response_options
|
|
6
|
+
|
|
7
|
+
protected
|
|
8
|
+
|
|
9
|
+
def sign_in_params
|
|
10
|
+
super.reverse_merge(remember_me: true)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def serialize_options(resource)
|
|
14
|
+
super.merge!(response_options || {})
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -19,6 +19,8 @@ module ThreddedCreateApp
|
|
|
19
19
|
':password, :password_confirmation'
|
|
20
20
|
run_generator 'devise:install'
|
|
21
21
|
run_generator 'devise User'
|
|
22
|
+
fix_migration_indices_limit_on_mysql
|
|
23
|
+
setup_controllers
|
|
22
24
|
setup_views
|
|
23
25
|
setup_emails
|
|
24
26
|
setup_after_sign_in_behaviour
|
|
@@ -53,20 +55,49 @@ module ThreddedCreateApp
|
|
|
53
55
|
RUBY
|
|
54
56
|
end
|
|
55
57
|
|
|
58
|
+
def fix_migration_indices_limit_on_mysql
|
|
59
|
+
return unless database_adapter_name =~ /mysql|maria/i
|
|
60
|
+
migration_file = Dir['db/migrate/*_devise_create_users.rb'][0]
|
|
61
|
+
replace migration_file,
|
|
62
|
+
/add_index :users, :(?:email|\w+_token), +unique: true/,
|
|
63
|
+
'\0, length: 191',
|
|
64
|
+
global: true
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def setup_controllers
|
|
68
|
+
copy 'add_devise/sessions_controller.rb',
|
|
69
|
+
'app/controllers/users/sessions_controller.rb'
|
|
70
|
+
replace 'config/routes.rb',
|
|
71
|
+
'devise_for :users',
|
|
72
|
+
<<~'RUBY'.chomp
|
|
73
|
+
devise_for :users,
|
|
74
|
+
skip: %i[sessions],
|
|
75
|
+
controllers: {
|
|
76
|
+
sessions: 'users/sessions',
|
|
77
|
+
},
|
|
78
|
+
path_names: { sign_up: 'register' }
|
|
79
|
+
devise_scope :user do
|
|
80
|
+
get 'sign-in', to: 'users/sessions#new', as: :new_user_session
|
|
81
|
+
post 'sign-in', to: 'users/sessions#create', as: :user_session
|
|
82
|
+
match 'sign-out', to: 'users/sessions#destroy', as: :destroy_user_session,
|
|
83
|
+
via: Devise.mappings[:user].sign_out_via
|
|
84
|
+
end
|
|
85
|
+
RUBY
|
|
86
|
+
end
|
|
87
|
+
|
|
56
88
|
def setup_views
|
|
57
|
-
|
|
89
|
+
# Generate all devise views that have forms, so that they use the
|
|
90
|
+
# app form template (e.g. simple_form).
|
|
91
|
+
run_generator 'devise:i18n:views -v confirmations passwords' \
|
|
92
|
+
' registrations sessions unlocks'
|
|
58
93
|
# Replace the back link with the correct URL
|
|
59
94
|
replace 'app/views/devise/registrations/edit.html.erb',
|
|
60
95
|
', :back %>', ', back_url %>'
|
|
61
|
-
#
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
replace path, /resource(?!:)/, ':user', optional: true, global: true
|
|
67
|
-
replace path, 'devise_mapping', 'Devise.mappings[:user]',
|
|
68
|
-
optional: true, global: true
|
|
69
|
-
end
|
|
96
|
+
# Remove "Password confirmation" from sign up.
|
|
97
|
+
# See https://github.com/plataformatec/devise/wiki/Disable-password-confirmation-during-registration
|
|
98
|
+
replace 'app/views/devise/registrations/new.html.erb',
|
|
99
|
+
" <%= f.input :password_confirmation, required: true %>\n",
|
|
100
|
+
''
|
|
70
101
|
end
|
|
71
102
|
|
|
72
103
|
def setup_emails
|
|
@@ -4,7 +4,12 @@ Rails.application.config.to_prepare do
|
|
|
4
4
|
Thredded::ApplicationController.module_eval do
|
|
5
5
|
rescue_from Thredded::Errors::LoginRequired do |exception|
|
|
6
6
|
flash.now[:notice] = exception.message
|
|
7
|
-
|
|
7
|
+
controller = Users::SessionsController.new
|
|
8
|
+
controller.request = request
|
|
9
|
+
controller.request.env['devise.mapping'] = Devise.mappings[:user]
|
|
10
|
+
controller.response = response
|
|
11
|
+
controller.response_options = { status: :forbidden }
|
|
12
|
+
controller.process(:new)
|
|
8
13
|
end
|
|
9
14
|
end
|
|
10
15
|
end
|
data/lib/thredded_create_app/tasks/setup_app_skeleton/spec/controllers/users_controller_spec.rb
CHANGED
|
@@ -16,7 +16,7 @@ RSpec.describe UsersController, type: :controller do
|
|
|
16
16
|
it 'returns http success' do
|
|
17
17
|
user = User.create(valid_attributes)
|
|
18
18
|
get :show, params: { id: user.id }
|
|
19
|
-
expect(response).to
|
|
19
|
+
expect(response).to be_successful
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
end
|
|
@@ -20,6 +20,12 @@
|
|
|
20
20
|
<li><%= t 'thredded.users.posts_count', count: user_detail.posts_count %></li>
|
|
21
21
|
<% end %>
|
|
22
22
|
</ul>
|
|
23
|
+
<% if current_user && current_user != user %>
|
|
24
|
+
<a class="thredded--link"
|
|
25
|
+
href="<%= Thredded::UrlsHelper.send_private_message_path(current_user: current_user, to: user) %>">
|
|
26
|
+
<%= t 'thredded.users.send_private_message' %>
|
|
27
|
+
</a>
|
|
28
|
+
<% end %>
|
|
23
29
|
<% posts_page = Thredded.posts_page_view(
|
|
24
30
|
scope: user.thredded_posts.order_newest_first.limit(5),
|
|
25
31
|
current_user: current_user) %>
|
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.
|
|
4
|
+
version: 0.1.24
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gleb Mazovetskiy
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-07-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: highline
|
|
@@ -131,6 +131,7 @@ files:
|
|
|
131
131
|
- lib/thredded_create_app/generator.rb
|
|
132
132
|
- lib/thredded_create_app/logging.rb
|
|
133
133
|
- lib/thredded_create_app/tasks/add_devise.rb
|
|
134
|
+
- lib/thredded_create_app/tasks/add_devise/sessions_controller.rb
|
|
134
135
|
- lib/thredded_create_app/tasks/add_devise/spec/features/devise_spec.rb
|
|
135
136
|
- lib/thredded_create_app/tasks/add_display_name_to_users.rb
|
|
136
137
|
- lib/thredded_create_app/tasks/add_display_name_to_users/add_display_name_to_users.rb.erb
|
|
@@ -212,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
212
213
|
version: '0'
|
|
213
214
|
requirements: []
|
|
214
215
|
rubyforge_project:
|
|
215
|
-
rubygems_version: 2.7.
|
|
216
|
+
rubygems_version: 2.7.7
|
|
216
217
|
signing_key:
|
|
217
218
|
specification_version: 4
|
|
218
219
|
summary: Rails app generator for Thredded.
|