archangel 0.0.8 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/.jshintrc +1 -1
  3. data/.reek.yml +42 -0
  4. data/.rubocop.yml +1 -12
  5. data/.rubocop_exclude.yml +12 -0
  6. data/.rubocop_todo.yml +0 -4
  7. data/.travis.yml +5 -7
  8. data/Gemfile +12 -14
  9. data/MIT-LICENSE +1 -1
  10. data/README.md +1 -1
  11. data/app/controllers/archangel/application_controller.rb +0 -2
  12. data/app/controllers/archangel/auth/registrations_controller.rb +12 -0
  13. data/app/controllers/archangel/backend/assets_controller.rb +10 -259
  14. data/app/controllers/archangel/backend/collections_controller.rb +5 -214
  15. data/app/controllers/archangel/backend/entries_controller.rb +25 -239
  16. data/app/controllers/archangel/backend/pages_controller.rb +11 -261
  17. data/app/controllers/archangel/backend/profiles_controller.rb +19 -12
  18. data/app/controllers/archangel/backend/sites_controller.rb +17 -16
  19. data/app/controllers/archangel/backend/templates_controller.rb +5 -232
  20. data/app/controllers/archangel/backend/users_controller.rb +10 -260
  21. data/app/controllers/archangel/backend/widgets_controller.rb +5 -226
  22. data/app/controllers/archangel/frontend/pages_controller.rb +6 -7
  23. data/app/controllers/concerns/archangel/actionable_concern.rb +9 -0
  24. data/app/controllers/concerns/archangel/controllers/backend/resourceful_concern.rb +28 -0
  25. data/app/controllers/concerns/archangel/controllers/resourceful_concern.rb +258 -0
  26. data/app/controllers/concerns/archangel/paginatable_concern.rb +2 -0
  27. data/app/controllers/concerns/archangel/seoable_concern.rb +9 -8
  28. data/app/models/archangel/metatag.rb +12 -0
  29. data/app/models/archangel/page.rb +7 -1
  30. data/app/models/archangel/site.rb +6 -1
  31. data/app/models/archangel/user.rb +7 -0
  32. data/app/views/archangel/backend/pages/_form.html.erb +12 -2
  33. data/app/views/archangel/backend/pages/_metatag_fields.html.erb +6 -0
  34. data/app/views/archangel/backend/pages/show.html.erb +0 -10
  35. data/app/views/archangel/backend/profiles/_form.html.erb +2 -0
  36. data/app/views/archangel/backend/sites/_form.html.erb +11 -2
  37. data/app/views/archangel/backend/sites/_metatag_fields.html.erb +6 -0
  38. data/app/views/archangel/backend/sites/show.html.erb +0 -10
  39. data/app/views/archangel/frontend/pages/show.json.jbuilder +1 -2
  40. data/archangel.gemspec +18 -11
  41. data/bin/archangel +6 -4
  42. data/config/locales/active_record.en.yml +3 -4
  43. data/config/locales/en.yml +6 -0
  44. data/db/migrate/20190101220919_add_preferences_to_archangel_users.rb +5 -0
  45. data/db/migrate/20190113130750_create_archangel_metatags.rb +14 -0
  46. data/db/migrate/20190113130751_remove_meta_keywords_and_meta_description_from_archangel_pages.rb +6 -0
  47. data/db/migrate/20190113130752_remove_meta_keywords_and_meta_description_from_archangel_sites.rb +6 -0
  48. data/docs/Developers.md +2 -2
  49. data/docs/Extension/Developers.md +1 -1
  50. data/docs/Extension/Uploaders.md +53 -1
  51. data/docs/Theme/Developers.md +8 -2
  52. data/lib/archangel.rb +2 -2
  53. data/lib/archangel/commands/base_command.rb +35 -0
  54. data/lib/archangel/commands/extension_command.rb +128 -0
  55. data/lib/archangel/{command/templates/extension → commands/templates/common}/.editorconfig +0 -0
  56. data/lib/archangel/{command/templates/extension → commands/templates/common}/.gitignore +0 -0
  57. data/lib/archangel/{command/templates/extension → commands/templates/common}/.rspec +0 -0
  58. data/lib/archangel/{command/templates/extension → commands/templates/common}/.rubocop.yml +0 -0
  59. data/lib/archangel/{command/templates/extension → commands/templates/common}/MIT-LICENSE +0 -0
  60. data/lib/archangel/{command/templates/extension → commands/templates/common}/spec/rails_helper.rb.tt +0 -3
  61. data/lib/archangel/{command/templates/extension → commands/templates/common}/spec/spec_helper.rb +0 -0
  62. data/lib/archangel/{command/templates/extension → commands/templates/common}/spec/support/.keep +0 -0
  63. data/lib/archangel/{command → commands}/templates/extension/Gemfile +9 -10
  64. data/lib/archangel/{command → commands}/templates/extension/README.md +0 -0
  65. data/lib/archangel/{command → commands}/templates/extension/Rakefile +0 -0
  66. data/lib/archangel/{command → commands}/templates/extension/app/assets/javascripts/archangel/auth/%extension_name%.js.tt +0 -0
  67. data/lib/archangel/{command → commands}/templates/extension/app/assets/javascripts/archangel/backend/%extension_name%.js.tt +0 -0
  68. data/lib/archangel/{command → commands}/templates/extension/app/assets/javascripts/archangel/frontend/%extension_name%.js.tt +0 -0
  69. data/lib/archangel/{command → commands}/templates/extension/app/assets/stylesheets/archangel/auth/%extension_name%.css.tt +0 -0
  70. data/lib/archangel/{command → commands}/templates/extension/app/assets/stylesheets/archangel/backend/%extension_name%.css.tt +0 -0
  71. data/lib/archangel/{command → commands}/templates/extension/app/assets/stylesheets/archangel/frontend/%extension_name%.css.tt +0 -0
  72. data/lib/archangel/{command → commands}/templates/extension/bin/rails.tt +0 -0
  73. data/lib/archangel/{command → commands}/templates/extension/config/locales/en.yml.tt +0 -0
  74. data/lib/archangel/{command → commands}/templates/extension/config/routes.rb +0 -0
  75. data/lib/archangel/{command/templates/extension/extension.gemspec → commands/templates/extension/extension.gemspec.tt} +0 -0
  76. data/lib/archangel/{command → commands}/templates/extension/lib/%extension_name%.rb.tt +0 -0
  77. data/lib/archangel/{command → commands}/templates/extension/lib/%extension_name%/engine.rb.tt +0 -0
  78. data/lib/archangel/{command → commands}/templates/extension/lib/%extension_name%/factories.rb.tt +0 -0
  79. data/lib/archangel/{command → commands}/templates/extension/lib/%extension_name%/version.rb.tt +0 -0
  80. data/lib/archangel/{command → commands}/templates/extension/lib/generators/%extension_name%/install/install_generator.rb.tt +0 -0
  81. data/lib/archangel/commands/templates/theme/Gemfile +27 -0
  82. data/lib/archangel/commands/templates/theme/README.md +44 -0
  83. data/lib/archangel/commands/templates/theme/Rakefile +29 -0
  84. data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/javascripts/%theme_base_name%/auth.js +2 -0
  85. data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/javascripts/%theme_base_name%/backend.js +2 -0
  86. data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/javascripts/%theme_base_name%/frontend.js +2 -0
  87. data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/stylesheets/%theme_base_name%/auth.css +4 -0
  88. data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/stylesheets/%theme_base_name%/backend.css +4 -0
  89. data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/stylesheets/%theme_base_name%/frontend.css +4 -0
  90. data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/config/locales/en.yml.tt +4 -0
  91. data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/views/layouts/frontend.liquid +18 -0
  92. data/lib/archangel/commands/templates/theme/bin/rails.tt +11 -0
  93. data/lib/archangel/commands/templates/theme/lib/%theme_name%.rb.tt +9 -0
  94. data/lib/archangel/commands/templates/theme/lib/%theme_name%/engine.rb.tt +29 -0
  95. data/lib/archangel/commands/templates/theme/lib/%theme_name%/version.rb.tt +5 -0
  96. data/lib/archangel/commands/templates/theme/theme.gemspec.tt +25 -0
  97. data/lib/archangel/commands/theme_command.rb +129 -0
  98. data/lib/archangel/config.rb +11 -2
  99. data/lib/archangel/liquid/drop.rb +26 -0
  100. data/lib/archangel/liquid/drops/page_drop.rb +1 -1
  101. data/lib/archangel/liquid/drops/site_drop.rb +1 -1
  102. data/lib/archangel/liquid/filters/link_to_filter.rb +1 -0
  103. data/lib/archangel/liquid/tags/application_tag.rb +18 -5
  104. data/lib/archangel/liquid/tags/collection_tag.rb +1 -1
  105. data/lib/archangel/liquid/tags/csrf_meta_tags_tag.rb +1 -0
  106. data/lib/archangel/liquid/tags/locale_tag.rb +1 -0
  107. data/lib/archangel/liquid/tags/meta_tags_tag.rb +1 -0
  108. data/lib/archangel/liquid/tags/noembed_tag.rb +140 -0
  109. data/lib/archangel/liquid/tags/text_direction_tag.rb +1 -0
  110. data/lib/archangel/liquid/tags/theme_javascript_tag.rb +1 -0
  111. data/lib/archangel/liquid/tags/theme_stylesheet_tag.rb +1 -0
  112. data/lib/archangel/testing_support/factories/archangel_assets.rb +2 -2
  113. data/lib/archangel/testing_support/factories/archangel_collections.rb +1 -1
  114. data/lib/archangel/testing_support/factories/archangel_entries.rb +1 -1
  115. data/lib/archangel/testing_support/factories/archangel_fields.rb +4 -4
  116. data/lib/archangel/testing_support/factories/archangel_metatags.rb +21 -0
  117. data/lib/archangel/testing_support/factories/archangel_pages.rb +5 -7
  118. data/lib/archangel/testing_support/factories/archangel_sites.rb +1 -3
  119. data/lib/archangel/testing_support/factories/archangel_templates.rb +7 -7
  120. data/lib/archangel/testing_support/factories/archangel_users.rb +10 -10
  121. data/lib/archangel/testing_support/factories/archangel_widgets.rb +2 -2
  122. data/lib/archangel/testing_support/matchers/have_meta.rb +18 -0
  123. data/lib/archangel/testing_support/matchers/have_title.rb +18 -0
  124. data/lib/archangel/testing_support/rake/dummy_rake.rb +0 -2
  125. data/lib/archangel/version.rb +1 -1
  126. data/lib/generators/archangel/install/templates/config/archangel.yml +52 -37
  127. data/spec/controllers/archangel/backend/entries_controller_spec.rb +3 -3
  128. data/spec/controllers/archangel/backend/pages_controller_spec.rb +17 -1
  129. data/spec/controllers/archangel/backend/profiles_controller_spec.rb +1 -1
  130. data/spec/controllers/archangel/backend/sites_controller_spec.rb +6 -6
  131. data/spec/controllers/archangel/backend/users_controller_spec.rb +2 -2
  132. data/spec/controllers/archangel/frontend/pages_controller_spec.rb +2 -6
  133. data/spec/controllers/concerns/archangel/controllers/backend/resourceful_concern_spec.rb +90 -0
  134. data/spec/features/auth/registration_spec.rb +18 -0
  135. data/spec/features/frontend/liquid_drop_variables_spec.rb +51 -57
  136. data/spec/features/frontend/pages/homepage_redirect_spec.rb +2 -2
  137. data/spec/features/frontend/pages/metatags_spec.rb +73 -0
  138. data/spec/helpers/archangel/flash_helper_spec.rb +14 -0
  139. data/spec/lib/archangel/{command/extension_spec.rb → commands/extension_command_spec.rb} +3 -3
  140. data/spec/lib/archangel/commands/theme_command_spec.rb +100 -0
  141. data/spec/lib/archangel/liquid/drops/page_drop_spec.rb +1 -9
  142. data/spec/lib/archangel/liquid/drops/site_drop_spec.rb +2 -12
  143. data/spec/lib/archangel/liquid/tags/noembed_tag_spec.rb +76 -0
  144. data/spec/mailers/archangel/{application_job_spec.rb → application_mailer_spec.rb} +0 -0
  145. data/spec/models/archangel/metatag_spec.rb +22 -0
  146. data/spec/models/archangel/page_spec.rb +5 -2
  147. data/spec/models/archangel/site_spec.rb +2 -0
  148. data/spec/rails_helper.rb +1 -0
  149. data/spec/uploaders/archangel/application_uploader_spec.rb +1 -1
  150. data/spec/uploaders/archangel/asset_uploader_spec.rb +1 -1
  151. metadata +108 -93
  152. data/.reek +0 -44
  153. data/lib/archangel/command/extension.rb +0 -97
