autoforme 1.10.0 → 1.11.0
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/CHANGELOG +8 -0
- data/README.rdoc +2 -0
- data/lib/autoforme/action.rb +8 -3
- data/lib/autoforme/frameworks/rails.rb +5 -1
- data/lib/autoforme/frameworks/roda.rb +7 -2
- data/lib/autoforme/frameworks/sinatra.rb +3 -1
- data/lib/autoforme/models/sequel.rb +6 -0
- data/lib/autoforme/version.rb +1 -1
- data/lib/autoforme.rb +7 -8
- data/lib/roda/plugins/autoforme.rb +1 -1
- data/spec/all.rb +1 -1
- data/spec/associations_spec.rb +1 -1
- data/spec/basic_spec.rb +9 -1
- data/spec/mtm_spec.rb +3 -3
- data/spec/rails_spec_helper.rb +7 -8
- data/spec/roda_spec.rb +1 -1
- data/spec/roda_spec_helper.rb +1 -2
- data/spec/sequel_spec_helper.rb +0 -1
- data/spec/sinatra_spec_helper.rb +1 -2
- data/spec/spec_helper.rb +2 -3
- data/spec/unit_spec.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0198a23636933034920c066694a4acd8e58d5529fbf21ada5f542a7de444cc2c'
|
4
|
+
data.tar.gz: 6cf1f310f06018a91573472c7410c1dda1842b7f96593a82deaf9be5f2bdd524
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8931ddb513d806df30b8a4fe36fb20583597ac4e9f45e1144c5732cff66d09f92a14967a5ac4c35724ac339bfd23af866b454490ffabe99b327dfaff2e1aa787
|
7
|
+
data.tar.gz: '097239f8074dc20537dec29064f24c2e5fbb521cf3586bb828726afc2b436eed190794d2b276e9b108c60bb6a4c3116a35dc651d54e32af5ff74d34e4a6b586e'
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
=== 1.11.0 (2021-11-30)
|
2
|
+
|
3
|
+
* Require forme 2.0.0 (jeremyevans)
|
4
|
+
|
5
|
+
* Add support for view_options framework option (nmb, jeremyevans) (#42)
|
6
|
+
|
7
|
+
* Drop support for Ruby 1.8 (jeremyevans)
|
8
|
+
|
1
9
|
=== 1.10.0 (2021-08-27)
|
2
10
|
|
3
11
|
* Do not consider read_only many_to_many associations to be editable (jeremyevans)
|
data/README.rdoc
CHANGED
@@ -174,6 +174,8 @@ page_header :: Override the default header used for pages
|
|
174
174
|
show_html :: The html to use for displaying the value for an object field. Should be a proc that takes the
|
175
175
|
model object, column symbol, type symbol, and request and returns the html to use.
|
176
176
|
table_class :: The html class string to use for the browse and search tables
|
177
|
+
view_options :: Hash with options passed when rendering the view (how these options are used varies
|
178
|
+
in each of the supported web frameworks), e.g. <tt>view_options: {:layout => :formelayout}</tt>
|
177
179
|
|
178
180
|
These hook options should be callable objects that are called with the model object and the request.
|
179
181
|
|
data/lib/autoforme/action.rb
CHANGED
@@ -227,10 +227,15 @@ module AutoForme
|
|
227
227
|
# Options to use for the form. If the form uses POST, automatically adds the CSRF token.
|
228
228
|
def form_opts(action=nil)
|
229
229
|
opts = model.form_options_for(type, request).dup
|
230
|
-
|
231
|
-
|
232
|
-
|
230
|
+
|
231
|
+
opts[:_before_post] = lambda do |form|
|
232
|
+
if csrf_hash = request.csrf_token_hash(action)
|
233
|
+
csrf_hash.each do |name, value|
|
234
|
+
form.tag(:input, :type=>:hidden, :name=>name, :value=>value)
|
235
|
+
end
|
236
|
+
end
|
233
237
|
end
|
238
|
+
|
234
239
|
opts
|
235
240
|
end
|
236
241
|
|
@@ -58,7 +58,11 @@ module AutoForme
|
|
58
58
|
elsif @autoforme_action.request.xhr?
|
59
59
|
render :html=>@autoforme_text.html_safe
|
60
60
|
else
|
61
|
-
|
61
|
+
opts = framework.opts[:view_options]
|
62
|
+
opts = opts ? opts.dup : {}
|
63
|
+
opts[:layout] = true unless opts.has_key?(:layout)
|
64
|
+
opts[:inline] = "<%=raw @autoforme_text %>"
|
65
|
+
render opts
|
62
66
|
end
|
63
67
|
else
|
64
68
|
render :plain=>'Unhandled Request', :status=>404
|
@@ -53,16 +53,18 @@ module AutoForme
|
|
53
53
|
def csrf_token_hash(action=nil)
|
54
54
|
if @controller.respond_to?(:check_csrf!)
|
55
55
|
# Using route_csrf plugin
|
56
|
-
# :nocov:
|
57
56
|
token = if @controller.use_request_specific_csrf_tokens?
|
58
57
|
@controller.csrf_token(@controller.csrf_path(action))
|
58
|
+
# :nocov:
|
59
59
|
else
|
60
60
|
@controller.csrf_token
|
61
|
+
# :nocov:
|
61
62
|
end
|
62
63
|
{@controller.csrf_field=>token}
|
63
64
|
# :nocov:
|
64
65
|
elsif defined?(::Rack::Csrf)
|
65
66
|
{::Rack::Csrf.field=>::Rack::Csrf.token(@env)}
|
67
|
+
# :nocov:
|
66
68
|
end
|
67
69
|
end
|
68
70
|
|
@@ -106,7 +108,10 @@ module AutoForme
|
|
106
108
|
elsif @autoforme_action.request.xhr?
|
107
109
|
@autoforme_text
|
108
110
|
else
|
109
|
-
|
111
|
+
opts = framework.opts[:view_options]
|
112
|
+
opts = opts ? opts.dup : {}
|
113
|
+
opts[:content] = @autoforme_text
|
114
|
+
view(opts)
|
110
115
|
end
|
111
116
|
end
|
112
117
|
end
|
@@ -50,7 +50,9 @@ module AutoForme
|
|
50
50
|
elsif @autoforme_action.request.xhr?
|
51
51
|
@autoforme_text
|
52
52
|
else
|
53
|
-
|
53
|
+
opts = framework.opts[:view_options]
|
54
|
+
opts = opts ? opts.dup : {}
|
55
|
+
erb("<%= @autoforme_text %>".dup, opts ? opts.dup : {})
|
54
56
|
end
|
55
57
|
else
|
56
58
|
pass
|
@@ -316,6 +316,12 @@ module AutoForme
|
|
316
316
|
model.db.transaction(:savepoint=>true){obj.send(meth, ret)}
|
317
317
|
rescue S::UniqueConstraintViolation
|
318
318
|
# Already added, safe to ignore
|
319
|
+
rescue S::ConstraintViolation
|
320
|
+
# Old versions of sqlite3 and jdbc-sqlite3 can raise generic
|
321
|
+
# ConstraintViolation instead of UniqueConstraintViolation
|
322
|
+
# :nocov:
|
323
|
+
raise unless model.db.database_type == :sqlite
|
324
|
+
# :nocov:
|
319
325
|
end
|
320
326
|
end
|
321
327
|
end
|
data/lib/autoforme/version.rb
CHANGED
data/lib/autoforme.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen-string-literal: true
|
2
2
|
|
3
3
|
require 'forme'
|
4
|
-
require 'thread'
|
5
4
|
require 'rack/utils'
|
6
5
|
|
7
6
|
module AutoForme
|
@@ -50,10 +49,10 @@ module AutoForme
|
|
50
49
|
end
|
51
50
|
end
|
52
51
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
52
|
+
require_relative 'autoforme/opts_attributes'
|
53
|
+
require_relative 'autoforme/model'
|
54
|
+
require_relative 'autoforme/framework'
|
55
|
+
require_relative 'autoforme/request'
|
56
|
+
require_relative 'autoforme/action'
|
57
|
+
require_relative 'autoforme/table'
|
58
|
+
require_relative 'autoforme/version'
|
data/spec/all.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
puts "Running specs with #{ENV['FRAMEWORK']||'roda'} framework"
|
2
|
-
Dir
|
2
|
+
Dir.new(File.dirname(__FILE__)).each{|f| require_relative f if f.end_with?('_spec.rb')}
|
data/spec/associations_spec.rb
CHANGED
data/spec/basic_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative 'spec_helper'
|
2
2
|
|
3
3
|
describe AutoForme do
|
4
4
|
before(:all) do
|
@@ -12,6 +12,7 @@ describe AutoForme do
|
|
12
12
|
it "should have basic functionality working" do
|
13
13
|
app_setup(Artist)
|
14
14
|
visit("/Artist/new")
|
15
|
+
page.html.must_include '<!DOCTYPE html>'
|
15
16
|
page.title.must_equal 'Artist - New'
|
16
17
|
fill_in 'Name', :with=>'TestArtistNew'
|
17
18
|
click_button 'Create'
|
@@ -607,6 +608,13 @@ describe AutoForme do
|
|
607
608
|
page.html.must_match(/Name.+TestArtistUpdate/m)
|
608
609
|
page.current_path.must_match %r{/Artist/edit/\d+}
|
609
610
|
end
|
611
|
+
|
612
|
+
it "should support view_options" do
|
613
|
+
app_setup(Artist, view_options: {:layout=>false}){}
|
614
|
+
visit("/Artist/browse")
|
615
|
+
page.html.wont_include '<!DOCTYPE html>'
|
616
|
+
page.all('table').first['id'].must_equal 'autoforme_table'
|
617
|
+
end
|
610
618
|
end
|
611
619
|
|
612
620
|
describe AutoForme do
|
data/spec/mtm_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative 'spec_helper'
|
2
2
|
|
3
3
|
describe AutoForme do
|
4
4
|
before(:all) do
|
@@ -595,7 +595,7 @@ describe AutoForme do
|
|
595
595
|
end
|
596
596
|
|
597
597
|
visit("/Artist/new")
|
598
|
-
page.html.wont_include '
|
598
|
+
page.html.wont_include 'Artist/mtm_edit'
|
599
599
|
fill_in 'Name', :with=>'Artist1'
|
600
600
|
click_button 'Create'
|
601
601
|
click_link 'Edit'
|
@@ -607,7 +607,7 @@ describe AutoForme do
|
|
607
607
|
page.html.must_include 'Unhandled Request'
|
608
608
|
|
609
609
|
visit("/Album/new")
|
610
|
-
page.html.wont_include '
|
610
|
+
page.html.wont_include 'Album/mtm_edit'
|
611
611
|
fill_in 'Name', :with=>'Album1'
|
612
612
|
click_button 'Create'
|
613
613
|
click_link 'Edit'
|
data/spec/rails_spec_helper.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'rails'
|
3
2
|
require 'action_controller/railtie'
|
4
|
-
|
3
|
+
require_relative '../lib/autoforme'
|
5
4
|
|
6
5
|
class AutoFormeSpec::App
|
7
6
|
class << self
|
@@ -78,12 +77,11 @@ HTML
|
|
78
77
|
# Work around issue in backported openssl environments where
|
79
78
|
# secret is 64 bytes intead of 32 bytes
|
80
79
|
require 'active_support/message_encryptor'
|
81
|
-
ActiveSupport::MessageEncryptor.
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
}
|
80
|
+
def (ActiveSupport::MessageEncryptor).new(secret, *signature_key_or_options)
|
81
|
+
obj = allocate
|
82
|
+
obj.send(:initialize, secret[0, 32], *signature_key_or_options)
|
83
|
+
obj
|
84
|
+
end
|
87
85
|
end
|
88
86
|
if Rails.version > '4.2'
|
89
87
|
config.action_dispatch.cookies_serializer = :json
|
@@ -91,6 +89,7 @@ HTML
|
|
91
89
|
if Rails.version > '5'
|
92
90
|
# Force Rails to dispatch to correct controller
|
93
91
|
ActionDispatch::Routing::RouteSet::Dispatcher.class_eval do
|
92
|
+
alias controller controller
|
94
93
|
define_method(:controller){|_| controller}
|
95
94
|
end
|
96
95
|
config.session_store :cookie_store, :key=>'_autoforme_test_session'
|
data/spec/roda_spec.rb
CHANGED
data/spec/roda_spec_helper.rb
CHANGED
data/spec/sequel_spec_helper.rb
CHANGED
data/spec/sinatra_spec_helper.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
$: << File.expand_path(File.join(__FILE__, '../../lib'))
|
3
2
|
ENV['FRAMEWORK'] ||= 'roda'
|
4
3
|
|
@@ -19,7 +18,7 @@ if ENV['COVERAGE']
|
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
22
|
-
|
21
|
+
require_relative "#{ENV['FRAMEWORK']}_spec_helper"
|
23
22
|
|
24
23
|
require 'capybara'
|
25
24
|
require 'capybara/dsl'
|
@@ -35,7 +34,7 @@ if ENV['WARNING']
|
|
35
34
|
Warning.ignore([:missing_ivar, :fixnum, :not_reached])
|
36
35
|
end
|
37
36
|
|
38
|
-
|
37
|
+
require_relative 'sequel_spec_helper'
|
39
38
|
|
40
39
|
class Minitest::HooksSpec
|
41
40
|
include Rack::Test::Methods
|
data/spec/unit_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: autoforme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: forme
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rack
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -278,14 +278,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
278
278
|
requirements:
|
279
279
|
- - ">="
|
280
280
|
- !ruby/object:Gem::Version
|
281
|
-
version:
|
281
|
+
version: 1.9.2
|
282
282
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
283
283
|
requirements:
|
284
284
|
- - ">="
|
285
285
|
- !ruby/object:Gem::Version
|
286
286
|
version: '0'
|
287
287
|
requirements: []
|
288
|
-
rubygems_version: 3.2.
|
288
|
+
rubygems_version: 3.2.32
|
289
289
|
signing_key:
|
290
290
|
specification_version: 4
|
291
291
|
summary: Web Administrative Console for Roda/Sinatra/Rails and Sequel::Model
|