hot-glue 0.6.28 → 0.6.29
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/Gemfile.lock +1 -14
- data/README.md +41 -5
- data/lib/generators/hot_glue/fields/attachment_field.rb +11 -2
- data/lib/generators/hot_glue/markup_templates/erb.rb +15 -3
- data/lib/generators/hot_glue/scaffold_generator.rb +25 -8
- data/lib/hot-glue.rb +0 -2
- data/lib/hotglue/version.rb +1 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2adecf8cc5b25919ee16219a6dbf4176a178a1a393adf6a79ae1370a9fe89a9
|
4
|
+
data.tar.gz: 0e02cf776a658911f19bc65f057eb60b57cb04e54a783883e6eb17cc05c0a2fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7789fd5eae2defcc87512f2d10fb3e40c8c68c8ae33380ea072b80239b985edd4f3a1cb4593472fc468e084b4ff480c450ea6edc79384fa3a3013fede972aff6
|
7
|
+
data.tar.gz: 0c5ed6e3d2478c86c6bfa08ed0b4e0306ff9160673c557cb02e633509ce5e93d636b4bd36c11e5d955de5443e5945d71c23caca424979dc9cc0f6377e88b418a
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hot-glue (0.6.
|
4
|
+
hot-glue (0.6.28)
|
5
5
|
ffaker (~> 2.16)
|
6
|
-
kaminari (~> 1.2)
|
7
6
|
rails (> 5.1)
|
8
7
|
|
9
8
|
GEM
|
@@ -114,18 +113,6 @@ GEM
|
|
114
113
|
importmap-rails (1.1.5)
|
115
114
|
actionpack (>= 6.0.0)
|
116
115
|
railties (>= 6.0.0)
|
117
|
-
kaminari (1.2.2)
|
118
|
-
activesupport (>= 4.1.0)
|
119
|
-
kaminari-actionview (= 1.2.2)
|
120
|
-
kaminari-activerecord (= 1.2.2)
|
121
|
-
kaminari-core (= 1.2.2)
|
122
|
-
kaminari-actionview (1.2.2)
|
123
|
-
actionview
|
124
|
-
kaminari-core (= 1.2.2)
|
125
|
-
kaminari-activerecord (1.2.2)
|
126
|
-
activerecord
|
127
|
-
kaminari-core (= 1.2.2)
|
128
|
-
kaminari-core (1.2.2)
|
129
116
|
loofah (2.19.0)
|
130
117
|
crass (~> 1.0.2)
|
131
118
|
nokogiri (>= 1.5.9)
|
data/README.md
CHANGED
@@ -1658,12 +1658,17 @@ bin/rails generate Book --include=name,author_id --search=set --search-fields=na
|
|
1658
1658
|
```
|
1659
1659
|
|
1660
1660
|
### `--phantom-search='{type}_{name}[All|choice A:scope_a|choice B:scope_b]`
|
1661
|
+
`--phantom-search='radio_{name}[All|choice A:scope_a|choice B:scope_b]`
|
1662
|
+
`--phantom-search='checkboxes_{name}[All|choice A:off_scope_a:on_scope_a|choice B:off_scope_b:on_scope_b]`
|
1663
|
+
|
1661
1664
|
|
1662
1665
|
A phantom search is a search we are doing on this result set that doesn't correspond to a single field. Currently, the only available implementation is for scopes with no arguments, as in the example below. It is called 'phantom' because it could be (probably is) querying fields within the scope, but the search doesn't match up with a single field on your model. (So it's like creating 'phantom' criteria.). Only RADIO type is implemented, dropdown & checkboxes an a way to input a search value passed into the scope as an argument is TBD.
|
1663
1666
|
|
1664
|
-
{type} is any of: radio,
|
1667
|
+
{type} is any of: radio, checkboxes (showing one of each type above)
|
1665
1668
|
|
1666
|
-
{name} is a designation for this phantom search.
|
1669
|
+
{name} is a designation for this phantom search.
|
1670
|
+
Should NOT match any field name on your table.
|
1671
|
+
This should describe the kind of categorization we are performing. Name is used for radio only; not shown to the user for checkboxes
|
1667
1672
|
|
1668
1673
|
Your phantom search selector will be appended to the search fields and will be treated like a first-class search input, able to be combined with any of the other fields specified in a set search.
|
1669
1674
|
|
@@ -1676,9 +1681,14 @@ After the type & name, comes a block marked by square braces [ ... ]
|
|
1676
1681
|
|
1677
1682
|
Within the square braces, each search option is separated by a pipe (|) character.
|
1678
1683
|
|
1679
|
-
Within each option is a label and ruby scope, separated by a colon (:).
|
1684
|
+
Within each option is a label and either one ruby scope (for radios) or an OFF scope and ON scope (for checkboxes), separated by a colon (:).
|
1685
|
+
|
1686
|
+
The label comes before the first colon the ruby scope. For checkboxes, you will have two colons followed by an "off" and "on scope'
|
1687
|
+
label:off scope:on scope
|
1688
|
+
|
1689
|
+
The ruby scope can be specified with or without a dot.
|
1680
1690
|
|
1681
|
-
|
1691
|
+
Each ruby scope must be defined on your model. If there is no scope specified (empty), we assume "all", but we still need to specify a label for "All", which is why in the example above "All" has no colon after it.
|
1682
1692
|
|
1683
1693
|
#### Radio Example
|
1684
1694
|
|
@@ -2234,7 +2244,33 @@ These automatic pickups for partials are detected at build time. This means that
|
|
2234
2244
|
|
2235
2245
|
# VERSION HISTORY
|
2236
2246
|
|
2237
|
-
#### 2025-
|
2247
|
+
#### 2025-10-11 - v0.6.39
|
2248
|
+
|
2249
|
+
• When specifying a alt lookup in non-Gd mode, we treat this a security concern because alt lookups can get any related record from the database; if you use a factory when creating your object, you can pass the lookup to the factory and scope your lookup in there; fix to not raise exception when specified an alt lookup in non-Gd mode if you are also using a factory
|
2250
|
+
|
2251
|
+
• Attachments now have a graceful fail if the attachment is invariable (cannot be made into a thumbnail), and so there is no thumbnail to display. Instead, a small box with the file type ("pdf" or "msword") is shown in place where the thumbnail would display
|
2252
|
+
|
2253
|
+
• Adds a 'tripple' implementation for newer pagination gems: will_paginate and pagy. HG will auto detect which pagination gem you have in your Gemfile, and pick ONE of the three based on this preference order: Pagy over will_paginate; will_paginate over Kaminari, no pagination if none of the three are installed.
|
2254
|
+
|
2255
|
+
Kaminari is barely workable with newer Rails and seems somewhat abandoned; will_paginate is officially in maintenance mode, so Pagy is the way to go. I have implemented all three for the widest legacy support. On my Rails Cookbook pages, I have replaced Kaminari with Pagy.
|
2256
|
+
|
2257
|
+
Migrating a large app from Kaminari to Pagy:
|
2258
|
+
|
2259
|
+
- If you rip out Kaminari right away, it will be necessary to rebuild all of your Hot Glue controllers & views. On a large or customized app, this will be too tedious to do at once. Instead, contrary to the Pagy documentation, which encourages you to aggressively rip out the old gem (Kaminari), you can leave both gems in place, operating side-by-side. As you rebuild each scaffold controller by controller, newly built scaffolds will use Pagy, replacing the older Kaminari syntax.
|
2260
|
+
|
2261
|
+
• Hot Glue is now _OFFICIALLY dependency-free_! I've been building and working with Rails gems for years and years, and one of the interesting challenges that Rails 7 & 8 posed is that when the JavaScript and CSS delivery paradigms shift, it caused a massive atrophy of several old Rails gems. Codebases that relied on, for example, the old jquery-rails gem suddenly found themselves pantless. JS tool-only Gems are now discouraged, in favor of importmaps, propshaft, or JSBundling.
|
2262
|
+
|
2263
|
+
When you build a gem, the naive gem builder thinks to themselves: Let me pull in other people's tools to make my tool stand on the shoulders of giants.
|
2264
|
+
|
2265
|
+
But when paradigms shift, those gems the gem depends on become a blocker for your Gem moving forward.
|
2266
|
+
|
2267
|
+
I already had very few dependencies in Hot Glue — really just Rspec, Kaminari, and Rails itself. Although you need Turbo (and by extension JS), bootstrap is optional (but recommended), and Rspec is optional (but default).
|
2268
|
+
|
2269
|
+
The ONLY remaining dependency is ffaker (sorry!), which is necessary for the specs.
|
2270
|
+
|
2271
|
+
Hot Glue is a companion tool to Turbo itself. Where Turbo Rails goes, we go. Although this gem is primarily built for Bootstrap, Bootstrap remains officially optional. Although you need Turbo for it to work, how you bring Turbo is up to you (bundling, pinning, propshafting, etc). With the removal of Kaminari and new support for will_paginate and Pagy, I hope this Gem can be integrated into more apps who may already have chosen their pagination system.
|
2272
|
+
|
2273
|
+
#### 2025-09-26 - v0.6.28
|
2238
2274
|
- Checkboxes option for Phantom Search (previously phantom searches only supported radio).
|
2239
2275
|
See "Checkboxes example" under the docs for `--phantom-search` above
|
2240
2276
|
|
@@ -42,7 +42,16 @@ def spec_setup_and_change_act(which_partial = nil)
|
|
42
42
|
|
43
43
|
def line_field_output
|
44
44
|
thumbnail = attachment_data[:thumbnail]
|
45
|
-
|
46
|
-
|
45
|
+
if thumbnail
|
46
|
+
"<% if #{singular}.#{name}.attached? %>
|
47
|
+
<% if !#{singular}.#{name}.variable? %>
|
48
|
+
<span class=\"badge bg-secondary\"><%= #{singular}.#{name}.blob.content_type.split('/')[1] %></span>
|
49
|
+
<% else %>
|
50
|
+
<%= image_tag(#{singular}.#{name}.variant(:thumb)) %>
|
51
|
+
<% end %>
|
52
|
+
<% end %>"
|
53
|
+
else
|
54
|
+
""
|
55
|
+
end
|
47
56
|
end
|
48
57
|
end
|
@@ -12,7 +12,7 @@ module HotGlue
|
|
12
12
|
:search, :search_fields, :search_query_fields, :search_position,
|
13
13
|
:form_path, :layout_object, :search_clear_button, :search_autosearch,
|
14
14
|
:stimmify, :stimmify_camel, :hidden_create, :hidden_update, :invisible_create,
|
15
|
-
:invisible_update, :plural, :phantom_search
|
15
|
+
:invisible_update, :plural, :phantom_search, :pagination_style
|
16
16
|
|
17
17
|
|
18
18
|
def initialize(singular:, singular_class: ,
|
@@ -25,7 +25,8 @@ module HotGlue
|
|
25
25
|
search:, search_fields:, search_query_fields: , search_position:,
|
26
26
|
search_clear_button:, search_autosearch:, layout_object:,
|
27
27
|
form_path: , stimmify: , stimmify_camel:, hidden_create:, hidden_update: ,
|
28
|
-
invisible_create:, invisible_update: , plural: , phantom_search
|
28
|
+
invisible_create:, invisible_update: , plural: , phantom_search:,
|
29
|
+
pagination_style: )
|
29
30
|
|
30
31
|
|
31
32
|
@form_path = form_path
|
@@ -66,6 +67,7 @@ module HotGlue
|
|
66
67
|
@attachments = attachments
|
67
68
|
@related_sets = related_sets
|
68
69
|
@phantom_search = phantom_search
|
70
|
+
@pagination_style = pagination_style
|
69
71
|
end
|
70
72
|
|
71
73
|
def add_spaces_each_line(text, num_spaces)
|
@@ -266,7 +268,17 @@ module HotGlue
|
|
266
268
|
def paginate(*args)
|
267
269
|
plural = args[0][:plural]
|
268
270
|
|
269
|
-
|
271
|
+
if @pagination_style == "kaminari"
|
272
|
+
"<% if #{plural}.respond_to?(:total_pages) %><%= paginate(#{plural}) %> <% end %>"
|
273
|
+
elsif @pagination_style == "will_paginate"
|
274
|
+
"<% if #{plural}.respond_to?(:total_pages) %><%= will_paginate(#{plural}) %> <% end %>"
|
275
|
+
elsif @pagination_style == "pagy"
|
276
|
+
if !@layout_strategy == "bootstrap"
|
277
|
+
"<%== pagy_nav(@pagy, anchor_string: 'data-turbo-action=\"advance\"') %>"
|
278
|
+
else
|
279
|
+
"<%== pagy_bootstrap_nav(@pagy, anchor_string: 'data-turbo-action=\"advance\"') %>"
|
280
|
+
end
|
281
|
+
end
|
270
282
|
end
|
271
283
|
|
272
284
|
|
@@ -166,6 +166,15 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
166
166
|
@stimulus_syntax = true
|
167
167
|
end
|
168
168
|
|
169
|
+
|
170
|
+
if Gem::Specification.find_all_by_name('pagy').any?
|
171
|
+
@pagination_style = 'pagy'
|
172
|
+
elsif Gem::Specification.find_all_by_name('will_paginate').any?
|
173
|
+
@pagination_style = 'will_paginate'
|
174
|
+
elsif Gem::Specification.find_all_by_name('kaminari').any?
|
175
|
+
@pagination_style = 'kaminari'
|
176
|
+
end
|
177
|
+
|
169
178
|
if !options['markup'].nil?
|
170
179
|
message = "Using --markup flag in the generator is deprecated; instead, use a file at config/hot_glue.yml with a key markup set to `erb` or `haml`"
|
171
180
|
raise(HotGlue::Error, message)
|
@@ -704,7 +713,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
704
713
|
raise "You specified an alt-lookup for #{key} but that field is not an association field"
|
705
714
|
elsif !@columns_map[key.to_sym]
|
706
715
|
raise "You specified an alt-lookup for #{key} but that field does not exist in the list of columns"
|
707
|
-
elsif !@god && !@hawk_keys.include?(key.to_sym)
|
716
|
+
elsif !@god && !@hawk_keys.include?(key.to_sym) && !@factory_creation
|
708
717
|
raise "You specified an alt-lookup for #{key} in non-Gd mode but this would leave the lookup unprotected. To fix, use with --hawk or with --factory-creation "
|
709
718
|
end
|
710
719
|
end
|
@@ -845,7 +854,8 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
845
854
|
hidden_update: @hidden_update,
|
846
855
|
invisible_create: @invisible_create,
|
847
856
|
invisible_update: @invisible_update,
|
848
|
-
phantom_search: @phantom_search
|
857
|
+
phantom_search: @phantom_search,
|
858
|
+
pagination_style: @pagination_style
|
849
859
|
)
|
850
860
|
elsif @markup == "slim"
|
851
861
|
raise(HotGlue::Error, "SLIM IS NOT IMPLEMENTED")
|
@@ -1448,10 +1458,10 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1448
1458
|
def any_nested?
|
1449
1459
|
@nested_set.any?
|
1450
1460
|
end
|
1451
|
-
|
1452
|
-
def all_objects_variable
|
1453
|
-
|
1454
|
-
end
|
1461
|
+
#
|
1462
|
+
# def all_objects_variable
|
1463
|
+
# all_objects_root + ".page(params[:page])"
|
1464
|
+
# end
|
1455
1465
|
|
1456
1466
|
def auth_object
|
1457
1467
|
@auth
|
@@ -1815,7 +1825,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1815
1825
|
else
|
1816
1826
|
if !@self_auth
|
1817
1827
|
|
1818
|
-
res << spaces(4) + "@#{ plural_name } = #{ object_scope.gsub("@",'') }#{ n_plus_one_includes }#{record_scope}"
|
1828
|
+
res << spaces(4) + "@#{ plural_name } = #{ object_scope.gsub("@",'') }#{ n_plus_one_includes }#{record_scope}#{".all" if n_plus_one_includes.blank? && record_scope.blank? }"
|
1819
1829
|
|
1820
1830
|
if @search_fields
|
1821
1831
|
res << @search_fields.collect{ |field|
|
@@ -1870,7 +1880,14 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1870
1880
|
res << "\n"
|
1871
1881
|
end
|
1872
1882
|
|
1873
|
-
|
1883
|
+
|
1884
|
+
if @pagination_style == "kaminari"
|
1885
|
+
res << " @#{plural} = @#{plural}.page(params[:page])#{ ".per(per)" if @paginate_per_page_selector }"
|
1886
|
+
elsif @pagination_style == "will_paginate"
|
1887
|
+
res << " @#{plural} = @#{plural}.paginate(page: params[:page], #{ ", per_page: per" if @paginate_per_page_selector })"
|
1888
|
+
elsif @pagination_style == "pagy"
|
1889
|
+
res << " @pagy, @#{plural} = pagy(@#{plural})"
|
1890
|
+
end
|
1874
1891
|
res
|
1875
1892
|
end
|
1876
1893
|
|
data/lib/hot-glue.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "hotglue/engine"
|
2
|
-
require 'kaminari'
|
3
2
|
|
4
3
|
module HotGlue
|
5
4
|
module TemplateBuilders
|
@@ -10,7 +9,6 @@ module HotGlue
|
|
10
9
|
class Error < StandardError
|
11
10
|
end
|
12
11
|
|
13
|
-
|
14
12
|
def self.to_camel_case(str)
|
15
13
|
words = str.split(/[^a-zA-Z0-9]/) # split by non-alphanumeric characters
|
16
14
|
return '' if words.empty?
|
data/lib/hotglue/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hot-glue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Fleetwood-Boldt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '5.1'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: kaminari
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.2'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.2'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: ffaker
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|