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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ada0c8ed4af07cb9635a364c3ac186aaeff079823aa2d63113b9386faa5dd74
4
- data.tar.gz: 59820ae9c8fed07aef979c3f44eec939645e611bb05ce104b53ff54c9f4904f2
3
+ metadata.gz: e1a64319173910746312e102a3101c834448b6b48ca2820c870ef07266bfc77f
4
+ data.tar.gz: f691facf12d5f3fd4b705bebb3af929e3a670d954a6629b0236d2d23e798638a
5
5
  SHA512:
6
- metadata.gz: f6169656cff9ed37878dc356ce5a47a61745e3829ed2d94fc646f5ede5017c84fa5587e28a7bffe1e3e0ed798ebfc3fb50b8b0a1b50a699fdc53c024fb80cc82
7
- data.tar.gz: 5c6be4b10f12046913e9723f42fbb96cd28ccf138b938fa30cc0152b0570a0dc8a9f99aef3b293281855fa9da1031782d3330ec517922b3731c5b780e712a9b9
6
+ metadata.gz: 9c94efb7d13766d7ccadaf9cb31021c844772c23bd2997dfc85cc79fcb84ab8943ce868f2cee1abdb45857211d8da877b39ffac446fd03838b2ac68b7d90d030
7
+ data.tar.gz: 5014fdc8c6b90b50d1f6b3780aae9de22e93b08ab74861b4302f14e723bd69c5bfb58fcfb78f5c40f1e6fb30c5e90d33b067ccd1a163f3b66730414613e6793e
data/.jshintrc CHANGED
@@ -3,12 +3,12 @@
3
3
  "$": true,
4
4
  "Archangel": true,
5
5
  "Event": true,
6
+ "Object": true,
6
7
  "Sortable": true,
7
8
  "XMLHttpRequest": true,
8
9
  "document": true,
9
10
  "jQuery": true,
10
11
  "localStorage": true,
11
- "Object": true,
12
12
  "window": true
13
13
  },
14
14
  "boss": true,
@@ -0,0 +1,42 @@
1
+ ---
2
+ exclude_paths:
3
+ - db/migrate
4
+ - spec/dummy
5
+
6
+ detectors:
7
+ BooleanParameter:
8
+ enabled: false
9
+ IrresponsibleModule:
10
+ enabled: false
11
+ UnusedPrivateMethod:
12
+ enabled: true
13
+ UtilityFunction:
14
+ public_methods_only: true
15
+
16
+ directories:
17
+ "app/controllers":
18
+ IrresponsibleModule:
19
+ enabled: false
20
+ NestedIterators:
21
+ max_allowed_nesting: 2
22
+ UnusedPrivateMethod:
23
+ enabled: false
24
+ InstanceVariableAssumption:
25
+ enabled: false
26
+ "app/helpers":
27
+ IrresponsibleModule:
28
+ enabled: false
29
+ UtilityFunction:
30
+ enabled: false
31
+ "app/inputs":
32
+ InstanceVariableAssumption:
33
+ enabled: false
34
+ "app/mailers":
35
+ InstanceVariableAssumption:
36
+ enabled: false
37
+ "app/policies":
38
+ InstanceVariableAssumption:
39
+ enabled: false
40
+ "app/uploaders":
41
+ UtilityFunction:
42
+ enabled: false
@@ -1,26 +1,15 @@
1
1
  inherit_from:
2
2
  - .rubocop_disabled.yml
3
3
  - .rubocop_enabled.yml
4
+ - .rubocop_exclude.yml
4
5
  - .rubocop_todo.yml
5
6
 
6
7
  AllCops:
7
- Include:
8
- - '**/Gemfile'
9
- - '**/Rakefile'
10
8
  Exclude:
11
9
  - 'bin/**/*'
12
10
  - 'db/migrate/**/*'
13
11
  - 'spec/dummy/**/*'
14
12
 
15
- Metrics/BlockLength:
16
- Exclude:
17
- - '**/*.gemspec'
18
- - '**/*.rake'
19
- - 'config/initializers/simple_form_bootstrap.rb'
20
- - 'config/routes.rb'
21
- - 'lib/archangel/testing_support/**/*.rb'
22
- - 'spec/**/*.rb'
23
-
24
13
  Style/StringLiterals:
25
14
  EnforcedStyle: double_quotes
26
15
 
