brick 1.0.131 → 1.0.132
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/brick/frameworks/rails/engine.rb +18 -16
- data/lib/brick/frameworks/rails/form_tags.rb +12 -1
- data/lib/brick/version_number.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08cc0b19ab0838b667534f4de64f3a7045bf395202a3602981a20ececdc91ab5'
|
4
|
+
data.tar.gz: 4b976489a05bb26c3702746700025c6bad3bb930fc129ae897bc9e1596a50901
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 580db611d4ab9e2bf7ab0ed62a90940b90a4818619a9a91788802f017845c0aef3c8da1b01ea8a6a87c8e1af8378dc5c0d030396ebebba05d101b46ca0bd4495
|
7
|
+
data.tar.gz: fe876de91852b7213fa4d35b378935c7f18e18ae09ff5058f0d34b32dcb3c802a15d1c2cc79f63f7b5eac4177b7bbbeae43603e55499447cfee9e1d3556f64fa
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Brick
|
4
4
|
module Rails
|
5
5
|
class << self
|
6
|
-
def display_value(col_type, val)
|
6
|
+
def display_value(col_type, val, lat_lng = nil)
|
7
7
|
is_mssql_geography = nil
|
8
8
|
# Some binary thing that really looks like a Microsoft-encoded WGS84 point? (With the first two bytes, E6 10, indicating an EPSG code of 4326)
|
9
9
|
if col_type == :binary && val && val.length < 31 && (val.length - 6) % 8 == 0 && val[0..5].bytes == [230, 16, 0, 0, 1, 12]
|
@@ -61,14 +61,19 @@ module Brick
|
|
61
61
|
::Brick::Rails.display_binary(val)
|
62
62
|
else
|
63
63
|
if col_type
|
64
|
-
|
64
|
+
if lat_lng
|
65
|
+
# Create a link to this style of Google maps URL: https://www.google.com/maps/place/38.7071296+-121.2810649/@38.7071296,-121.2810649,12z
|
66
|
+
"<a href=\"https://www.google.com/maps/place/#{lat_lng.first}+#{lat_lng.last}/@#{lat_lng.first},#{lat_lng.last},12z\" target=\"blank\">#{val}</a>"
|
67
|
+
else
|
68
|
+
::Brick::Rails::FormBuilder.hide_bcrypt(val, col_type == :xml)
|
69
|
+
end
|
65
70
|
else
|
66
71
|
'?'
|
67
72
|
end
|
68
73
|
end
|
69
74
|
end
|
70
75
|
|
71
|
-
def display_binary(val)
|
76
|
+
def display_binary(val, max_size = 100_000)
|
72
77
|
return unless val
|
73
78
|
|
74
79
|
@image_signatures ||= { (+"\xFF\xD8\xFF\xEE").force_encoding('ASCII-8BIT') => 'jpeg',
|
@@ -94,15 +99,12 @@ module Brick
|
|
94
99
|
val = val[object_start...object_start + real_object_size]
|
95
100
|
end
|
96
101
|
|
97
|
-
if (signature = @image_signatures.find { |k, _v| val[0...k.length] == k }) ||
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
else
|
102
|
-
"< #{signature.last} image, #{val.length} bytes >"
|
103
|
-
end
|
102
|
+
if ((signature = @image_signatures.find { |k, _v| val[0...k.length] == k }&.last) ||
|
103
|
+
(val[0..3] == 'RIFF' && val[8..11] == 'WEBP' && binding.local_variable_set(:signature, 'webp'))) &&
|
104
|
+
val.length < max_size
|
105
|
+
"<img src=\"data:image/#{signature.last};base64,#{Base64.encode64(val)}\">"
|
104
106
|
else
|
105
|
-
"< 
|
107
|
+
"< #{signature ? "#{signature} image" : 'Binary'}, #{val.length} bytes >"
|
106
108
|
end
|
107
109
|
end
|
108
110
|
end
|
@@ -1636,10 +1638,10 @@ end
|
|
1636
1638
|
<tr><td colspan=\"2\">(No displayable fields)</td></tr>
|
1637
1639
|
<% end %>
|
1638
1640
|
</table>#{
|
1639
|
-
"<%=
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1641
|
+
"<%= begin
|
1642
|
+
::Brick::Rails.display_binary(obj&.blob&.download, 500_000)&.html_safe
|
1643
|
+
rescue
|
1644
|
+
end %>" if model_name == 'ActiveStorage::Attachment'}
|
1643
1645
|
<% end %>
|
1644
1646
|
|
1645
1647
|
#{unless args.first == 'new'
|
@@ -1674,7 +1676,7 @@ end
|
|
1674
1676
|
collection = collection.instance_exec(&assoc.scopes.first) if assoc.scopes.present?
|
1675
1677
|
if assoc.klass.name == 'ActiveStorage::Attachment'
|
1676
1678
|
br_descrip = begin
|
1677
|
-
::Brick::Rails.display_binary(obj.send(assoc.name)&.blob&.download)&.html_safe
|
1679
|
+
::Brick::Rails.display_binary(obj.send(assoc.name)&.blob&.download, 500_000)&.html_safe
|
1678
1680
|
rescue
|
1679
1681
|
end
|
1680
1682
|
end
|
@@ -139,8 +139,19 @@ module Brick::Rails::FormTags
|
|
139
139
|
out << if @_brick_monetized_attributes&.include?(col_name)
|
140
140
|
val ? Money.new(val.to_i).format : ''
|
141
141
|
else
|
142
|
+
lat_lng = if [:float, :decimal].include?(col.type) &&
|
143
|
+
(
|
144
|
+
((col_name == 'latitude' && obj.respond_to?('longitude') && (lng = obj.send('longitude')) && lng.is_a?(Numeric) && (lat = val)) ||
|
145
|
+
(col_name == 'longitude' && obj.respond_to?('latitude') && (lat = obj.send('latitude')) && lat.is_a?(Numeric) && (lng = val))
|
146
|
+
) ||
|
147
|
+
((col_name == 'lat' && obj.respond_to?('lng') && (lng = obj.send('lng')) && lng.is_a?(Numeric) && (lat = val)) ||
|
148
|
+
(col_name == 'lng' && obj.respond_to?('lat') && (lat = obj.send('lat')) && lat.is_a?(Numeric) && (lng = val))
|
149
|
+
)
|
150
|
+
)
|
151
|
+
[lat, lng]
|
152
|
+
end
|
142
153
|
col_type = col&.sql_type == 'geography' ? col.sql_type : col&.type
|
143
|
-
::Brick::Rails.display_value(col_type || col&.sql_type, val).to_s
|
154
|
+
::Brick::Rails.display_value(col_type || col&.sql_type, val, lat_lng).to_s
|
144
155
|
end
|
145
156
|
elsif cust_col
|
146
157
|
data = cust_col.first.map { |cc_part| obj.send(cc_part.last) }
|
data/lib/brick/version_number.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.132
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lorin Thwaits
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|