avo 2.13.3.pre.3 → 2.13.3.pre.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of avo might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e872452c4bd0412af9b42203d98aaa4f4d98c3ac1e64bac3f83829cc74512a1
4
- data.tar.gz: b6599c9c3e7115f555757525eec57b4ea8295f72acc5b5c5b5762d49b5b40ac4
3
+ metadata.gz: 595d05c5a12fe197d118cbaf142d64f445224afe450334f09f6e7a3e041f6c0f
4
+ data.tar.gz: a5101fe7f1c44fc5d8ccef230dbe44f73228e81e327893547b7d7004b0cc0e4a
5
5
  SHA512:
6
- metadata.gz: 0645c82e51a7771452b702108d9fa022e74a8445d70d44d45bdb9bed5f95112efe86ecfb376e5c7c015c4bcafe87db89ab61bade18abf96ffb070c8c05cdad0c
7
- data.tar.gz: 283be87c9d1c2c5977f61b04436ca947353c49845b372d25fd07cefa7adb4ec2d199e3f1f3a180ed438c241eb802f7d77c430df86b289c99b03b77c98da4d3cc
6
+ metadata.gz: ee55e57a363c34808c4f3b3fdd03bb34ebf262aff29739cf5114572ba4d22cd3b19dbfc9825eb80d25e701f8b11791205e77677dd5d2efba5988bc01dc623c6c
7
+ data.tar.gz: c3faf170cfeeb42af70b66858d12c5af938292649eefd2288661e272970704b9cf5edbef4a3bb9418ae862976e9119d7d05b175266810760746ec289282c5620
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.13.3.pre.3)
4
+ avo (2.13.3.pre.4)
5
5
  active_link_to
6
6
  addressable
7
7
  breadcrumbs_on_rails
@@ -256,6 +256,8 @@ GEM
256
256
  nokogiri (1.13.7)
257
257
  mini_portile2 (~> 2.8.0)
258
258
  racc (~> 1.4)
259
+ nokogiri (1.13.7-x86_64-linux)
260
+ racc (~> 1.4)
259
261
  orm_adapter (0.5.0)
260
262
  pagy (5.10.1)
261
263
  activesupport
@@ -64,43 +64,15 @@ module Avo
64
64
  classes
65
65
  end
66
66
 
67
- # Just use inline_svg gem.
67
+ # Use inline_svg gem but with our own finder implementation.
68
68
  def svg(file_name, **args)
69
+ return if file_name.blank?
70
+
69
71
  file_name = "#{file_name}.svg" unless file_name.end_with? ".svg"
70
72
 
71
- inline_svg_tag file_name, **args
72
- # return if file_name.nil?
73
-
74
- # file_name = "#{file_name}.svg" unless file_name.end_with? ".svg"
75
-
76
- # final_path = nil
77
- # [Rails.root, Avo::Engine.root].each do |root|
78
- # [["app", "assets", "svgs", file_name], [file_name]].each do |file_path|
79
- # path = root.join(*file_path).to_s
80
- # puts ["path->", path].inspect
81
- # if File.exist? path
82
- # # final_path = file_path.join('/')
83
- # final_path = path
84
- # break
85
- # end
86
- # end
87
- # end
88
- # puts ["final_path->", final_path].inspect
89
-
90
- # # paths = [
91
- # # Rails.root.join("app", "assets", "svgs", file_name).to_s,
92
- # # Rails.root.join(file_name).to_s,
93
- # # Avo::Engine.root.join("app", "assets", "svgs", file_name).to_s,
94
- # # Avo::Engine.root.join(file_name).to_s,
95
- # # ]
96
-
97
- # # path = paths.find do |path|
98
- # # File.exist? path
99
- # # end
100
-
101
- # return if final_path.nil?
102
-
103
- # inline_svg_tag final_path, **args
73
+ with_asset_finder(::Avo::SvgFinder) do
74
+ inline_svg file_name, **args
75
+ end
104
76
  end