@@ -0,0 +1,12 @@
1
+ Metrics/BlockLength:
2
+ Exclude:
3
+ - '**/*.gemspec'
4
+ - '**/*.rake'
5
+ - 'config/initializers/simple_form_bootstrap.rb'
6
+ - 'config/routes.rb'
7
+ - 'lib/archangel/testing_support/**/*.rb'
8
+ - 'spec/**/*.rb'
9
+
10
+ Metrics/ModuleLength:
11
+ Exclude:
12
+ - 'spec/**/*.rb'
@@ -1,7 +1,3 @@
1
1
  Metrics/ClassLength:
2
2
  Exclude:
3
3
  - 'lib/generators/archangel/install/install_generator.rb'
4
-
5
- Metrics/ModuleLength:
6
- Exclude:
7
- - 'spec/**/*.rb'
@@ -1,7 +1,6 @@
1
1
  sudo: false
2
2
  language: ruby
3
- cache:
4
- bundler: true
3
+ cache: bundler
5
4
  env:
6
5
  global:
7
6
  - CC_TEST_REPORTER_ID=10625f04e4c8c9fe7c22d49639163f1427fe16bc253aabcb316edbe43c41270b
@@ -19,8 +18,7 @@ script:
19
18
  after_script:
20
19
  - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
21
20
  rvm:
22
- - 2.2.10
23
- - 2.3.7
24
- - 2.4.4
25
- - 2.5.1
26
- - ruby-head
21
+ - 2.3.8
22
+ - 2.4.5
23
+ - 2.5.3
24
+ - 2.6.0
data/Gemfile CHANGED
@@ -5,32 +5,30 @@ source "https://rubygems.org"
5
5
  gemspec
6
6
 
7
7
  group :development do
8
- gem "brakeman", "~> 4.1", require: false
9
- gem "bundler-audit", "~> 0.6", require: false
8
+ gem "brakeman", "~> 4.3", require: false
10
9
  gem "inch", "~> 0.8", require: false
11
10
  gem "listen", "~> 3.1", require: false
12
- gem "mdl", "~> 0.4", require: false
13
- gem "reek", "~> 4.7", require: false
14
- gem "rubocop", "~> 0.52", require: false
15
- gem "scss_lint", "~> 0.56", require: false
11
+ gem "mdl", "~> 0.5", require: false
12
+ gem "reek", "~> 5.2", require: false
13
+ gem "rubocop", "~> 0.59", require: false
14
+ gem "scss_lint", "~> 0.57", require: false
16
15
  gem "yard", "~> 0.9", require: false
17
16
  end
18
17
 
19
18
  group :development, :test do
20
- gem "launchy", "~> 2.4"
21
- gem "pg", "~> 1.0"
22
- gem "pry-byebug", "~> 3.5"
19
+ gem "pg", "~> 1.1"
20
+ gem "pry-byebug", "~> 3.6"
23
21
  gem "sqlite3", ">= 1.3", platforms: %i[ruby mswin mswin64 mingw x64_mingw]
24
22
  end
25
23
 
26
24
  group :test do
27
- gem "capybara", "~> 3.0"
28
- gem "database_cleaner", "~> 1.6"
29
- gem "factory_bot_rails", "~> 4.8"
25
+ gem "capybara", "~> 3.8"
26
+ gem "database_cleaner", "~> 1.7"
27
+ gem "factory_bot_rails", "~> 4.11"
30
28
  gem "poltergeist", "~> 1.18"
31
29
  gem "rails-controller-testing", "~> 1.0"
32
- gem "rspec-rails", "~> 3.7"
30
+ gem "rspec-rails", "~> 3.8"
33
31
  gem "shoulda-callback-matchers", "~> 1.1"
34
32
  gem "shoulda-matchers", "~> 3.1"
