brick 1.0.128 → 1.0.129
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/lib/brick/extensions.rb +3 -0
- data/lib/brick/frameworks/rails/engine.rb +36 -21
- data/lib/brick/frameworks/rails/form_tags.rb +8 -1
- data/lib/brick/version_number.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b46bf80d393c0d6e4ffea3e8bfc1fbc03dc667902077efc9a887c8ab046a817
|
4
|
+
data.tar.gz: 927828e46dfd9ae6b7c14aced0f814bbc1d876e5af14aa872a13d2c13af85083
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49073fb48479c8df6805a35632ef321efa3144556feb1e2da701044ce110aa6cfcb8ced12186408929b8c3d6280ca6e393e886ba54eea87f0a622a58f9216e8e
|
7
|
+
data.tar.gz: eaccf857c54a108c764e786b5e8abd0f54ff5abbcadec558138dc947a5d7e3015fc1a5510a311301947cee815d086018e535a15958357abd3463ab59ee375908
|
data/lib/brick/extensions.rb
CHANGED
@@ -864,6 +864,9 @@ JOIN (SELECT #{hm_selects.map { |s| "#{'br_t0.' if from_clause}#{s}" }.join(', '
|
|
864
864
|
def brick_list
|
865
865
|
pks = klass.primary_key.is_a?(String) ? [klass.primary_key] : klass.primary_key
|
866
866
|
selects = pks.each_with_object([]) { |pk, s| s << pk unless s.include?(pk) }
|
867
|
+
# ActiveStorage compatibility
|
868
|
+
selects << 'service_name' if klass.name == 'ActiveStorage::Blob' && ActiveStorage::Blob.columns_hash.key?('service_name')
|
869
|
+
selects << 'blob_id' if klass.name == 'ActiveStorage::Attachment' && ActiveStorage::Attachment.columns_hash.key?('blob_id')
|
867
870
|
pieces, my_dsl = klass.brick_parse_dsl(join_array = ::Brick::JoinArray.new, [], translations = {}, false, nil, true)
|
868
871
|
brick_select(
|
869
872
|
where_values_hash, selects, nil, translations, join_array,
|
@@ -58,7 +58,7 @@ module Brick
|
|
58
58
|
'(Add RGeo gem to parse geometry detail)'
|
59
59
|
end
|
60
60
|
when :binary
|
61
|
-
::Brick::Rails.display_binary(val)
|
61
|
+
::Brick::Rails.display_binary(val)
|
62
62
|
else
|
63
63
|
if col_type
|
64
64
|
::Brick::Rails::FormBuilder.hide_bcrypt(val, col_type == :xml)
|
@@ -69,8 +69,12 @@ module Brick
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def display_binary(val)
|
72
|
+
return unless val
|
73
|
+
|
72
74
|
@image_signatures ||= { (+"\xFF\xD8\xFF\xEE").force_encoding('ASCII-8BIT') => 'jpeg',
|
73
75
|
(+"\xFF\xD8\xFF\xE0\x00\x10\x4A\x46\x49\x46\x00\x01").force_encoding('ASCII-8BIT') => 'jpeg',
|
76
|
+
(+"\xFF\xD8\xFF\xDB").force_encoding('ASCII-8BIT') => 'jpeg',
|
77
|
+
(+"\xFF\xD8\xFF\xE1").force_encoding('ASCII-8BIT') => 'jpeg',
|
74
78
|
(+"\x89PNG\r\n\x1A\n").force_encoding('ASCII-8BIT') => 'png',
|
75
79
|
'<svg' => 'svg+xml', # %%% Not yet very good detection for SVG
|
76
80
|
(+'BM').force_encoding('ASCII-8BIT') => 'bmp',
|
@@ -90,7 +94,8 @@ module Brick
|
|
90
94
|
val = val[object_start...object_start + real_object_size]
|
91
95
|
end
|
92
96
|
|
93
|
-
if (signature = @image_signatures.find { |k, _v| val[0...k.length] == k })
|
97
|
+
if (signature = @image_signatures.find { |k, _v| val[0...k.length] == k }) ||
|
98
|
+
(val[0..3] == 'RIFF' && val[8..11] == 'WEBP' && (signature = 'webp'))
|
94
99
|
if val.length < 500_000
|
95
100
|
"<img src=\"data:image/#{signature.last};base64,#{Base64.encode64(val)}\">"
|
96
101
|
else
|
@@ -1290,7 +1295,7 @@ erDiagram
|
|
1290
1295
|
</head>
|
1291
1296
|
<body>
|
1292
1297
|
<div id=\"titleBox\"><div id=\"titleSticky\">
|
1293
|
-
<p style=\"color: green\"><%= notice %></p>#{"
|
1298
|
+
<p style=\"color: green\"><%= notice if request.respond_to?(:flash) %></p>#{"
|
1294
1299
|
#{schema_options}" if schema_options}
|
1295
1300
|
<select id=\"tbl\">#{table_options}</select>
|
1296
1301
|
<table id=\"resourceName\"><tr>
|
@@ -1411,7 +1416,8 @@ end
|
|
1411
1416
|
brick_grid(@#{table_name}, @_brick_bt_descrip, @_brick_sequence, @_brick_incl, @_brick_excl,
|
1412
1417
|
cols, poly_cols, bts, #{hms_keys.inspect}, {#{hms_columns.join(', ')}}) %>
|
1413
1418
|
|
1414
|
-
#{"<hr><%= link_to
|
1419
|
+
#{"<hr><%= link_to(\"New #{new_path_name = "new_#{path_obj_name}_path"
|
1420
|
+
obj_name}\", #{new_path_name}) if respond_to?(:#{new_path_name}) %>" unless @_brick_model.is_view?}
|
1415
1421
|
#{script}
|
1416
1422
|
</body>
|
1417
1423
|
</html>
|
@@ -1423,7 +1429,7 @@ end
|
|
1423
1429
|
# Must load all models, and then find what table names are represented
|
1424
1430
|
# Easily could be multiple files involved (STI for instance)
|
1425
1431
|
+"#{css}
|
1426
|
-
<p style=\"color: green\"><%= notice %></p>#{"
|
1432
|
+
<p style=\"color: green\"><%= notice if request.respond_to?(:flash) %></p>#{"
|
1427
1433
|
#{schema_options}" if schema_options}
|
1428
1434
|
<select id=\"tbl\">#{table_options}</select>
|
1429
1435
|
<h1>Status</h1>
|
@@ -1473,7 +1479,7 @@ end
|
|
1473
1479
|
when 'orphans'
|
1474
1480
|
if is_orphans
|
1475
1481
|
+"#{css}
|
1476
|
-
<p style=\"color: green\"><%= notice %></p>#{"
|
1482
|
+
<p style=\"color: green\"><%= notice if request.respond_to?(:flash) %></p>#{"
|
1477
1483
|
#{schema_options}" if schema_options}
|
1478
1484
|
<select id=\"tbl\">#{table_options}</select>
|
1479
1485
|
<h1>Orphans<%= \" for #\{}\" if false %></h1>
|
@@ -1520,7 +1526,7 @@ end
|
|
1520
1526
|
c23.141-70.188,89.141-120.906,167.063-120.906c97.25,0,176,78.813,176,176C511.828,227.078,404.391,119.641,271.844,119.641z\" />
|
1521
1527
|
</svg>
|
1522
1528
|
|
1523
|
-
<p style=\"color: green\"><%= notice %></p>#{"
|
1529
|
+
<p style=\"color: green\"><%= notice if request.respond_to?(:flash) %></p>#{"
|
1524
1530
|
#{schema_options}" if schema_options}
|
1525
1531
|
<select id=\"tbl\">#{table_options}</select>
|
1526
1532
|
<table><td><h1><%= page_title %></h1></td>
|
@@ -1555,14 +1561,13 @@ end
|
|
1555
1561
|
%><%= link_to \"(See all #\{model_name.pluralize})\", see_all_path %>
|
1556
1562
|
#{erd_markup}
|
1557
1563
|
<% if obj
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
end
|
1564
|
+
# path_options = [obj.#{pk}]
|
1565
|
+
# path_options << { '_brick_schema': } if
|
1566
|
+
options = {}
|
1567
|
+
if ::Brick.config.path_prefix
|
1568
|
+
path_helper = obj.new_record? ? #{model_name}._brick_index : #{model_name}._brick_index(:singular)
|
1569
|
+
options[:url] = send(\"#\{path_helper}_path\".to_sym, obj)
|
1570
|
+
end
|
1566
1571
|
%>
|
1567
1572
|
<br><br>
|
1568
1573
|
<%= form_for(obj.becomes(#{model_name}), options) do |f| %>
|
@@ -1570,11 +1575,11 @@ end
|
|
1570
1575
|
<% has_fields = false
|
1571
1576
|
@#{obj_name}.attributes.each do |k, val|
|
1572
1577
|
next if !(col = #{model_name}.columns_hash[k]) ||
|
1573
|
-
(#{(pk || []).inspect}.include?(k) && !bts.key?(k)) ||
|
1578
|
+
(#{(pk.map(&:to_s) || []).inspect}.include?(k) && !bts.key?(k)) ||
|
1574
1579
|
::Brick.config.metadata_columns.include?(k) %>
|
1575
1580
|
<tr>
|
1576
1581
|
<th class=\"show-field\"<%= \" title=\\\"#\{col.comment}\\\"\".html_safe if col.respond_to?(:comment) && !col.comment.blank? %>>
|
1577
|
-
|
1582
|
+
<% has_fields = true
|
1578
1583
|
if (bt = bts[k])
|
1579
1584
|
# Add a final member in this array with descriptive options to be used in <select> drop-downs
|
1580
1585
|
bt_name = bt[1].map { |x| x.first.name }.join('/')
|
@@ -1627,7 +1632,11 @@ end
|
|
1627
1632
|
<% else %>
|
1628
1633
|
<tr><td colspan=\"2\">(No displayable fields)</td></tr>
|
1629
1634
|
<% end %>
|
1630
|
-
</table
|
1635
|
+
</table>#{
|
1636
|
+
"<%= binary = begin
|
1637
|
+
::Brick::Rails.display_binary(obj&.blob&.download)&.html_safe
|
1638
|
+
rescue
|
1639
|
+
end %>" if model_name == 'ActiveStorage::Attachment'}
|
1631
1640
|
<% end %>
|
1632
1641
|
|
1633
1642
|
#{unless args.first == 'new'
|
@@ -1660,6 +1669,12 @@ end
|
|
1660
1669
|
# In order to apply DSL properly, evaluate this HO the other way around as if it were as a BT
|
1661
1670
|
collection = assoc.klass.where(assoc.foreign_key => @#{obj_name}.#{pk})
|
1662
1671
|
collection = collection.instance_exec(&assoc.scopes.first) if assoc.scopes.present?
|
1672
|
+
if assoc.klass.name == 'ActiveStorage::Attachment'
|
1673
|
+
br_descrip = begin
|
1674
|
+
::Brick::Rails.display_binary(obj.send(assoc.name)&.blob&.download)&.html_safe
|
1675
|
+
rescue
|
1676
|
+
end
|
1677
|
+
end
|
1663
1678
|
else
|
1664
1679
|
collection = @#{obj_name}.#{hm_name}
|
1665
1680
|
end
|
@@ -1677,9 +1692,9 @@ end
|
|
1677
1692
|
<tr><td>(none)</td></tr>
|
1678
1693
|
<% else
|
1679
1694
|
collection2.each do |#{hm_singular_name}| %>
|
1680
|
-
<tr><td><%= br_descrip
|
1681
|
-
|
1682
|
-
|
1695
|
+
<tr><td><%= br_descrip ||= #{hm_singular_name}.brick_descrip(
|
1696
|
+
descrip_cols&.first&.map { |col| #{hm_singular_name}.send(col.last) }
|
1697
|
+
)
|
1683
1698
|
link_to(br_descrip, #{hm.first.klass._brick_index(:singular)}_path(slashify(#{obj_pk}))) %></td></tr>
|
1684
1699
|
<% end %>
|
1685
1700
|
<% end %>
|
@@ -115,7 +115,14 @@ module Brick::Rails::FormTags
|
|
115
115
|
if col[2] == 'HO'
|
116
116
|
descrips = bt_descrip[col_name.to_sym][hm_klass]
|
117
117
|
if (ho_id = (ho_id_col = descrips.last).map { |id_col| obj.send(id_col.to_sym) })&.first
|
118
|
-
ho_txt = hm_klass.
|
118
|
+
ho_txt = if hm_klass.name == 'ActiveStorage::Attachment'
|
119
|
+
begin
|
120
|
+
::Brick::Rails.display_binary(obj.send(col[3])&.blob&.download)&.html_safe
|
121
|
+
rescue
|
122
|
+
end
|
123
|
+
else
|
124
|
+
hm_klass.brick_descrip(obj, descrips[0..-2].map { |id| obj.send(id.last[0..62]) }, ho_id_col)
|
125
|
+
end
|
119
126
|
out << link_to(ho_txt, send("#{hm_klass.base_class._brick_index(:singular)}_path".to_sym, ho_id))
|
120
127
|
end
|
121
128
|
else
|
data/lib/brick/version_number.rb
CHANGED