inline_forms 8.1.66 → 8.1.70

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: 7d798e9e7a6d981b422009a82073f77675148cfcd17263b501067d7d6e0a3b57
4
- data.tar.gz: 76876893fbad74dd364b02c21f927bc414cb86b2b6e7a89b1caa5a3a941bab4d
3
+ metadata.gz: bba553f79844842a8f729c901f5b80e7e9648d5d3aa87f24ac27b639d912e1a6
4
+ data.tar.gz: 6ebc4014b08c59dc54ac2477a911fe52ce5dbec418eee026746986fe472ea295
5
5
  SHA512:
6
- metadata.gz: d1c4624d5315833d86d2578112d2f494b8f7cd32219698de060afbc7570a638fb98c5bf07fd376de87854b264c85521033da2c88920093c3552b5925c5062c8b
7
- data.tar.gz: dab2278a87d37e9005baafc360503a0a767cbd95ce1e20ad0484463098d65763547daac3f25c6e16ca1707ca8ee92ef7e9f922ffdfce996c74670af849f028bc
6
+ metadata.gz: 65785f30dad13fe689f34c0470542ac68472c084a40aea628a7855cd9f38a517bede9e2443f05143253531f540d890145eb3ffbce9ab6a30be7836feb6992ca1
7
+ data.tar.gz: 4eb53f8cf94cfedbc2fcec376e74522b002f8093dda8beee33db4a4298f12526a61f1dd465e541163df5c0ad36917f42007ee3d43c05dc301d798847fd5d10dc
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # Brakeman on a generated app together with the engine code.
4
+ #
5
+ # .forgejo/brakeman-engine.sh APP [extra brakeman options]
6
+ #
7
+ # Brakeman skips gem code, so scanning the app alone never looks at the
8
+ # engine's controllers, helpers and views. Scanning the engine alone does not
9
+ # work either: without an app Brakeman cannot tell the Rails version and the
10
+ # templates do not parse. So: a temporary copy of APP with the engine's code
11
+ # in engines/, scanned as one application. APP itself is not touched.
12
+ #
13
+ # Accepted warnings, each with its reason, are in brakeman.ignore beside this
14
+ # file; --ensure-ignore-notes fails on one without a reason, and
15
+ # --ensure-no-obsolete-ignore-entries on one that no longer occurs. The paths
16
+ # in the copy are relative and fixed (engines/...), because Brakeman's
17
+ # fingerprints include them.
18
+ #
19
+ # Not scanned: lib/installer_templates and lib/generators (they produce code;
20
+ # what they produce is in APP).
21
+
22
+ set -euo pipefail
23
+
24
+ here=$(cd "$(dirname "$0")" && pwd)
25
+ root=$(dirname "$here")
26
+ app=$(cd "${1:?usage: brakeman-engine.sh APP [brakeman options]}" && pwd)
27
+ shift
28
+
29
+ work=$(mktemp -d)
30
+ trap 'rm -rf "$work"' EXIT
31
+ mkdir -p "$work/app/engines/inline_forms" "$work/app/engines/inline_forms_schema_edit"
32
+
33
+ # No keys or credentials: Brakeman does not need them.
34
+ tar -C "$app" --exclude='*.key' --exclude='credentials*' -cf - \
35
+ app config lib Gemfile Gemfile.lock | tar -C "$work/app" -xf -
36
+
37
+ for part in app config lib; do
38
+ if [ -d "$root/$part" ]; then
39
+ cp -R "$root/$part" "$work/app/engines/inline_forms/"
40
+ fi
41
+ if [ -d "$root/inline_forms_schema_edit/$part" ]; then
42
+ cp -R "$root/inline_forms_schema_edit/$part" "$work/app/engines/inline_forms_schema_edit/"
43
+ fi
44
+ done
45
+ rm -rf "$work/app/engines/inline_forms/lib/installer_templates" \
46
+ "$work/app/engines/inline_forms/lib/generators"
47
+
48
+ brakeman --no-pager \
49
+ --add-engines-path engines/inline_forms,engines/inline_forms_schema_edit \
50
+ -i "$here/brakeman.ignore" --ensure-ignore-notes --ensure-no-obsolete-ignore-entries \
51
+ --path "$work/app" "$@"
@@ -0,0 +1,211 @@
1
+ {
2
+ "ignored_warnings": [
3
+ {
4
+ "warning_type": "SQL Injection",
5
+ "warning_code": 0,
6
+ "fingerprint": "09d9d139a9c55d2f8ddc853b4e488d8b90a22e81f9b808d5ac60503296a17c40",
7
+ "check_name": "SQL",
8
+ "message": "Possible SQL injection",
9
+ "file": "engines/inline_forms/app/controllers/inline_forms_controller.rb",
10
+ "line": 181,
11
+ "link": "https://brakemanscanner.org/docs/warning_types/sql_injection/",
12
+ "code": "(self.controller_name.classify.constantize.accessible_by(current_ability) or self.controller_name.classify.constantize.all).merge(self.controller_name.classify.constantize.inline_forms_list).merge(self.controller_name.classify.constantize.inline_forms_search(params[:search])).where((nil or [\"#{(self.controller_name.classify.constantize.reflect_on_association(params[:parent_class].underscore.to_sym).options[:foreign_key] or params[:parent_class].foreign_key)} = ?\", params[:parent_id]]))",
13
+ "render_path": null,
14
+ "location": {
15
+ "type": "method",
16
+ "class": "InlineFormsController",
17
+ "method": "create"
18
+ },
19
+ "user_input": "params[:parent_class].underscore.to_sym",
20
+ "confidence": "Medium",
21
+ "cwe_id": [
22
+ 89
23
+ ],
24
+ "note": "parent_class and parent_id are refused (400) by refuse_malformed_parent_params unless parent_class names a belongs_to association of the model and parent_id is all digits; foreign_key comes from the model's reflection or that class name, and parent_id is a bind value. Tests: test/integration/list_params_test.rb."
25
+ },
26
+ {
27
+ "warning_type": "SQL Injection",
28
+ "warning_code": 0,
29
+ "fingerprint": "0ea384debe73789ae09a12359f268b7362bec05090e670f180ab1434d822a012",
30
+ "check_name": "SQL",
31
+ "message": "Possible SQL injection",
32
+ "file": "engines/inline_forms/app/views/inline_forms/_list.html.erb",
33
+ "line": 41,
34
+ "link": "https://brakemanscanner.org/docs/warning_types/sql_injection/",
35
+ "code": "(parent_class.find(parent_id).send(attribute) or parent_class.find(parent_id).send(attribute).accessible_by(current_ability)).merge(attribute.to_s.singularize.camelcase.constantize.inline_forms_list).where([\"#{attribute.to_s.singularize.camelcase.constantize.table_name}.#{(parent_class.reflect_on_association(attribute.to_sym).options[:foreign_key] or parent_class.name.foreign_key)} = ?\", parent_id])",
36
+ "render_path": [
37
+ {
38
+ "type": "controller",
39
+ "class": "InlineFormsController",
40
+ "method": "index",
41
+ "line": 105,
42
+ "file": "engines/inline_forms/app/controllers/inline_forms_controller.rb",
43
+ "rendered": {
44
+ "name": "inline_forms/_list",
45
+ "file": "engines/inline_forms/app/views/inline_forms/_list.html.erb"
46
+ }
47
+ }
48
+ ],
49
+ "location": {
50
+ "type": "template",
51
+ "template": "inline_forms/_list"
52
+ },
53
+ "user_input": "parent_class.reflect_on_association(attribute.to_sym).options[:foreign_key]",
54
+ "confidence": "Weak",
55
+ "cwe_id": [
56
+ 89
57
+ ],
58
+ "note": "In this branch parent_class is a class passed by _show.html.erb, not a param, and foreign_key is the association's foreign key or the class name's. parent_id is a bind value."
59
+ },
60
+ {
61
+ "warning_type": "Remote Code Execution",
62
+ "warning_code": 24,
63
+ "fingerprint": "61c8f32dd8829cb209a4136d62ff04f729a3f04ea1d1c69b64728ecabc1f4c66",
64
+ "check_name": "UnsafeReflection",
65
+ "message": "Unsafe reflection method `constantize` called on parameter value",
66
+ "file": "engines/inline_forms/app/views/inline_forms/_list.html.erb",
67
+ "line": 19,
68
+ "link": "https://brakemanscanner.org/docs/warning_types/remote_code_execution/",
69
+ "code": "params[:parent_class].constantize",
70
+ "render_path": [
71
+ {
72
+ "type": "controller",
73
+ "class": "InlineFormsController",
74
+ "method": "index",
75
+ "line": 105,
76
+ "file": "engines/inline_forms/app/controllers/inline_forms_controller.rb",
77
+ "rendered": {
78
+ "name": "inline_forms/_list",
79
+ "file": "engines/inline_forms/app/views/inline_forms/_list.html.erb"
80
+ }
81
+ }
82
+ ],
83
+ "location": {
84
+ "type": "template",
85
+ "template": "inline_forms/_list"
86
+ },
87
+ "user_input": "params[:parent_class]",
88
+ "confidence": "High",
89
+ "cwe_id": [
90
+ 470
91
+ ],
92
+ "note": "@parent_class is only set in index, new and create, and the before_action refuse_malformed_parent_params covers index, new, create and show: parent_class is blank or the class name of a non-polymorphic belongs_to of the controller's model, so no other class is constantized. Tests: test/integration/list_params_test.rb."
93
+ },
94
+ {
95
+ "warning_type": "Dangerous Send",
96
+ "warning_code": 23,
97
+ "fingerprint": "67076d627523cb3c2746069c8e98d2261b3fcfe04a11463f6eb56e4f10e789a4",
98
+ "check_name": "Send",
99
+ "message": "User controlled method execution",
100
+ "file": "engines/inline_forms/app/controllers/inline_forms_controller.rb",
101
+ "line": 221,
102
+ "link": "https://brakemanscanner.org/docs/warning_types/dangerous_send/",
103
+ "code": "send(\"#{params[:form_element]}_update\", referenced_object, params[:attribute])",
104
+ "render_path": null,
105
+ "location": {
106
+ "type": "method",
107
+ "class": "InlineFormsController",
108
+ "method": "update"
109
+ },
110
+ "user_input": "params[:form_element]",
111
+ "confidence": "High",
112
+ "cwe_id": [
113
+ 77
114
+ ],
115
+ "note": "field_request_permitted?(:update) runs first and refuses (400) unless attribute and form_element name a row of the model's own attribute list, so only the *_update method of a declared form element can be called."
116
+ },
117
+ {
118
+ "warning_type": "Dangerous Send",
119
+ "warning_code": 23,
120
+ "fingerprint": "6988827dc9c767b44428caabc78a6c8596ad933a406ae1a32b85ae3fd4a4ed23",
121
+ "check_name": "Send",
122
+ "message": "User controlled method execution",
123
+ "file": "engines/inline_forms/app/controllers/inline_forms_controller.rb",
124
+ "line": 259,
125
+ "link": "https://brakemanscanner.org/docs/warning_types/dangerous_send/",
126
+ "code": "referenced_object.send(params[:attribute])",
127
+ "render_path": null,
128
+ "location": {
129
+ "type": "method",
130
+ "class": "InlineFormsController",
131
+ "method": "show"
132
+ },
133
+ "user_input": "params[:attribute]",
134
+ "confidence": "High",
135
+ "cwe_id": [
136
+ 77
137
+ ],
138
+ "note": "field_request_permitted?(:read) refuses (400) unless attribute and form_element name a row of the model's own attribute list, then authorizes the attribute. With no attribute the send is of nil, which raises. Covers the associated and has_one branches of show."
139
+ },
140
+ {
141
+ "warning_type": "Command Injection",
142
+ "warning_code": 14,
143
+ "fingerprint": "70ea329216e82770ca0de3975a7082e37fe86e417b021e68f95cc6e823e14a77",
144
+ "check_name": "Execute",
145
+ "message": "Possible command injection",
146
+ "file": "engines/inline_forms/lib/inline_forms_installer/create_log.rb",
147
+ "line": 55,
148
+ "link": "https://brakemanscanner.org/docs/warning_types/command_injection/",
149
+ "code": "system(\"bash\", \"-c\", \"#{shell_command} 2>&1 | tee -a #{Shellwords.escape(File.expand_path(basename_for(started_at)))}; exit ${PIPESTATUS[0]}\")",
150
+ "render_path": null,
151
+ "location": {
152
+ "type": "method",
153
+ "class": "InlineFormsInstaller::CreateLog",
154
+ "method": "tee_rails_new"
155
+ },
156
+ "user_input": "shell_command",
157
+ "confidence": "Medium",
158
+ "cwe_id": [
159
+ 77
160
+ ],
161
+ "note": "Installer command line, not reachable from a web request. shell_command is built by Creator#create from the rails command, the app name (checked against its regex first) and a path in the installer; the operator runs it as themself."
162
+ },
163
+ {
164
+ "warning_type": "Dangerous Send",
165
+ "warning_code": 23,
166
+ "fingerprint": "a858a85120c0ef89f96452d8bcb0d01664507ceb2ae4d834cfc237403b4b93a8",
167
+ "check_name": "Send",
168
+ "message": "User controlled method execution",
169
+ "file": "engines/inline_forms/app/controllers/inline_forms_controller.rb",
170
+ "line": 258,
171
+ "link": "https://brakemanscanner.org/docs/warning_types/dangerous_send/",
172
+ "code": "referenced_object.send((params[:attribute].to_s.singularize + \"_ids\"))",
173
+ "render_path": null,
174
+ "location": {
175
+ "type": "method",
176
+ "class": "InlineFormsController",
177
+ "method": "show"
178
+ },
179
+ "user_input": "(params[:attribute].to_s.singularize + \"_ids\")",
180
+ "confidence": "High",
181
+ "cwe_id": [
182
+ 77
183
+ ],
184
+ "note": "field_request_permitted?(:read) refuses (400) unless attribute and form_element name a row of the model's own attribute list, so only <association>_ids of a declared association is called."
185
+ },
186
+ {
187
+ "warning_type": "SQL Injection",
188
+ "warning_code": 0,
189
+ "fingerprint": "ad2b4dd8ced8aa1edf48bfbb80730b2bd4dadc84a15de67fd9dde25d81c46e00",
190
+ "check_name": "SQL",
191
+ "message": "Possible SQL injection",
192
+ "file": "engines/inline_forms/app/controllers/inline_forms_controller.rb",
193
+ "line": 64,
194
+ "link": "https://brakemanscanner.org/docs/warning_types/sql_injection/",
195
+ "code": "self.controller_name.classify.constantize.all.merge(self.controller_name.classify.constantize.inline_forms_list).merge(self.controller_name.classify.constantize.inline_forms_search(params[:search])).where((nil or [\"#{(self.controller_name.classify.constantize.reflect_on_association(params[:parent_class].underscore.to_sym).options[:foreign_key] or params[:parent_class].foreign_key)} = ?\", params[:parent_id]]))",
196
+ "render_path": null,
197
+ "location": {
198
+ "type": "method",
199
+ "class": "InlineFormsController",
200
+ "method": "index"
201
+ },
202
+ "user_input": "params[:parent_class].underscore.to_sym",
203
+ "confidence": "Medium",
204
+ "cwe_id": [
205
+ 89
206
+ ],
207
+ "note": "parent_class and parent_id are refused (400) by refuse_malformed_parent_params unless parent_class names a belongs_to association of the model and parent_id is all digits; foreign_key comes from the model's reflection or that class name, and parent_id is a bind value. Tests: test/integration/list_params_test.rb."
208
+ }
209
+ ],
210
+ "brakeman_version": "8.1.1"
211
+ }
@@ -1,7 +1,9 @@
1
1
  # CI for Forgejo Actions (runner on dev02, jobs run in Docker containers).