@@ -9,208 +9,7 @@ module Archangel
9
9
  # Backend templates controller
10
10
  #
11
11
  class TemplatesController < BackendController
12
- before_action :set_resources, only: %i[index]
13
- before_action :set_resource, only: %i[destroy edit show update]
14
- before_action :set_new_resource, only: %i[create new]
15
-
16
- ##
17
- # Backend templates
18
- #
19
- # Formats
20
- # HTML, JSON
21
- #
22
- # Request
23
- # GET /backend/templates
24
- # GET /backend/templates.json
25
- #
26
- # Response
27
- # [
28
- # {
29
- # "id": 123,
30
- # "site_id": 123,
31
- # "parent_id": null,
32
- # "name": "Template Name",
33
- # "slug": "template_slug",
34
- # "content": "</p>Content of Template 1</p>",
35
- # "partial": false,
36
- # "deleted_at": null,
37
- # "created_at": "YYYY-MM-DDTHH:MM:SS.MSZ",
38
- # "updated_at": "YYYY-MM-DDTHH:MM:SS.MSZ"
39
- # },
40
- # ...
41
- # ]
42
- #
43
- def index
44
- respond_with @templates
45
- end
46
-
47
- ##
48
- # Backend template
49
- #
50
- # Formats
51
- # HTML, JSON
52
- #
53
- # Params
54
- # [Integer] id - the template id
55
- #
56
- # Request
57
- # GET /backend/templates/:id
58
- # GET /backend/templates/:id.json
59
- #
60
- # Response
61
- # {
62
- # "id": 123,
63
- # "site_id": 123,
64
- # "parent_id": null,
65
- # "name": "Template Name",
66
- # "slug": "template_slug",
67
- # "content": "</p>Content of Template</p>",
68
- # "partial": false,
69
- # "deleted_at": null,
70
- # "created_at": "YYYY-MM-DDTHH:MM:SS.MSZ",
71
- # "updated_at": "YYYY-MM-DDTHH:MM:SS.MSZ"
72
- # }
73
- #
74
- def show
75
- respond_with @template
76
- end
77
-
78
- ##
79
- # New backend template
80
- #
81
- # Formats
82
- # HTML, JSON
83
- #
84
- # Request
85
- # GET /backend/templates/new
86
- # GET /backend/templates/new.json
87
- #
88
- # Response
89
- # {
90
- # "id": null,
91
- # "site_id": 123,
92
- # "parent_id": null,
93
- # "name": null,
94
- # "slug": null,
95
- # "content": null,
96
- # "partial": false,
97
- # "deleted_at": null,
98
- # "created_at": null,
99
- # "updated_at": null
100
- # }
101
- #
102
- def new
103
- respond_with @template
104
- end
105
-
106
- ##
107
- # Create backend template
108
- #
109
- # Formats
110
- # HTML, JSON
111
- #
112
- # Request
113
- # POST /backend/templates
114
- # POST /backend/templates.json
115
- #
116
- # Paramaters
117
- # {
118
- # "template": {
119
- # "parent_id": null,
120
- # "name": "Template Name",
121
- # "slug": "template_slug",
122
- # "content": "</p>Content of Template</p>",
123
- # "partial": false
124
- # }
125
- # }
126
- #
127
- def create
128
- @template.save
129
-
130
- respond_with @template, location: -> { location_after_create }
131
- end
132
-
133
- ##
134
- # Edit backend template
135
- #
136
- # Formats
137
- # HTML, JSON
138
- #
139
- # Params
140
- # [Integer] id - the template id
141
- #
142
- # Request
143
- # GET /backend/templates/:id/edit
144
- # GET /backend/templates/:id/edit.json
145
- #
146
- # Response
147
- # {
148
- # "id": 123,
149
- # "site_id": 123,
150
- # "parent_id": null,
151
- # "name": "Template Name",
152
- # "slug": "template_slug",
153
- # "content": "</p>Content of Template</p>",
154
- # "partial": false,
155
- # "deleted_at": null,
156
- # "created_at": "YYYY-MM-DDTHH:MM:SS.MSZ",
157
- # "updated_at": "YYYY-MM-DDTHH:MM:SS.MSZ"
158
- # }
159
- #
160
- def edit
161
- respond_with @template
162
- end
163
-
164
- ##
165
- # Update backend template
166
- #
167
- # Formats
168
- # HTML, JSON
169
- #
170
- # Params
171
- # [Integer] id - the template id
172
- #
173
- # Request
174
- # PATCH /backend/templates/:id
175
- # PATCH /backend/templates/:id.json
176
- # PUT /backend/templates/:id
177
- # PUT /backend/templates/:id.json
178
- #
179
- # Paramaters
180
- # {
181
- # "template": {
182
- # "parent_id": null,
183
- # "name": "Template Name",
184
- # "slug": "template_slug",
185
- # "content": "</p>Content of Template</p>",
186
- # "partial": false
187
- # }
188
- # }
189
- #
190
- def update
191
- @template.update(resource_params)
192
-
193
- respond_with @template, location: -> { location_after_update }
194
- end
195
-
196
- ##
197
- # Destroy backend template
198
- #
199
- # Formats
200
- # HTML, JSON
201
- #
202
- # Params
203
- # [Integer] id - the template id
204
- #
205
- # Request
206
- # DELETE /backend/templates/:id
207
- # DELETE /backend/templates/:id.json
208
- #
209
- def destroy
210
- @template.destroy
211
-
212
- respond_with @template, location: -> { location_after_destroy }
213
- end
12
+ include Archangel::Controllers::Backend::ResourcefulConcern
214
13
 
