dismissible_blocks 0.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/README.markdown +58 -39
  3. data/app/controllers/dismissible_blocks_controller.rb +15 -1
  4. data/app/helpers/dismissible_blocks_helper.rb +31 -1
  5. data/lib/dismissible_blocks.rb +0 -5
  6. data/lib/dismissible_blocks/controllers/helpers.rb +17 -0
  7. data/lib/dismissible_blocks/engine.rb +7 -0
  8. data/lib/dismissible_blocks/version.rb +1 -1
  9. data/test/capybara_helper.rb +1 -0
  10. data/test/dummy/Rakefile +1 -1
  11. data/test/dummy/bin/rails +1 -1
  12. data/test/dummy/bin/setup +29 -0
  13. data/test/dummy/config/application.rb +4 -1
  14. data/test/dummy/config/environment.rb +1 -1
  15. data/test/dummy/config/environments/development.rb +3 -20
  16. data/test/dummy/config/environments/test.rb +4 -27
  17. data/test/dummy/config/initializers/assets.rb +1 -0
  18. data/test/dummy/config/initializers/cookies_serializer.rb +1 -0
  19. data/test/dummy/config/initializers/session_store.rb +1 -1
  20. data/test/dummy/config/initializers/wrap_parameters.rb +3 -0
  21. data/test/dummy/config/routes.rb +1 -1
  22. data/test/dummy/config/secrets.yml +5 -0
  23. data/test/dummy/db/test.sqlite3 +0 -0
  24. data/test/dummy/log/test.log +8591 -0
  25. data/test/dummy/public/404.html +20 -11
  26. data/test/dummy/public/422.html +20 -11
  27. data/test/dummy/public/500.html +19 -10
  28. data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  29. data/test/dummy/tmp/cache/assets/test/sprockets/20baaf5349726643b47186eb8ef347cd +0 -0
  30. data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  31. data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  32. data/test/dummy/tmp/cache/assets/test/sprockets/521b1a38668a260afc395f0b0853e2c2 +0 -0
  33. data/test/dummy/tmp/cache/assets/test/sprockets/58a8328804a777933d757eb9a448eaf5 +0 -0
  34. data/test/dummy/tmp/cache/assets/test/sprockets/96c147c638b08a4c0178d9c66c3b9c48 +0 -0
  35. data/test/dummy/tmp/cache/assets/test/sprockets/9708d20fa7cc14e3657195722d1a3948 +0 -0
  36. data/test/dummy/tmp/cache/assets/test/sprockets/ac2d5385dbcd9cea11c510dc83189bba +0 -0
  37. data/test/dummy/tmp/cache/assets/test/sprockets/bec12e1e92fe458e19b5f9869454ac1a +0 -0
  38. data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  39. data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  40. data/test/dummy/tmp/cache/assets/test/sprockets/ecbb0d7ff91e9d89fc001dcc70d1d48f +0 -0
  41. data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  42. data/test/lib/controllers/helpers_test.rb +14 -0
  43. data/test/test_helper.rb +1 -2
  44. metadata +20 -7
  45. data/lib/dismissible_blocks/controller.rb +0 -18
  46. data/lib/dismissible_blocks/helper.rb +0 -34
  47. data/test/dummy/config/initializers/secret_token.rb +0 -1
@@ -2,17 +2,23 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
5
6
  <style>
6
7
  body {
7
8
  background-color: #EFEFEF;
8
9
  color: #2E2F30;
9
10
  text-align: center;
10
11
  font-family: arial, sans-serif;
12
+ margin: 0;
11
13
  }
12
14
 
13
15
  div.dialog {
14
- width: 25em;
15
- margin: 4em auto 0 auto;
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
16
22
  border: 1px solid #CCC;
17
23
  border-right-color: #999;
18
24
  border-left-color: #999;
@@ -21,7 +27,8 @@
21
27
  border-top-left-radius: 9px;
22
28
  border-top-right-radius: 9px;
23
29
  background-color: white;
24
- padding: 7px 4em 0 4em;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
25
32
  }
26
33
 
27
34
  h1 {
@@ -30,19 +37,19 @@
30
37
  line-height: 1.5em;
31
38
  }
32
39
 
33
- body > p {
34
- width: 33em;
35
- margin: 0 auto 1em;
36
- padding: 1em 0;
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
37
43
  background-color: #F7F7F7;
38
44
  border: 1px solid #CCC;
39
45
  border-right-color: #999;
46
+ border-left-color: #999;
40
47
  border-bottom-color: #999;
41
48
  border-bottom-left-radius: 4px;
42
49
  border-bottom-right-radius: 4px;
43
50
  border-top-color: #DADADA;
44
51
  color: #666;
45
- box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
46
53
  }
