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,245 +9,19 @@ module Archangel
9
9
  # Backend pages controller
10
10
  #
11
11
  class PagesController < 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 pages
18
- #
19
- # Formats
20
- # HTML, JSON
21
- #
22
- # Request
23
- # GET /backend/pages
24
- # GET /backend/pages.json
25
- #
26
- # Response
27
- # [
28
- # {
29
- # "id": 123,
30
- # "site_id": 123,
31
- # "parent_id": nil,
32
- # "template_id": nil,
33
- # "title": "Page Title",
34
- # "slug": "my-page",
35
- # "path": "my-page",
36
- # "content": "</p>Content of the Page</p>",
37
- # "homepage": false,
38
- # "meta_keywords": "keywords,for,the,page",
39
- # "meta_description": "Description of the page",
40
- # "published_at": "YYYY-MM-DDTHH:MM:SS.MSZ",
41
- # "deleted_at": null,
42
- # "created_at": "YYYY-MM-DDTHH:MM:SS.MSZ",
43
- # "updated_at": "YYYY-MM-DDTHH:MM:SS.MSZ"
44
- # },
45
- # ...
46
- # ]
47
- #
48
- def index
49
- respond_with @pages
50
- end
51
-
52
- ##
53
- # Backend page
54
- #
55
- # Formats
56
- # HTML, JSON
57
- #
58
- # Params
59
- # [Integer] id - the page id
60
- #
61
- # Request
62
- # GET /backend/pages/:id
63
- # GET /backend/pages/:id.json
64
- #
65
- # Response
66
- # {
67
- # "id": 123,
68
- # "site_id": 123,
69
- # "parent_id": nil,
70
- # "template_id": nil,
71
- # "title": "Page Title",
72
- # "slug": "my-page",
73
- # "path": "my-page",
74
- # "content": "</p>Content of the Page</p>",
75
- # "homepage": false,
76
- # "meta_keywords": "keywords,for,the,page",
77
- # "meta_description": "Description of the page",
78
- # "published_at": "YYYY-MM-DDTHH:MM:SS.MSZ",
79
- # "deleted_at": null,
80
- # "created_at": "YYYY-MM-DDTHH:MM:SS.MSZ",
81
- # "updated_at": "YYYY-MM-DDTHH:MM:SS.MSZ"
82
- # }
83
- #
84
- def show
85
- respond_with @page
86
- end
87
-
88
- ##
89
- # New backend page
90
- #
91
- # Formats
92
- # HTML, JSON
93
- #
94
- # Request
95
- # GET /backend/pages/new
96
- # GET /backend/pages/new.json
97
- #
98
- # Response
99
- # {
100
- # "id": null,
101
- # "site_id": 123,
102
- # "parent_id": nil,
103
- # "template_id": nil,
104
- # "title": null,
105
- # "slug": null,
106
- # "path": null,
107
- # "content": null,
108
- # "homepage": false,
109
- # "meta_keywords": null,
110
- # "meta_description": null,
111
- # "published_at": null,
112
- # "deleted_at": null,
113
- # "created_at": null,
114
- # "updated_at": null
115
- # }
116
- #
117
- def new
118
- respond_with @page
119
- end
120
-
121
- ##
122
- # Create backend page
123
- #
124
- # Formats
125
- # HTML, JSON
126
- #
127
- # Request
128
- # POST /backend/pages
129
- # POST /backend/pages.json
130
- #
131
- # Paramaters
132
- # {
133
- # "page": {
134
- # "parent_id": nil,
135
- # "template_id": nil,
136
- # "title": "Page Title",
137
- # "slug": "my-page",
138
- # "content": "</p>Content of the Page</p>",
139
- # "homepage": false,
140
- # "meta_keywords": "keywords,for,the,page",
141
- # "meta_description": "Description of the page",
142
- # "published_at": "YYYY-MM-DDTHH:MM:SS.MSZ"
143
- # }
144
- # }
145
- #
146
- def create
147
- @page.save
148
-
149
- respond_with @page, location: -> { location_after_create }
150
- end
151
-
152
- ##
153
- # Edit backend page
154
- #
155
- # Formats
156
- # HTML, JSON
157
- #
158
- # Params
159
- # [Integer] id - the page id
160
- #
161
- # Request
162
- # GET /backend/pages/:id/edit
163
- # GET /backend/pages/:id/edit.json
164
- #
165
- # Response
166
- # {
167
- # "id": 123,
168
- # "site_id": 123,
169
- # "parent_id": nil,
170
- # "template_id": nil,
171
- # "title": "Page Title",
172
- # "slug": "my-page",
173
- # "path": "my-page",
174
- # "content": "</p>Content of the Page</p>",
175
- # "homepage": false,
176
- # "meta_keywords": "keywords,for,the,page",
177
- # "meta_description": "Description of the page",
178
- # "published_at": "YYYY-MM-DDTHH:MM:SS.MSZ",
179
- # "deleted_at": null,
180
- # "created_at": "YYYY-MM-DDTHH:MM:SS.MSZ",
181
- # "updated_at": "YYYY-MM-DDTHH:MM:SS.MSZ"
182
- # }
183
- #
184
- def edit
185
- respond_with @page
186
- end
187
-
188
- ##
189
- # Update backend page
190
- #
191
- # Formats
192
- # HTML, JSON
193
- #
194
- # Params
195
- # [Integer] id - the page id
196
- #
197
- # Request
198
- # PATCH /backend/pages/:id
199
- # PATCH /backend/pages/:id.json
200
- # PUT /backend/pages/:id
201
- # PUT /backend/pages/:id.json
202
- #
203
- # Paramaters
204
- # {
205
- # "page": {
206
- # "parent_id": nil,
207
- # "template_id": nil,
208
- # "title": "Page Title",
209
- # "slug": "my-page",
210
- # "content": "</p>Content of the Page</p>",
211
- # "homepage": false,
212
- # "meta_keywords": "keywords,for,the,page",
213
- # "meta_description": "Description of the page",
214
- # "published_at": "YYYY-MM-DDTHH:MM:SS.MSZ"
215
- # }
216
- # }
217
- #
218
- def update
219
- @page.update(resource_params)
220
-
221
- respond_with @page, location: -> { location_after_update }
222
- end
223
-
224
- ##
225
- # Destroy backend page
226
- #
227
- # Formats
228
- # HTML, JSON
229
- #
230
- # Params
231
- # [Integer] id - the page id
232
- #
233
- # Request
234
- # DELETE /backend/pages/:id
235
- # DELETE /backend/pages/:id.json
236
- #
237
- def destroy
238
- @page.destroy
239
-
240
- respond_with @page, location: -> { location_after_destroy }
241
- end
12
+ include Archangel::Controllers::Backend::ResourcefulConcern
242
13
 
