turboboost 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Appraisals +17 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +6 -44
- data/README.md +36 -22
- data/Rakefile +2 -0
- data/app/assets/javascripts/turboboost.js.coffee +19 -7
- data/gemfiles/rails_3_2.gemfile +13 -0
- data/gemfiles/rails_3_2.gemfile.lock +135 -0
- data/gemfiles/rails_4_0.gemfile +12 -0
- data/gemfiles/rails_4_0.gemfile.lock +116 -0
- data/gemfiles/rails_4_1.gemfile +12 -0
- data/gemfiles/rails_4_1.gemfile.lock +121 -0
- data/gemfiles/rails_4_2.gemfile +13 -0
- data/gemfiles/rails_4_2.gemfile.lock +150 -0
- data/lib/turboboost.rb +2 -159
- data/lib/turboboost/controller.rb +111 -0
- data/lib/turboboost/form_helper.rb +46 -0
- data/lib/turboboost/version.rb +1 -1
- data/test/controller_test.rb +51 -88
- data/test/controllers/items_controller.rb +23 -0
- data/test/controllers/posts_controller.rb +27 -0
- data/test/controllers/users_controller.rb +32 -0
- data/test/locales/en.yml +4 -0
- data/test/test_helper.rb +27 -15
- data/test/view_test.rb +9 -11
- data/test/views/items/show.html.erb +1 -0
- metadata +24 -3
@@ -0,0 +1,116 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
turboboost (0.0.11)
|
5
|
+
coffee-rails
|
6
|
+
jquery-rails
|
7
|
+
railties
|
8
|
+
turbolinks
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
actionmailer (4.0.13)
|
14
|
+
actionpack (= 4.0.13)
|
15
|
+
mail (~> 2.5, >= 2.5.4)
|
16
|
+
actionpack (4.0.13)
|
17
|
+
activesupport (= 4.0.13)
|
18
|
+
builder (~> 3.1.0)
|
19
|
+
erubis (~> 2.7.0)
|
20
|
+
rack (~> 1.5.2)
|
21
|
+
rack-test (~> 0.6.2)
|
22
|
+
activemodel (4.0.13)
|
23
|
+
activesupport (= 4.0.13)
|
24
|
+
builder (~> 3.1.0)
|
25
|
+
activerecord (4.0.13)
|
26
|
+
activemodel (= 4.0.13)
|
27
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
28
|
+
activesupport (= 4.0.13)
|
29
|
+
arel (~> 4.0.0)
|
30
|
+
activerecord-deprecated_finders (1.0.3)
|
31
|
+
activesupport (4.0.13)
|
32
|
+
i18n (~> 0.6, >= 0.6.9)
|
33
|
+
minitest (~> 4.2)
|
34
|
+
multi_json (~> 1.3)
|
35
|
+
thread_safe (~> 0.1)
|
36
|
+
tzinfo (~> 0.3.37)
|
37
|
+
ansi (1.5.0)
|
38
|
+
appraisal (1.0.2)
|
39
|
+
bundler
|
40
|
+
rake
|
41
|
+
thor (>= 0.14.0)
|
42
|
+
arel (4.0.2)
|
43
|
+
awesome_print (1.6.1)
|
44
|
+
builder (3.1.4)
|
45
|
+
coffee-rails (4.1.0)
|
46
|
+
coffee-script (>= 2.2.0)
|
47
|
+
railties (>= 4.0.0, < 5.0)
|
48
|
+
coffee-script (2.3.0)
|
49
|
+
coffee-script-source
|
50
|
+
execjs
|
51
|
+
coffee-script-source (1.8.0)
|
52
|
+
erubis (2.7.0)
|
53
|
+
execjs (2.2.2)
|
54
|
+
hike (1.2.3)
|
55
|
+
i18n (0.7.0)
|
56
|
+
jquery-rails (3.1.2)
|
57
|
+
railties (>= 3.0, < 5.0)
|
58
|
+
thor (>= 0.14, < 2.0)
|
59
|
+
mail (2.6.3)
|
60
|
+
mime-types (>= 1.16, < 3)
|
61
|
+
metaclass (0.0.4)
|
62
|
+
mime-types (2.4.3)
|
63
|
+
minitest (4.7.5)
|
64
|
+
mocha (1.1.0)
|
65
|
+
metaclass (~> 0.0.1)
|
66
|
+
multi_json (1.10.1)
|
67
|
+
rack (1.5.2)
|
68
|
+
rack-test (0.6.3)
|
69
|
+
rack (>= 1.0)
|
70
|
+
rails (4.0.13)
|
71
|
+
actionmailer (= 4.0.13)
|
72
|
+
actionpack (= 4.0.13)
|
73
|
+
activerecord (= 4.0.13)
|
74
|
+
activesupport (= 4.0.13)
|
75
|
+
bundler (>= 1.3.0, < 2.0)
|
76
|
+
railties (= 4.0.13)
|
77
|
+
sprockets-rails (~> 2.0)
|
78
|
+
railties (4.0.13)
|
79
|
+
actionpack (= 4.0.13)
|
80
|
+
activesupport (= 4.0.13)
|
81
|
+
rake (>= 0.8.7)
|
82
|
+
thor (>= 0.18.1, < 2.0)
|
83
|
+
rake (0.9.6)
|
84
|
+
sprockets (2.12.3)
|
85
|
+
hike (~> 1.2)
|
86
|
+
multi_json (~> 1.0)
|
87
|
+
rack (~> 1.0)
|
88
|
+
tilt (~> 1.1, != 1.3.0)
|
89
|
+
sprockets-rails (2.2.2)
|
90
|
+
actionpack (>= 3.0)
|
91
|
+
activesupport (>= 3.0)
|
92
|
+
sprockets (>= 2.8, < 4.0)
|
93
|
+
sqlite3 (1.3.10)
|
94
|
+
thor (0.19.1)
|
95
|
+
thread_safe (0.3.4)
|
96
|
+
tilt (1.4.1)
|
97
|
+
turbolinks (2.5.3)
|
98
|
+
coffee-rails
|
99
|
+
turn (0.9.7)
|
100
|
+
ansi
|
101
|
+
minitest (~> 4)
|
102
|
+
tzinfo (0.3.42)
|
103
|
+
|
104
|
+
PLATFORMS
|
105
|
+
ruby
|
106
|
+
|
107
|
+
DEPENDENCIES
|
108
|
+
appraisal
|
109
|
+
awesome_print
|
110
|
+
bundler (~> 1.3)
|
111
|
+
mocha
|
112
|
+
rails (~> 4.0.13)
|
113
|
+
rake (~> 0)
|
114
|
+
sqlite3
|
115
|
+
turboboost!
|
116
|
+
turn
|
@@ -0,0 +1,121 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
turboboost (0.0.11)
|
5
|
+
coffee-rails
|
6
|
+
jquery-rails
|
7
|
+
railties
|
8
|
+
turbolinks
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
actionmailer (4.1.9)
|
14
|
+
actionpack (= 4.1.9)
|
15
|
+
actionview (= 4.1.9)
|
16
|
+
mail (~> 2.5, >= 2.5.4)
|
17
|
+
actionpack (4.1.9)
|
18
|
+
actionview (= 4.1.9)
|
19
|
+
activesupport (= 4.1.9)
|
20
|
+
rack (~> 1.5.2)
|
21
|
+
rack-test (~> 0.6.2)
|
22
|
+
actionview (4.1.9)
|
23
|
+
activesupport (= 4.1.9)
|
24
|
+
builder (~> 3.1)
|
25
|
+
erubis (~> 2.7.0)
|
26
|
+
activemodel (4.1.9)
|
27
|
+
activesupport (= 4.1.9)
|
28
|
+
builder (~> 3.1)
|
29
|
+
activerecord (4.1.9)
|
30
|
+
activemodel (= 4.1.9)
|
31
|
+
activesupport (= 4.1.9)
|
32
|
+
arel (~> 5.0.0)
|
33
|
+
activesupport (4.1.9)
|
34
|
+
i18n (~> 0.6, >= 0.6.9)
|
35
|
+
json (~> 1.7, >= 1.7.7)
|
36
|
+
minitest (~> 5.1)
|
37
|
+
thread_safe (~> 0.1)
|
38
|
+
tzinfo (~> 1.1)
|
39
|
+
ansi (1.5.0)
|
40
|
+
appraisal (1.0.2)
|
41
|
+
bundler
|
42
|
+
rake
|
43
|
+
thor (>= 0.14.0)
|
44
|
+
arel (5.0.1.20140414130214)
|
45
|
+
awesome_print (1.6.1)
|
46
|
+
builder (3.2.2)
|
47
|
+
coffee-rails (4.1.0)
|
48
|
+
coffee-script (>= 2.2.0)
|
49
|
+
railties (>= 4.0.0, < 5.0)
|
50
|
+
coffee-script (2.3.0)
|
51
|
+
coffee-script-source
|
52
|
+
execjs
|
53
|
+
coffee-script-source (1.8.0)
|
54
|
+
erubis (2.7.0)
|
55
|
+
execjs (2.2.2)
|
56
|
+
hike (1.2.3)
|
57
|
+
i18n (0.7.0)
|
58
|
+
jquery-rails (3.1.2)
|
59
|
+
railties (>= 3.0, < 5.0)
|
60
|
+
thor (>= 0.14, < 2.0)
|
61
|
+
json (1.8.2)
|
62
|
+
mail (2.6.3)
|
63
|
+
mime-types (>= 1.16, < 3)
|
64
|
+
metaclass (0.0.4)
|
65
|
+
mime-types (2.4.3)
|
66
|
+
minitest (5.5.1)
|
67
|
+
mocha (1.1.0)
|
68
|
+
metaclass (~> 0.0.1)
|
69
|
+
multi_json (1.10.1)
|
70
|
+
rack (1.5.2)
|
71
|
+
rack-test (0.6.3)
|
72
|
+
rack (>= 1.0)
|
73
|
+
rails (4.1.9)
|
74
|
+
actionmailer (= 4.1.9)
|
75
|
+
actionpack (= 4.1.9)
|
76
|
+
actionview (= 4.1.9)
|
77
|
+
activemodel (= 4.1.9)
|
78
|
+
activerecord (= 4.1.9)
|
79
|
+
activesupport (= 4.1.9)
|
80
|
+
bundler (>= 1.3.0, < 2.0)
|
81
|
+
railties (= 4.1.9)
|
82
|
+
sprockets-rails (~> 2.0)
|
83
|
+
railties (4.1.9)
|
84
|
+
actionpack (= 4.1.9)
|
85
|
+
activesupport (= 4.1.9)
|
86
|
+
rake (>= 0.8.7)
|
87
|
+
thor (>= 0.18.1, < 2.0)
|
88
|
+
rake (0.9.6)
|
89
|
+
sprockets (2.12.3)
|
90
|
+
hike (~> 1.2)
|
91
|
+
multi_json (~> 1.0)
|
92
|
+
rack (~> 1.0)
|
93
|
+
tilt (~> 1.1, != 1.3.0)
|
94
|
+
sprockets-rails (2.2.2)
|
95
|
+
actionpack (>= 3.0)
|
96
|
+
activesupport (>= 3.0)
|
97
|
+
sprockets (>= 2.8, < 4.0)
|
98
|
+
sqlite3 (1.3.10)
|
99
|
+
thor (0.19.1)
|
100
|
+
thread_safe (0.3.4)
|
101
|
+
tilt (1.4.1)
|
102
|
+
turbolinks (2.5.3)
|
103
|
+
coffee-rails
|
104
|
+
turn (0.9.6)
|
105
|
+
ansi
|
106
|
+
tzinfo (1.2.2)
|
107
|
+
thread_safe (~> 0.1)
|
108
|
+
|
109
|
+
PLATFORMS
|
110
|
+
ruby
|
111
|
+
|
112
|
+
DEPENDENCIES
|
113
|
+
appraisal
|
114
|
+
awesome_print
|
115
|
+
bundler (~> 1.3)
|
116
|
+
mocha
|
117
|
+
rails (~> 4.1.9)
|
118
|
+
rake (~> 0)
|
119
|
+
sqlite3
|
120
|
+
turboboost!
|
121
|
+
turn
|
@@ -0,0 +1,150 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
turboboost (0.0.11)
|
5
|
+
coffee-rails
|
6
|
+
jquery-rails
|
7
|
+
railties
|
8
|
+
turbolinks
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
actionmailer (4.2.0)
|
14
|
+
actionpack (= 4.2.0)
|
15
|
+
actionview (= 4.2.0)
|
16
|
+
activejob (= 4.2.0)
|
17
|
+
mail (~> 2.5, >= 2.5.4)
|
18
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
19
|
+
actionpack (4.2.0)
|
20
|
+
actionview (= 4.2.0)
|
21
|
+
activesupport (= 4.2.0)
|
22
|
+
rack (~> 1.6.0)
|
23
|
+
rack-test (~> 0.6.2)
|
24
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
25
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
26
|
+
actionview (4.2.0)
|
27
|
+
activesupport (= 4.2.0)
|
28
|
+
builder (~> 3.1)
|
29
|
+
erubis (~> 2.7.0)
|
30
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
31
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
32
|
+
activejob (4.2.0)
|
33
|
+
activesupport (= 4.2.0)
|
34
|
+
globalid (>= 0.3.0)
|
35
|
+
activemodel (4.2.0)
|
36
|
+
activesupport (= 4.2.0)
|
37
|
+
builder (~> 3.1)
|
38
|
+
activerecord (4.2.0)
|
39
|
+
activemodel (= 4.2.0)
|
40
|
+
activesupport (= 4.2.0)
|
41
|
+
arel (~> 6.0)
|
42
|
+
activesupport (4.2.0)
|
43
|
+
i18n (~> 0.7)
|
44
|
+
json (~> 1.7, >= 1.7.7)
|
45
|
+
minitest (~> 5.1)
|
46
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
47
|
+
tzinfo (~> 1.1)
|
48
|
+
ansi (1.5.0)
|
49
|
+
appraisal (1.0.2)
|
50
|
+
bundler
|
51
|
+
rake
|
52
|
+
thor (>= 0.14.0)
|
53
|
+
arel (6.0.0)
|
54
|
+
awesome_print (1.6.1)
|
55
|
+
builder (3.2.2)
|
56
|
+
coffee-rails (4.1.0)
|
57
|
+
coffee-script (>= 2.2.0)
|
58
|
+
railties (>= 4.0.0, < 5.0)
|
59
|
+
coffee-script (2.3.0)
|
60
|
+
coffee-script-source
|
61
|
+
execjs
|
62
|
+
coffee-script-source (1.8.0)
|
63
|
+
erubis (2.7.0)
|
64
|
+
execjs (2.2.2)
|
65
|
+
globalid (0.3.0)
|
66
|
+
activesupport (>= 4.1.0)
|
67
|
+
hike (1.2.3)
|
68
|
+
i18n (0.7.0)
|
69
|
+
jquery-rails (4.0.3)
|
70
|
+
rails-dom-testing (~> 1.0)
|
71
|
+
railties (>= 4.2.0)
|
72
|
+
thor (>= 0.14, < 2.0)
|
73
|
+
json (1.8.2)
|
74
|
+
loofah (2.0.1)
|
75
|
+
nokogiri (>= 1.5.9)
|
76
|
+
mail (2.6.3)
|
77
|
+
mime-types (>= 1.16, < 3)
|
78
|
+
metaclass (0.0.4)
|
79
|
+
mime-types (2.4.3)
|
80
|
+
mini_portile (0.6.2)
|
81
|
+
minitest (5.5.1)
|
82
|
+
mocha (1.1.0)
|
83
|
+
metaclass (~> 0.0.1)
|
84
|
+
multi_json (1.10.1)
|
85
|
+
nokogiri (1.6.5)
|
86
|
+
mini_portile (~> 0.6.0)
|
87
|
+
rack (1.6.0)
|
88
|
+
rack-test (0.6.3)
|
89
|
+
rack (>= 1.0)
|
90
|
+
rails (4.2.0)
|
91
|
+
actionmailer (= 4.2.0)
|
92
|
+
actionpack (= 4.2.0)
|
93
|
+
actionview (= 4.2.0)
|
94
|
+
activejob (= 4.2.0)
|
95
|
+
activemodel (= 4.2.0)
|
96
|
+
activerecord (= 4.2.0)
|
97
|
+
activesupport (= 4.2.0)
|
98
|
+
bundler (>= 1.3.0, < 2.0)
|
99
|
+
railties (= 4.2.0)
|
100
|
+
sprockets-rails
|
101
|
+
rails-deprecated_sanitizer (1.0.3)
|
102
|
+
activesupport (>= 4.2.0.alpha)
|
103
|
+
rails-dom-testing (1.0.5)
|
104
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
105
|
+
nokogiri (~> 1.6.0)
|
106
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
107
|
+
rails-html-sanitizer (1.0.1)
|
108
|
+
loofah (~> 2.0)
|
109
|
+
railties (4.2.0)
|
110
|
+
actionpack (= 4.2.0)
|
111
|
+
activesupport (= 4.2.0)
|
112
|
+
rake (>= 0.8.7)
|
113
|
+
thor (>= 0.18.1, < 2.0)
|
114
|
+
rake (0.9.6)
|
115
|
+
responders (2.0.2)
|
116
|
+
railties (>= 4.2.0.alpha, < 5)
|
117
|
+
sprockets (2.12.3)
|
118
|
+
hike (~> 1.2)
|
119
|
+
multi_json (~> 1.0)
|
120
|
+
rack (~> 1.0)
|
121
|
+
tilt (~> 1.1, != 1.3.0)
|
122
|
+
sprockets-rails (2.2.2)
|
123
|
+
actionpack (>= 3.0)
|
124
|
+
activesupport (>= 3.0)
|
125
|
+
sprockets (>= 2.8, < 4.0)
|
126
|
+
sqlite3 (1.3.10)
|
127
|
+
thor (0.19.1)
|
128
|
+
thread_safe (0.3.4)
|
129
|
+
tilt (1.4.1)
|
130
|
+
turbolinks (2.5.3)
|
131
|
+
coffee-rails
|
132
|
+
turn (0.9.6)
|
133
|
+
ansi
|
134
|
+
tzinfo (1.2.2)
|
135
|
+
thread_safe (~> 0.1)
|
136
|
+
|
137
|
+
PLATFORMS
|
138
|
+
ruby
|
139
|
+
|
140
|
+
DEPENDENCIES
|
141
|
+
appraisal
|
142
|
+
awesome_print
|
143
|
+
bundler (~> 1.3)
|
144
|
+
mocha
|
145
|
+
rails (~> 4.2.0)
|
146
|
+
rake (~> 0)
|
147
|
+
responders (~> 2.0)
|
148
|
+
sqlite3
|
149
|
+
turboboost!
|
150
|
+
turn
|
data/lib/turboboost.rb
CHANGED
@@ -1,170 +1,13 @@
|
|
1
|
+
require 'turboboost/controller'
|
2
|
+
require 'turboboost/form_helper'
|
1
3
|
require 'turboboost/version'
|
2
4
|
|
3
|
-
CATCHABLE_ERRORS = {
|
4
|
-
"EOFError" => 500,
|
5
|
-
"Errno::ECONNRESET" => 500,
|
6
|
-
"Errno::EINVAL" => 500,
|
7
|
-
"Timeout::Error" => :request_timeout,
|
8
|
-
"Net::HTTPBadResponse" => 500,
|
9
|
-
"Net::HTTPHeaderSyntaxError" => 500,
|
10
|
-
"Net::ProtocolError" => 500,
|
11
|
-
"ActiveRecord::RecordNotFound" => :not_found,
|
12
|
-
"ActiveRecord::StaleObjectError" => :conflict,
|
13
|
-
"ActiveRecord::RecordInvalid" => :unprocessable_entity,
|
14
|
-
"ActiveRecord::RecordNotSaved" => :unprocessable_entity,
|
15
|
-
"ActiveModel::StrictValidationFailed" => :unprocessable_entity,
|
16
|
-
"ActiveModel::MissingAttributeError" => :unprocessable_entity
|
17
|
-
}
|
18
|
-
|
19
5
|
module Turboboost
|
20
|
-
|
21
|
-
module Controller
|
22
|
-
extend ActiveSupport::Concern
|
23
|
-
|
24
|
-
included do
|
25
|
-
send :rescue_from, *(CATCHABLE_ERRORS.keys), with: :turboboost_error_handler
|
26
|
-
end
|
27
|
-
|
28
|
-
def turboboost_error_handler(error)
|
29
|
-
if request.xhr? and request.headers['HTTP_X_TURBOBOOST']
|
30
|
-
error_status = CATCHABLE_ERRORS[error.class.name]
|
31
|
-
response.headers["X-Turboboosted"] = "1"
|
32
|
-
if defined?(error.record)
|
33
|
-
render_turboboost_errors_for(error.record)
|
34
|
-
else
|
35
|
-
translation = I18n.t("turboboost.errors.#{error.class.name}")
|
36
|
-
message = translation.match("translation missing: (.+)") ? error.class.name : translation
|
37
|
-
render json: [message], status: error_status || 500, root: false
|
38
|
-
end
|
39
|
-
else
|
40
|
-
raise error
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def render_turboboost_errors_for(record)
|
45
|
-
render json: record.errors.full_messages.to_a, status: :unprocessable_entity, root: false
|
46
|
-
end
|
47
|
-
|
48
|
-
def head_turboboost_success(turboboost_flash={})
|
49
|
-
turboboost_flash = _turboboost_get_flash_messages(turboboost_flash)
|
50
|
-
head :ok, "X-Flash" => turboboost_flash.to_json, "X-Turboboosted" => "1"
|
51
|
-
end
|
52
|
-
|
53
|
-
def render(*args, &block)
|
54
|
-
if request.xhr? and request.headers['HTTP_X_TURBOBOOST']
|
55
|
-
turboboost_render(*args, &block)
|
56
|
-
else
|
57
|
-
super
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def turboboost_render(*args, &block)
|
62
|
-
options = _normalize_render(*args, &block)
|
63
|
-
[:replace, :within, :append, :prepend].each do |h|
|
64
|
-
response.headers["X-#{h.capitalize}"] = options[h] if options[h]
|
65
|
-
end
|
66
|
-
response.headers["X-Flash"] = flash.to_hash.to_json if !flash.empty?
|
67
|
-
response.headers["X-Turboboosted"] = "1"
|
68
|
-
self.response_body = render_to_body(options)
|
69
|
-
end
|
70
|
-
|
71
|
-
def redirect_to(options={}, response_status_and_flash={})
|
72
|
-
if request.xhr? and request.headers['HTTP_X_TURBOBOOST']
|
73
|
-
turboboost_redirect_to(options, response_status_and_flash)
|
74
|
-
else
|
75
|
-
super
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def turboboost_redirect_to(options={}, response_status_and_flash={})
|
80
|
-
raise ActionControllerError.new("Cannot redirect to nil!") unless options
|
81
|
-
raise AbstractController::DoubleRenderError if response_body
|
82
|
-
|
83
|
-
# set flash for turbo redirect headers
|
84
|
-
turboboost_flash = _turboboost_get_flash_messages(response_status_and_flash)
|
85
|
-
|
86
|
-
if Rails.version < "4.2"
|
87
|
-
self.location = _compute_redirect_to_location(options)
|
88
|
-
else
|
89
|
-
self.location = _compute_redirect_to_location(request, options)
|
90
|
-
end
|
91
|
-
|
92
|
-
head :ok, "X-Flash" => turboboost_flash.to_json
|
93
|
-
|
94
|
-
flash.update(turboboost_flash) # set flash for rendered view
|
95
|
-
end
|
96
|
-
|
97
|
-
def _turboboost_get_flash_messages(response_status_and_flash={})
|
98
|
-
turboboost_flash = {}
|
99
|
-
flash_types = defined?(self.class._flash_types) ? self.class._flash_types : [:alert, :notice]
|
100
|
-
flash_types.each do |flash_type|
|
101
|
-
if type = flash.delete(type)
|
102
|
-
turboboost_flash.update(type)
|
103
|
-
end
|
104
|
-
if type = response_status_and_flash.delete(flash_type)
|
105
|
-
turboboost_flash[flash_type] = type
|
106
|
-
end
|
107
|
-
end
|
108
|
-
if other_flashes = response_status_and_flash.delete(:flash)
|
109
|
-
turboboost_flash.update(other_flashes)
|
110
|
-
end
|
111
|
-
turboboost_flash
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
115
|
-
|
116
|
-
# borrowed from - https://github.com/fs/turboforms/blob/master/lib/turboforms.rb
|
117
|
-
module FormHelper
|
118
|
-
extend ActiveSupport::Concern
|
119
|
-
|
120
|
-
included do
|
121
|
-
alias_method_chain :form_for, :data_turboboost
|
122
|
-
alias_method_chain :form_tag, :data_turboboost
|
123
|
-
end
|
124
|
-
|
125
|
-
def form_for_with_data_turboboost(record_or_name_or_array, *args, &proc)
|
126
|
-
options = args.extract_options!
|
127
|
-
|
128
|
-
if options.has_key?(:turboboost) && options.delete(:turboboost)
|
129
|
-
options[:html] ||= {}
|
130
|
-
options[:html]["data-turboboost"] = true
|
131
|
-
options[:remote] = true
|
132
|
-
end
|
133
|
-
|
134
|
-
form_for_without_data_turboboost(record_or_name_or_array, *(args << options), &proc)
|
135
|
-
end
|
136
|
-
|
137
|
-
def form_tag_with_data_turboboost(record_or_name_or_array, *args, &proc)
|
138
|
-
options = args.extract_options!
|
139
|
-
|
140
|
-
if options.has_key?(:turboboost) && options.delete(:turboboost)
|
141
|
-
options[:data] ||= {}
|
142
|
-
options[:data]["turboboost"] = true
|
143
|
-
options[:remote] = true
|
144
|
-
end
|
145
|
-
|
146
|
-
form_tag_without_data_turboboost(record_or_name_or_array, *(args << options), &proc)
|
147
|
-
end
|
148
|
-
|
149
|
-
def convert_options_to_data_attributes(options, html_options)
|
150
|
-
if html_options
|
151
|
-
html_options = html_options.stringify_keys
|
152
|
-
if turboboost = html_options.delete("turboboost")
|
153
|
-
html_options["data-remote"] = "true"
|
154
|
-
html_options["data-turboboost"] = "true"
|
155
|
-
end
|
156
|
-
end
|
157
|
-
super options, html_options
|
158
|
-
end
|
159
|
-
|
160
|
-
end
|
161
|
-
|
162
6
|
class Engine < Rails::Engine
|
163
7
|
initializer :turboboost do
|
164
8
|
ActionView::Base.send :include, Turboboost::FormHelper
|
165
9
|
end
|
166
10
|
end
|
167
|
-
|
168
11
|
end
|
169
12
|
|
170
13
|
ActiveSupport.on_load(:action_controller) do
|