215
14
  protected
216
15
 
@@ -218,7 +17,7 @@ module Archangel
218
17
  %w[content name parent_id partial]
219
18
  end
220
19
 
221
- def set_resources
20
+ def resources_content
222
21
  @templates = current_site.templates
223
22
  .order(name: :asc)
224
23
  .page(page_num).per(per_page)
@@ -226,7 +25,7 @@ module Archangel
226
25
  authorize @templates
227
26
  end
228
27
 
229
- def set_resource
28
+ def resource_content
230
29
  resource_id = params.fetch(:id)
231
30
 
232
31
  @template = current_site.templates.find_by!(id: resource_id)
@@ -234,37 +33,11 @@ module Archangel
234
33
  authorize @template
235
34
  end
236
35
 
237
- def set_new_resource
238
- new_params = action_name.to_sym == :create ? resource_params : nil
239
-
240
- @template = current_site.templates.new(new_params)
36
+ def resource_new_content
37
+ @template = current_site.templates.new(resource_new_params)
241
38
 
242
39
  authorize @template
243
40
  end
244
-
245
- def resource_params
246
- params.require(resource_namespace).permit(permitted_attributes)
247
- end
248
-
249
- def resource_namespace
250
- controller_name.singularize.to_sym
251
- end
252
-
253
- def location_after_create
254
- location_after_save
255
- end
256
-
257
- def location_after_update
258
- location_after_save
259
- end
260
-
261
- def location_after_destroy
262
- location_after_save
263
- end
264
-
265
- def location_after_save
266
- backend_templates_path
267
- end
268
41
  end