2
- # Mirrors the Papiamentu setup: runner label `docker`, shared CI image
3
- # `papiamentu-ci:ruby-4.0.4-node20` (same Ruby as these gems; node for the
4
- # checkout/cache actions). See stuff/2026-07-06-forgejo-ci-rubocop-brakeman.md.
2
+ #
3
+ # No Node: the job runs in the official ruby image (same Ruby as these gems) and
4
+ # uses only shell steps. actions/checkout and actions/cache are JavaScript and
5
+ # need node inside the container, so the checkouts are plain git and the gems
6
+ # are installed fresh each run.
5
7
  #
6
8
  # GitHub deliberately has NO workflows (.github/workflows was removed in
7
9
  # 8.1.34): pushing to GitHub triggers nothing; CI runs only on Forgejo.
@@ -18,29 +20,38 @@ jobs:
18
20
  test:
19
21
  runs-on: docker
20
22
  container:
21
- image: papiamentu-ci:ruby-4.0.4-node20
23
+ image: docker.io/library/ruby:4.0.10
22
24
  steps:
23
- - uses: actions/checkout@v4
24
- with:
25
- path: inline_forms
25
+ - name: Check out inline_forms
26
+ env:
27
+ TOKEN: ${{ github.token }}
28
+ SERVER: ${{ github.server_url }}
29
+ REPO: ${{ github.repository }}
30
+ SHA: ${{ github.sha }}
31
+ run: |
32
+ auth=$(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)
33
+ git init -q inline_forms
34
+ cd inline_forms
35
+ git -c http.extraHeader="Authorization: basic $auth" fetch -q --depth 1 "$SERVER/$REPO.git" "$SHA"
36
+ git checkout -q FETCH_HEAD
37
+ git log --oneline -1
26
38
 
