sibu 1.1.1 → 1.1.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: bdec9bea3e256312e8182ec4527fbb73e0c7563154bddd149cca3abf09f7b1a8
4
- data.tar.gz: 712052bb1d87519fe78a864d777145ef5d5d154dcad783d9b2da541c1e25babf
3
+ metadata.gz: cb6b66f4e135820ce4b6b6be0e9d5e655c83ff67510cb53ef56166f652ed7221
4
+ data.tar.gz: 71f22109b0ba1c918e0da57741d86eee7cb3c6656985aba6d38496a63beaa1b8
5
5
  SHA512:
6
- metadata.gz: f607982440fb15249373f019fb060e91312b2a05564e8f02edb6fc301be3140930fa035d9c57978790040d0372c953855a463274d12ed27864ca5cb5bb589a8a
7
- data.tar.gz: bed37930c35feeeebbe8d1740fc18ca3b2b4d15e8984ae08416aa810dd4eb2e23283efc4e48b58f63e79d6cb47608c03911b30ffa9f33458b2efa061019aed93
6
+ metadata.gz: 0a1bcceafab8d50bb61b22b17b3247595a69ee56110b279730b75cd36b70832cebf1f8e641167da5da02925aa3aa1b87e944a4b7ad89f388b0b7dae685476e45
7
+ data.tar.gz: 14c8ec6982235da49511f937b0133487ced642c50b9c4a29513581ccde249e8398cb0cf112ab3766755c0472347a27a85f78c70e702c804538bfa86cefe987c0
@@ -1,31 +1,46 @@
1
1
  require "image_processing/mini_magick"
2
2
 
3
3
  class Sibu::ImageUploader < Shrine
4
- include ImageProcessing::MiniMagick
5
- plugin :processing
6
- plugin :versions
7
- plugin :delete_raw
4
+ # include ImageProcessing::MiniMagick
5
+ # plugin :versions
6
+ # plugin :delete_raw
8
7
 
9
- process(:store) do |io, context|
10
- original = io.download
8
+ Attacher.derivatives do |original|
9
+ magick = ImageProcessing::MiniMagick.source(original)
11
10
  images_config = Rails.application.config.sibu[:images]
12
- image_type = io.mime_type
11
+ image_type = original.path.ends_with?('.svg') ? "image/svg+xml" : "image"
13
12
 
14
- if image_type == "image/svg+xml" || io.metadata['filename'].end_with?('.svg')
15
- {original: io, large: io.download, medium: io.download, small: io.download}
13
+ if image_type == "image/svg+xml"
14
+ {large: original, medium: original, small: original}
16
15
  else
17
- large = resize_to_limit!(original, images_config[:large], images_config[:large]) {|cmd| cmd.auto_orient}
18
- medium = resize_to_limit(large, images_config[:medium], images_config[:medium])
19
- small = resize_to_limit(medium, images_config[:small], images_config[:small])
20
-
21
- {original: io, large: large, medium: medium, small: small}
16
+ {
17
+ large: magick.resize_to_limit!(images_config[:large], images_config[:large]) {|cmd| cmd.auto_orient},
18
+ medium: magick.resize_to_limit!(images_config[:medium], images_config[:medium]),
19
+ small: magick.resize_to_limit!(images_config[:small], images_config[:small]),
20
+ }
22
21
  end
23
22
  end
24
23
 
24
+ # process(:store) do |io, context|
25
+ # original = io.download
26
+ # images_config = Rails.application.config.sibu[:images]
27
+ # image_type = io.mime_type
28
+ #
29
+ # if image_type == "image/svg+xml" || io.metadata['filename'].end_with?('.svg')
30
+ # {original: io, large: io.download, medium: io.download, small: io.download}
31
+ # else
32
+ # large = resize_to_limit!(original, images_config[:large], images_config[:large]) {|cmd| cmd.auto_orient}
33
+ # medium = resize_to_limit(large, images_config[:medium], images_config[:medium])
34
+ # small = resize_to_limit(medium, images_config[:small], images_config[:small])
35
+ #
36
+ # {original: io, large: large, medium: medium, small: small}
37
+ # end
38
+ # end
39
+
25
40
  def generate_location(io, context)
26
41
  user_id = context[:record] ? context[:record].user_id : nil
27
42
  style = context[:version] != :original ? "resized" : "originals"
28
- name = "#{context.dig(:metadata, 'filename') ? context.dig(:metadata, 'filename').gsub(/\.\w+$/, '').parameterize : 'image'}-#{super}"
43
+ name = "#{context.dig(:metadata, 'filename') ? context.dig(:metadata, 'filename').gsub(/\.\w+$/, '').parameterize : 'image'}-#{super(io, derivative: context[:version])}#{style}"
29
44
 
30
45
  [user_id, style, name].compact.join("/")
31
46
  end
@@ -1,6 +1,6 @@
1
1
  module Sibu
2
2
  class Document < ApplicationRecord
3
- # include DocumentUploader::Attachment.new(:file, cache: :documents_cache, store: :documents_store)
3
+ include DocumentUploader::Attachment.new(:file, cache: :documents_cache, store: :documents_store)
4
4
  extend Sibu::UserConcern
5
5
 
6
6
  validates_presence_of :file_data
@@ -1,10 +1,10 @@
1
1
  module Sibu
2
2
  class Image < ApplicationRecord
3
- # include ImageUploader::Attachment.new(:file)
3
+ include ImageUploader::Attachment(:file)
4
4
  extend Sibu::UserConcern
5
5
 
6
6
  store :metadata, accessors: [:alt, :reference, :credits], coder: JSON
7
7
 
8
- validates_presence_of :file_data
8
+ validates_presence_of :file
9
9
  end
10
10
  end
@@ -1,6 +1,6 @@
1
1
  module Sibu
2
2
  class Site < ApplicationRecord
3
- # include StyleUploader::Attachment(:style, cache: :styles_cache, store: :styles_store)
3
+ include StyleUploader::Attachment(:style, cache: :styles_cache, store: :styles_store)
4
4
  include Sibu::SectionsConcern
5
5
  extend Sibu::UserConcern
6
6
 
@@ -12,6 +12,9 @@ Shrine.storages = {
12
12
  }
13
13
 
14
14
  Shrine.plugin :activerecord
15
+ Shrine.plugin :validation
16
+ Shrine.plugin :tempfile
17
+ Shrine.plugin :derivatives, create_on_promote: true
15
18
  Shrine.plugin :cached_attachment_data
16
19
 
17
20
  MiniMagick.configure do |config|
data/lib/sibu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sibu
2
- VERSION = '1.1.1'
2
+ VERSION = '1.1.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sibu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Baptiste Vilain
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-12-08 00:00:00.000000000 Z
11
+ date: 2026-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.8'
47
+ version: '3.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2.8'
54
+ version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: image_processing
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.2'
61
+ version: '1.8'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.2'
68
+ version: '1.8'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: mini_magick
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -241,7 +241,7 @@ homepage: http://hotentic.com
241
241
  licenses:
242
242
  - MIT
243
243
  metadata: {}
244
- post_install_message:
244
+ post_install_message:
245
245
  rdoc_options: []
246
246
  require_paths:
247
247
  - lib
@@ -256,8 +256,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
256
  - !ruby/object:Gem::Version
257
257
  version: '0'
258
258
  requirements: []
259
- rubygems_version: 3.1.6
260
- signing_key:
259
+ rubygems_version: 3.5.22
260
+ signing_key:
261
261
  specification_version: 4
262
262
  summary: Sibu - A Site Builder for Ruby on Rails
263
263
  test_files: []