269
42
  end
270
43
  end
@@ -9,165 +9,7 @@ module Archangel
9
9
  # Backend users controller
10
10
  #
11
11
  class UsersController < BackendController
12
- before_action :set_resources, only: %i[index]
13
- before_action :set_resource, only: %i[destroy edit show update]
14
- before_action :set_new_resource, only: %i[create new]
15
-
16
- ##
17
- # Backend users
18
- #
19
- # Formats
20
- # HTML, JSON
21
- #
22
- # Request
23
- # GET /backend/users
24
- # GET /backend/users.json
25
- #
26
- # Response
27
- # [
28
- # {
29
- # "id": 123,
30
- # "site_id": 123,
31
- # "name": "First Last",
32
- # "username": "user_name",
33
- # "role": "editor",
34
- # "avatar": {
35
- # "url": "/uploads/file.png",
36
- # "large": {
37
- # "url": "/uploads/large_file.png"
38
- # },
39
- # "medium": {
40
- # "url": "/uploads/medium_file.png"
41
- # },
42
- # "small": {
43
- # "url": "/uploads/small_file.png"
44
- # },
45
- # "tiny": {
46
- # "url": "/uploads/tiny_file.png"
47
- # }
48
- # },
49
- # "email": "me@example.com",
50
- # "invitation_token": "abc123xyz",
51
- # "invitation_created_at": "YYYY-MM-DDTHH:MM:SS.MSZ",
52
- # "invitation_sent_at": null,
53
- # "invitation_accepted_at": null,
54
- # "invitation_limit": null,
55
- # "invited_by_type": "Archangel::User",
56
- # "invited_by_id": 2,
57
- # "invitations_count": 0,
58
- # "deleted_at": null,
59
- # "created_at": "YYYY-MM-DDTHH:MM:SS.MSZ",
60
- # "updated_at": "YYYY-MM-DDTHH:MM:SS.MSZ"
61
- # },
62
- # ...
63
- # ]
64
- #
65
- def index
66
- respond_with @users
67
- end
68
-
69
- ##
70
- # Backend user
71
- #
72
- # Formats
73
- # HTML, JSON
74
- #
75
- # Params
76
- # [String] username - the user username
77
- #
78
- # Request
79
- # GET /backend/users/:username
80
- # GET /backend/users/:username.json
81
- #
82
- # Response
83
- # {
84
- # "id": 123,
85
- # "site_id": 123,
86
- # "name": "First Last",
87
- # "username": "user_name",
88
- # "role": "editor",
89
- # "avatar": {
90
- # "url": "/uploads/file.png",
91
- # "large": {
92
- # "url": "/uploads/large_file.png"
93
- # },
94
- # "medium": {
95
- # "url": "/uploads/medium_file.png"
96
- # },
97
- # "small": {
98
- # "url": "/uploads/small_file.png"
99
- # },
100
- # "tiny": {
101
- # "url": "/uploads/tiny_file.png"
102
- # }
103
- # },
104
- # "email": "me@example.com",
105
- # "invitation_token": "abc123xyz",
106
- # "invitation_created_at": "YYYY-MM-DDTHH:MM:SS.MSZ",
107
- # "invitation_sent_at": null,
108
- # "invitation_accepted_at": null,
109
- # "invitation_limit": null,
110
- # "invited_by_type": "Archangel::User",
111
- # "invited_by_id": 2,
112
- # "invitations_count": 0,
113
- # "deleted_at": null,
114
- # "created_at": "YYYY-MM-DDTHH:MM:SS.MSZ",
115
- # "updated_at": "YYYY-MM-DDTHH:MM:SS.MSZ"
116
- # }
117
- #
118
- def show
119
- respond_with @user
120
- end
121
-
122
- ##
123
- # New backend user
124
- #
125
- # Formats
126
- # HTML, JSON
127
- #
128
- # Request
129
- # GET /backend/users/new
130
- # GET /backend/users/new.json
131
- #
132
- # Response
133
- # {
134
- # "id": null,
135
- # "site_id": 123,
136
- # "name": null,
137
- # "username": null,
138
- # "role": "editor",
139
- # "avatar": {
140
- # "url": null,
141
- # "large": {
142
- # "url": null
143
- # },
144
- # "medium": {
145
- # "url": null
146
- # },
147
- # "small": {
148
- # "url": null
149
- # },
150
- # "tiny": {
151
- # "url": null
152
- # }
153
- # },
154
- # "email": null,
155
- # "invitation_token": null,
156
- # "invitation_created_at": null,
157
- # "invitation_sent_at": null,
158
- # "invitation_accepted_at": null,
159
- # "invitation_limit": null,
160
- # "invited_by_type": null,
161
- # "invited_by_id": null,
162
- # "invitations_count": 0,
163
- # "deleted_at": null,
164
- # "created_at": null,
165
- # "updated_at": null,
166
- # }
167
- #
168
- def new
169
- respond_with @user
170
- end
12
+ include Archangel::Controllers::Backend::ResourcefulConcern
171
13
 