47
54
  </style>
48
55
  </head>
@@ -50,9 +57,11 @@
50
57
  <body>
51
58
  <!-- This file lives in public/404.html -->
52
59
  <div class="dialog">
53
- <h1>The page you were looking for doesn't exist.</h1>
54
- <p>You may have mistyped the address or the page may have moved.</p>
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
55
65
  </div>
56
- <p>If you are the application owner check the logs for more information.</p>
57
66
  </body>
58
67
  </html>
@@ -2,17 +2,23 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
5
6
  <style>
6
7
  body {
7
8
  background-color: #EFEFEF;
8
9
  color: #2E2F30;
9
10
  text-align: center;
10
11
  font-family: arial, sans-serif;
12
+ margin: 0;
11
13
  }
12
14
 
13
15
  div.dialog {
14
- width: 25em;
15
- margin: 4em auto 0 auto;
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
16
22
  border: 1px solid #CCC;
17
23
  border-right-color: #999;
18
24
  border-left-color: #999;
@@ -21,7 +27,8 @@
21
27
  border-top-left-radius: 9px;
22
28
  border-top-right-radius: 9px;
23
29
  background-color: white;
24
- padding: 7px 4em 0 4em;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
25
32
  }
26
33
 
27
34
  h1 {
@@ -30,19 +37,19 @@
30
37
  line-height: 1.5em;
31
38
  }
32
39
 
33
- body > p {
34
- width: 33em;
35
- margin: 0 auto 1em;
36
- padding: 1em 0;
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
37
43
  background-color: #F7F7F7;
38
44
  border: 1px solid #CCC;
39
45
  border-right-color: #999;
46
+ border-left-color: #999;
40
47
  border-bottom-color: #999;
41
48
  border-bottom-left-radius: 4px;
42
49
  border-bottom-right-radius: 4px;
43
50
  border-top-color: #DADADA;
44
51
  color: #666;
45
- box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
46
53
  }
47
54
  </style>
48
55
  </head>
@@ -50,9 +57,11 @@
50
57
  <body>
51
58
  <!-- This file lives in public/422.html -->
52
59
  <div class="dialog">
53
- <h1>The change you wanted was rejected.</h1>
54
- <p>Maybe you tried to change something you didn't have access to.</p>
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
55
65
  </div>
56
- <p>If you are the application owner check the logs for more information.</p>
57
66
  </body>
58
67
  </html>
@@ -2,17 +2,23 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
5
6
  <style>
6
7
  body {
7
8
  background-color: #EFEFEF;
8
9
  color: #2E2F30;
9
10
  text-align: center;
10
11
  font-family: arial, sans-serif;
12
+ margin: 0;
11
13
  }
12
14
 
13
15
  div.dialog {
14
- width: 25em;
15
- margin: 4em auto 0 auto;
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
16
22
  border: 1px solid #CCC;
17
23
  border-right-color: #999;
18
24
  border-left-color: #999;
@@ -21,7 +27,8 @@
21
27
  border-top-left-radius: 9px;
22
28
  border-top-right-radius: 9px;
23
29
  background-color: white;
24
- padding: 7px 4em 0 4em;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
25
32
  }
26
33
 
27
34
  h1 {
@@ -30,19 +37,19 @@
30
37
  line-height: 1.5em;
31
38
  }
32
39
 
33
- body > p {
34
- width: 33em;
35
- margin: 0 auto 1em;
36
- padding: 1em 0;
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
37
43
  background-color: #F7F7F7;
38
44
  border: 1px solid #CCC;
39
45
  border-right-color: #999;
46
+ border-left-color: #999;
40
47
  border-bottom-color: #999;
41
48
  border-bottom-left-radius: 4px;
42
49
  border-bottom-right-radius: 4px;
43
50
  border-top-color: #DADADA;
44
51
  color: #666;
45
- box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
46
53
  }
47
54
  </style>
48
55
  </head>
@@ -50,8 +57,10 @@
50
57
  <body>
51
58
  <!-- This file lives in public/500.html -->
52
59
  <div class="dialog">
53
- <h1>We're sorry, but something went wrong.</h1>
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
54
64
  </div>
55
- <p>If you are the application owner check the logs for more information.</p>
56
65
  </body>
57
66
  </html>