105
77
 
106
78
  def input_classes(extra_classes = "", has_error: false)
@@ -130,5 +102,17 @@ module Avo
130
102
  rescue
131
103
  Avo.configuration.root_path
132
104
  end
105
+
106
+ private
107
+
108
+ # Taken from the original library
109
+ # https://github.com/jamesmartin/inline_svg/blob/main/lib/inline_svg/action_view/helpers.rb#L76
110
+ def with_asset_finder(asset_finder)
111
+ Thread.current[:inline_svg_asset_finder] = asset_finder
112
+ output = yield
113
+ Thread.current[:inline_svg_asset_finder] = nil
114
+
115
+ output
116
+ end
133
117
  end
134
118
  end
@@ -33,7 +33,6 @@
33
33
  <div class="content p-4 lg:p-6 flex-1 flex flex-col justify-between items-stretch <%= @container_classes %>">
34
34
  <%= render partial: "avo/partials/custom_tools_alert" %>
35
35
  <div class="flex flex-1 flex-col justify-between items-stretch space-y-8">
36
- <!-- <%= ::Rails.application.assets_manifest.inspect %> -->
37
36
  <%= yield %>
38
37
  <%= render partial: "avo/partials/footer" %>
39
38
  </div>
data/lib/avo/engine.rb CHANGED
@@ -53,9 +53,6 @@ module Avo
53
53
  # app.config.logger = ::Logger.new(STDOUT)
54
54
  end
55
55
 
56
- # Add the outline heroicons to the path
57
- config.assets.paths << Avo::Engine.root.join("app", "assets", "svgs", "heroicons", "outline")
58
-
59
56
  config.app_middleware.use(
60
57
  Rack::Static,
61
58
  urls: ["/avo-assets"],
@@ -0,0 +1,41 @@
1
+ class Avo::SvgFinder
2
+ def self.find_asset(filename)
3
+ new(filename)
4
+ end
5
+
6
+ def initialize(filename)
7
+ @filename = filename
8
+ end
9
+
10
+ # Use the default static finder logic. If that doesn't find anything, search according to our pattern:
11
+ def pathname
12
+ found_asset = if ::Rails.application.config.assets.compile
13
+ asset = ::Rails.application.assets[@filename]
14
+ Pathname.new(asset.filename) if asset.present?
15
+ else
16
+ manifest = ::Rails.application.assets_manifest
17
+ asset_path = manifest.assets[@filename]
18
+ unless asset_path.nil?
19
+ ::Rails.root.join(manifest.directory, asset_path)
20
+ end
21
+ end
22
+
23
+ # Use the found asset
24
+ return found_asset if found_asset.present?
25
+
26
+ paths = [
27
+ Rails.root.join("app", "assets", "svgs", @filename).to_s,
28
+ Rails.root.join(@filename).to_s,
29
+ Avo::Engine.root.join("app", "assets", "svgs", @filename).to_s,
30
+ Avo::Engine.root.join("app", "assets", "svgs", "heroicons", "outline", @filename).to_s,
31
+ Avo::Engine.root.join(@filename).to_s,
32
+ ]
33
+
34
+ path = paths.find do |path|
35
+ File.exist? path
36
+ end
37
+
38
+ path
39
+ end
40
+ end
41
+
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.13.3.pre.3" unless const_defined?(:VERSION)
2
+ VERSION = "2.13.3.pre.4" unless const_defined?(:VERSION)
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.13.3.pre.3
4
+ version: 2.13.3.pre.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
@@ -1297,6 +1297,7 @@ files:
1297
1297
  - lib/avo/resources/controls/link_to.rb
1298
1298
  - lib/avo/services/authorization_service.rb
1299
1299
  - lib/avo/services/uri_service.rb
1300
+ - lib/avo/svg_finder.rb
1300
1301
  - lib/avo/tab.rb
1301
1302
  - lib/avo/tab_builder.rb
1302
1303
  - lib/avo/tab_group.rb