172
14
  ##
173
15
  # Invite backend user
@@ -191,62 +33,11 @@ module Archangel
191
33
  # }
192
34
  #
193
35
  def create
194
- @user.invite! @user
36
+ user = resource_new_content
195
37
 
196
- respond_with @user, location: -> { location_after_create }
197
- end
38
+ user.invite! user
198
39
 
199
- ##
200
- # Edit backend user
201
- #
202
- # Formats
203
- # HTML, JSON
204
- #
205
- # Params
206
- # [String] username - the user username
207
- #
208
- # Request
209
- # GET /backend/users/:username/edit
210
- # GET /backend/users/:username/edit.json
211
- #
212
- # Response
213
- # {
214
- # "id": 123,
215
- # "site_id": 123,
216
- # "name": "First Last",
217
- # "username": "user_name",
218
- # "role": "editor",
219
- # "avatar": {
220
- # "url": "/uploads/file.png",
221
- # "large": {
222
- # "url": "/uploads/large_file.png"
223
- # },
224
- # "medium": {
225
- # "url": "/uploads/medium_file.png"
226
- # },
227
- # "small": {
228
- # "url": "/uploads/small_file.png"
229
- # },
230
- # "tiny": {
231
- # "url": "/uploads/tiny_file.png"
232
- # }
233
- # },
234
- # "email": "me@example.com",
235
- # "invitation_token": "abc123xyz",
236
- # "invitation_created_at": "YYYY-MM-DDTHH:MM:SS.MSZ",
237
- # "invitation_sent_at": null,
238
- # "invitation_accepted_at": null,
239
- # "invitation_limit": null,
240
- # "invited_by_type": "Archangel::User",
241
- # "invited_by_id": 2,
242
- # "invitations_count": 0,
243
- # "deleted_at": null,
244
- # "created_at": "YYYY-MM-DDTHH:MM:SS.MSZ",
245
- # "updated_at": "YYYY-MM-DDTHH:MM:SS.MSZ"
246
- # }
247
- #
248
- def edit
249
- respond_with @user
40
+ respond_with user, location: -> { location_after_create }
250
41
  end
