hancock_cms_gallery 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +54 -0
- data/Rakefile +1 -0
- data/app/assets/javascripts/hancock/gallery/init.coffee +2 -0
- data/app/assets/javascripts/hancock/gallery/loaders/gallery_images_loader.coffee +29 -0
- data/app/assets/javascripts/hancock/gallery/loaders/gallery_loader.coffee +29 -0
- data/app/assets/javascripts/hancock/gallery/page_selector.coffee +65 -0
- data/app/assets/javascripts/hancock/gallery.coffee +11 -0
- data/app/controllers/concerns/hancock/gallery/load_gallery.rb +74 -0
- data/app/controllers/concerns/hancock/gallery/load_gallery_images.rb +58 -0
- data/app/controllers/concerns/rails_admin/jcrop_controller.rb +138 -0
- data/app/models/concerns/hancock/gallery/active_record_paperclip.rb +95 -0
- data/app/models/concerns/hancock/gallery/auto_crop.rb +86 -0
- data/app/models/concerns/hancock/gallery/decorators/embedded_image.rb +47 -0
- data/app/models/concerns/hancock/gallery/decorators/gallery.rb +47 -0
- data/app/models/concerns/hancock/gallery/decorators/image.rb +52 -0
- data/app/models/concerns/hancock/gallery/decorators/original_image.rb +35 -0
- data/app/models/concerns/hancock/gallery/gallerable.rb +13 -0
- data/app/models/concerns/hancock/gallery/mongoid_paperclip.rb +96 -0
- data/app/models/concerns/hancock/gallery/paperclipable.rb +19 -0
- data/app/models/concerns/hancock/gallery/watermarkable.rb +117 -0
- data/app/models/hancock/gallery/embedded_image.rb +17 -0
- data/app/models/hancock/gallery/gallery.rb +16 -0
- data/app/models/hancock/gallery/image.rb +16 -0
- data/app/models/hancock/gallery/original_image.rb +15 -0
- data/app/views/rails_admin/jcrop/edit.html.slim +18 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/config/initializers/hancock_gallery.rb +29 -0
- data/config/initializers/paperclip_fix.rb +4 -0
- data/config/locales/hancock.gallery.ru.yml +17 -0
- data/hancock_cms_gallery.gemspec +37 -0
- data/lib/generators/hancock/gallery/config/install_generator.rb +13 -0
- data/lib/generators/hancock/gallery/config/templates/hancock_gallery.erb +9 -0
- data/lib/generators/hancock/gallery/migrations/migration_generator.rb +18 -0
- data/lib/generators/hancock/gallery/migrations/templates/migration_gallery.rb +51 -0
- data/lib/generators/hancock/gallery/models/decorators_generator.rb +21 -0
- data/lib/generators/hancock/gallery/models/embedded_image_generator.rb +52 -0
- data/lib/generators/hancock/gallery/models/gallery_generator.rb +55 -0
- data/lib/generators/hancock/gallery/models/image_generator.rb +51 -0
- data/lib/generators/hancock/gallery/models/templates/embedded_image.erb +52 -0
- data/lib/generators/hancock/gallery/models/templates/gallery.erb +48 -0
- data/lib/generators/hancock/gallery/models/templates/image.erb +50 -0
- data/lib/generators/hancock/gallery/models/templates/original_image.erb +34 -0
- data/lib/hancock/gallery/admin/embedded_image.rb +41 -0
- data/lib/hancock/gallery/admin/gallery.rb +52 -0
- data/lib/hancock/gallery/admin/image.rb +45 -0
- data/lib/hancock/gallery/admin/original_image.rb +33 -0
- data/lib/hancock/gallery/admin.rb +26 -0
- data/lib/hancock/gallery/configuration.rb +26 -0
- data/lib/hancock/gallery/engine.rb +5 -0
- data/lib/hancock/gallery/models/active_record/gallery.rb +19 -0
- data/lib/hancock/gallery/models/active_record/image.rb +21 -0
- data/lib/hancock/gallery/models/embedded_image.rb +28 -0
- data/lib/hancock/gallery/models/gallery.rb +62 -0
- data/lib/hancock/gallery/models/image.rb +57 -0
- data/lib/hancock/gallery/models/mongoid/embedded_image.rb +12 -0
- data/lib/hancock/gallery/models/mongoid/gallery.rb +16 -0
- data/lib/hancock/gallery/models/mongoid/image.rb +15 -0
- data/lib/hancock/gallery/models/mongoid/original_image.rb +14 -0
- data/lib/hancock/gallery/models/original_image.rb +30 -0
- data/lib/hancock/gallery/rails_admin_ext/hancock_image.rb +32 -0
- data/lib/hancock/gallery/version.rb +5 -0
- data/lib/hancock_cms_gallery.rb +66 -0
- data/release.sh +6 -0
- metadata +176 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hancock/gallery/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "hancock_cms_gallery"
|
8
|
+
spec.version = Hancock::Gallery::VERSION
|
9
|
+
spec.authors = ["Alexander Kiseliev"]
|
10
|
+
spec.email = ["dev@redrocks.pro"]
|
11
|
+
|
12
|
+
spec.description = %q{hancock_cms_gallery}
|
13
|
+
spec.summary = %q{hancock_cms_gallery}
|
14
|
+
spec.homepage = 'https://github.com/red-rocks/hancock_cms_gallery'
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
# end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
|
33
|
+
spec.add_dependency 'hancock_cms', [">=1.0", "<=2.0"]
|
34
|
+
# spec.add_dependency 'hancock_cms', ["~> 1.0", "~> 2.0"]
|
35
|
+
|
36
|
+
spec.add_dependency 'ack_rails_admin_jcrop', '~> 0.2.0'
|
37
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Hancock::Gallery
|
4
|
+
class ConfigGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
desc 'Hancock::Gallery Config generator'
|
8
|
+
def config
|
9
|
+
template 'hancock_gallery.erb', "config/initializers/hancock_gallery.rb"
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Hancock::Gallery.configure do |config|
|
2
|
+
##### defaults #####
|
3
|
+
# config.localize = Hancock.config.localize
|
4
|
+
#
|
5
|
+
# config.model_settings_support = defined?(RailsAdminModelSettings)
|
6
|
+
# config.user_abilities_support = defined?(RailsAdminUserAbilities)
|
7
|
+
# config.ra_comments_support = defined?(RailsAdminComments)
|
8
|
+
# config.watermark_support = defined?(PaperclipWatermark)
|
9
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/active_record'
|
3
|
+
|
4
|
+
module Hancock::Gallery
|
5
|
+
class MigrationGenerator < Rails::Generators::Base
|
6
|
+
include ActiveRecord::Generators::Migration
|
7
|
+
source_root File.expand_path('../templates', __FILE__)
|
8
|
+
|
9
|
+
desc 'Hancock Gallery migration generator'
|
10
|
+
def migration
|
11
|
+
if Hancock.active_record?
|
12
|
+
%w(gallery).each do |table_name|
|
13
|
+
migration_template "migration_#{table_name}.rb", "db/migrate/hancock_gallery_create_#{table_name}.rb"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class HancockGalleryCreateGallery < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
########### c #################
|
4
|
+
create_table :hancock_gallery_gallery_images do |t|
|
5
|
+
t.integer :gallery_id
|
6
|
+
t.integer :hancock_gallery_imagable_id
|
7
|
+
t.string :hancock_gallery_imagable_type
|
8
|
+
|
9
|
+
t.boolean :enabled, default: true, null: false
|
10
|
+
|
11
|
+
if Hancock::Gallery.config.localize
|
12
|
+
t.column :name_translations, 'hstore', default: {}
|
13
|
+
else
|
14
|
+
t.string :name, null: false
|
15
|
+
end
|
16
|
+
|
17
|
+
t.attachment :image
|
18
|
+
t.timestamps
|
19
|
+
end
|
20
|
+
|
21
|
+
add_index :hancock_gallery_gallery_images, [:enabled]
|
22
|
+
add_index :hancock_gallery_gallery_images, [:gallery_id]
|
23
|
+
add_index :hancock_gallery_gallery_images, [:hancock_gallery_imagable_id, :hancock_gallery_imagable_type]
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
########### Galleries #################
|
28
|
+
create_table :hancock_gallery_gallery do |t|
|
29
|
+
t.boolean :enabled, default: true, null: false
|
30
|
+
|
31
|
+
if Hancock::Gallery.config.localize
|
32
|
+
t.column :name_translations, 'hstore', default: {}
|
33
|
+
else
|
34
|
+
t.string :name, null: false
|
35
|
+
end
|
36
|
+
|
37
|
+
t.integer :parent_id
|
38
|
+
t.integer :lft
|
39
|
+
t.integer :rgt
|
40
|
+
t.integer :depth
|
41
|
+
|
42
|
+
t.string :slug, null: false
|
43
|
+
t.attachment :image
|
44
|
+
t.timestamps
|
45
|
+
end
|
46
|
+
|
47
|
+
add_index :hancock_gallery_galleries, :slug, unique: true
|
48
|
+
add_index :hancock_gallery_galleries, [:enabled, :lft]
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Hancock::Gallery::Models
|
4
|
+
class DecoratorsGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../../../../../../app/models/concerns/hancock/gallery/decorators', __FILE__)
|
6
|
+
argument :models, type: :array, default: []
|
7
|
+
|
8
|
+
desc 'Hancock::Gallery Models decorators generator'
|
9
|
+
def decorators
|
10
|
+
(models == ['all'] ? permitted_models : models & permitted_models).each do |m|
|
11
|
+
copy_file "#{m}.rb", "app/models/concerns/hancock/gallery/decorators/#{m}.rb"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def permitted_models
|
17
|
+
['embedded_image', 'gallery', 'image', 'original_image']
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Hancock::Gallery::Models
|
4
|
+
class EmbeddedImageGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
argument :class_name_arg, type: :string, default: ""
|
7
|
+
argument :parent_class_name_arg, type: :string, default: ""
|
8
|
+
|
9
|
+
desc 'Hancock::Gallery EmbeddedImage Model generator'
|
10
|
+
def embedded_image
|
11
|
+
template 'embedded_image.erb', "app/models/#{file_name}.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
def class_name
|
16
|
+
class_name_arg.blank? ? "SetClassForEmbeddedImage" : class_name_arg
|
17
|
+
end
|
18
|
+
|
19
|
+
def capitalized_class_name
|
20
|
+
class_name.capitalize
|
21
|
+
end
|
22
|
+
|
23
|
+
def camelcased_class_name
|
24
|
+
class_name.camelcase
|
25
|
+
end
|
26
|
+
|
27
|
+
def file_name
|
28
|
+
underscored_class_name
|
29
|
+
end
|
30
|
+
|
31
|
+
def underscored_class_name
|
32
|
+
camelcased_class_name.underscore
|
33
|
+
end
|
34
|
+
|
35
|
+
def underscored_pluralized_class_name
|
36
|
+
underscored_class_name.pluralize
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
def underscored_parent_class_name
|
41
|
+
parent_class_name.underscore
|
42
|
+
end
|
43
|
+
|
44
|
+
def camelcased_parent_class_name
|
45
|
+
parent_class_name.camelcase
|
46
|
+
end
|
47
|
+
|
48
|
+
def parent_class_name
|
49
|
+
parent_class_name_arg.blank? ? "SetParentClassForEmbeddedImage" : parent_class_name_arg
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Hancock::Gallery::Models
|
4
|
+
class GalleryGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
argument :class_name_arg, type: :string, default: ""
|
7
|
+
argument :image_class_name_arg, type: :string, default: ""
|
8
|
+
|
9
|
+
desc 'Hancock::Gallery Gallery Model generator'
|
10
|
+
def gallery
|
11
|
+
template 'gallery.erb', "app/models/#{file_name}.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
def class_name
|
16
|
+
class_name_arg.blank? ? "SetClassForGallery" : class_name_arg
|
17
|
+
end
|
18
|
+
|
19
|
+
def capitalized_class_name
|
20
|
+
class_name.capitalize
|
21
|
+
end
|
22
|
+
|
23
|
+
def camelcased_class_name
|
24
|
+
class_name.camelcase
|
25
|
+
end
|
26
|
+
|
27
|
+
def file_name
|
28
|
+
underscored_class_name
|
29
|
+
end
|
30
|
+
|
31
|
+
def underscored_class_name
|
32
|
+
camelcased_class_name.underscore
|
33
|
+
end
|
34
|
+
|
35
|
+
def underscored_pluralized_class_name
|
36
|
+
underscored_class_name.pluralize
|
37
|
+
end
|
38
|
+
|
39
|
+
def camelcased_class_name
|
40
|
+
gallery_class_name.camelcase
|
41
|
+
end
|
42
|
+
|
43
|
+
def underscored_image_class_name
|
44
|
+
image_class_name.underscore
|
45
|
+
end
|
46
|
+
|
47
|
+
def camelcased_image_class_name
|
48
|
+
image_class_name.camelcase
|
49
|
+
end
|
50
|
+
|
51
|
+
def image_class_name
|
52
|
+
image_class_name_arg.blank? ? "#{camelcased_class_name}Image" : image_class_name_arg
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Hancock::Gallery::Models
|
4
|
+
class ImageGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
argument :class_name_arg, type: :string, default: ""
|
7
|
+
argument :gallery_class_name_arg, type: :string, default: ""
|
8
|
+
|
9
|
+
desc 'Hancock::Gallery Image Model generator'
|
10
|
+
def image
|
11
|
+
template 'image.erb', "app/models/#{file_name}.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
def class_name
|
16
|
+
class_name_arg.blank? ? "SetClassForImage" : class_name_arg
|
17
|
+
end
|
18
|
+
|
19
|
+
def capitalized_class_name
|
20
|
+
class_name.capitalize
|
21
|
+
end
|
22
|
+
|
23
|
+
def camelcased_class_name
|
24
|
+
class_name.camelcase
|
25
|
+
end
|
26
|
+
|
27
|
+
def file_name
|
28
|
+
underscored_class_name
|
29
|
+
end
|
30
|
+
|
31
|
+
def underscored_class_name
|
32
|
+
camelcased_class_name.underscore
|
33
|
+
end
|
34
|
+
|
35
|
+
def underscored_pluralized_class_name
|
36
|
+
underscored_class_name.pluralize
|
37
|
+
end
|
38
|
+
|
39
|
+
def camelcased_gallery_class_name
|
40
|
+
gallery_class_name.camelcase
|
41
|
+
end
|
42
|
+
|
43
|
+
def underscored_gallery_class_name
|
44
|
+
gallery_class_name.underscore
|
45
|
+
end
|
46
|
+
|
47
|
+
def gallery_class_name
|
48
|
+
gallery_class_name_arg.blank? ? camelcased_class_name.sub(/Image$/i, "") : gallery_class_name_arg
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
class <%= camelcased_class_name %> < Hancock::Gallery::EmbeddedImage
|
2
|
+
embedded_in :<%= underscored_parent_class_name %>, class_name: "<%= camelcased_parent_class_name %>"
|
3
|
+
|
4
|
+
def self.find(id)
|
5
|
+
find_through(<%= camelcased_parent_class_name %>, '<%= underscored_pluralized_class_name %>', id)
|
6
|
+
end
|
7
|
+
|
8
|
+
# # after_save :image_auto_rails_admin_jcrop
|
9
|
+
# def image_auto_rails_admin_jcrop
|
10
|
+
# auto_rails_admin_jcrop(:image) # or nil for cancel autocrop
|
11
|
+
# end
|
12
|
+
|
13
|
+
# # hancock_cms_attached_file(:image)
|
14
|
+
# def image_styles
|
15
|
+
# super
|
16
|
+
# end
|
17
|
+
|
18
|
+
# def image_jcrop_options
|
19
|
+
# super
|
20
|
+
# end
|
21
|
+
|
22
|
+
############# rails_admin ##############
|
23
|
+
def self.rails_admin_add_fields
|
24
|
+
super
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.rails_admin_add_config(config)
|
28
|
+
super(config)
|
29
|
+
end
|
30
|
+
|
31
|
+
def admin_can_user_defined_actions
|
32
|
+
[].freeze
|
33
|
+
end
|
34
|
+
def admin_cannot_user_defined_actions
|
35
|
+
[].freeze
|
36
|
+
end
|
37
|
+
def manager_can_user_defined_actions
|
38
|
+
[].freeze
|
39
|
+
end
|
40
|
+
def manager_cannot_user_defined_actions
|
41
|
+
[].freeze
|
42
|
+
end
|
43
|
+
def rails_admin_user_defined_visible_actions
|
44
|
+
[].freeze
|
45
|
+
end
|
46
|
+
|
47
|
+
# rails_admin(&Hancock::Gallery::Admin::EmbeddedElement.config(%NAV_LABEL%, rails_admin_add_fields) { |config|
|
48
|
+
rails_admin(&Hancock::Gallery::Admin::EmbeddedImage.config(nil, rails_admin_add_fields) { |config|
|
49
|
+
rails_admin_add_config(config)
|
50
|
+
})
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class <%= camelcased_class_name %> < Hancock::Gallery::Gallery
|
2
|
+
|
3
|
+
# has_many :<%= underscored_image_class_name %>, class_name: "<%= camelcased_image_class_name %>"
|
4
|
+
|
5
|
+
# # after_save :image_auto_rails_admin_jcrop
|
6
|
+
# def image_auto_rails_admin_jcrop
|
7
|
+
# auto_rails_admin_jcrop(:image) # or nil for cancel autocrop
|
8
|
+
# end
|
9
|
+
|
10
|
+
# # hancock_cms_attached_file(:image)
|
11
|
+
# def image_styles
|
12
|
+
# super
|
13
|
+
# end
|
14
|
+
|
15
|
+
# def image_jcrop_options
|
16
|
+
# super
|
17
|
+
# end
|
18
|
+
|
19
|
+
############# rails_admin ##############
|
20
|
+
def self.rails_admin_add_fields
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.rails_admin_add_config(config)
|
25
|
+
super(config)
|
26
|
+
end
|
27
|
+
|
28
|
+
def admin_can_user_defined_actions
|
29
|
+
[].freeze
|
30
|
+
end
|
31
|
+
def admin_cannot_user_defined_actions
|
32
|
+
[].freeze
|
33
|
+
end
|
34
|
+
def manager_can_user_defined_actions
|
35
|
+
[].freeze
|
36
|
+
end
|
37
|
+
def manager_cannot_user_defined_actions
|
38
|
+
[].freeze
|
39
|
+
end
|
40
|
+
def rails_admin_user_defined_visible_actions
|
41
|
+
[].freeze
|
42
|
+
end
|
43
|
+
|
44
|
+
# rails_admin(&Hancock::Gallery::Admin::Gallery.config(%NAV_LABEL%, rails_admin_add_fields) { |config|
|
45
|
+
rails_admin(&Hancock::Gallery::Admin::Gallery.config(rails_admin_add_fields) { |config|
|
46
|
+
rails_admin_add_config(config)
|
47
|
+
})
|
48
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class <%= camelcased_class_name %> < Hancock::Gallery::Image
|
2
|
+
|
3
|
+
# belongs_to :<%= underscored_gallery_class_name %>, class_name: "<%= camelcased_gallery_class_name %>"
|
4
|
+
|
5
|
+
# # after_save :image_auto_rails_admin_jcrop
|
6
|
+
# def image_auto_rails_admin_jcrop
|
7
|
+
# auto_rails_admin_jcrop(:image) # or nil for cancel autocrop
|
8
|
+
# end
|
9
|
+
|
10
|
+
# # hancock_cms_attached_file(:image)
|
11
|
+
# def image_styles
|
12
|
+
# super
|
13
|
+
# end
|
14
|
+
|
15
|
+
# def image_jcrop_options
|
16
|
+
# super
|
17
|
+
# end
|
18
|
+
|
19
|
+
############# rails_admin ##############
|
20
|
+
def self.rails_admin_add_fields
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.rails_admin_add_config(config)
|
25
|
+
super(config)
|
26
|
+
end
|
27
|
+
|
28
|
+
def admin_can_user_defined_actions
|
29
|
+
[].freeze
|
30
|
+
end
|
31
|
+
def admin_cannot_user_defined_actions
|
32
|
+
[].freeze
|
33
|
+
end
|
34
|
+
def manager_can_user_defined_actions
|
35
|
+
[].freeze
|
36
|
+
end
|
37
|
+
def manager_cannot_user_defined_actions
|
38
|
+
[].freeze
|
39
|
+
end
|
40
|
+
def rails_admin_user_defined_visible_actions
|
41
|
+
[].freeze
|
42
|
+
end
|
43
|
+
|
44
|
+
# rails_admin(&Hancock::Gallery::Admin::Image.config(%NAV_LABEL%, %WITHOUT_GALLERY%, rails_admin_add_fields) { |config|
|
45
|
+
# rails_admin(&Hancock::Gallery::Admin::Image.config(%NAV_LABEL%, rails_admin_add_fields) { |config|
|
46
|
+
# rails_admin(&Hancock::Gallery::Admin::Image.config(%WITHOUT_GALLERY%, rails_admin_add_fields) { |config|
|
47
|
+
rails_admin(&Hancock::Gallery::Admin::Image.config(rails_admin_add_fields) { |config|
|
48
|
+
rails_admin_add_config(config)
|
49
|
+
})
|
50
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class <%= camelcased_class_name %> < Hancock::Gallery::OriginalImage
|
2
|
+
|
3
|
+
############# rails_admin ##############
|
4
|
+
def self.rails_admin_add_fields
|
5
|
+
super
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.rails_admin_add_config(config)
|
9
|
+
super(config)
|
10
|
+
end
|
11
|
+
|
12
|
+
def admin_can_user_defined_actions
|
13
|
+
[].freeze
|
14
|
+
end
|
15
|
+
def admin_cannot_user_defined_actions
|
16
|
+
[].freeze
|
17
|
+
end
|
18
|
+
def manager_can_user_defined_actions
|
19
|
+
[].freeze
|
20
|
+
end
|
21
|
+
def manager_cannot_user_defined_actions
|
22
|
+
[].freeze
|
23
|
+
end
|
24
|
+
def rails_admin_user_defined_visible_actions
|
25
|
+
[].freeze
|
26
|
+
end
|
27
|
+
|
28
|
+
# rails_admin(&Hancock::Gallery::Admin::OriginalImage.config(%NAV_LABEL%, %VISIBLE%, rails_admin_add_fields) { |config|
|
29
|
+
# rails_admin(&Hancock::Gallery::Admin::OriginalImage.config(%NAV_LABEL%, rails_admin_add_fields) { |config|
|
30
|
+
# rails_admin(&Hancock::Gallery::Admin::OriginalImage.config(%VISIBLE%, rails_admin_add_fields) { |config|
|
31
|
+
rails_admin(&Hancock::Gallery::Admin::OriginalImage.config(rails_admin_add_fields) { |config|
|
32
|
+
rails_admin_add_config(config)
|
33
|
+
})
|
34
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Hancock::Gallery
|
2
|
+
module Admin
|
3
|
+
module EmbeddedImage
|
4
|
+
def self.config(nav_label = I18n.t('hancock.gallery'), fields = {})
|
5
|
+
if nav_label.is_a?(Hash)
|
6
|
+
nav_label, fields = nav_label[:nav_label], nav_label
|
7
|
+
elsif nav_label.is_a?(Array)
|
8
|
+
nav_label, fields = nil, nav_label
|
9
|
+
end
|
10
|
+
nav_label ||= I18n.t('hancock.gallery')
|
11
|
+
|
12
|
+
if fields
|
13
|
+
if fields.is_a?(Hash)
|
14
|
+
fields.reverse_merge!({image: :hancock_image})
|
15
|
+
else
|
16
|
+
finded = false
|
17
|
+
fields.each { |g|
|
18
|
+
finded = !!g[:fields][:image] unless finded
|
19
|
+
}
|
20
|
+
unless finded
|
21
|
+
fields << {
|
22
|
+
name: :default,
|
23
|
+
fields: {
|
24
|
+
image: :hancock_image
|
25
|
+
}
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
if block_given?
|
32
|
+
Hancock::Admin::EmbeddedElement.config(nav_label, fields) do |config|
|
33
|
+
yield config
|
34
|
+
end
|
35
|
+
else
|
36
|
+
Hancock::Admin::EmbeddedElement.config(nav_label, fields)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Hancock::Gallery
|
2
|
+
module Admin
|
3
|
+
module Gallery
|
4
|
+
def self.config(nav_label = nil, fields = {})
|
5
|
+
if nav_label.is_a?(Hash)
|
6
|
+
nav_label, fields = nav_label[:nav_label], nav_label
|
7
|
+
elsif nav_label.is_a?(Array)
|
8
|
+
nav_label, fields = nil, nav_label
|
9
|
+
end
|
10
|
+
|
11
|
+
Proc.new {
|
12
|
+
navigation_label(!nav_label.blank? ? nav_label : I18n.t('hancock.gallery'))
|
13
|
+
field :enabled, :toggle do
|
14
|
+
searchable false
|
15
|
+
end
|
16
|
+
|
17
|
+
field :name, :string do
|
18
|
+
searchable true
|
19
|
+
end
|
20
|
+
group :URL, &Hancock::Admin.url_block
|
21
|
+
# group :URL do
|
22
|
+
# active false
|
23
|
+
# field :slugs, :hancock_slugs
|
24
|
+
# field :text_slug
|
25
|
+
# end
|
26
|
+
|
27
|
+
field :image, :hancock_image
|
28
|
+
|
29
|
+
field :gallerable do
|
30
|
+
read_only true
|
31
|
+
end
|
32
|
+
|
33
|
+
nested_set({max_depth: 1, scopes: []})
|
34
|
+
|
35
|
+
if defined?(RailsAdminMultipleFileUpload)
|
36
|
+
multiple_file_upload(
|
37
|
+
{
|
38
|
+
fields: [:gallery_images]
|
39
|
+
}
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
Hancock::RailsAdminGroupPatch::hancock_cms_group(self, fields)
|
44
|
+
|
45
|
+
if block_given?
|
46
|
+
yield self
|
47
|
+
end
|
48
|
+
}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Hancock::Gallery
|
2
|
+
module Admin
|
3
|
+
module Image
|
4
|
+
def self.config(nav_label = nil, without_gallery = false, fields = {})
|
5
|
+
if nav_label.is_a?(Hash)
|
6
|
+
nav_label, without_gallery, fields = nav_label[:nav_label], (nav_label[:without_gallery].nil? ? true : nav_label[:without_gallery]), nav_label
|
7
|
+
elsif nav_label.is_a?(Array)
|
8
|
+
nav_label, without_gallery, fields = nil, true, nav_label
|
9
|
+
end
|
10
|
+
if nav_label.is_a?(Boolean)
|
11
|
+
if without_gallery.is_a?(Hash)
|
12
|
+
nav_label, without_gallery, fields = without_gallery[:nav_label], nav_label, without_gallery
|
13
|
+
end
|
14
|
+
nav_label, without_gallery, fields = fields[:nav_label], nav_label, fields
|
15
|
+
end
|
16
|
+
|
17
|
+
Proc.new {
|
18
|
+
navigation_label(!nav_label.blank? ? nav_label : I18n.t('hancock.gallery'))
|
19
|
+
field :enabled, :toggle do
|
20
|
+
searchable false
|
21
|
+
end
|
22
|
+
unless without_gallery
|
23
|
+
field :gallery do
|
24
|
+
searchable :name
|
25
|
+
end
|
26
|
+
end
|
27
|
+
field :name, :string do
|
28
|
+
searchable true
|
29
|
+
end
|
30
|
+
field :image, :hancock_image
|
31
|
+
|
32
|
+
group :caching, &Hancock::Admin.caching_block
|
33
|
+
|
34
|
+
nested_set({max_depth: 1, scopes: []})
|
35
|
+
|
36
|
+
Hancock::RailsAdminGroupPatch::hancock_cms_group(self, fields)
|
37
|
+
|
38
|
+
if block_given?
|
39
|
+
yield self
|
40
|
+
end
|
41
|
+
}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Hancock::Gallery
|
2
|
+
module Admin
|
3
|
+
module OriginalImage
|
4
|
+
def self.config(nav_label = nil, _visible = false, fields = {})
|
5
|
+
if nav_label.is_a?(Hash)
|
6
|
+
nav_label, _visible, fields = nav_label[:nav_label], (nav_label[:visible].nil? ? false : nav_label[:visible]), nav_label
|
7
|
+
elsif nav_label.is_a?(Array)
|
8
|
+
nav_label, _visible, fields = nil, false, nav_label
|
9
|
+
end
|
10
|
+
if nav_label.is_a?(Boolean)
|
11
|
+
if _visible.is_a?(Hash)
|
12
|
+
nav_label, _visible, fields = _visible[:nav_label], nav_label, _visible
|
13
|
+
end
|
14
|
+
nav_label, _visible, fields = fields[:nav_label], nav_label, fields
|
15
|
+
end
|
16
|
+
|
17
|
+
Proc.new {
|
18
|
+
navigation_label(!nav_label.blank? ? nav_label : I18n.t('hancock.gallery'))
|
19
|
+
visible _visible
|
20
|
+
|
21
|
+
field :originable
|
22
|
+
field :original
|
23
|
+
|
24
|
+
Hancock::RailsAdminGroupPatch::hancock_cms_group(self, fields)
|
25
|
+
|
26
|
+
if block_given?
|
27
|
+
yield self
|
28
|
+
end
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|