@@ -0,0 +1,14 @@
1
+ require 'test_helper'
2
+
3
+ class DismissibleBlocks::Controllers::HelpersTest < ActionController::TestCase
4
+
5
+ test "should be DismissibleBlocksController" do
6
+ controller = DismissibleBlocksController.new
7
+ assert controller.send(:dismissible_blocks_controller?)
8
+ end
9
+
10
+ test "should not be DismissibleBlocksController" do
11
+ controller = SessionsController.new
12
+ refute controller.send(:dismissible_blocks_controller?)
13
+ end
14
+ end
data/test/test_helper.rb CHANGED
@@ -3,7 +3,6 @@ ENV['RAILS_ENV'] = 'test'
3
3
  require File.expand_path('../dummy/config/environment.rb', __FILE__)
4
4
  require 'rails/test_help'
5
5
 
6
- Rails.backtrace_cleaner.remove_silencers!
7
- ActiveRecord::Migrator.migrate File.expand_path('../dummy/db/migrate', __FILE__)
6
+ Minitest.backtrace_filter = Minitest::BacktraceFilter.new
8
7
  ActiveSupport::TestCase.fixture_path = File.expand_path('../fixtures', __FILE__)
9
8
  ActiveSupport::TestCase.fixtures :all
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dismissible_blocks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Bougie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-05 00:00:00.000000000 Z
11
+ date: 2014-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -126,9 +126,8 @@ files:
126
126
  - app/helpers/dismissible_blocks_helper.rb
127
127
  - config/routes.rb
128
128
  - lib/dismissible_blocks.rb
129
- - lib/dismissible_blocks/controller.rb
129
+ - lib/dismissible_blocks/controllers/helpers.rb
130
130
  - lib/dismissible_blocks/engine.rb
131
- - lib/dismissible_blocks/helper.rb
132
131
  - lib/dismissible_blocks/version.rb
133
132
  - test/capybara_helper.rb
134
133
  - test/controllers/dismissible_blocks_controller_test.rb
@@ -148,6 +147,7 @@ files:
148
147
  - test/dummy/bin/bundle
149
148
  - test/dummy/bin/rails
150
149
  - test/dummy/bin/rake
150
+ - test/dummy/bin/setup
151
151
  - test/dummy/config.ru
152
152
  - test/dummy/config/application.rb
153
153
  - test/dummy/config/boot.rb
@@ -155,10 +155,13 @@ files:
155
155
  - test/dummy/config/environment.rb
156
156
  - test/dummy/config/environments/development.rb
157
157
  - test/dummy/config/environments/test.rb
158
+ - test/dummy/config/initializers/assets.rb
159
+ - test/dummy/config/initializers/cookies_serializer.rb
158
160
  - test/dummy/config/initializers/filter_parameter_logging.rb
159
- - test/dummy/config/initializers/secret_token.rb
160
161
  - test/dummy/config/initializers/session_store.rb
162
+ - test/dummy/config/initializers/wrap_parameters.rb
161
163
  - test/dummy/config/routes.rb
164
+ - test/dummy/config/secrets.yml
162
165
  - test/dummy/db/migrate/20140303154458_create_users.rb
163
166
  - test/dummy/db/migrate/20140303161500_add_dismissed_blocks_to_users.rb
164
167
  - test/dummy/db/schema.rb
@@ -185,8 +188,10 @@ files:
185
188
  - test/dummy/tmp/cache/assets/development/sprockets/ecbb0d7ff91e9d89fc001dcc70d1d48f
186
189
  - test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655
187
190
  - test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705
191
+ - test/dummy/tmp/cache/assets/test/sprockets/20baaf5349726643b47186eb8ef347cd
188
192
  - test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af
189
193
  - test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953
194
+ - test/dummy/tmp/cache/assets/test/sprockets/521b1a38668a260afc395f0b0853e2c2
190
195
  - test/dummy/tmp/cache/assets/test/sprockets/58a8328804a777933d757eb9a448eaf5
191
196
  - test/dummy/tmp/cache/assets/test/sprockets/96c147c638b08a4c0178d9c66c3b9c48
192
197
  - test/dummy/tmp/cache/assets/test/sprockets/9708d20fa7cc14e3657195722d1a3948
@@ -199,6 +204,7 @@ files:
199
204
  - test/features/dismissible_blocks_test.rb
200
205
  - test/fixtures/users.yml
201
206
  - test/helpers/dismissible_blocks_helper_test.rb
207
+ - test/lib/controllers/helpers_test.rb
202
208
  - test/test_helper.rb
203
209
  homepage: https://github.com/pbougie/dismissible_blocks
204
210
  licenses:
