archangel 0.0.8 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.jshintrc +1 -1
- data/.reek.yml +42 -0
- data/.rubocop.yml +1 -12
- data/.rubocop_exclude.yml +12 -0
- data/.rubocop_todo.yml +0 -4
- data/.travis.yml +5 -7
- data/Gemfile +12 -14
- data/MIT-LICENSE +1 -1
- data/README.md +1 -1
- data/app/controllers/archangel/application_controller.rb +0 -2
- data/app/controllers/archangel/auth/registrations_controller.rb +12 -0
- data/app/controllers/archangel/backend/assets_controller.rb +10 -259
- data/app/controllers/archangel/backend/collections_controller.rb +5 -214
- data/app/controllers/archangel/backend/entries_controller.rb +25 -239
- data/app/controllers/archangel/backend/pages_controller.rb +11 -261
- data/app/controllers/archangel/backend/profiles_controller.rb +19 -12
- data/app/controllers/archangel/backend/sites_controller.rb +17 -16
- data/app/controllers/archangel/backend/templates_controller.rb +5 -232
- data/app/controllers/archangel/backend/users_controller.rb +10 -260
- data/app/controllers/archangel/backend/widgets_controller.rb +5 -226
- data/app/controllers/archangel/frontend/pages_controller.rb +6 -7
- data/app/controllers/concerns/archangel/actionable_concern.rb +9 -0
- data/app/controllers/concerns/archangel/controllers/backend/resourceful_concern.rb +28 -0
- data/app/controllers/concerns/archangel/controllers/resourceful_concern.rb +258 -0
- data/app/controllers/concerns/archangel/paginatable_concern.rb +2 -0
- data/app/controllers/concerns/archangel/seoable_concern.rb +9 -8
- data/app/models/archangel/metatag.rb +12 -0
- data/app/models/archangel/page.rb +7 -1
- data/app/models/archangel/site.rb +6 -1
- data/app/models/archangel/user.rb +7 -0
- data/app/views/archangel/backend/pages/_form.html.erb +12 -2
- data/app/views/archangel/backend/pages/_metatag_fields.html.erb +6 -0
- data/app/views/archangel/backend/pages/show.html.erb +0 -10
- data/app/views/archangel/backend/profiles/_form.html.erb +2 -0
- data/app/views/archangel/backend/sites/_form.html.erb +11 -2
- data/app/views/archangel/backend/sites/_metatag_fields.html.erb +6 -0
- data/app/views/archangel/backend/sites/show.html.erb +0 -10
- data/app/views/archangel/frontend/pages/show.json.jbuilder +1 -2
- data/archangel.gemspec +18 -11
- data/bin/archangel +6 -4
- data/config/locales/active_record.en.yml +3 -4
- data/config/locales/en.yml +6 -0
- data/db/migrate/20190101220919_add_preferences_to_archangel_users.rb +5 -0
- data/db/migrate/20190113130750_create_archangel_metatags.rb +14 -0
- data/db/migrate/20190113130751_remove_meta_keywords_and_meta_description_from_archangel_pages.rb +6 -0
- data/db/migrate/20190113130752_remove_meta_keywords_and_meta_description_from_archangel_sites.rb +6 -0
- data/docs/Developers.md +2 -2
- data/docs/Extension/Developers.md +1 -1
- data/docs/Extension/Uploaders.md +53 -1
- data/docs/Theme/Developers.md +8 -2
- data/lib/archangel.rb +2 -2
- data/lib/archangel/commands/base_command.rb +35 -0
- data/lib/archangel/commands/extension_command.rb +128 -0
- data/lib/archangel/{command/templates/extension → commands/templates/common}/.editorconfig +0 -0
- data/lib/archangel/{command/templates/extension → commands/templates/common}/.gitignore +0 -0
- data/lib/archangel/{command/templates/extension → commands/templates/common}/.rspec +0 -0
- data/lib/archangel/{command/templates/extension → commands/templates/common}/.rubocop.yml +0 -0
- data/lib/archangel/{command/templates/extension → commands/templates/common}/MIT-LICENSE +0 -0
- data/lib/archangel/{command/templates/extension → commands/templates/common}/spec/rails_helper.rb.tt +0 -3
- data/lib/archangel/{command/templates/extension → commands/templates/common}/spec/spec_helper.rb +0 -0
- data/lib/archangel/{command/templates/extension → commands/templates/common}/spec/support/.keep +0 -0
- data/lib/archangel/{command → commands}/templates/extension/Gemfile +9 -10
- data/lib/archangel/{command → commands}/templates/extension/README.md +0 -0
- data/lib/archangel/{command → commands}/templates/extension/Rakefile +0 -0
- data/lib/archangel/{command → commands}/templates/extension/app/assets/javascripts/archangel/auth/%extension_name%.js.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/app/assets/javascripts/archangel/backend/%extension_name%.js.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/app/assets/javascripts/archangel/frontend/%extension_name%.js.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/app/assets/stylesheets/archangel/auth/%extension_name%.css.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/app/assets/stylesheets/archangel/backend/%extension_name%.css.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/app/assets/stylesheets/archangel/frontend/%extension_name%.css.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/bin/rails.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/config/locales/en.yml.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/config/routes.rb +0 -0
- data/lib/archangel/{command/templates/extension/extension.gemspec → commands/templates/extension/extension.gemspec.tt} +0 -0
- data/lib/archangel/{command → commands}/templates/extension/lib/%extension_name%.rb.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/lib/%extension_name%/engine.rb.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/lib/%extension_name%/factories.rb.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/lib/%extension_name%/version.rb.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/lib/generators/%extension_name%/install/install_generator.rb.tt +0 -0
- data/lib/archangel/commands/templates/theme/Gemfile +27 -0
- data/lib/archangel/commands/templates/theme/README.md +44 -0
- data/lib/archangel/commands/templates/theme/Rakefile +29 -0
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/javascripts/%theme_base_name%/auth.js +2 -0
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/javascripts/%theme_base_name%/backend.js +2 -0
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/javascripts/%theme_base_name%/frontend.js +2 -0
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/stylesheets/%theme_base_name%/auth.css +4 -0
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/stylesheets/%theme_base_name%/backend.css +4 -0
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/stylesheets/%theme_base_name%/frontend.css +4 -0
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/config/locales/en.yml.tt +4 -0
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/views/layouts/frontend.liquid +18 -0
- data/lib/archangel/commands/templates/theme/bin/rails.tt +11 -0
- data/lib/archangel/commands/templates/theme/lib/%theme_name%.rb.tt +9 -0
- data/lib/archangel/commands/templates/theme/lib/%theme_name%/engine.rb.tt +29 -0
- data/lib/archangel/commands/templates/theme/lib/%theme_name%/version.rb.tt +5 -0
- data/lib/archangel/commands/templates/theme/theme.gemspec.tt +25 -0
- data/lib/archangel/commands/theme_command.rb +129 -0
- data/lib/archangel/config.rb +11 -2
- data/lib/archangel/liquid/drop.rb +26 -0
- data/lib/archangel/liquid/drops/page_drop.rb +1 -1
- data/lib/archangel/liquid/drops/site_drop.rb +1 -1
- data/lib/archangel/liquid/filters/link_to_filter.rb +1 -0
- data/lib/archangel/liquid/tags/application_tag.rb +18 -5
- data/lib/archangel/liquid/tags/collection_tag.rb +1 -1
- data/lib/archangel/liquid/tags/csrf_meta_tags_tag.rb +1 -0
- data/lib/archangel/liquid/tags/locale_tag.rb +1 -0
- data/lib/archangel/liquid/tags/meta_tags_tag.rb +1 -0
- data/lib/archangel/liquid/tags/noembed_tag.rb +140 -0
- data/lib/archangel/liquid/tags/text_direction_tag.rb +1 -0
- data/lib/archangel/liquid/tags/theme_javascript_tag.rb +1 -0
- data/lib/archangel/liquid/tags/theme_stylesheet_tag.rb +1 -0
- data/lib/archangel/testing_support/factories/archangel_assets.rb +2 -2
- data/lib/archangel/testing_support/factories/archangel_collections.rb +1 -1
- data/lib/archangel/testing_support/factories/archangel_entries.rb +1 -1
- data/lib/archangel/testing_support/factories/archangel_fields.rb +4 -4
- data/lib/archangel/testing_support/factories/archangel_metatags.rb +21 -0
- data/lib/archangel/testing_support/factories/archangel_pages.rb +5 -7
- data/lib/archangel/testing_support/factories/archangel_sites.rb +1 -3
- data/lib/archangel/testing_support/factories/archangel_templates.rb +7 -7
- data/lib/archangel/testing_support/factories/archangel_users.rb +10 -10
- data/lib/archangel/testing_support/factories/archangel_widgets.rb +2 -2
- data/lib/archangel/testing_support/matchers/have_meta.rb +18 -0
- data/lib/archangel/testing_support/matchers/have_title.rb +18 -0
- data/lib/archangel/testing_support/rake/dummy_rake.rb +0 -2
- data/lib/archangel/version.rb +1 -1
- data/lib/generators/archangel/install/templates/config/archangel.yml +52 -37
- data/spec/controllers/archangel/backend/entries_controller_spec.rb +3 -3
- data/spec/controllers/archangel/backend/pages_controller_spec.rb +17 -1
- data/spec/controllers/archangel/backend/profiles_controller_spec.rb +1 -1
- data/spec/controllers/archangel/backend/sites_controller_spec.rb +6 -6
- data/spec/controllers/archangel/backend/users_controller_spec.rb +2 -2
- data/spec/controllers/archangel/frontend/pages_controller_spec.rb +2 -6
- data/spec/controllers/concerns/archangel/controllers/backend/resourceful_concern_spec.rb +90 -0
- data/spec/features/auth/registration_spec.rb +18 -0
- data/spec/features/frontend/liquid_drop_variables_spec.rb +51 -57
- data/spec/features/frontend/pages/homepage_redirect_spec.rb +2 -2
- data/spec/features/frontend/pages/metatags_spec.rb +73 -0
- data/spec/helpers/archangel/flash_helper_spec.rb +14 -0
- data/spec/lib/archangel/{command/extension_spec.rb → commands/extension_command_spec.rb} +3 -3
- data/spec/lib/archangel/commands/theme_command_spec.rb +100 -0
- data/spec/lib/archangel/liquid/drops/page_drop_spec.rb +1 -9
- data/spec/lib/archangel/liquid/drops/site_drop_spec.rb +2 -12
- data/spec/lib/archangel/liquid/tags/noembed_tag_spec.rb +76 -0
- data/spec/mailers/archangel/{application_job_spec.rb → application_mailer_spec.rb} +0 -0
- data/spec/models/archangel/metatag_spec.rb +22 -0
- data/spec/models/archangel/page_spec.rb +5 -2
- data/spec/models/archangel/site_spec.rb +2 -0
- data/spec/rails_helper.rb +1 -0
- data/spec/uploaders/archangel/application_uploader_spec.rb +1 -1
- data/spec/uploaders/archangel/asset_uploader_spec.rb +1 -1
- metadata +108 -93
- data/.reek +0 -44
- data/lib/archangel/command/extension.rb +0 -97
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1a64319173910746312e102a3101c834448b6b48ca2820c870ef07266bfc77f
|
4
|
+
data.tar.gz: f691facf12d5f3fd4b705bebb3af929e3a670d954a6629b0236d2d23e798638a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c94efb7d13766d7ccadaf9cb31021c844772c23bd2997dfc85cc79fcb84ab8943ce868f2cee1abdb45857211d8da877b39ffac446fd03838b2ac68b7d90d030
|
7
|
+
data.tar.gz: 5014fdc8c6b90b50d1f6b3780aae9de22e93b08ab74861b4302f14e723bd69c5bfb58fcfb78f5c40f1e6fb30c5e90d33b067ccd1a163f3b66730414613e6793e
|
data/.jshintrc
CHANGED
data/.reek.yml
ADDED
@@ -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
|
data/.rubocop.yml
CHANGED
@@ -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'
|
data/.rubocop_todo.yml
CHANGED
data/.travis.yml
CHANGED
@@ -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.
|
23
|
-
- 2.
|
24
|
-
- 2.
|
25
|
-
- 2.
|
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.
|
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.
|
13
|
-
gem "reek", "~>
|
14
|
-
gem "rubocop", "~> 0.
|
15
|
-
gem "scss_lint", "~> 0.
|
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 "
|
21
|
-
gem "
|
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.
|
28
|
-
gem "database_cleaner", "~> 1.
|
29
|
-
gem "factory_bot_rails", "~> 4.
|
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.
|
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.
|
33
|
+
gem "simplecov", "~> 0.16"
|
36
34
|
end
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -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
|
-
|
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
|
-
|
36
|
+
asset = resource_wysiwyg_content
|
37
|
+
|
38
|
+
asset.save
|
262
39
|
|
263
40
|
asset_response = {
|
264
41
|
success: true,
|
265
|
-
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
|
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
|
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
|
296
|
-
|
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
|
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
|