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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d81796250feb6e1aa2d2fd09cdef36acd168b8c92f05af8dc6854db9b8106529
4
- data.tar.gz: 421a234d3f208e98c497f941b591dcec9c5141801bec1605db40434108fa1ea2
3
+ metadata.gz: 1dd7956b8e247ace0302f2da00df9bd1a437de8b0ed52bc1e5bb575fe4889fcc
4
+ data.tar.gz: 2980ad30232cc36f622c1059c6c77e0273500a6ba53cd9513e4c66e10aedd012
5
5
  SHA512:
6
- metadata.gz: 2c813a2d485a528460f3507f61fa404d610e035547b2c6bae80af35ed432e84a6d7d282ad45826cefcdecf2d1edb3af2135810426de909ecf786e660f7de61c0
7
- data.tar.gz: ff2d6772b3b57eee01438148bb9a6c503df2a3a9d7302b08dea521b6ce8ca6437bf456d2a12824698f34f46630b72bd453b68de4970049d7ac0216cfd1570f92
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: 2/3 }
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.1'
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'
@@ -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(object.send("#{attribute_name}_attr_coord"))
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
- aspect_ratio = input_html_options.delete(:aspect_ratio) || 16/9
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: object.send("#{attribute_name}_attr_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 object.send("#{attribute_name}_attr_coord").blank?
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, coord_attribute = nil)
5
+ def cropped(as_attribute, *args)
6
+ options = args.extract_options!
6
7
 
7
- define_method "#{as_attribute}_cropped" do
8
- public_send(as_attribute).variant(combine_options: { crop: public_send("#{as_attribute}_cropped_coord") })
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 || "#{as_attribute}_coord"
15
+ define_method "#{version}_#{as_attribute}_attr_coord" do
16
+ coord_attribute
13
17
  end
14
18
 
15
- define_method "#{as_attribute}_cropped_coord" do
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
- run 'bundle exec rails action_text:install'
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
@@ -27,7 +27,6 @@ html#no-js lang="ru"
27
27
 
28
28
  = csrf_meta_tag
29
29
 
30
- = javascript_pack_tag 'vendor', rel: "prefetch"
31
30
  = javascript_pack_tag 'admin'
32
31
 
33
32
  = yield :javascript
@@ -1,4 +1,3 @@
1
1
 
2
2
 
3
- Settings.reset_column_information
4
3
  Settings.first_or_initialize.update_attributes email: 'studio@molinos.ru', email_header_from: 'studio@molinos.ru', company_name: 'Molinos'
@@ -1,4 +1,3 @@
1
- const customConfig = require('./custom')
1
+ const setupAdminos = require('adminos/webpacker');
2
2
 
3
- // Merge custom config
4
- environment.config.merge(customConfig)
3
+ setupAdminos(environment);
@@ -1,2 +1 @@
1
1
  import 'adminos/adminos'
2
- import 'actiontext';
@@ -1,2 +1 @@
1
1
  @import '~adminos/src/scss/adminos_base.scss';
2
- @import 'trix/dist/trix.css';
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.1
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: 2018-12-29 00:00:00.000000000 Z
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
- )