@@ -220,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
226
  version: '0'
221
227
  requirements: []
222
228
  rubyforge_project:
223
- rubygems_version: 2.2.2
229
+ rubygems_version: 2.4.5
224
230
  signing_key:
225
231
  specification_version: 4
226
232
  summary: Dismissible HTML blocks for Ruby on Rails
@@ -242,16 +248,20 @@ test_files:
242
248
  - test/dummy/bin/bundle
243
249
  - test/dummy/bin/rails
244
250
  - test/dummy/bin/rake
251
+ - test/dummy/bin/setup
245
252
  - test/dummy/config/application.rb
246
253
  - test/dummy/config/boot.rb
247
254
  - test/dummy/config/database.yml
248
255
  - test/dummy/config/environment.rb
249
256
  - test/dummy/config/environments/development.rb
250
257
  - test/dummy/config/environments/test.rb
258
+ - test/dummy/config/initializers/assets.rb
259
+ - test/dummy/config/initializers/cookies_serializer.rb
251
260
  - test/dummy/config/initializers/filter_parameter_logging.rb
252
- - test/dummy/config/initializers/secret_token.rb
253
261
  - test/dummy/config/initializers/session_store.rb
262
+ - test/dummy/config/initializers/wrap_parameters.rb
254
263
  - test/dummy/config/routes.rb
264
+ - test/dummy/config/secrets.yml
255
265
  - test/dummy/config.ru
256
266
  - test/dummy/db/migrate/20140303154458_create_users.rb
257
267
  - test/dummy/db/migrate/20140303161500_add_dismissed_blocks_to_users.rb
@@ -280,8 +290,10 @@ test_files:
280
290
  - test/dummy/tmp/cache/assets/development/sprockets/ecbb0d7ff91e9d89fc001dcc70d1d48f
281
291
  - test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655
282
292
  - test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705
293
+ - test/dummy/tmp/cache/assets/test/sprockets/20baaf5349726643b47186eb8ef347cd
283
294
  - test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af
284
295
  - test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953
296
+ - test/dummy/tmp/cache/assets/test/sprockets/521b1a38668a260afc395f0b0853e2c2
285
297
  - test/dummy/tmp/cache/assets/test/sprockets/58a8328804a777933d757eb9a448eaf5
286
298
  - test/dummy/tmp/cache/assets/test/sprockets/96c147c638b08a4c0178d9c66c3b9c48
287
299
  - test/dummy/tmp/cache/assets/test/sprockets/9708d20fa7cc14e3657195722d1a3948
@@ -294,4 +306,5 @@ test_files:
294
306
  - test/features/dismissible_blocks_test.rb
295
307
  - test/fixtures/users.yml
296
308
  - test/helpers/dismissible_blocks_helper_test.rb
309
+ - test/lib/controllers/helpers_test.rb
297
310
  - test/test_helper.rb
@@ -1,18 +0,0 @@
1
- module DismissibleBlocks::Controller
2
-
3
- def create
4
- if current_user_available
5
- current_user.dismissed_blocks += [ params[:block].to_s ]
6
- current_user.save!
7
- render :json => {}, :status => :ok
8
- else
9
- render :json => {}, :status => :unprocessable_entity
10
- end
11
- end
12
-
13
- private
14
-
15
- def current_user_available
16
- respond_to?(:current_user) && current_user.respond_to?(:dismissed_blocks)
17
- end
18
- end
@@ -1,34 +0,0 @@
1
- module DismissibleBlocks::Helper
2
-
3
- def render_dismissible_block(name, &block)
4
- unless dismissed?(name)
5
- if block_given?
6
- contents = capture(&block)
7
- add_block_name_to_attributes(contents, name)
8
- else
9
- raise DismissibleBlocks::ContentMissing
10
- end
11
- end
12
- end
13
-
14
- private
15
-
16
- def dismissed?(name)
17
- if respond_to?(:current_user)
18
- if !current_user.respond_to?(:dismissed_blocks)
19
- raise DismissibleBlocks::AttributeUnavailable
20
- elsif !current_user.dismissed_blocks.is_a?(Array)
21
- raise DismissibleBlocks::AttributeNotArray
22
- else
23
- current_user.dismissed_blocks.include?(name)
24
- end
25
- else
26
- raise DismissibleBlocks::ModelUnavailable
27
- end
28
- end
29
-
30
- def add_block_name_to_attributes(contents, name)
31
- contents.gsub! /(data-dismissible)(-hide)?(?!-)/, "\\1\\2='#{name}'"
32
- contents.html_safe
33
- end
34
- end