251
42
 
252
43
  ##
@@ -276,28 +67,11 @@ module Archangel
276
67
  # }
277
68
  #
278
69
  def update
279
- @user.update_without_password(resource_params)
70
+ user = resource_content
280
71
 
281
- respond_with @user, location: -> { location_after_update }
282
- end
72
+ user.update_without_password(resource_params)
283
73
 
284
- ##
285
- # Destroy backend user
286
- #
287
- # Formats
288
- # HTML, JSON
289
- #
290
- # Params
291
- # [String] username - the user username
292
- #
293
- # Request
294
- # DELETE /backend/users/:username
295
- # DELETE /backend/users/:username.json
296
- #
297
- def destroy
298
- @user.destroy
299
-
300
- respond_with @user, location: -> { location_after_destroy }
74
+ respond_with user, location: -> { location_after_update }
301
75
  end
302
76
 
303
77
  protected
@@ -306,7 +80,7 @@ module Archangel
306
80
  %w[email locale name remove_avatar role username]
307
81
  end
308
82
 
309
- def set_resources
83
+ def resources_content
310
84
  @users = current_site.users
311
85
  .where.not(id: current_user.id)
312
86
  .order(name: :asc)
@@ -315,7 +89,7 @@ module Archangel
315
89
  authorize @users
316
90
  end
317
91
 
318
- def set_resource
92
+ def resource_content
319
93
  resource_id = params.fetch(:id)
320
94
 
321
95
  @user = current_site.users
@@ -325,7 +99,7 @@ module Archangel
325
99
  authorize @user
326
100
  end
327
101
 
328
- def set_new_resource
102
+ def resource_new_content
329
103
  users = current_site.users
330
104
  @user = users.new
331
105
 
@@ -337,30 +111,6 @@ module Archangel
337
111
 
338
112
  authorize @user
339
113
  end
340
-
341
- def resource_params
342
- params.require(resource_namespace).permit(permitted_attributes)
343
- end
344
-
345
- def resource_namespace
346
- controller_name.singularize.to_sym
347
- end
348
-
349
- def location_after_create
350
- location_after_save
351
- end
352
-
353
- def location_after_update
354
- location_after_save
355
- end
356
-
357
- def location_after_destroy
358
- location_after_save
359
- end
360
-
361
- def location_after_save
362
- backend_users_path
363
- end
364
114
  end
365
115
  end
366
116
  end