adminos 1.0.0.pre.rc.1 → 1.0.0.pre.rc.2
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 +4 -4
- data/README.md +7 -2
- data/adminos.gemspec +1 -1
- data/app/inputs/cropp_input.rb +13 -6
- data/lib/adminos/helpers/models/cropped.rb +11 -7
- data/lib/generators/adminos/install_generator.rb +6 -3
- data/lib/generators/templates/install/Gemfile +1 -1
- data/lib/generators/templates/install/admin.slim +0 -1
- data/lib/generators/templates/install/prepare_settings.rb +0 -1
- data/lib/generators/templates/install/webpack/environment.js +2 -3
- data/lib/generators/templates/install/webpack/javascript/admin/js/index.js +0 -1
- data/lib/generators/templates/install/webpack/javascript/admin/styles/admin.scss +0 -1
- metadata +2 -3
- data/lib/generators/templates/install/webpack/custom.js +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dd7956b8e247ace0302f2da00df9bd1a437de8b0ed52bc1e5bb575fe4889fcc
|
4
|
+
data.tar.gz: 2980ad30232cc36f622c1059c6c77e0273500a6ba53cd9513e4c66e10aedd012
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7271cb01c26fc3fc4471fffa46ee1250934f85872b2438eb7d590d13334585ca78a1347968254913e0a00383e9ee0a90041b46e33b046149f326c75b509750cc
|
7
|
+
data.tar.gz: 50b733a689694add1c82c11b26eadb3fc8abf3a7212fe1bca1dc22ffa8395d9335b7c4feb073a5c380748dd4db6782113c9d1091d1383b4bf2ca3a23c6fc5ec2
|
data/README.md
CHANGED
@@ -60,7 +60,11 @@ If no need in SEO fields, switch it off using `--no-seo`.
|
|
60
60
|
has_one_attached :avatar
|
61
61
|
has_one_attached :photo
|
62
62
|
|
63
|
-
cropped :avatar
|
63
|
+
cropped :avatar, version: :default, coord_attribute: :avatar_coord
|
64
|
+
cropped :avatar, version: :mobile, coord_attribute: :avatar_mobile_coord
|
65
|
+
|
66
|
+
# default versions name is :default
|
67
|
+
# default coord_attribute attribute name is has_one_attached attribute + '_coord'
|
64
68
|
cropped :photo
|
65
69
|
end
|
66
70
|
```
|
@@ -68,7 +72,8 @@ If no need in SEO fields, switch it off using `--no-seo`.
|
|
68
72
|
```slim
|
69
73
|
# admin
|
70
74
|
# aspect_ratio default 16/9
|
71
|
-
= f.input :avatar, as: :cropp, input_html: { aspect_ratio:
|
75
|
+
= f.input :avatar, as: :cropp, input_html: { coord_attribute: :avatar_coord, version: :default, aspect_ratio: 16/9 }
|
76
|
+
= f.input :avatar, as: :cropp, input_html: { coord_attribute: :avatar_mobile_coord, version: :mobile, aspect_ratio: 2/3 }
|
72
77
|
= f.input :photo, as: :cropp
|
73
78
|
|
74
79
|
# public
|
data/adminos.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = 'adminos'
|
3
|
-
gem.version = '1.0.0-rc.
|
3
|
+
gem.version = '1.0.0-rc.2'
|
4
4
|
gem.authors = ['RavWar', 'milushov', 'abuhtoyarov', 'SiebenSieben']
|
5
5
|
gem.email = ['studio@molinos.ru']
|
6
6
|
gem.homepage = 'https://gitlab.molinos.ru/global/adminos'
|
data/app/inputs/cropp_input.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
class CroppInput < SimpleForm::Inputs::Base
|
2
2
|
def input(wrapper_options = nil)
|
3
|
+
@version = input_html_options.delete(:version) || :default
|
4
|
+
@coord_attribute = input_html_options.delete(:coord_attribute) || object.send("#{@version}_#{attribute_name}_attr_coord")
|
5
|
+
|
3
6
|
out = []
|
4
7
|
out << %{<div class="f-file">}
|
5
8
|
out << %{ <label class="f-file__selection js-file">}
|
6
9
|
out << %{ <span class="f-file__button">Выбрать</span>}
|
7
10
|
out << @builder.file_field(attribute_name, input_html_options)
|
8
|
-
out << @builder.hidden_field(
|
11
|
+
out << @builder.hidden_field(@coord_attribute)
|
9
12
|
out << %{ <span class="f-file__selected"></span>}
|
10
13
|
out << %{ </label>}
|
11
14
|
out << %{</div>}
|
@@ -17,14 +20,18 @@ class CroppInput < SimpleForm::Inputs::Base
|
|
17
20
|
def preview
|
18
21
|
return unless object.send(attribute_name).attached?
|
19
22
|
out = []
|
20
|
-
|
23
|
+
|
24
|
+
aspect_ratio = input_html_options.delete(:aspect_ratio) || '16/9'
|
25
|
+
aspect_ratio = aspect_ratio.split('/').map(&:to_f)
|
26
|
+
aspect_ratio = aspect_ratio[0]/aspect_ratio[1]
|
27
|
+
|
21
28
|
out << %{<div class="row"><div class="col-md-8"><div class="img-container">}
|
22
29
|
|
23
|
-
out << template.image_tag(object.send(attribute_name), data: { aspect_ratio: aspect_ratio, preview: ".#{attribute_name}_preview", toggle: 'cropp', coord:
|
30
|
+
out << template.image_tag(object.send(attribute_name), data: { aspect_ratio: aspect_ratio, preview: ".#{@version}_#{attribute_name}_preview", toggle: 'cropp', coord: @coord_attribute })
|
24
31
|
|
25
32
|
out << %{</div></div><div class="col-md-4">}
|
26
33
|
out << %{<div class="docs-preview clearfix">}
|
27
|
-
out << %{<div class="img-preview preview-lg #{attribute_name}_preview"></div>}
|
34
|
+
out << %{<div class="img-preview preview-lg #{@version}_#{attribute_name}_preview"></div>}
|
28
35
|
out << cropped
|
29
36
|
|
30
37
|
out << %{</div></div></div>}
|
@@ -32,12 +39,12 @@ class CroppInput < SimpleForm::Inputs::Base
|
|
32
39
|
end
|
33
40
|
|
34
41
|
def cropped
|
35
|
-
return if
|
42
|
+
return if @coord_attribute.blank?
|
36
43
|
|
37
44
|
out = []
|
38
45
|
out << %{<div class="preview-cropped"><figure class="figure">}
|
39
46
|
|
40
|
-
out << template.image_tag(object.send("#{attribute_name}_cropped"))
|
47
|
+
out << template.image_tag(object.send("#{@version}_#{attribute_name}_cropped"))
|
41
48
|
|
42
49
|
out << %{<figcaption class="figure-caption text-center">Cropped image</figcaption></figure></div>}
|
43
50
|
out.join
|
@@ -2,18 +2,22 @@ module Adminos::Cropped
|
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
4
|
module ClassMethods
|
5
|
-
def cropped(as_attribute,
|
5
|
+
def cropped(as_attribute, *args)
|
6
|
+
options = args.extract_options!
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
version = options.delete(:version) || :default
|
9
|
+
coord_attribute = options.delete(:coord_attribute) || "#{as_attribute}_coord"
|
10
|
+
|
11
|
+
define_method "#{version}_#{as_attribute}_cropped" do
|
12
|
+
public_send(as_attribute).variant(combine_options: { crop: public_send("#{version}_#{as_attribute}_coord") })
|
9
13
|
end
|
10
14
|
|
11
|
-
define_method "#{as_attribute}_attr_coord" do
|
12
|
-
coord_attribute
|
15
|
+
define_method "#{version}_#{as_attribute}_attr_coord" do
|
16
|
+
coord_attribute
|
13
17
|
end
|
14
18
|
|
15
|
-
define_method "#{as_attribute}
|
16
|
-
public_send(public_send("#{as_attribute}_attr_coord"))
|
19
|
+
define_method "#{version}_#{as_attribute}_coord" do
|
20
|
+
public_send(public_send("#{version}_#{as_attribute}_attr_coord"))
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
@@ -76,9 +76,7 @@ module Adminos::Generators
|
|
76
76
|
|
77
77
|
def install_webpacker
|
78
78
|
run 'bundle exec rails webpacker:install'
|
79
|
-
run "yarn add resolve-url-loader adminos"
|
80
79
|
|
81
|
-
copy_file 'webpack/custom.js', 'config/webpack/custom.js'
|
82
80
|
copy_file 'webpack/javascript/packs/admin.js', 'app/javascript/packs/admin.js'
|
83
81
|
directory 'webpack/javascript/admin', 'app/javascript/admin'
|
84
82
|
inject_into_file 'config/webpack/environment.js', file_content('webpack/environment.js'), before: /\nmodule.exports/
|
@@ -89,7 +87,12 @@ module Adminos::Generators
|
|
89
87
|
end
|
90
88
|
|
91
89
|
def install_actiontext
|
92
|
-
|
90
|
+
# Assets are stored in adminos-assets
|
91
|
+
run 'bundle exec rails action_text:copy_migrations'
|
92
|
+
end
|
93
|
+
|
94
|
+
def install_adminos_assets
|
95
|
+
run "yarn add adminos"
|
93
96
|
end
|
94
97
|
|
95
98
|
def install_devise
|
@@ -7,7 +7,7 @@ gem 'puma', '~> 3.7'
|
|
7
7
|
gem 'jbuilder', '~> 2.5'
|
8
8
|
gem 'role_model'
|
9
9
|
gem 'webpacker', '~> 3.5'
|
10
|
-
gem "actiontext", github: "rails/actiontext", require: "action_text"
|
10
|
+
gem "actiontext", github: "rails/actiontext", require: "action_text", ref: "cfe4674d3637c746cdb3c2b5131e2de498775529"
|
11
11
|
gem "image_processing", "~> 1.2" # for Active Storage variants
|
12
12
|
|
13
13
|
group :production, :staging do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adminos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.pre.rc.
|
4
|
+
version: 1.0.0.pre.rc.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RavWar
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2019-01-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: path
|
@@ -562,7 +562,6 @@ files:
|
|
562
562
|
- lib/generators/templates/install/routes.rb.erb
|
563
563
|
- lib/generators/templates/install/routes/pages.rb
|
564
564
|
- lib/generators/templates/install/settings_migration.rb
|
565
|
-
- lib/generators/templates/install/webpack/custom.js
|
566
565
|
- lib/generators/templates/install/webpack/environment.js
|
567
566
|
- lib/generators/templates/install/webpack/javascript/admin/js/index.js
|
568
567
|
- lib/generators/templates/install/webpack/javascript/admin/styles/admin.scss
|
@@ -1,36 +0,0 @@
|
|
1
|
-
const {
|
2
|
-
environment
|
3
|
-
} = require('@rails/webpacker')
|
4
|
-
const webpack = require('webpack')
|
5
|
-
|
6
|
-
module.exports = {
|
7
|
-
resolve: {
|
8
|
-
alias: {
|
9
|
-
jquery: 'jquery/src/jquery'
|
10
|
-
}
|
11
|
-
}
|
12
|
-
}
|
13
|
-
|
14
|
-
// resolve-url-loader must be used before sass-loader
|
15
|
-
environment.loaders.get('sass').use.splice(-1, 0, {
|
16
|
-
loader: 'resolve-url-loader'
|
17
|
-
});
|
18
|
-
|
19
|
-
|
20
|
-
// Insert before a given plugin
|
21
|
-
environment.plugins.insert('CommonChunkVendor',
|
22
|
-
new webpack.optimize.CommonsChunkPlugin({
|
23
|
-
name: 'vendor', // Vendor code
|
24
|
-
minChunks: (module) => module.context && module.context.indexOf('node_modules') !== -1
|
25
|
-
}), {
|
26
|
-
before: 'manifest'
|
27
|
-
})
|
28
|
-
|
29
|
-
// Add an additional plugin of your choosing : ProvidePlugin
|
30
|
-
environment.plugins.prepend(
|
31
|
-
'Provide',
|
32
|
-
new webpack.ProvidePlugin({
|
33
|
-
$: 'jquery',
|
34
|
-
jQuery: 'jquery'
|
35
|
-
})
|
36
|
-
)
|