forme 2.3.0 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +14 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +1 -1
- data/lib/forme/transformers/formatter.rb +2 -1
- data/lib/forme/transformers/helper.rb +1 -1
- data/lib/forme/version.rb +2 -2
- data/lib/forme.rb +22 -17
- data/lib/roda/plugins/forme_set.rb +12 -0
- data/lib/sequel/plugins/forme.rb +6 -1
- data/lib/sequel/plugins/forme_set.rb +15 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60794aa5c742e3b40bacd043172a0e201358b944a653f3bd013bf8e6a254154b
|
4
|
+
data.tar.gz: ae16923653b5bb463f430735a57b1f710a3ccb53420b124f15b6a5e72f290c2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3f915c5dd32938874513739d29a2f6c04365a1f636c2dc814ce2a17de07beb4a9c8000e4f40b112bb8d4198d005552dafcf0cbb957dc0ffa9e11c0b6b820f33
|
7
|
+
data.tar.gz: 5528741694ca0c36800ce9cacab5a7e764698da5c9c9f1e4bb17bfce9c9a0ba86a354a0e2eca14a9825b5ee792aa7dc5c62eb687b8d5a540fa7b2fea47220617
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
=== 2.4.1 (2023-09-19)
|
2
|
+
|
3
|
+
* Add dependency on bigdecimal, as bigdecimal is moving from standard library to bundled gem in Ruby 3.4 (jeremyevans)
|
4
|
+
|
5
|
+
=== 2.4.0 (2023-04-05)
|
6
|
+
|
7
|
+
* Support Sequel::Model#forme_use_required_abbr? to control whether to add abbr * tag for required inputs (jeremyevans) (#105)
|
8
|
+
|
9
|
+
* Make select input with option groups and a :value option correctly set selected attribute on options in all optgroups (v-kolesnikov) (#111, #110)
|
10
|
+
|
11
|
+
* Make Roda forme_set plugin only include metadata for inputs in the same form, and not inputs on other forms on the same page (jeremyevans) (#109)
|
12
|
+
|
13
|
+
* Use erb/escape for faster HTML escaping if available (jeremyevans)
|
14
|
+
|
1
15
|
=== 2.3.0 (2022-11-15)
|
2
16
|
|
3
17
|
* Add forme/bs5 for Bootstrap 5 support (janko) (#106)
|
data/MIT-LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -53,7 +53,7 @@ This results in the following HTML:
|
|
53
53
|
</label>
|
54
54
|
</form>
|
55
55
|
|
56
|
-
In addition to integrating with Sequel,
|
56
|
+
In addition to integrating with Sequel, Forme also integrates into
|
57
57
|
three separate web frameworks, Roda, Rails, and Sinatra, allowing
|
58
58
|
use of forms inside templates. This is the most common usage of Forme.
|
59
59
|
|
@@ -417,6 +417,7 @@ module Forme
|
|
417
417
|
return unless @opts[:options]
|
418
418
|
process_select_options(@opts[:options], &block)
|
419
419
|
end
|
420
|
+
@attr.delete(:value)
|
420
421
|
|
421
422
|
if prompt = @opts[:add_blank]
|
422
423
|
unless prompt.is_a?(String)
|
@@ -434,7 +435,7 @@ module Forme
|
|
434
435
|
def process_select_options(os)
|
435
436
|
vm = @opts[:value_method]
|
436
437
|
tm = @opts[:text_method]
|
437
|
-
sel = @opts[:selected] || @attr
|
438
|
+
sel = @opts[:selected] || @attr[:value]
|
438
439
|
|
439
440
|
if @opts[:multiple]
|
440
441
|
sel = Array(sel)
|
@@ -7,7 +7,7 @@ module Forme
|
|
7
7
|
class Helper
|
8
8
|
Forme.register_transformer(:helper, :default, new)
|
9
9
|
|
10
|
-
# Return tag with
|
10
|
+
# Return tag with help message span tag after it.
|
11
11
|
def call(tag, input)
|
12
12
|
attr = input.opts[:helper_attr]
|
13
13
|
attr = attr ? attr.dup : {}
|
data/lib/forme/version.rb
CHANGED
@@ -6,11 +6,11 @@ module Forme
|
|
6
6
|
MAJOR = 2
|
7
7
|
|
8
8
|
# The minor version of Forme, updated for new feature releases of Forme.
|
9
|
-
MINOR =
|
9
|
+
MINOR = 4
|
10
10
|
|
11
11
|
# The patch version of Forme, updated only for bug fixes from the last
|
12
12
|
# feature release.
|
13
|
-
TINY =
|
13
|
+
TINY = 1
|
14
14
|
|
15
15
|
# Version constant, use <tt>Forme.version</tt> instead.
|
16
16
|
VERSION = "#{MAJOR}.#{MINOR}.#{TINY}".freeze
|
data/lib/forme.rb
CHANGED
@@ -9,27 +9,32 @@ module Forme
|
|
9
9
|
end
|
10
10
|
|
11
11
|
begin
|
12
|
-
require '
|
12
|
+
require 'erb/escape'
|
13
|
+
define_singleton_method(:h, ERB::Escape.instance_method(:html_escape))
|
13
14
|
# :nocov:
|
14
|
-
unless CGI.respond_to?(:escapeHTML) # work around for JRuby 9.1
|
15
|
-
CGI = Object.new
|
16
|
-
CGI.extend(defined?(::CGI::Escape) ? ::CGI::Escape : ::CGI::Util)
|
17
|
-
end
|
18
|
-
def self.h(value)
|
19
|
-
CGI.escapeHTML(value.to_s)
|
20
|
-
end
|
21
15
|
rescue LoadError
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
def self.h(value)
|
28
|
-
value.to_s.gsub(/[&<>"']/, ESCAPE_TABLE)
|
16
|
+
begin
|
17
|
+
require 'cgi/escape'
|
18
|
+
unless CGI.respond_to?(:escapeHTML) # work around for JRuby 9.1
|
19
|
+
CGI = Object.new
|
20
|
+
CGI.extend(defined?(::CGI::Escape) ? ::CGI::Escape : ::CGI::Util)
|
29
21
|
end
|
30
|
-
else
|
31
22
|
def self.h(value)
|
32
|
-
value.to_s
|
23
|
+
CGI.escapeHTML(value.to_s)
|
24
|
+
end
|
25
|
+
rescue LoadError
|
26
|
+
ESCAPE_TABLE = {'&' => '&', '<' => '<', '>' => '>', '"' => '"', "'" => '''}.freeze
|
27
|
+
ESCAPE_TABLE.each_value(&:freeze)
|
28
|
+
if RUBY_VERSION >= '1.9'
|
29
|
+
# Escape the following characters with their HTML/XML
|
30
|
+
# equivalents.
|
31
|
+
def self.h(value)
|
32
|
+
value.to_s.gsub(/[&<>"']/, ESCAPE_TABLE)
|
33
|
+
end
|
34
|
+
else
|
35
|
+
def self.h(value)
|
36
|
+
value.to_s.gsub(/[&<>"']/){|s| ESCAPE_TABLE[s]}
|
37
|
+
end
|
33
38
|
end
|
34
39
|
end
|
35
40
|
end
|
@@ -37,6 +37,18 @@ class Roda
|
|
37
37
|
}.freeze
|
38
38
|
|
39
39
|
module InstanceMethods
|
40
|
+
# If a Sequel::Model object that supports forme_set is passed,
|
41
|
+
# isolate the inputs so that each form only includes metadata
|
42
|
+
# for inputs on the form, and not inputs for earlier forms on
|
43
|
+
# the same page.
|
44
|
+
def form(obj=nil, attr={}, opts={}, &block)
|
45
|
+
if obj.is_a?(Sequel::Plugins::FormeSet::InstanceMethods)
|
46
|
+
obj.isolate_forme_inputs{super}
|
47
|
+
else
|
48
|
+
super
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
40
52
|
# Return hash based on submitted parameters, with :values key
|
41
53
|
# being submitted values for the object, and :validations key
|
42
54
|
# being a hash of validation metadata for the object.
|
data/lib/sequel/plugins/forme.rb
CHANGED
@@ -207,7 +207,7 @@ module Sequel # :nodoc:
|
|
207
207
|
# is required.
|
208
208
|
def handle_label(f)
|
209
209
|
opts[:label] = humanize(field) unless opts.has_key?(:label)
|
210
|
-
opts[:label] = [opts[:label], form._tag(:abbr, {:title=>'required'}, '*')] if opts[:label] && opts[:required]
|
210
|
+
opts[:label] = [opts[:label], form._tag(:abbr, {:title=>'required'}, '*')] if opts[:label] && opts[:required] && obj.forme_use_required_abbr?
|
211
211
|
end
|
212
212
|
|
213
213
|
# Update the attributes and options for any recognized validations
|
@@ -492,6 +492,11 @@ module Sequel # :nodoc:
|
|
492
492
|
'post'
|
493
493
|
end
|
494
494
|
|
495
|
+
# Whether to set an abbr tag in labels for required inputs.
|
496
|
+
def forme_use_required_abbr?
|
497
|
+
true
|
498
|
+
end
|
499
|
+
|
495
500
|
# Use the underscored model name as the default namespace.
|
496
501
|
def forme_namespace
|
497
502
|
model.send(:underscore, model.name)
|
@@ -24,6 +24,21 @@ module Sequel # :nodoc:
|
|
24
24
|
@forme_inputs ||= {}
|
25
25
|
end
|
26
26
|
|
27
|
+
# Temporarily reset forme_inputs to the empty hash before yielding to the block.
|
28
|
+
# Used by the Roda forme_set plugin to make sure each form only includes metadata
|
29
|
+
# for inputs in that form, and not metadata for inputs for earlier forms on the same page.
|
30
|
+
def isolate_forme_inputs
|
31
|
+
return yield if frozen?
|
32
|
+
|
33
|
+
forme_inputs = self.forme_inputs
|
34
|
+
begin
|
35
|
+
@forme_inputs = {}
|
36
|
+
yield
|
37
|
+
ensure
|
38
|
+
@forme_inputs = forme_inputs.merge(@forme_inputs)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
27
42
|
# Hash with column name symbol keys and <tt>[subset, allowed_values]</tt> values. +subset+
|
28
43
|
# is a boolean flag, if true, the uploaded values should be a subset of the allowed values,
|
29
44
|
# otherwise, there should be a single uploaded value that is a member of the allowed values.
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bigdecimal
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: minitest
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -225,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
239
|
- !ruby/object:Gem::Version
|
226
240
|
version: '0'
|
227
241
|
requirements: []
|
228
|
-
rubygems_version: 3.
|
242
|
+
rubygems_version: 3.4.10
|
229
243
|
signing_key:
|
230
244
|
specification_version: 4
|
231
245
|
summary: HTML forms library
|