243
14
  protected
244
15
 
245
16
  def permitted_attributes
246
- %w[content homepage meta_description meta_keywords parent_id path
247
- published_at slug template_id title]
17
+ [
18
+ :content, :homepage, :parent_id, :path, :published_at, :slug,
19
+ :template_id, :title,
20
+ metatags_attributes: %i[id _destroy name content]
21
+ ]
248
22
  end
249
23
 
250
- def set_resources
24
+ def resources_content
251
25
  @pages = current_site.pages
252
26
  .order(title: :asc)
253
27
  .page(page_num).per(per_page)
@@ -255,7 +29,7 @@ module Archangel
255
29
  authorize @pages
256
30
  end
257
31
 
258
- def set_resource
32
+ def resource_content
259
33
  resource_id = params.fetch(:id)
260
34
 
261
35
  @page = current_site.pages.find_by!(id: resource_id)
@@ -263,37 +37,13 @@ module Archangel
263
37
  authorize @page
264
38
  end
265
39
 
266
- def set_new_resource
267
- new_params = action_name.to_sym == :create ? resource_params : nil
40
+ def resource_new_content
41
+ @page = current_site.pages.new(resource_new_params)
268
42
 
269
- @page = current_site.pages.new(new_params)
43
+ @page.metatags.build unless @page.metatags.present?
270
44
 
271
45
  authorize @page
272
46
  end
273
-
274
- def resource_params
275
- params.require(resource_namespace).permit(permitted_attributes)
276
- end
277
-
278
- def resource_namespace
279
- controller_name.singularize.to_sym
280
- end
281
-
282
- def location_after_create
283
- location_after_save
284
- end
285
-
286
- def location_after_update
287
- location_after_save
288
- end
289
-
290
- def location_after_destroy
291
- location_after_save
292
- end
293
-
294
- def location_after_save
295
- backend_pages_path
296
- end
297
47
  end
298
48
  end
299
49
  end
@@ -11,8 +11,6 @@ module Archangel
11
11
  class ProfilesController < BackendController
12
12
  include Archangel::SkipAuthorizableConcern
13
13
 
14
- before_action :set_resource
15
-
16
14
  ##
17
15
  # Backend profile
18
16
  #
@@ -60,7 +58,9 @@ module Archangel
60
58
  # }
61
59
  #
62
60
  def show