35
- gem "simplecov", "~> 0.14"
33
+ gem "simplecov", "~> 0.16"
36
34
  end
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2018 Archangel
3
+ Copyright (c) 2019 Archangel
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -31,7 +31,7 @@ Deploy a sample application to [Heroku](https://www.heroku.com/) to play with.
31
31
  Add to your application's Gemfile
32
32
 
33
33
  ```
34
- gem "archangel", "< 1.0"
34
+ gem "archangel", "~> 0.3"
35
35
  ```
36
36
 
37
37
  Run the bundle command
@@ -54,8 +54,6 @@ module Archangel
54
54
  # },
55
55
  # "content": "</p>Content of the Widget</p>",
56
56
  # "template_id": 123,
57
- # "meta_keywords": "keywords,for,the,site",
58
- # "meta_description": "Description of the site",
59
57
  # "deleted_at": null,
60
58
  # "created_at": "YYYY-MM-DDTHH:MM:SS.MSZ",
61
59
  # "updated_at": "YYYY-MM-DDTHH:MM:SS.MSZ"
@@ -14,6 +14,18 @@ module Archangel
14
14
 
15
15
  protected
16
16
 
17
+ def after_sign_up_path_for(resource)
18
+ stored_location_for(resource) || root_path
19
+ end
20
+
21
+ def after_inactive_sign_up_path_for(resource)
22
+ after_sign_up_path_for(resource)
23
+ end
24
+
25
+ def sign_up_params
26
+ super.merge(site_id: current_site.id)
27
+ end
28
+
17
29
  def allow_registration
18
30
  return render_404_error unless Archangel.config.allow_registration
19
31
  end
@@ -9,232 +9,7 @@ module Archangel
9
9
  # Backend assets controller
10
10
  #
11
11
  class AssetsController < 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
- before_action :set_wysiwyg_resource, only: %i[wysiwyg]
16
-
17
- ##
18
- # Backend assets
19
- #
20
- # Formats
21
- # HTML, JSON
22
- #
23
- # Request
24
- # GET /backend/assets
25
- # GET /backend/assets.json
26
- #
27
- # Response
28
- # [
29
- # {
30
- # "id": 123,
31
- # "site_id": 123,
32
- # "file_name": "file_name.gif",
33
- # "file": {
34
- # "url": "/uploads/file.gif",
35
- # "small": {
36
- # "url": "/uploads/small_file.gif"
37
- # },
38
- # "tiny": {
39
- # "url": "/uploads/tiny_file.gif"
40
- # }
41
- # },
42
- # "content_type": "image/gif",
43
- # "file_size": 1234,
44
- # "deleted_at": null,
45
- # "created_at": "YYYY-MM-DDTHH:MM:SS.MSZ",
46
- # "updated_at": "YYYY-MM-DDTHH:MM:SS.MSZ"
47
- # },
48
- # ...
49
- # ]
50
- #
51
- def index
52
- respond_with @assets
53
- end
54
-
55
- ##
56
- # Backend asset
57
- #
58
- # Formats
59
- # HTML, JSON
60
- #
61
- # Params
62
- # [Integer] id - the asset id
63
- #
64
- # Request
65
- # GET /backend/assets/:id
66
- # GET /backend/assets/:id.json
67
- #
68
- # Response
69
- # {
70
- # "id": 123,
71
- # "site_id": 123,
72
- # "file_name": "file_name.gif",
73
- # "file": {
74
- # "url": "/uploads/file.gif",
75
- # "small": {
76
- # "url": "/uploads/small_file.gif"
77
- # },
78
- # "tiny": {
79
- # "url": "/uploads/tiny_file.gif"
80
- # }
81
- # },
82
- # "content_type": "image/gif",
83
- # "file_size": 1234,
84
- # "deleted_at": null,
85
- # "created_at": "YYYY-MM-DDTHH:MM:SS.MSZ",
86
- # "updated_at": "YYYY-MM-DDTHH:MM:SS.MSZ"
87
- # }
88
- #
89
- def show
90
- respond_with @asset
91
- end
92
-
93
- ##
94
- # New backend asset
95
- #
96
- # Formats
97
- # HTML, JSON
98
- #
99
- # Request
100
- # GET /backend/assets/new
101
- # GET /backend/assets/new.json
102
- #
103
- # Response
104
- # {
105
- # "id": null,
106
- # "site_id": null,
107
- # "file_name": null,
108
- # "file": {
109
- # "url": null,
110
- # "small": {
111
- # "url": null
112
- # },
113
- # "tiny": {
114
- # "url": null
115
- # }
116
- # },
117
- # "content_type": null,
118
- # "file_size": null,
119
- # "deleted_at": null,
120
- # "created_at": null,
121
- # "updated_at": null
122
- # }
123
- #
124
- def new
125
- respond_with @asset
126
- end
127
-
128
- ##
129
- # Create backend asset
130
- #
131
- # Formats
132
- # HTML, JSON
133
- #
134
- # Request
135
- # POST /backend/assets
136
- # POST /backend/assets.json
137
- #
138
- # Paramaters
139
- # {
140
- # "asset": {
141
- # "file_name": "file_name.gif",
142
- # "file": "local/path/to/new_file.gif"
143
- # }
144
- # }
145
- #
146
- def create
147
- @asset.save
148
-
149
- respond_with @asset, location: -> { location_after_create }
150
- end
151
-
152
- ##
153
- # Edit backend asset
154
- #
155
- # Formats
156
- # HTML, JSON
157
- #
158
- # Params
159
- # [Integer] id - the asset id
160
- #
161
- # Request
162
- # GET /backend/assets/:id/edit
163
- # GET /backend/assets/:id/edit.json
164
- #
165
- # Response
166
- # {
167
- # "id": 123,
168
- # "site_id": 123,
169
- # "file_name": "file_name.gif",
170
- # "file": {
171
- # "url": "/uploads/file.gif",
172
- # "small": {
173
- # "url": "/uploads/small_file.gif"
174
- # },
175
- # "tiny": {
176
- # "url": "/uploads/tiny_file.gif"
177
- # }
178
- # },
179
- # "content_type": "image/gif",
180
- # "file_size": 1234,
181
- # "deleted_at": null,
182
- # "created_at": "YYYY-MM-DDTHH:MM:SS.MSZ",
183
- # "updated_at": "YYYY-MM-DDTHH:MM:SS.MSZ"
184
- # }
185
- #
186
- def edit
187
- respond_with @asset
188
- end
189
-
190
- ##
191
- # Update backend asset
192
- #
193
- # Formats
194
- # HTML, JSON
195
- #
196
- # Params
197
- # [Integer] id - the asset id
198
- #
199
- # Request
200
- # PATCH /backend/assets/:id
201
- # PATCH /backend/assets/:id.json
202
- # PUT /backend/assets/:id
203
- # PUT /backend/assets/:id.json
204
- #
205
- # Paramaters
206
- # {
207
- # "asset": {
208
- # "file_name": "file_name.gif",
209
- # "file": "local/path/to/new_file.gif"
210
- # }
211
- # }
212
- # }
213
- #
214
- def update
215
- @asset.update(resource_params)
216
-
217
- respond_with @asset, location: -> { location_after_update }
218
- end
219
-
220
- ##
221
- # Destroy backend asset
222
- #
223
- # Formats
224
- # HTML, JSON
225
- #
226
- # Params
227
- # [Integer] id - the asset id
228
- #
229
- # Request
230
- # DELETE /backend/assets/:id
231
- # DELETE /backend/assetsidslug.json
232
- #
233
- def destroy
234
- @asset.destroy
235
-
236
- respond_with @asset, location: -> { location_after_destroy }
237
- end
12
+ include Archangel::Controllers::Backend::ResourcefulConcern
238
13
 
239
14
  ##
240
15
  # Create backend asset from WYSIWYG upload
@@ -258,11 +33,13 @@ module Archangel
258
33
  # }
259
34
  #
260
35
  def wysiwyg
261
- @asset.save
36
+ asset = resource_wysiwyg_content
37
+
38
+ asset.save
262
39
 
263
40
  asset_response = {
264
41
  success: true,
265
- url: @asset.file.url
42
+ url: asset.file.url
266
43
  }
267
44
 
268
45
  respond_to do |format|
@@ -276,7 +53,7 @@ module Archangel
276
53
  %w[file file_name]
277
54
  end
278
55
 
279
- def set_resources
56
+ def resources_content
280
57
  @assets = current_site.assets
281
58
  .order(file_name: :asc)
282
59
  .page(page_num).per(per_page)
@@ -284,7 +61,7 @@ module Archangel
284
61
  authorize @assets
285
62
  end
286
63
 
287
- def set_resource
64
+ def resource_content
288
65
  resource_id = params.fetch(:id)
289
66
 
290
67
  @asset = current_site.assets.find_by!(id: resource_id)
@@ -292,15 +69,13 @@ module Archangel
292
69
  authorize @asset
293
70
  end
294
71
 
295
- def set_new_resource
296
- new_params = action_name.to_sym == :create ? resource_params : nil
297
-
298
- @asset = current_site.assets.new(new_params)
72
+ def resource_new_content
73
+ @asset = current_site.assets.new(resource_new_params)
299
74
 
300
75
  authorize @asset
301
76
  end
302
77
 
303
- def set_wysiwyg_resource
78
+ def resource_wysiwyg_content
304
79
  wysiwyg_params = params.permit(permitted_attributes).reverse_merge(
305
80
  file_name: "#{SecureRandom.hex}.jpg"
306
81
  )
@@ -309,30 +84,6 @@ module Archangel
309
84
 
310
85
  authorize @asset
311
86
  end
312
-
313
- def resource_params
314
- params.require(resource_namespace).permit(permitted_attributes)
315
- end
316
-
317
- def resource_namespace
318
- controller_name.singularize.to_sym
319
- end
320
-
321
- def location_after_create
322
- location_after_save
323
- end
324
-
325
- def location_after_update
326
- location_after_save
327
- end
328
-
329
- def location_after_destroy
330
- location_after_save
331
- end
332
-
333
- def location_after_save
334
- backend_assets_path
335
- end
336
87
  end
337
88
  end
338
89
  end