27
39
  # The dev Gemfile points at the validation_hints sibling
28
40
  # (gem "validation_hints", path: "../validation_hints"). The job's
29
41
  # automatic token is scoped to this repo only and validation_hints is
30
42
  # private, so the repo secret VALIDATION_HINTS (a token with read
31
43
  # access to ace/validation_hints) authorizes the checkout.
32
- - uses: actions/checkout@v4
33
- with:
34
- repository: ace/validation_hints
35
- token: ${{ secrets.VALIDATION_HINTS }}
36
- path: validation_hints
37
-
38
- - name: Cache gems
39
- uses: actions/cache@v4
40
- with:
41
- path: inline_forms/vendor/bundle
42
- key: gems-inline_forms-${{ hashFiles('inline_forms/Gemfile', 'inline_forms/inline_forms.gemspec') }}
43
- restore-keys: gems-inline_forms-
44
+ - name: Check out validation_hints
45
+ env:
46
+ TOKEN: ${{ secrets.VALIDATION_HINTS }}
47
+ SERVER: ${{ github.server_url }}
48
+ run: |
49
+ auth=$(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)
50
+ git init -q validation_hints
51
+ cd validation_hints
52
+ git -c http.extraHeader="Authorization: basic $auth" fetch -q --depth 1 "$SERVER/ace/validation_hints.git" HEAD
53
+ git checkout -q FETCH_HEAD
54
+ git log --oneline -1
44
55
 
45
56
  - name: Install gems
46
57
  working-directory: inline_forms
@@ -2,14 +2,20 @@
2
2
  # generate the example app (which runs its own 150+ test suite as part of
3
3
  # `inline_forms create`), then run Brakeman against the generated app.
4
4
  #
5
- # Brakeman is aimed at Rails *applications*; scanning the generated MyApp
6
- # covers the engine's controllers/views in their real app context plus
7
- # everything the installer writes — scanning the bare engine repo would
8
- # skip most checks. bundler-audit for the engine runs in ci.yml.
5
+ # Brakeman is aimed at Rails *applications* and skips gem code, so it runs
6
+ # twice: on the generated MyApp (everything the installer writes), and on
7
+ # MyApp together with the engine's own controllers, helpers and views
8
+ # (.forgejo/brakeman-engine.sh; accepted warnings, with their reasons, in
9
+ # .forgejo/brakeman.ignore). bundler-audit for the engine runs in ci.yml.
9
10
  #
10
11
  # Heavy (~3-4 min: rails new + bundle + migrations + tests), so it runs on
11
12
  # demand and weekly, not per push. Requires network access to rubygems.org
12
13
  # from the runner (same as Papiamentu's bundle install).
14
+ #
15
+ # No Node: the official ruby image and plain git, as in ci.yml. The generated
16
+ # app's autoprefixer-rails needs a JavaScript runtime; ExecJS takes mini_racer,
17
+ # which `bundle install` installs because no group is excluded (it is in the
18
+ # app's production group).
13
19
  name: Full gate
14
20
 
15
21
  on:
@@ -21,17 +27,33 @@ jobs:
21
27
  full-gate:
22
28
  runs-on: docker
23
29
  container:
24
- image: papiamentu-ci:ruby-4.0.4-node20
30
+ image: docker.io/library/ruby:4.0.10
25
31
  steps:
26
- - uses: actions/checkout@v4
27
- with:
28
- path: inline_forms
32
+ - name: Check out inline_forms
33
+ env:
34
+ TOKEN: ${{ github.token }}
35
+ SERVER: ${{ github.server_url }}
36
+ REPO: ${{ github.repository }}
37
+ SHA: ${{ github.sha }}
38
+ run: |
39
+ auth=$(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)
40
+ git init -q inline_forms
41
+ cd inline_forms
42
+ git -c http.extraHeader="Authorization: basic $auth" fetch -q --depth 1 "$SERVER/$REPO.git" "$SHA"
43
+ git checkout -q FETCH_HEAD
44
+ git log --oneline -1
29
45
 
30
- - uses: actions/checkout@v4
31
- with:
32
- repository: ace/validation_hints
33
- token: ${{ secrets.VALIDATION_HINTS }}
34
- path: validation_hints
46
+ - name: Check out validation_hints
47
+ env:
48
+ TOKEN: ${{ secrets.VALIDATION_HINTS }}
49
+ SERVER: ${{ github.server_url }}
50
+ run: |
51
+ auth=$(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)
52
+ git init -q validation_hints
53
+ cd validation_hints
54
+ git -c http.extraHeader="Authorization: basic $auth" fetch -q --depth 1 "$SERVER/ace/validation_hints.git" HEAD
55
+ git checkout -q FETCH_HEAD
56
+ git log --oneline -1
35
57
 
36
58
  - name: Build the four gems
37
59
  run: |
@@ -75,3 +97,8 @@ jobs:
75
97
  # Pedantic full set stays informational: it includes checks that
76
98
  # can fire on perfectly reasonable future code.
77
99
  brakeman --run-all-checks --no-pager || true
100
+
101
+ # ENFORCING: a warning that is not in .forgejo/brakeman.ignore fails, and
102
+ # so does an entry there that has no reason or no longer occurs.
103
+ - name: Brakeman against the app together with the engine
104
+ run: bash inline_forms/.forgejo/brakeman-engine.sh apps/MyApp
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-4.0.4
1
+ ruby-4.0.10
data/CHANGELOG.md CHANGED
@@ -8,6 +8,68 @@ All notable changes to this project are documented in this file.
8
8
 
9
9
  - Known issues, parked (local note `stuff/2026-10-31-dropdown-rule-3-parked.md`) with dropdown order rule 3: `includes`, `group` or `select` in `inline_forms_list` make `dropdown` and `dropdown_with_other` raise while `/index` works, so 8.1.65's fix for a list order on a joined table holds only for `joins`, `left_joins` and `eager_load`; a has_many join gives duplicate options. Present since 8.1.60. No host's list scope has these today. Parked; not changed.
10
10
 