63
- respond_with @profile
61
+ profile = resource_content
62
+
63
+ respond_with profile
64
64
  end
65
65
 
66
66
  ##
@@ -110,7 +110,9 @@ module Archangel
110
110
  # }
111
111
  #
112
112
  def edit
113
- respond_with @profile
113
+ profile = resource_content
114
+
115
+ respond_with profile
114
116
  end
115
117
 
116
118
  ##
@@ -136,16 +138,18 @@ module Archangel
136
138
  def update
137
139
  empty_password_params if resource_params.fetch(:password, nil).blank?
138
140
 
141
+ profile = resource_content
142
+
139
143
  successfully_updated =
140
- if needs_password?(@profile, resource_params)
141
- @profile.update(resource_params)
144
+ if needs_password?(profile, resource_params)
145
+ profile.update(resource_params)
142
146
  else
143
- @profile.update_without_password(resource_params)
147
+ profile.update_without_password(resource_params)
144
148
  end
145
149
 
146
150
  reauth_current_user if successfully_updated
147
151
 
148
- respond_with @profile, location: -> { location_after_update }
152
+ respond_with profile, location: -> { location_after_update }
149
153
  end
150
154
 
151
155
  ##
@@ -159,18 +163,21 @@ module Archangel
159
163
  # DELETE /backend/profile.json
160
164
  #
161
165
  def destroy
162
- @profile.destroy
166
+ profile = resource_content
167
+
168
+ profile.destroy
163
169
 
164
- respond_with @profile, location: -> { location_after_destroy }
170
+ respond_with profile, location: -> { location_after_destroy }
165
171
  end
166
172
 
167
173
  protected
168
174
 
169
175
  def permitted_attributes
170
- %w[avatar email name password remove_avatar username]
176
+ %w[avatar email name password remove_avatar username
177
+ newsletter]
171
178
  end
172
179
 
173
- def set_resource
180
+ def resource_content
174
181
  @profile = current_user
175
182
  end
176
183
 
@@ -9,8 +9,6 @@ module Archangel
9
9
  # Backend sites controller
10
10
  #
11
11
  class SitesController < BackendController
12
- before_action :set_resource
13
-
14
12
  ##
15
13
  # Backend site
16
14
  #
@@ -44,15 +42,15 @@ module Archangel
44
42
  # },
45
43
  # "content": "</p>Content of the Widget</p>",
46
44
  # "template_id": 123,
47
- # "meta_keywords": "keywords,for,the,site",
48
- # "meta_description": "Description of the site",
49
45
  # "deleted_at": null,
50
46
  # "created_at": "YYYY-MM-DDTHH:MM:SS.MSZ",
51
47
  # "updated_at": "YYYY-MM-DDTHH:MM:SS.MSZ"
52
48
  # }
53
49
  #
54
50
  def show
55
- respond_with @site
51
+ site = resource_content
52
+
53
+ respond_with site
56
54
  end
57
55
 
58
56
  ##
@@ -87,13 +85,13 @@ module Archangel
87
85
  # }
88
86
  # },
89
87
  # "content": "</p>Content of the Widget</p>",
90
- # "template_id": 123,
91
- # "meta_keywords": "keywords,for,the,site",
92
- # "meta_description": "Description of the site"
88
+ # "template_id": 123
93
89
  # }
94
90
  #
95
91
  def edit
96
- respond_with @site
92
+ site = resource_content
93
+
94
+ respond_with site
97
95
  end
98
96
 
99
97
  ##
@@ -130,25 +128,28 @@ module Archangel
130
128
  # }
131
129
  # },
132
130
  # "content": "</p>Content of the Widget</p>",
133
- # "template_id": 123,
134
- # "meta_keywords": "keywords,for,the,site",
135
- # "meta_description": "Description of the site"
131
+ # "template_id": 123
136
132
  # }
137
133
  # }
138
134
  #
139
135
  def update
140
- @site.update(resource_params)
136
+ site = resource_content
137
+
138
+ site.update(resource_params)
141
139
 
142
- respond_with @site, location: -> { location_after_update }
140
+ respond_with site, location: -> { location_after_update }
143
141
  end
144
142
 
145
143
  protected
146
144
 
147
145
  def permitted_attributes
148
- %w[locale logo meta_description meta_keywords name remove_logo theme]
146
+ [
147
+ :locale, :logo, :name, :remove_logo, :theme,
148
+ metatags_attributes: %i[id _destroy name content]
149
+ ]
149
150
  end
150
151
 
151
- def set_resource
152
+ def resource_content
152
153
  @site = current_site
153
154
 
154
155
  authorize @site