next_on_rails 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +591 -0
- data/Rakefile +32 -0
- data/app/controllers/next_on_rails/application_controller.rb +21 -0
- data/app/controllers/next_on_rails/devise_token_auth_override/concerns/current_resource_serializer.rb +15 -0
- data/app/controllers/next_on_rails/devise_token_auth_override/confirmations_controller.rb +4 -0
- data/app/controllers/next_on_rails/devise_token_auth_override/omniauth_callbacks_controller.rb +7 -0
- data/app/controllers/next_on_rails/devise_token_auth_override/passwords_controller.rb +23 -0
- data/app/controllers/next_on_rails/devise_token_auth_override/registrations_controller.rb +33 -0
- data/app/controllers/next_on_rails/devise_token_auth_override/sessions_controller.rb +27 -0
- data/app/controllers/next_on_rails/devise_token_auth_override/token_validations_controller.rb +13 -0
- data/app/controllers/next_on_rails/devise_token_auth_override/unlocks_controller.rb +23 -0
- data/app/controllers/next_on_rails/merger_controller.rb +36 -0
- data/app/serializers/next_on_rails/active_model_errors_serializer.rb +45 -0
- data/app/serializers/next_on_rails/errors_serializer.rb +16 -0
- data/config/routes.rb +12 -0
- data/lib/generators/nor/backend/backend_generator.rb +129 -0
- data/lib/generators/nor/backend/templates/Procfile +2 -0
- data/lib/generators/nor/backend/templates/application_controller.rb +2 -0
- data/lib/generators/nor/backend/templates/cors.rb +23 -0
- data/lib/generators/nor/backend/templates/current_user_serializer.rb.tt +8 -0
- data/lib/generators/nor/backend/templates/user.rb.tt +8 -0
- data/lib/generators/nor/backend/templates/user_migration.rb.tt +53 -0
- data/lib/generators/nor/backend/templates/user_serializer.rb.tt +11 -0
- data/lib/generators/nor/frontend/frontend_generator.rb +60 -0
- data/lib/generators/nor/frontend/templates/frontend/components/flash.js +29 -0
- data/lib/generators/nor/frontend/templates/frontend/components/inputs.js +69 -0
- data/lib/generators/nor/frontend/templates/frontend/components/login-form.js +23 -0
- data/lib/generators/nor/frontend/templates/frontend/components/registration-form.js +49 -0
- data/lib/generators/nor/frontend/templates/frontend/next-on-rails.config.js +3 -0
- data/lib/generators/nor/frontend/templates/frontend/next.config.js +20 -0
- data/lib/generators/nor/frontend/templates/frontend/pages/_app.js +3 -0
- data/lib/generators/nor/frontend/templates/frontend/pages/index.js +57 -0
- data/lib/generators/nor/frontend/templates/frontend/server.js +31 -0
- data/lib/generators/nor/frontend/templates/frontend/stylesheets/application.scss +2 -0
- data/lib/generators/nor/install/USAGE +30 -0
- data/lib/generators/nor/install/install_generator.rb +8 -0
- data/lib/generators/nor/scaffold/USAGE +10 -0
- data/lib/generators/nor/scaffold/scaffold_generator.rb +53 -0
- data/lib/generators/nor/scaffold/templates/controller.rb.tt +40 -0
- data/lib/generators/nor/scaffold/templates/frontend/components/details.js.tt +20 -0
- data/lib/generators/nor/scaffold/templates/frontend/components/form.js.tt +17 -0
- data/lib/generators/nor/scaffold/templates/frontend/pages/crud.js.tt +123 -0
- data/lib/generators/nor/scaffold/templates/frontend/pages/edit.js.tt +55 -0
- data/lib/generators/nor/scaffold/templates/frontend/pages/index.js.tt +88 -0
- data/lib/generators/nor/scaffold/templates/frontend/pages/new.js.tt +51 -0
- data/lib/generators/nor/scaffold/templates/frontend/pages/show.js.tt +43 -0
- data/lib/next_on_rails.rb +12 -0
- data/lib/next_on_rails/engine.rb +5 -0
- data/lib/next_on_rails/version.rb +3 -0
- data/lib/tasks/next_on_rails_tasks.rake +4 -0
- metadata +235 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
import { useState } from 'react'
|
2
|
+
import Link from 'next/link'
|
3
|
+
import Router from 'next/router'
|
4
|
+
import { useLoading, useFlash, getDetailFromResponseError } from 'next-on-rails/utils'
|
5
|
+
import { getInitialResource, useResources, useResourceForm } from 'next-on-rails/resources'
|
6
|
+
|
7
|
+
import <%= controller_class_name %>Form from '../../components/<%= plural_table_name %>/form'
|
8
|
+
|
9
|
+
const <%= controller_class_name %>New = props => {
|
10
|
+
const loading = useLoading()
|
11
|
+
const { setFlash } = useFlash()
|
12
|
+
|
13
|
+
const [, <%= singular_table_name.camelize(:lower) %>, { create }] = useResources('<%= plural_table_name.camelize(:lower) %>', props.<%= plural_table_name.camelize(:lower) %>, props.<%= singular_table_name.camelize(:lower) %>)
|
14
|
+
|
15
|
+
const [submit, getError] = useResourceForm(
|
16
|
+
create,
|
17
|
+
<%= singular_table_name.camelize(:lower) %> => {
|
18
|
+
Router.push(`/<%= plural_table_name %>/show?id=${<%= singular_table_name.camelize(:lower) %>.id}`, `/<%= plural_table_name %>/${<%= singular_table_name.camelize(:lower) %>.id}`).then(() =>
|
19
|
+
setFlash({ notice: '<%= class_name.titleize %> created successfully' })
|
20
|
+
)
|
21
|
+
},
|
22
|
+
error => {
|
23
|
+
setFlash({ alert: getDetailFromResponseError(error) })
|
24
|
+
}
|
25
|
+
)
|
26
|
+
|
27
|
+
return (
|
28
|
+
<div>
|
29
|
+
<div className="position-absolute">{loading ? 'Loading...' : null}</div>
|
30
|
+
<div className="container pt-4">
|
31
|
+
<h1 className="mb-5">Create New <%= class_name.titleize %></h1>
|
32
|
+
|
33
|
+
<<%= controller_class_name %>Form submit={submit} getError={getError} />
|
34
|
+
|
35
|
+
<hr />
|
36
|
+
|
37
|
+
<ul className="nav">
|
38
|
+
<li className="nav-item">
|
39
|
+
<Link href="/<%= plural_table_name %>">
|
40
|
+
<a className="nav-link">List <%= controller_class_name.titleize %></a>
|
41
|
+
</Link>
|
42
|
+
</li>
|
43
|
+
</ul>
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
)
|
47
|
+
}
|
48
|
+
|
49
|
+
<%= controller_class_name %>New.getInitialProps = getInitialResource('<%= singular_table_name.camelize(:lower) %>')
|
50
|
+
|
51
|
+
export default <%= controller_class_name %>New
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { useState } from 'react'
|
2
|
+
import Link from 'next/link'
|
3
|
+
import { useLoading } from 'next-on-rails/utils'
|
4
|
+
import { getInitialResource, useResources } from 'next-on-rails/resources'
|
5
|
+
|
6
|
+
import Flash from '../../components/flash'
|
7
|
+
import <%= controller_class_name %>Details from '../../components/<%= plural_table_name %>/details'
|
8
|
+
|
9
|
+
const <%= controller_class_name %>Show = props => {
|
10
|
+
const loading = useLoading()
|
11
|
+
const [, <%= singular_table_name.camelize(:lower) %>] = useResources('<%= plural_table_name.camelize(:lower) %>', props.<%= plural_table_name.camelize(:lower) %>, props.<%= singular_table_name.camelize(:lower) %>)
|
12
|
+
|
13
|
+
return (
|
14
|
+
<div>
|
15
|
+
<div className="position-absolute">{loading ? 'Loading...' : null}</div>
|
16
|
+
<div className="container pt-4">
|
17
|
+
<Flash />
|
18
|
+
<h1 className="mb-5"><%= class_name.titleize %> #{<%= singular_table_name.camelize(:lower) %>.id}</h1>
|
19
|
+
|
20
|
+
<<%= controller_class_name %>Details <%= singular_table_name.camelize(:lower) %>={<%= singular_table_name.camelize(:lower) %>} />
|
21
|
+
|
22
|
+
<hr />
|
23
|
+
|
24
|
+
<ul className="nav">
|
25
|
+
<li className="nav-item">
|
26
|
+
<Link href="/<%= plural_table_name %>">
|
27
|
+
<a className="nav-link">List <%= controller_class_name.titleize %></a>
|
28
|
+
</Link>
|
29
|
+
</li>
|
30
|
+
<li className="nav-item">
|
31
|
+
<Link href={`/<%= plural_table_name %>/edit?id=${<%= singular_table_name.camelize(:lower) %>.id}`} as={`/<%= plural_table_name %>/${<%= singular_table_name.camelize(:lower) %>.id}/edit`}>
|
32
|
+
<a className="nav-link">Edit</a>
|
33
|
+
</Link>
|
34
|
+
</li>
|
35
|
+
</ul>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
)
|
39
|
+
}
|
40
|
+
|
41
|
+
<%= controller_class_name %>Show.getInitialProps = getInitialResource('<%= singular_table_name.camelize(:lower) %>')
|
42
|
+
|
43
|
+
export default <%= controller_class_name %>Show
|
metadata
ADDED
@@ -0,0 +1,235 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: next_on_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- pioz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-08-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: devise_token_auth
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fast_jsonapi
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.5.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.5.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: omniauth
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.9.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.9.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: omniauth-facebook
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 5.0.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 5.0.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rack-cors
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.0.3
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.0.3
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rails
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 5.2.3
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 5.2.3
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: byebug
|
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'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: factory_bot_rails
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 5.0.2
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 5.0.2
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: faker
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: sqlite3
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description: Next On Rails is a Ruby gem and a NPM package that help developers connecting
|
154
|
+
Rails --api backend app to Next.js frontend app.
|
155
|
+
email:
|
156
|
+
- epilotto@gmx.com
|
157
|
+
executables: []
|
158
|
+
extensions: []
|
159
|
+
extra_rdoc_files: []
|
160
|
+
files:
|
161
|
+
- MIT-LICENSE
|
162
|
+
- README.md
|
163
|
+
- Rakefile
|
164
|
+
- app/controllers/next_on_rails/application_controller.rb
|
165
|
+
- app/controllers/next_on_rails/devise_token_auth_override/concerns/current_resource_serializer.rb
|
166
|
+
- app/controllers/next_on_rails/devise_token_auth_override/confirmations_controller.rb
|
167
|
+
- app/controllers/next_on_rails/devise_token_auth_override/omniauth_callbacks_controller.rb
|
168
|
+
- app/controllers/next_on_rails/devise_token_auth_override/passwords_controller.rb
|
169
|
+
- app/controllers/next_on_rails/devise_token_auth_override/registrations_controller.rb
|
170
|
+
- app/controllers/next_on_rails/devise_token_auth_override/sessions_controller.rb
|
171
|
+
- app/controllers/next_on_rails/devise_token_auth_override/token_validations_controller.rb
|
172
|
+
- app/controllers/next_on_rails/devise_token_auth_override/unlocks_controller.rb
|
173
|
+
- app/controllers/next_on_rails/merger_controller.rb
|
174
|
+
- app/serializers/next_on_rails/active_model_errors_serializer.rb
|
175
|
+
- app/serializers/next_on_rails/errors_serializer.rb
|
176
|
+
- config/routes.rb
|
177
|
+
- lib/generators/nor/backend/backend_generator.rb
|
178
|
+
- lib/generators/nor/backend/templates/Procfile
|
179
|
+
- lib/generators/nor/backend/templates/application_controller.rb
|
180
|
+
- lib/generators/nor/backend/templates/cors.rb
|
181
|
+
- lib/generators/nor/backend/templates/current_user_serializer.rb.tt
|
182
|
+
- lib/generators/nor/backend/templates/user.rb.tt
|
183
|
+
- lib/generators/nor/backend/templates/user_migration.rb.tt
|
184
|
+
- lib/generators/nor/backend/templates/user_serializer.rb.tt
|
185
|
+
- lib/generators/nor/frontend/frontend_generator.rb
|
186
|
+
- lib/generators/nor/frontend/templates/frontend/components/flash.js
|
187
|
+
- lib/generators/nor/frontend/templates/frontend/components/inputs.js
|
188
|
+
- lib/generators/nor/frontend/templates/frontend/components/login-form.js
|
189
|
+
- lib/generators/nor/frontend/templates/frontend/components/registration-form.js
|
190
|
+
- lib/generators/nor/frontend/templates/frontend/next-on-rails.config.js
|
191
|
+
- lib/generators/nor/frontend/templates/frontend/next.config.js
|
192
|
+
- lib/generators/nor/frontend/templates/frontend/pages/_app.js
|
193
|
+
- lib/generators/nor/frontend/templates/frontend/pages/index.js
|
194
|
+
- lib/generators/nor/frontend/templates/frontend/server.js
|
195
|
+
- lib/generators/nor/frontend/templates/frontend/stylesheets/application.scss
|
196
|
+
- lib/generators/nor/install/USAGE
|
197
|
+
- lib/generators/nor/install/install_generator.rb
|
198
|
+
- lib/generators/nor/scaffold/USAGE
|
199
|
+
- lib/generators/nor/scaffold/scaffold_generator.rb
|
200
|
+
- lib/generators/nor/scaffold/templates/controller.rb.tt
|
201
|
+
- lib/generators/nor/scaffold/templates/frontend/components/details.js.tt
|
202
|
+
- lib/generators/nor/scaffold/templates/frontend/components/form.js.tt
|
203
|
+
- lib/generators/nor/scaffold/templates/frontend/pages/crud.js.tt
|
204
|
+
- lib/generators/nor/scaffold/templates/frontend/pages/edit.js.tt
|
205
|
+
- lib/generators/nor/scaffold/templates/frontend/pages/index.js.tt
|
206
|
+
- lib/generators/nor/scaffold/templates/frontend/pages/new.js.tt
|
207
|
+
- lib/generators/nor/scaffold/templates/frontend/pages/show.js.tt
|
208
|
+
- lib/next_on_rails.rb
|
209
|
+
- lib/next_on_rails/engine.rb
|
210
|
+
- lib/next_on_rails/version.rb
|
211
|
+
- lib/tasks/next_on_rails_tasks.rake
|
212
|
+
homepage: https://github.com/Uqido/next-on-rails
|
213
|
+
licenses:
|
214
|
+
- MIT
|
215
|
+
metadata: {}
|
216
|
+
post_install_message:
|
217
|
+
rdoc_options: []
|
218
|
+
require_paths:
|
219
|
+
- lib
|
220
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
221
|
+
requirements:
|
222
|
+
- - ">="
|
223
|
+
- !ruby/object:Gem::Version
|
224
|
+
version: '0'
|
225
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
requirements: []
|
231
|
+
rubygems_version: 3.0.2
|
232
|
+
signing_key:
|
233
|
+
specification_version: 4
|
234
|
+
summary: Next On Rails connect Next.js to Rails
|
235
|
+
test_files: []
|