11
+ ## [8.1.70] - 2026-11-22
12
+
13
+ ### Changed
14
+
15
+ - **Rails 8.1.4.1 is the minimum** (was 8.1.0; still `< 8.2`). Older 8.1 releases have known vulnerabilities, up to critical (Active Storage file read and write, CVE-2026-122006). A host on an older Rails updates Rails together with inline_forms: `bundle update --conservative rails inline_forms inline_forms_installer inline_forms_schema_edit validation_hints`, naming the ones it uses.
16
+
17
+ ### CI
18
+
19
+ - The full gate runs Brakeman on the engine's own code too: `.forgejo/brakeman-engine.sh` scans the generated app together with the engine and `inline_forms_schema_edit`. Brakeman skips gem code, so until now the engine was not scanned. Accepted warnings are in `.forgejo/brakeman.ignore`, each with its reason.
20
+
21
+ ## [8.1.69] - 2026-11-22
22
+
23
+ ### Changed
24
+
25
+ - **Installer: generated apps use terser instead of uglifier,** and compress JavaScript on `assets:precompile`: the production group has `terser` next to `mini_racer` (its ExecJS runtime, so no Node), and `config/environments/production.rb` gets `config.assets.js_compressor = :terser`. Before, uglifier was in the Gemfile but nothing set a compressor. Existing apps are not changed.
26
+
27
+ ### Tests
28
+
29
+ - The example app checks the setting and the production group (`example_app_production_js_compressor_test.rb`).
30
+
31
+ ## [8.1.68] - 2026-11-22
32
+
33
+ ### Security
34
+
35
+ - **Ruby 4.0.10 instead of 4.0.4.** Ruby 4.0.4 has eight advisories in ruby-advisory-db (31efd9aa, 2026-11-22), among them CVE-2026-132825 (heap buffer overflow in string case conversion, fixed in 4.0.10) and CVE-2026-46727 (use-after-free in `getaddrinfo`, fixed in 4.0.5). `bundler-audit` does not check the interpreter.
36
+
37
+ ### Changed
38
+
39
+ - **Installer: generated apps pin Ruby 4.0.10** in `.ruby-version` (`InlineFormsInstaller::TARGET_RUBY_VERSION` and the template's fallback). That Ruby must be installed before `inline_forms create`. Existing apps keep the `.ruby-version` they have.
40
+ - The repo's own `.ruby-version` follows. `required_ruby_version` stays `>= 4.0.0`.
41
+ - **CI runs without Node.** `ci.yml`, `full-gate.yml` and the `inline_forms_schema_edit` example workflow run in the official `ruby:4.0.10` image and check out with plain git instead of `actions/checkout` and `actions/cache`, which are JavaScript. Gems are installed fresh each run.
42
+
43
+ ## [8.1.67] - 2026-11-06
44
+
45
+ Fixes from a code review of 8.1.66.
46
+
47
+ ### Fixed
48
+
49
+ - **Version and file trash pages no longer crash in a locale without `time.formats.inline_forms`.** 8.1.66 defined the format in en and nl only, and a bare `l(time, format: :inline_forms)` raises `I18n::MissingTranslationData` in any other locale when the host has no i18n fallbacks (rails-i18n's `:short`, used before, exists in every locale). The versions list, the file entries and the file trash now go through `inline_forms_time_text`, which passes the same format (`InlineForms::TIME_FORMAT`) as the default; the month names still come from the locale.
50
+ - **No more document listeners piling up on Turbo visits.** 8.1.66's once-guard in `inline_forms.js` left the `turbo:frame-load` listener and the `.translation_missing` mouseover handler outside it, so a layout that re-runs the bundle added another of each per visit (after 10 visits every frame load rebuilt each tooltip 11 times). Both are inside the guard now (the mouseover handler is a plain DOM listener).
51
+ - **Foundation and the widgets initialise once per page.** The first page ran `foundation()` and `initInlineFormsWidgets` from both the ready event and `turbo:load`, which destroyed and rebuilt every tooltip; one boot function now runs once per `<body>`.
52
+ - **The submenu rule no longer hides drilldown submenus.** 8.1.66 hid every `.dropdown.menu` submenu without `is-dropdown-submenu`, which beats Foundation's own `.is-drilldown-submenu` rules for a `data-responsive-menu` on small screens. It now applies to `[data-dropdown-menu]` menus only.
53
+ - **The title keys exist again, and say the application's name.** 8.1.66 removed `inline_forms.general.application_title`, `inline_forms.devise.title_for_devise` and `inline_forms.devise.welcome`, so a host view calling one bare (Papiamentu has several) showed "translation missing" in any locale it did not translate and that had no fallbacks. In en and nl they are now lambdas (`lib/locales/inline_forms_titles.rb`) that return `InlineForms.application_title`; a host's own translation still wins (its locale files load after the gem's; the example app checks the order).
54
+ - **One source for the application's name.** `InlineForms.application_title` is the host's `application_name` translation, else its `ApplicationHelper#application_name` (8.1.66 skipped that and used the titleized module name, so an app could say "MyApp" in en and "My App" in nl), else the Rails module name. `inline_forms_application_title`, the admin layout's `<title>` and the Devise header use it.
55
+
56
+ ### Changed
57
+
58
+ - **The admin layout loads Popper, Tippy and `inline_forms.js` in `<head>`.** In `<body>` Turbo Drive re-ran them on every visit with a fresh jQuery, the cause of 8.1.66's menu flash; Turbo runs head scripts once and appends missing ones in order on a visit from another layout. `no-js`, the once-guard and the submenu rule stay for host layouts that still load the bundle in `<body>`.
59
+ - **Installer: the generated `config/locales/inline_forms_local.en.yml` has only `application_name`.** It also wrote the three title keys, in en only.
60
+ - **`inline_forms_search_on` builds its clause once,** on the first search (`inline_forms_search_clause`), instead of on every search.
61
+
62
+ ### Tests
63
+
64
+ - `turbo_menu_test`: the scripts in `<head>` in order, no document listener outside the guard, one boot per body, the `[data-dropdown-menu]` rule.
65
+ - `locale_test`: the title keys resolve to the app's name in en and nl (translation, then the helper), a host translation wins, timestamps render in a locale without the gem's format.
66
+ - `model_top_bar_test`: the search clause is built once.
67
+ - Example app: `example_app_layout_title_test` checks the host's locale files load after the gem's title keys and that the keys say the app name in en and nl; `example_app_stylesheet_test` expects the scoped rule.
68
+
69
+ ### Lockstep
70
+
71
+ - validation_hints 8.1.67, inline_forms_installer 8.1.67, inline_forms_schema_edit 8.1.67.
72
+
11
73
  ## [8.1.66] - 2026-11-06
12
74
 
13
75
  Requests from Papiamentu's move to the 8.1.65 admin (gem layout, engine model top bar, gem stylesheet); each was worked around in the apps.
data/README.rdoc CHANGED
@@ -4,13 +4,13 @@ Inline Forms is almost a complete admin application. You can try it out easily.
4
4
 
5
5
  = Requirements
6
6
 
7
- * Ruby **>= 4.0** (generated apps pin **4.0.4** via +.ruby-version+)
8
- * Rails **8.1.x** (+rails ~> 8.1+, +config.load_defaults 8.1+)
7
+ * Ruby **>= 4.0** (generated apps pin **4.0.10** via +.ruby-version+)
8
+ * Rails **8.1.x**, at least **8.1.4.1** (+rails ~> 8.1+, +config.load_defaults 8.1+)
9
9
  * **validation_hints** **~> 8** (companion gem; same version line as +inline_forms+ / +inline_forms_installer+)
10
10
 
11
11
  = Ruby version managers (RVM is optional)
12
12
 
13
- +inline_forms+ does *not* require RVM. Generated apps get a +.ruby-version+ whose format matches the version manager you are using: a *bare* +4.0.4+ for +rbenv+ / +chruby+ / +asdf+ / +mise+, or +ruby-4.0.4+ for RVM (whose +.ruby-version+ reader needs the +ruby-+ prefix). So any version manager — or none — works. Bundler isolates each app's gems through its own +Gemfile.lock+.
13
+ +inline_forms+ does *not* require RVM. Generated apps get a +.ruby-version+ whose format matches the version manager you are using: a *bare* +4.0.10+ for +rbenv+ / +chruby+ / +asdf+ / +mise+, or +ruby-4.0.10+ for RVM (whose +.ruby-version+ reader needs the +ruby-+ prefix). So any version manager — or none — works. Bundler isolates each app's gems through its own +Gemfile.lock+.
14
14
 
15
15
  RVM integration is purely opt-in. If the +rvm+ gem is installed *and* your shell is inside an RVM environment, +inline_forms create+ additionally writes a +.ruby-gemset+ and installs into a per-app gemset. To enable that, +gem install rvm+ before creating the app. To skip RVM even when it is present, pass +--no-rvm+:
16
16
 
@@ -14,28 +14,41 @@
14
14
  // dropdown_with_other combobox is an <input list> + <datalist>, and
15
15
  // slider_with_values is a native <input type="range">. jQuery itself stays
16
16
  // only because Foundation 6's JS requires it.
17
- // Once per page load. Turbo Drive re-runs this bundle on every visit (it sits
18
- // in <body>), and each run brings a fresh jQuery: without the guard each run
19
- // added another turbo:load listener, and a ready-handler `foundation()` from
20
- // the fresh copy (its own plugin data) would initialise the menus twice.
17
+ // Listeners are added once per page load. The gem's layouts load this bundle
18
+ // in <head>, which Turbo Drive keeps across visits, but a host layout may
19
+ // still have it in <body>, which Turbo re-runs on every visit (each run with a
20
+ // fresh jQuery): without the guard every run would add another set.
21
21
  if (!window.inlineFormsBooted) {
22
22
  window.inlineFormsBooted = true;
23
23
 
24
- $(function(){
25
- $(document).foundation();
26
- initInlineFormsWidgets(document);
27
- });
28
-
29
- // Turbo Drive replaces <body> on a visit: the new top bar's DropdownMenu
30
- // has to be initialised again, or its submenus show as plain lists.
31
- // Foundation's reflow skips elements that already carry a plugin, so the
32
- // call on the first page (turbo:load fires there too) is harmless. jQuery
33
- // is looked up at call time.
34
- document.addEventListener("turbo:load", function() {
24
+ // Foundation and the widgets, once per <body>. Turbo Drive replaces <body>
25
+ // on a visit, and the new top bar's DropdownMenu needs initialising or its
26
+ // submenus show as plain lists. The first page gets both the ready event
27
+ // and turbo:load (and a layout without Turbo only the first), so the body
28
+ // check keeps it to one init. jQuery is looked up at call time.
29
+ var inlineFormsBootedBody = null;
30
+ var bootInlineFormsPage = function() {
31
+ if (!document.body || document.body === inlineFormsBootedBody) { return; }
32
+ inlineFormsBootedBody = document.body;
35
33
  if (window.jQuery && window.jQuery.fn.foundation) {
36
34
  window.jQuery(document).foundation();
37
35
  }
38
36
  initInlineFormsWidgets(document);
37
+ };
38
+ $(bootInlineFormsPage);
39
+ document.addEventListener("turbo:load", bootInlineFormsPage);
40
+
41
+ // Re-bind widgets (tooltips) after Turbo Frame swaps.
42
+ document.addEventListener("turbo:frame-load", function(event) {
43
+ var root = event.target;
44
+ if (!root || !root.querySelectorAll) { return; }
45
+ initInlineFormsWidgets(root);
46
+ });
47
+
48
+ // get rid of translation_missing tooltips
49
+ document.addEventListener("mouseover", function(event) {
50
+ var el = event.target.closest && event.target.closest(".translation_missing");
51
+ if (el) { el.setAttribute("title", ""); }
39
52
  });
40
53
  }
41
54
 
@@ -104,17 +117,3 @@ function initValidationHintTooltips(root) {
104
117
  }
105
118
  });
106
119
  }
107
-
108
- // get rid of translation_missing tooltips
109
- $(document).ready(function() {
110
- $(this).on('mouseover', '.translation_missing', function() {
111
- $(this).attr('title', '');
112
- });
113
- });
114
-
115
- // Re-bind widgets (tooltips) after Turbo Frame swaps.
116
- document.addEventListener("turbo:frame-load", function(event) {
117
- var root = event.target;
118
- if (!root || !root.querySelectorAll) { return; }
119
- initInlineFormsWidgets(root);
120
- });
@@ -117,9 +117,12 @@
117
117
  // marks it `is-dropdown-submenu` (whose own rules then hide it). On the first
118
118
  // page `html.no-js` covers that gap (layouts/inline_forms.html.erb), but
119
119
  // Foundation removes the class and Turbo Drive never restores it, so after a
120
- // visit the new body's submenus flashed open until inline_forms.js
121
- // re-initialised them on turbo:load.
122
- .dropdown.menu > li > ul.menu:not(.is-dropdown-submenu) {
120
+ // visit the new body's submenus could flash open until inline_forms.js
121
+ // re-initialised them on turbo:load (most of all from a host layout that
122
+ // still loads the bundle in <body>). Only for menus marked
123
+ // `data-dropdown-menu`: a `data-responsive-menu` turns its submenus into
124
+ // `is-drilldown-submenu` on small screens, which this rule would hide.
125
+ .dropdown.menu[data-dropdown-menu] > li > ul.menu:not(.is-dropdown-submenu) {
123
126
  display: none;
124
127
  }
125
128
 
@@ -398,15 +398,21 @@ module InlineFormsHelper
398
398
  # (time.formats.inline_forms; rails-i18n's :short has none, so edits years
399
399
  # apart read the same), the exact ISO 8601 time on hover.
400
400
  def inline_forms_time(time)
401
- tag.time(l(time, format: :inline_forms), datetime: time.iso8601, title: time.iso8601)
401
+ tag.time(inline_forms_time_text(time), datetime: time.iso8601, title: time.iso8601)
402
402
  end
403
403
 
404
- # The application's name for the gem's titles and the Devise pages: the
405
- # host's `application_name` translation, else its Rails module name. The
406
- # gem used to ship "Application Title" / "Title for Devise" placeholders,
407
- # shown in every locale the host did not override (nl, in all of them).
404
+ # The text alone. The gem defines time.formats.inline_forms only in en and
405
+ # nl; in another locale without it (and without i18n fallbacks) a bare
406
+ # l(format: :inline_forms) raises, so the same format is the default. The
407
+ # month names still come from that locale (rails-i18n).
408
+ def inline_forms_time_text(time)
409
+ l(time, format: :inline_forms, default: InlineForms::TIME_FORMAT)
410
+ end
411
+
412
+ # The application's name for the gem's titles and the Devise pages
413
+ # (InlineForms.application_title).
408
414
  def inline_forms_application_title
409
- t("application_name", default: Rails.application.class.module_parent_name.titleize)
415
+ InlineForms.application_title
410
416
  end
411
417
 
412
418
  def version_modified_by(id)
@@ -1,7 +1,7 @@
1
1
  <%# Unused by the gem's own devise views; kept for host apps that render it. %>
2
2
  <%# Same title source as layouts/inline_forms; Devise 5 dropped %>
3
3
  <%# devise_error_messages!, so errors use Devise's own error_messages partial. %>
4
- <div id="large_title"><%= t('application_name', default: application_name) %></div>
4
+ <div id="large_title"><%= inline_forms_application_title %></div>
5
5
  <div id="flash_message">
6
6
  <% if resource.errors.any? %>
7
7
  <%= render "devise/shared/error_messages", resource: resource %>
@@ -14,7 +14,7 @@
14
14
  <% elsif @last_sweep.error.present? %>
15
15
  <%= t("inline_forms.files.global.sweep_failed", error: @last_sweep.error) %>
16
16
  <% else %>
17
- <%= t("inline_forms.files.global.sweep_last", at: l(@last_sweep.ran_at, format: :inline_forms), count: @last_sweep.purged_count) %>
17
+ <%= t("inline_forms.files.global.sweep_last", at: inline_forms_time_text(@last_sweep.ran_at), count: @last_sweep.purged_count) %>
18
18
  <% end %>
19
19
  </p>
20
20
 
@@ -78,10 +78,10 @@
78
78
  <span class="inline_forms-file-name"><%= inline_forms_file_entry_name(entry) %></span>
79
79
  <span class="inline_forms-file-meta"><%= inline_forms_file_size(entry.byte_size) %> &middot; <%= t("inline_forms.files.reason.#{entry.reason}") %></span>
80
80
  </td>
81
- <td><%= t("inline_forms.files.by_on", user: inline_forms_file_user_name(entry.trashed_by_id), at: l(entry.trashed_at, format: :inline_forms)) %></td>
81
+ <td><%= t("inline_forms.files.by_on", user: inline_forms_file_user_name(entry.trashed_by_id), at: inline_forms_time_text(entry.trashed_at)) %></td>
82
82
  <td>
83
- <% if entry.state == :restored %><%= t("inline_forms.files.state_restored", user: inline_forms_file_user_name(entry.restored_by_id), at: l(entry.restored_at, format: :inline_forms)) %>
84
- <% elsif entry.state == :purged %><%= t("inline_forms.files.state_purged", user: inline_forms_file_user_name(entry.purged_by_id), at: l(entry.purged_at, format: :inline_forms)) %>
83
+ <% if entry.state == :restored %><%= t("inline_forms.files.state_restored", user: inline_forms_file_user_name(entry.restored_by_id), at: inline_forms_time_text(entry.restored_at)) %>
84
+ <% elsif entry.state == :purged %><%= t("inline_forms.files.state_purged", user: inline_forms_file_user_name(entry.purged_by_id), at: inline_forms_time_text(entry.purged_at)) %>
85
85
  <% elsif entry.state == :expired %><%= t("inline_forms.files.state_expired") %>
86
86
  <% else %>
87
87
  <% if entry.purge_after %><%= t("inline_forms.files.expires_in", count: ((entry.purge_after - Time.current) / 1.day).ceil, date: l(entry.purge_after.to_date)) %><% else %><%= t("inline_forms.files.global.states.trashed") %><% end %>
@@ -41,13 +41,13 @@
41
41
  <span class="inline_forms-file-meta">
42
42
  <%= inline_forms_file_size(entry.byte_size) %> &middot;
43
43
  <%= t("inline_forms.files.reason.#{entry.reason}") %>
44
- <%= t("inline_forms.files.by_on", user: inline_forms_file_user_name(entry.trashed_by_id), at: l(entry.trashed_at, format: :inline_forms)) %>
44
+ <%= t("inline_forms.files.by_on", user: inline_forms_file_user_name(entry.trashed_by_id), at: inline_forms_time_text(entry.trashed_at)) %>
45
45
  </span>
46
46
  <span class="inline_forms-file-meta">
47
47
  <% if entry.state == :restored %>
48
- <%= t("inline_forms.files.state_restored", user: inline_forms_file_user_name(entry.restored_by_id), at: l(entry.restored_at, format: :inline_forms)) %>
48
+ <%= t("inline_forms.files.state_restored", user: inline_forms_file_user_name(entry.restored_by_id), at: inline_forms_time_text(entry.restored_at)) %>
49
49
  <% elsif entry.state == :purged %>
50
- <%= t("inline_forms.files.state_purged", user: inline_forms_file_user_name(entry.purged_by_id), at: l(entry.purged_at, format: :inline_forms)) %>
50
+ <%= t("inline_forms.files.state_purged", user: inline_forms_file_user_name(entry.purged_by_id), at: inline_forms_time_text(entry.purged_at)) %>
51
51
  <% elsif entry.state == :expired %>
52
52
  <%= t("inline_forms.files.state_expired") %>
53
53
  <% else %>
@@ -1,18 +1,17 @@
1
1
  <!DOCTYPE html>
2
2
  <%# class="no-js": Foundation's CSS hides the top-bar submenus while it is set %>
3
3
  <%# and its JS removes it on the first init, so the submenus do not show as %>
4
- <%# plain lists before then. Turbo Drive never puts it back, so later visits %>
5
- <%# rely on the `ul.menu:not(.is-dropdown-submenu)` rule in inline_forms.scss %>
6
- <%# and on the turbo:load handler in inline_forms.js. %>
4
+ <%# plain lists before then. Turbo Drive never puts it back; after a visit %>
5
+ <%# inline_forms.js initialises the new body on turbo:load, and the %>
6
+ <%# `[data-dropdown-menu]` rule in inline_forms.scss covers any gap. %>
7
7
  <html lang="<%= I18n.locale %>" class="no-js">
8
8
  <head>
9
9
  <meta charset="utf-8" />
10
10
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
11
11
  <%# A missing translation must not reach <title>: a bare t() returns an %>
12
12
  <%# html_safe <span class="translation_missing"> that shows up as markup. %>
13
- <%# The `default:` (the host's ApplicationHelper#application_name, which %>
14
- <%# the header partial needs anyway) makes t() return plain, escaped text. %>
15
- <title><%= t('application_name', default: application_name) %> v<%= InlineForms::VERSION %></title>
13
+ <%# inline_forms_application_title always has a plain-text fallback. %>
14
+ <title><%= inline_forms_application_title %> v<%= InlineForms::VERSION %></title>
16
15
  <%= stylesheet_link_tag "application" %>
17
16
  <%= stylesheet_link_tag "inline_forms_fonts" %>
18
17
  <%= stylesheet_link_tag "inline_forms/inline_forms" %>
@@ -22,6 +21,16 @@
22
21
  <%# Publishes the CSP nonce (nothing without a nonce generator) for the %>
23
22
  <%# scripts Turbo inserts. %>
24
23
  <%= csp_meta_tag %>
24
+ <%# In <head>, so Turbo Drive runs them once: it keeps head scripts across %>
25
+ <%# visits (a body script runs again on every visit, with a fresh jQuery), %>
26
+ <%# and appends them, in order, on a visit from a page that lacks them. %>
27
+ <%# Tippy.js (v6) needs Popper.js as a global before its UMD factory runs %>
28
+ <%# (`tippy-bundle.umd.min` only bundles default themes, not Popper itself). %>
29
+ <%# inline_forms.js initialises Foundation on the ready event and on %>
30
+ <%# turbo:load, once per <body>. %>
31
+ <%= javascript_include_tag 'popper.min' %>
32
+ <%= javascript_include_tag 'tippy-bundle.umd.min' %>
33
+ <%= javascript_include_tag 'inline_forms/inline_forms' %>
25
34
  </head>
26
35
 
27
36
  <body class="<%= inline_forms_body_theme_class %>">
@@ -40,14 +49,6 @@
40
49
  <div id="outer_container">
41
50
  <%= yield %>
42
51
  </div>
43
- <%# Tippy.js (v6) needs Popper.js as a global before its UMD factory runs %>
44
- <%# (`tippy-bundle.umd.min` only bundles default themes, not Popper itself). %>
45
- <%# Turbo Drive re-runs these on every visit (no data-turbo-eval="false": %>
46
- <%# a visit from a page whose layout lacks them must still load them). %>
47
- <%# inline_forms.js boots once and re-initialises Foundation on turbo:load. %>
48
- <%= javascript_include_tag 'popper.min' %>
49
- <%= javascript_include_tag 'tippy-bundle.umd.min' %>
50
- <%= javascript_include_tag 'inline_forms/inline_forms' %>
51
52
  <%# Turbo (Hotwire) is loaded as an ES module so it does not collide with %>
52
53
  <%# the classic-script Sprockets bundle above. Drive stays at the default %>
53
54
  <%# (enabled); inline interactions use `<turbo-frame>` + HTML responses. %>
data/inline_forms.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.require_paths = [ "lib" ]
22
22
 
23
23
  s.add_dependency("validation_hints", ">= 8.1.4", "< 9.0")
24
- s.add_dependency("rails", ">= 8.1", "< 8.2")
24
+ s.add_dependency("rails", ">= 8.1.4.1", "< 8.2")
25
25
  s.add_dependency("rails-i18n", ">= 8.1", "< 9.0")
26
26
 
27
27
  s.add_development_dependency("minitest", "~> 5.0")
@@ -19,16 +19,21 @@ module InlineForms
19
19
  end
20
20
 
21
21
  @inline_forms_searchable = true
22
- # The clause is built when the scope runs, not here: quoting needs a
23
- # database connection, and the class body runs whenever the model
24
- # loads (eager loading, assets:precompile without a database).
22
+ @inline_forms_search_columns = cols
23
+ model = self
25
24
  scope :inline_forms_search, ->(q) {
26
- clause = cols.map { |c|
27
- "#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(c)} LIKE :q"
28
- }.join(" OR ")
29
- where(clause, q: "%#{sanitize_sql_like(q.to_s)}%")
25
+ where(model.inline_forms_search_clause, q: "%#{sanitize_sql_like(q.to_s)}%")
30
26
  }
31
27
  end
28
+
29
+ # Built on the first search, not in inline_forms_search_on: quoting
30
+ # needs a database connection, and the class body runs whenever the
31
+ # model loads (eager loading, assets:precompile without a database).
32
+ def inline_forms_search_clause
33
+ @inline_forms_search_clause ||= @inline_forms_search_columns.map { |c|
34
+ "#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(c)} LIKE :q"
35
+ }.join(" OR ")
36
+ end
32
37
  end
33
38
  end
34
39
  end
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  module InlineForms
4
- VERSION = "8.1.66"
4
+ VERSION = "8.1.70"
5
5
  end
data/lib/inline_forms.rb CHANGED
@@ -187,6 +187,28 @@ module InlineForms
187
187
  # programmatically (generator / GUI); the user edits it to real values after.
188
188
  PLACEHOLDER_VALUES = { 1 => "one", 2 => "two" }.freeze
189
189
 
190
+ # Version and file timestamps: time.formats.inline_forms in the gem's en
191
+ # and nl locales, and the default where a locale lacks it.
192
+ TIME_FORMAT = "%d %b %Y %H:%M"
193
+
194
+ # The application's name for the gem's titles and the Devise pages: the
195
+ # host's `application_name` translation, else its
196
+ # ApplicationHelper#application_name (the installer writes both, and the
197
+ # gem's header partial uses the helper), else its Rails module name. The
198
+ # gem's title keys (inline_forms.general.application_title,
199
+ # inline_forms.devise.title_for_devise and .welcome) resolve to this in en
200
+ # and nl unless the host translates them (lib/locales/inline_forms_titles.rb).
201
+ def self.application_title
202
+ I18n.t("application_name", default: application_name_from_helper || Rails.application.class.module_parent_name)
203
+ end
204
+
205
+ def self.application_name_from_helper
206
+ return unless defined?(::ApplicationController)
207
+
208
+ helpers = ::ApplicationController.helpers
209
+ helpers.application_name if helpers.respond_to?(:application_name)
210
+ end
211
+
190
212
  def self.plain_text_form_element?(form_element)
191
213
  PLAIN_TEXT_FORM_ELEMENTS.include?(form_element.to_sym)
192
214
  rescue NoMethodError
@@ -408,7 +430,8 @@ module InlineForms
408
430
  end
409
431
  end
410
432
 
411
- I18n.load_path << Dir[File.join(File.expand_path(File.dirname(__FILE__) + "/locales"), "*.yml")]
433
+ # .rb too: inline_forms_titles.rb holds the title keys as lambdas.
434
+ I18n.load_path << Dir[File.join(File.expand_path(File.dirname(__FILE__) + "/locales"), "*.{yml,rb}")]
412
435
  I18n.load_path.flatten!
413
436
  end
414
437
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The gem's title keys, resolved to the application's name
4
+ # (InlineForms.application_title) instead of a placeholder. Lambdas, so a
5
+ # host view that calls a key bare gets the real name too. A host translation
6
+ # of the same key still wins: the host's locale files load after the gem's.
7
+ title = ->(_key, **_options) { InlineForms.application_title }
8
+ welcome = ->(_key, **_options) { I18n.t("inline_forms.devise.welcome_to", name: InlineForms.application_title) }
9
+ keys = {
10
+ inline_forms: {
11
+ general: { application_title: title },
12
+ devise: { title_for_devise: title, welcome: welcome }
13
+ }
14
+ }
15
+
16
+ { en: keys, nl: keys }
@@ -143,26 +143,56 @@ class LocaleTest < InlineFormsIntegrationTestCase
143
143
 
144
144
  # The gem shipped "Application Title" / "Title for Devise" / "Welcome for
145
145
  # Devise" in en and nl; any locale the host did not override showed them.
146
- test "no placeholder titles: the gem's titles use the host's application name" do
147
- %i[en nl].each do |locale|
148
- %w[inline_forms.general.application_title inline_forms.devise.title_for_devise inline_forms.devise.welcome].each do |key|
149
- refute I18n.exists?(key, locale), "#{locale}.#{key} is a placeholder; the views fall back to application_name"
150
- end
151
- end
152
-
146
+ # The keys now resolve to the application's name, also when a host view
147
+ # calls them bare.
148
+ test "the gem's title keys resolve to the application's name" do
153
149
  get widgets_path
154
150
  I18n.backend.store_translations(:nl, application_name: "Werkplaats")
155
151
  strictly(:nl) do
152
+ assert_equal "Werkplaats", I18n.t("inline_forms.general.application_title")
153
+ assert_equal "Werkplaats", I18n.t("inline_forms.devise.title_for_devise")
154
+ assert_equal "Welkom bij Werkplaats!", I18n.t("inline_forms.devise.welcome")
156
155
  devise = controller.render_to_string(template: "stats/show", layout: "devise")
157
156
  assert_includes devise, "Werkplaats v#{InlineForms::VERSION}"
158
157
  top_bar = controller.render_to_string(partial: "devise/sessions/top-bar")
159
158
  assert_includes top_bar, "Werkplaats #{InlineForms::VERSION}"
160
- assert_equal "Welkom bij Werkplaats!",
161
- I18n.t("inline_forms.devise.welcome", default: I18n.t("inline_forms.devise.welcome_to", name: "Werkplaats"))
162
159
  end
163
160
  I18n.with_locale(:en) do
161
+ # No en application_name translation here: the host's
162
+ # ApplicationHelper#application_name.
163
+ assert_equal "Dummy", I18n.t("inline_forms.general.application_title")
164
+ assert_equal "Welcome to Dummy!", I18n.t("inline_forms.devise.welcome")
164
165
  assert_includes controller.render_to_string(template: "stats/show", layout: "application"), "Dummy v#{InlineForms::VERSION}"
165
166
  end
167
+ ensure
168
+ I18n.backend.reload!
169
+ end
170
+
171
+ test "a host translation of a title key wins" do
172
+ I18n.t("inline_forms.general.application_title") # loads the gem's files first, as a host app does
173
+ I18n.backend.store_translations(:nl, inline_forms: { general: { application_title: "Banko" } })
174
+
175
+ assert_equal "Banko", I18n.t("inline_forms.general.application_title", locale: :nl)
176
+ ensure
177
+ I18n.backend.reload!
178
+ end
179
+
180
+ # time.formats.inline_forms is defined in en and nl only; a bare
181
+ # l(format: :inline_forms) raises in any other locale without fallbacks.
182
+ test "version and trash timestamps render in a locale without the gem's format" do
183
+ original = I18n.available_locales
184
+ I18n.available_locales = original + [ :de ]
185
+ months = %w[Jan Feb Mär Apr Mai Jun Jul Aug Sep Okt Nov Dez]
186
+ I18n.backend.store_translations(:de, date: { abbr_month_names: [ nil, *months ] })
187
+ time = Time.zone.local(2019, 3, 5, 14, 7)
188
+
189
+ I18n.with_locale(:de) do
190
+ assert_raises(I18n::MissingTranslationData) { I18n.l(time, format: :inline_forms, raise: true) }
191
+ assert_equal "05 Mär 2019 14:07", ApplicationController.helpers.send(:inline_forms_time_text, time)
192
+ end
193
+ ensure
194
+ I18n.available_locales = original
195
+ I18n.backend.reload!
166
196
  end
167
197
 
168
198
  test "the versions list in en keeps its English labels" do
@@ -79,5 +79,7 @@ class ModelTopBarTest < InlineFormsIntegrationTestCase
79
79
  %i[connection lease_connection with_connection].each { |m| model.singleton_class.remove_method(m) }
80
80
  Widget.create!(name: "Gamma")
81
81
  assert_equal [ "Gamma" ], model.inline_forms_search("amm").pluck(:name)
82
+ # Built once, on the first search.
83
+ assert_same model.inline_forms_search_clause, model.inline_forms_search_clause
82
84
  end
83
85
  end
@@ -2,38 +2,52 @@
2
2
 
3
3
  require_relative "../integration_test_helper"
4
4
 
5
- # Top-bar submenus after a Turbo Drive visit. Turbo replaced <body> and re-ran
6
- # the inline_forms bundle (a fresh jQuery, its own Foundation plugin data),
7
- # and until that finished the new body's submenus showed as plain lists;
8
- # StProject, Scouting and Papiamentu each carried the same layout copy to
9
- # hide them (html.no-js, a turbo:load re-init, a CSS rule). Now the gem does.
5
+ # Top-bar submenus after a Turbo Drive visit. The bundle sat in <body>, so
6
+ # Turbo re-ran it on every visit (a fresh jQuery, its own Foundation plugin
7
+ # data), and until that finished the new body's submenus showed as plain
8
+ # lists; StProject, Scouting and Papiamentu each carried the same layout copy
9
+ # to hide them (html.no-js, a turbo:load re-init, a CSS rule). Now the gem
10
+ # loads the bundle in <head>, which Turbo runs once.
10
11
  class TurboMenuTest < InlineFormsIntegrationTestCase
11
12
  ROOT = File.expand_path("../..", __dir__)
12
13
 
13
- test "the layout starts as no-js" do
14
+ def boot_block
15
+ js = File.read(File.join(ROOT, "app/assets/javascripts/inline_forms/inline_forms.js"))
16
+ js[/^if \(!window\.inlineFormsBooted\) \{.*?\n\}\n/m]
17
+ end
18
+
19
+ test "the layout starts as no-js and loads the bundle in head" do
14
20
  get widgets_path
15
21
 
16
22
  assert_response :success
17
23
  assert_match %r{<html lang="en" class="no-js">}, response.body
18
- # Not data-turbo-eval="false": a Turbo visit from a page whose layout
19
- # lacks the bundle has to run it.
20
- assert_match %r{<script src="[^"]*/inline_forms/inline_forms[^"]*\.js"></script>}, response.body
24
+ head = response.body[%r{<head>.*</head>}m]
25
+ scripts = %w[popper.min tippy-bundle.umd.min inline_forms/inline_forms].map { |name|
26
+ head.index(%r{<script src="[^"]*/#{Regexp.escape(name)}[^"]*\.js"></script>})
27
+ }
28
+ assert scripts.all?, "popper, tippy and inline_forms.js are in <head>"
29
+ assert_equal scripts.sort, scripts, "in that order"
30
+ refute_match %r{<body.*inline_forms/inline_forms[^"]*\.js}m, response.body
21
31
  end
22
32
 
23
- test "inline_forms.js boots once and re-initialises Foundation on turbo:load" do
24
- js = File.read(File.join(ROOT, "app/assets/javascripts/inline_forms/inline_forms.js"))
25
- boot = js[/if \(!window\.inlineFormsBooted\) \{.*?\n\}\n/m]
26
-
27
- assert boot, "the DOM-ready and turbo:load wiring sits behind the once-guard"
28
- turbo_load = boot[/addEventListener\("turbo:load".*?\n \}\);/m]
29
- assert_includes turbo_load, "window.jQuery(document).foundation();"
30
- assert_includes turbo_load, "initInlineFormsWidgets(document);"
33
+ test "inline_forms.js wires every document listener once, and boots once per body" do
34
+ boot = boot_block
35
+
36
+ assert boot, "the listeners sit behind the once-guard"
37
+ rest = File.read(File.join(ROOT, "app/assets/javascripts/inline_forms/inline_forms.js")).sub(boot, "")
38
+ refute_match(/addEventListener|\$\(document\)|\.ready\(/, rest.gsub(%r{^\s*//.*$}, "").gsub(/el\.addEventListener\("input"/, ""),
39
+ "no document listener outside the guard: a host layout with the bundle in <body> re-runs it on every visit")
40
+ %w[turbo:load turbo:frame-load mouseover].each do |event|
41
+ assert_includes boot, "document.addEventListener(\"#{event}\""
42
+ end
43
+ assert_includes boot, "document.body === inlineFormsBootedBody"
44
+ assert_includes boot, "window.jQuery(document).foundation();"
31
45
  end
32
46
 
33
- test "uninitialised submenus stay hidden after a visit" do
47
+ test "uninitialised dropdown submenus stay hidden, drilldown menus are left alone" do
34
48
  scss = File.read(File.join(ROOT, "app/assets/stylesheets/inline_forms/inline_forms.scss"))
35
49
 
36
- assert_match(/^\.dropdown\.menu > li > ul\.menu:not\(\.is-dropdown-submenu\) \{\n display: none;\n\}/, scss)
50
+ assert_match(/^\.dropdown\.menu\[data-dropdown-menu\] > li > ul\.menu:not\(\.is-dropdown-submenu\) \{\n display: none;\n\}/, scss)
37
51
  end
38
52
 
39
53
  # Compiled CSS is checked in the example app (example_app_stylesheet_test).
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.66
4
+ version: 8.1.70
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares
@@ -37,7 +37,7 @@ dependencies:
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '8.1'
40
+ version: 8.1.4.1
41
41
  - - "<"
42
42
  - !ruby/object:Gem::Version
43
43
  version: '8.2'
@@ -47,7 +47,7 @@ dependencies:
47
47
  requirements:
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
- version: '8.1'
50
+ version: 8.1.4.1
51
51
  - - "<"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '8.2'
@@ -95,6 +95,8 @@ extensions: []
95
95
  extra_rdoc_files: []
96
96
  files:
97
97
  - ".document"
98
+ - ".forgejo/brakeman-engine.sh"
99
+ - ".forgejo/brakeman.ignore"
98
100
  - ".forgejo/workflows/ci.yml"
99
101
  - ".forgejo/workflows/full-gate.yml"
100
102
  - ".gitignore"
@@ -273,6 +275,7 @@ files:
273
275
  - lib/inline_forms/version.rb
274
276
  - lib/locales/inline_forms.en.yml
275
277
  - lib/locales/inline_forms.nl.yml
278
+ - lib/locales/inline_forms_titles.rb
276
279
  - lib/otherstuff/add_roles.sql
277
280
  - lib/otherstuff/mkrole
278
281
  - lib/otherstuff/roles_users.sql
@@ -366,7 +369,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
366
369
  - !ruby/object:Gem::Version
367
370
  version: '0'
368
371
  requirements: []
369
- rubygems_version: 4.0.12
372
+ rubygems_version: 4.0.20
370
373
  specification_version: 4
371
374
  summary: Inline editing of forms for Rails 8.
372
375
  test_files: