effective_style_guide 1.5.5 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +13 -9
  4. data/app/controllers/effective/style_guide_controller.rb +17 -2
  5. data/app/models/effective/style_guide.rb +14 -2
  6. data/app/views/effective/style_guide/_alerts.html +45 -0
  7. data/app/views/effective/style_guide/_badges.html +45 -0
  8. data/app/views/effective/style_guide/_breadcrumbs.html +20 -0
  9. data/app/views/effective/style_guide/_buttons.html +87 -0
  10. data/app/views/effective/style_guide/_buttons_group.html +90 -0
  11. data/app/views/effective/style_guide/_cards.html +496 -0
  12. data/app/views/effective/style_guide/_collapse.html +85 -0
  13. data/app/views/effective/style_guide/_dropdowns.html +177 -0
  14. data/app/views/effective/style_guide/_form_with.html.haml +77 -0
  15. data/app/views/effective/style_guide/_input_groups.html +300 -0
  16. data/app/views/effective/style_guide/_jumbotrons.html +18 -0
  17. data/app/views/effective/style_guide/_list_groups.html +156 -0
  18. data/app/views/effective/style_guide/_modals.html +81 -0
  19. data/app/views/effective/style_guide/_navs.html +204 -0
  20. data/app/views/effective/style_guide/_pagination.html +126 -0
  21. data/app/views/effective/style_guide/_progress.html +120 -0
  22. data/app/views/effective/style_guide/show.html.haml +14 -80
  23. data/app/views/effective/{style_guide → style_guide_bootstrap3}/_alerts.html.haml +0 -0
  24. data/app/views/effective/{style_guide → style_guide_bootstrap3}/_breadcrumbs.html.haml +0 -0
  25. data/app/views/effective/{style_guide → style_guide_bootstrap3}/_buttons.html.haml +0 -0
  26. data/app/views/effective/{style_guide → style_guide_bootstrap3}/_form_horizontal.html.haml +0 -0
  27. data/app/views/effective/{style_guide → style_guide_bootstrap3}/_form_inline.html.haml +0 -0
  28. data/app/views/effective/{style_guide → style_guide_bootstrap3}/_form_vertical.html.haml +0 -0
  29. data/app/views/effective/{style_guide → style_guide_bootstrap3}/_jumbotron.html.haml +0 -0
  30. data/app/views/effective/{style_guide → style_guide_bootstrap3}/_labels.html.haml +0 -0
  31. data/app/views/effective/{style_guide → style_guide_bootstrap3}/_list_groups.html.haml +0 -0
  32. data/app/views/effective/{style_guide → style_guide_bootstrap3}/_modals.html.haml +0 -0
  33. data/app/views/effective/{style_guide → style_guide_bootstrap3}/_navs.html.haml +0 -0
  34. data/app/views/effective/{style_guide → style_guide_bootstrap3}/_pagination.html.haml +0 -0
  35. data/app/views/effective/{style_guide → style_guide_bootstrap3}/_panels.html.haml +0 -0
  36. data/app/views/effective/{style_guide → style_guide_bootstrap3}/_progress_bars.html.haml +0 -0
  37. data/app/views/effective/{style_guide → style_guide_bootstrap3}/_tables.html.haml +0 -0
  38. data/app/views/effective/{style_guide → style_guide_bootstrap3}/_thumbnails.html.haml +3 -2
  39. data/app/views/effective/{style_guide → style_guide_bootstrap3}/_typography.html.haml +0 -0
  40. data/app/views/effective/{style_guide → style_guide_bootstrap3}/_wells.html.haml +0 -0
  41. data/app/views/effective/style_guide_bootstrap3/show.html.haml +89 -0
  42. data/config/effective_style_guide.rb +14 -14
  43. data/config/routes.rb +2 -3
  44. data/lib/effective_style_guide.rb +20 -6
  45. data/lib/effective_style_guide/version.rb +1 -1
  46. metadata +41 -56
  47. data/Rakefile +0 -20
  48. data/app/datatables/effective_style_guide_datatable.rb +0 -45
  49. data/app/models/effective/datatables/style_guide.rb +0 -55
  50. data/app/views/effective/style_guide/_effective_datatable.html.haml +0 -9
@@ -2,25 +2,25 @@ EffectiveStyleGuide.setup do |config|
2
2
  # Authorization Method
3
3
  #
4
4
  # This method is called by all controller actions with the appropriate action and resource
5
- # If the method returns false, an Effective::AccessDenied Error will be raised (see README.md for complete info)
5
+ # If it raises an exception or returns false, an Effective::AccessDenied Error will be raised
6
6
  #
7
- # Use via Proc (and with CanCan):
8
- # config.authorization_method = Proc.new { |controller, action, resource| can?(action, resource) }
7
+ # Use via Proc:
8
+ # Proc.new { |controller, action, resource| authorize!(action, resource) } # CanCan
9
+ # Proc.new { |controller, action, resource| can?(action, resource) } # CanCan with skip_authorization_check
10
+ # Proc.new { |controller, action, resource| authorize "#{action}?", resource } # Pundit
11
+ # Proc.new { |controller, action, resource| current_user.is?(:admin) } # Custom logic
9
12
  #
10
- # Use via custom method:
11
- # config.authorization_method = :my_authorization_method
12
- #
13
- # And then in your application_controller.rb:
13
+ # Use via Boolean:
14
+ # config.authorization_method = true # Always authorized
15
+ # config.authorization_method = false # Always unauthorized
14
16
  #
15
- # def my_authorization_method(action, resource)
16
- # current_user.is?(:admin)
17
+ # Use via Method (probably in your application_controller.rb):
18
+ # config.authorization_method = :my_authorization_method
19
+ # def my_authorization_method(resource, action)
20
+ # true
17
21
  # end
18
- #
19
- # Or disable the check completely:
20
- # config.authorization_method = false
21
22
  config.authorization_method = Proc.new { |controller, action, resource| authorize!(action, resource) } # CanCanCan
22
23
 
23
- # Admin Screens Layout Settings
24
+ # Layout Settings
24
25
  config.layout = 'application' # All EffectiveStyleGuide controllers will use this layout
25
-
26
26
  end
data/config/routes.rb CHANGED
@@ -4,8 +4,7 @@ end
4
4
 
5
5
  EffectiveStyleGuide::Engine.routes.draw do
6
6
  scope :module => 'effective' do
7
- match '/styleguide', :to => 'style_guide#show', :via => [:get], :as => 'style_guide'
8
- match '/style-guide', :to => 'style_guide#show', :via => [:get]
9
- match '/style_guide', :to => 'style_guide#show', :via => [:get]
7
+ match '/styleguide', to: 'style_guide#show', via: [:get, :post, :patch], as: 'style_guide'
8
+ match '/styleguide/bootstrap3', to: 'style_guide#bootstrap3', via: :get
10
9
  end
11
10
  end
@@ -12,10 +12,20 @@ module EffectiveStyleGuide
12
12
  end
13
13
 
14
14
  def self.authorized?(controller, action, resource)
15
- if authorization_method.respond_to?(:call) || authorization_method.kind_of?(Symbol)
16
- raise Effective::AccessDenied.new() unless (controller || self).instance_exec(controller, action, resource, &authorization_method)
15
+ @_exceptions ||= [Effective::AccessDenied, (CanCan::AccessDenied if defined?(CanCan)), (Pundit::NotAuthorizedError if defined?(Pundit))].compact
16
+
17
+ return !!authorization_method unless authorization_method.respond_to?(:call)
18
+ controller = controller.controller if controller.respond_to?(:controller)
19
+
20
+ begin
21
+ !!(controller || self).instance_exec((controller || self), action, resource, &authorization_method)
22
+ rescue *@_exceptions
23
+ false
17
24
  end
18
- true
25
+ end
26
+
27
+ def self.authorize!(controller, action, resource)
28
+ raise Effective::AccessDenied unless authorized?(controller, action, resource)
19
29
  end
20
30
 
21
31
  def self.colors
@@ -23,14 +33,18 @@ module EffectiveStyleGuide
23
33
  end
24
34
 
25
35
  def self.foods
36
+ ['bacon', 'eggs', 'hash browns']
37
+ end
38
+
39
+ def self.drinks
26
40
  ['Coffee', 'Tea', 'Soda']
27
41
  end
28
42
 
29
43
  def self.grouped_colors
30
44
  {
31
- 'Top' => [['Red', 1], ['Orange', 2], ['Yellow', 3]],
32
- 'Middle' => [['Green', 4], ['Blue', 5], ['Indigo', 6]],
33
- 'Bottom' => [['Violet', 7]]
45
+ 'Top' => [['red', 'red'], ['orange', 'orange'], ['yellow', 'yellow']],
46
+ 'Middle' => [['green', 'green'], ['blue', 'blue'], ['indigo', 'indigo']],
47
+ 'Bottom' => [['violet', 'violet']]
34
48
  }
35
49
  end
36
50
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveStyleGuide
2
- VERSION = '1.5.5'.freeze
2
+ VERSION = '2.0.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_style_guide
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-11 00:00:00.000000000 Z
11
+ date: 2018-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.2.0
27
- - !ruby/object:Gem::Dependency
28
- name: coffee-rails
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: faker
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,22 +38,8 @@ dependencies:
52
38
  - - ">="
53
39
  - !ruby/object:Gem::Version
54
40
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: simple_form
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- description: Ensure that your custom CSS theme looks good with all Twitter Bootstrap3
70
- html components.
41
+ description: Ensure that your custom CSS theme looks good with all Twitter Bootstrap4
42
+ (and 3) html components.
71
43
  email:
72
44
  - info@codeandeffect.com
73
45
  executables: []
@@ -76,32 +48,45 @@ extra_rdoc_files: []
76
48
  files:
77
49
  - MIT-LICENSE
78
50
  - README.md
79
- - Rakefile
80
51
  - app/controllers/effective/style_guide_controller.rb
81
- - app/datatables/effective_style_guide_datatable.rb
82
52
  - app/models/effective/access_denied.rb
83
- - app/models/effective/datatables/style_guide.rb
84
53
  - app/models/effective/style_guide.rb
85
- - app/views/effective/style_guide/_alerts.html.haml
86
- - app/views/effective/style_guide/_breadcrumbs.html.haml
87
- - app/views/effective/style_guide/_buttons.html.haml
88
- - app/views/effective/style_guide/_effective_datatable.html.haml
89
- - app/views/effective/style_guide/_form_horizontal.html.haml
90
- - app/views/effective/style_guide/_form_inline.html.haml
91
- - app/views/effective/style_guide/_form_vertical.html.haml
92
- - app/views/effective/style_guide/_jumbotron.html.haml
93
- - app/views/effective/style_guide/_labels.html.haml
94
- - app/views/effective/style_guide/_list_groups.html.haml
95
- - app/views/effective/style_guide/_modals.html.haml
96
- - app/views/effective/style_guide/_navs.html.haml
97
- - app/views/effective/style_guide/_pagination.html.haml
98
- - app/views/effective/style_guide/_panels.html.haml
99
- - app/views/effective/style_guide/_progress_bars.html.haml
100
- - app/views/effective/style_guide/_tables.html.haml
101
- - app/views/effective/style_guide/_thumbnails.html.haml
102
- - app/views/effective/style_guide/_typography.html.haml
103
- - app/views/effective/style_guide/_wells.html.haml
54
+ - app/views/effective/style_guide/_alerts.html
55
+ - app/views/effective/style_guide/_badges.html
56
+ - app/views/effective/style_guide/_breadcrumbs.html
57
+ - app/views/effective/style_guide/_buttons.html
58
+ - app/views/effective/style_guide/_buttons_group.html
59
+ - app/views/effective/style_guide/_cards.html
60
+ - app/views/effective/style_guide/_collapse.html
61
+ - app/views/effective/style_guide/_dropdowns.html
62
+ - app/views/effective/style_guide/_form_with.html.haml
63
+ - app/views/effective/style_guide/_input_groups.html
64
+ - app/views/effective/style_guide/_jumbotrons.html
65
+ - app/views/effective/style_guide/_list_groups.html
66
+ - app/views/effective/style_guide/_modals.html
67
+ - app/views/effective/style_guide/_navs.html
68
+ - app/views/effective/style_guide/_pagination.html
69
+ - app/views/effective/style_guide/_progress.html
104
70
  - app/views/effective/style_guide/show.html.haml
71
+ - app/views/effective/style_guide_bootstrap3/_alerts.html.haml
72
+ - app/views/effective/style_guide_bootstrap3/_breadcrumbs.html.haml
73
+ - app/views/effective/style_guide_bootstrap3/_buttons.html.haml
74
+ - app/views/effective/style_guide_bootstrap3/_form_horizontal.html.haml
75
+ - app/views/effective/style_guide_bootstrap3/_form_inline.html.haml
76
+ - app/views/effective/style_guide_bootstrap3/_form_vertical.html.haml
77
+ - app/views/effective/style_guide_bootstrap3/_jumbotron.html.haml
78
+ - app/views/effective/style_guide_bootstrap3/_labels.html.haml
79
+ - app/views/effective/style_guide_bootstrap3/_list_groups.html.haml
80
+ - app/views/effective/style_guide_bootstrap3/_modals.html.haml
81
+ - app/views/effective/style_guide_bootstrap3/_navs.html.haml
82
+ - app/views/effective/style_guide_bootstrap3/_pagination.html.haml
83
+ - app/views/effective/style_guide_bootstrap3/_panels.html.haml
84
+ - app/views/effective/style_guide_bootstrap3/_progress_bars.html.haml
85
+ - app/views/effective/style_guide_bootstrap3/_tables.html.haml
86
+ - app/views/effective/style_guide_bootstrap3/_thumbnails.html.haml
87
+ - app/views/effective/style_guide_bootstrap3/_typography.html.haml
88
+ - app/views/effective/style_guide_bootstrap3/_wells.html.haml
89
+ - app/views/effective/style_guide_bootstrap3/show.html.haml
105
90
  - config/effective_style_guide.rb
106
91
  - config/routes.rb
107
92
  - lib/effective_style_guide.rb
@@ -132,6 +117,6 @@ rubyforge_project:
132
117
  rubygems_version: 2.4.5.1
133
118
  signing_key:
134
119
  specification_version: 4
135
- summary: Ensure that your custom CSS theme looks good with all Twitter Bootstrap3
136
- html components.
120
+ summary: Ensure that your custom CSS theme looks good with all Twitter Bootstrap4
121
+ (and 3) html components.
137
122
  test_files: []
data/Rakefile DELETED
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env rake
2
- begin
3
- require 'bundler/setup'
4
- rescue LoadError
5
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
- end
7
-
8
- # Testing tasks
9
- APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
10
- load 'rails/tasks/engine.rake'
11
-
12
- Bundler::GemHelper.install_tasks
13
-
14
- require 'rspec/core'
15
- require 'rspec/core/rake_task'
16
-
17
- desc "Run all specs in spec directory (excluding plugin specs)"
18
- RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
19
-
20
- task :default => :spec
@@ -1,45 +0,0 @@
1
- if defined?(EffectiveDatatables) && Gem::Version.new(EffectiveDatatables::VERSION) >= Gem::Version.new('3.0')
2
- class EffectiveStyleGuideDatatable < Effective::Datatable
3
-
4
- datatable do
5
- col :id
6
- col :material, search: { collection: ['Stainless Steel', 'Copper', 'Cast Iron', 'Composite'] }
7
- col :bowl, search: { collection: ['Single Bowl', 'Double Bowl', 'Triple Bowl'] }
8
- col :name
9
-
10
- actions_col show: false, edit: false, destroy: false do
11
- [link_to('View', '#'), link_to('Edit', '#')].join('&nbsp;-&nbsp;').html_safe
12
- end
13
- end
14
-
15
- collection do
16
- [
17
- [1, 'Stainless Steel', 'Single Bowl', 'KOHLER Staccato'],
18
- [2, 'Stainless Steel', 'Double Bowl', 'KOHLER Vault Undercounter'],
19
- [3, 'Stainless Steel', 'Triple Bowl', 'KRAUS All-In-One'],
20
- [4, 'Stainless Steel', 'Single Bowl', 'KOHLER Vault Dual Mount'],
21
- [5, 'Stainless Steel', 'Single Bowl', 'KRAUS All-In-One Undermount'],
22
- [6, 'Stainless Steel', 'Double Bowl', 'Glacier Bay All-in-One'],
23
- [7, 'Stainless Steel', 'Single Bowl', 'Elkay Neptune'],
24
- [8, 'Copper', 'Single Bowl', 'ECOSINKS Apron Front Dual Mount'],
25
- [9, 'Copper', 'Double Bowl', 'ECOSINKS Dual Mount Front Hammered'],
26
- [10, 'Copper', 'Triple Bowl', 'Glarier Bay Undermount'],
27
- [11, 'Copper', 'Single Bowl', 'Whitehaus Undermount'],
28
- [12, 'Copper', 'Double Bowl', 'Belle Foret Apron Front'],
29
- [13, 'Copper', 'Double Bowl', 'Pegasus Dual Mount'],
30
- [14, 'Cast Iron', 'Double Bowl', 'KOHLER Whitehaven'],
31
- [15, 'Cast Iron', 'Triple Bowl', 'KOHLER Hartland'],
32
- [16, 'Cast Iron', 'Single Bowl', 'KOHLER Cape Dory Undercounter'],
33
- [17, 'Cast Iron', 'Double Bowl', 'KOLER Bakersfield'],
34
- [18, 'Cast Iron', 'Double Bowl', 'American Standard Offset'],
35
- [19, 'Cast Iron', 'Single Bowl', 'Brookfield Top'],
36
- [20, 'Composite', 'Single Bowl', 'Blanco Diamond Undermount'],
37
- [21, 'Composite', 'Double Bowl', 'Mont Blanc Waterbrook'],
38
- [22, 'Composite', 'Triple Bowl', 'Pegasus Triple Mount'],
39
- [23, 'Composite', 'Single Bowl', 'Swanstone Dual Mount']
40
- ]
41
- end
42
-
43
- end
44
- end
45
-
@@ -1,55 +0,0 @@
1
- if defined?(EffectiveDatatables) && Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
2
- module Effective
3
- module Datatables
4
- class StyleGuide < Effective::Datatable
5
- any_version = Proc.new do
6
- array_column :id, :width => '10%'
7
- array_column :material, :filter => {:type => :select, :values => ['Stainless Steel', 'Copper', 'Cast Iron', 'Composite']}
8
- array_column :bowl, :filter => {:type => :select, :values => ['Single Bowl', 'Double Bowl', 'Triple Bowl']}
9
- array_column :name
10
- array_column :actions, :filter => false, :sortable => false do
11
- [link_to('View', '#'), link_to('Edit', '#')].join('&nbsp;-&nbsp;').html_safe
12
- end
13
- end
14
-
15
- require 'effective_datatables/version'
16
- if Gem::Version.new(EffectiveDatatables::VERSION) >= Gem::Version.new('2.0')
17
- datatable do
18
- instance_eval &any_version
19
- end
20
- else
21
- instance_eval &any_version
22
- end
23
-
24
- def collection
25
- [
26
- [1, 'Stainless Steel', 'Single Bowl', 'KOHLER Staccato'],
27
- [2, 'Stainless Steel', 'Double Bowl', 'KOHLER Vault Undercounter'],
28
- [3, 'Stainless Steel', 'Triple Bowl', 'KRAUS All-In-One'],
29
- [4, 'Stainless Steel', 'Single Bowl', 'KOHLER Vault Dual Mount'],
30
- [5, 'Stainless Steel', 'Single Bowl', 'KRAUS All-In-One Undermount'],
31
- [6, 'Stainless Steel', 'Double Bowl', 'Glacier Bay All-in-One'],
32
- [7, 'Stainless Steel', 'Single Bowl', 'Elkay Neptune'],
33
- [8, 'Copper', 'Single Bowl', 'ECOSINKS Apron Front Dual Mount'],
34
- [9, 'Copper', 'Double Bowl', 'ECOSINKS Dual Mount Front Hammered'],
35
- [10, 'Copper', 'Triple Bowl', 'Glarier Bay Undermount'],
36
- [11, 'Copper', 'Single Bowl', 'Whitehaus Undermount'],
37
- [12, 'Copper', 'Double Bowl', 'Belle Foret Apron Front'],
38
- [13, 'Copper', 'Double Bowl', 'Pegasus Dual Mount'],
39
- [14, 'Cast Iron', 'Double Bowl', 'KOHLER Whitehaven'],
40
- [15, 'Cast Iron', 'Triple Bowl', 'KOHLER Hartland'],
41
- [16, 'Cast Iron', 'Single Bowl', 'KOHLER Cape Dory Undercounter'],
42
- [17, 'Cast Iron', 'Double Bowl', 'KOLER Bakersfield'],
43
- [18, 'Cast Iron', 'Double Bowl', 'American Standard Offset'],
44
- [19, 'Cast Iron', 'Single Bowl', 'Brookfield Top'],
45
- [20, 'Composite', 'Single Bowl', 'Blanco Diamond Undermount'],
46
- [21, 'Composite', 'Double Bowl', 'Mont Blanc Waterbrook'],
47
- [22, 'Composite', 'Triple Bowl', 'Pegasus Triple Mount'],
48
- [23, 'Composite', 'Single Bowl', 'Swanstone Dual Mount']
49
- ]
50
- end
51
-
52
- end
53
- end
54
- end
55
- end
@@ -1,9 +0,0 @@
1
- %br
2
- - if defined?(EffectiveDatatables)
3
- - if Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
4
- = render_datatable Effective::Datatables::StyleGuide.new()
5
- - else
6
- = render_datatable EffectiveStyleGuideDatatable.new()
7
-
8
- - else
9
- %p Please install the effective_datatables gem