wobapphelpers 3.1.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.
Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +22 -0
  3. data/README.md +155 -0
  4. data/Rakefile +30 -0
  5. data/app/assets/stylesheets/wobapphelpers/breadcrumbs.scss +13 -0
  6. data/config/locales/de.yml +9 -0
  7. data/config/locales/en.yml +9 -0
  8. data/lib/generators/templates/erb/scaffold/_form.html.erb +26 -0
  9. data/lib/generators/templates/erb/scaffold/edit.html.erb +1 -0
  10. data/lib/generators/templates/erb/scaffold/index.html.erb +32 -0
  11. data/lib/generators/templates/erb/scaffold/new.html.erb +1 -0
  12. data/lib/generators/templates/erb/scaffold/show.html.erb +15 -0
  13. data/lib/generators/templates/initializers/wobapphelpers.rb +18 -0
  14. data/lib/generators/templates/layouts/application.html.erb +44 -0
  15. data/lib/generators/templates/rails/scaffold_controller/controller.rb +66 -0
  16. data/lib/generators/wobapphelpers/install_generator.rb +24 -0
  17. data/lib/generators/wobapphelpers/scaffold_templates_generator.rb +20 -0
  18. data/lib/tasks/wobapphelpers_tasks.rake +4 -0
  19. data/lib/wobapphelpers.rb +37 -0
  20. data/lib/wobapphelpers/breadcrumbs.rb +16 -0
  21. data/lib/wobapphelpers/breadcrumbs/action_controller.rb +57 -0
  22. data/lib/wobapphelpers/breadcrumbs/breadcrumbs_helper.rb +26 -0
  23. data/lib/wobapphelpers/helpers.rb +12 -0
  24. data/lib/wobapphelpers/helpers/action_view_helper.rb +170 -0
  25. data/lib/wobapphelpers/helpers/icon_helper.rb +39 -0
  26. data/lib/wobapphelpers/rails.rb +4 -0
  27. data/lib/wobapphelpers/responders.rb +13 -0
  28. data/lib/wobapphelpers/responders/locales/de.yml +12 -0
  29. data/lib/wobapphelpers/responders/locales/en.yml +12 -0
  30. data/lib/wobapphelpers/version.rb +4 -0
  31. data/test/breadcrumbs/action_controller_test.rb +44 -0
  32. data/test/breadcrumbs/breadcrumb_helper_test.rb +35 -0
  33. data/test/dummy/app/controllers/application_controller.rb +19 -0
  34. data/test/dummy/app/controllers/blogs_controller.rb +55 -0
  35. data/test/dummy/app/controllers/home_controller.rb +7 -0
  36. data/test/dummy/app/controllers/posts_controller.rb +58 -0
  37. data/test/dummy/app/helpers/application_helper.rb +3 -0
  38. data/test/dummy/app/helpers/blogs_helper.rb +2 -0
  39. data/test/dummy/app/helpers/posts_helper.rb +2 -0
  40. data/test/dummy/app/models/blog.rb +2 -0
  41. data/test/dummy/app/models/post.rb +2 -0
  42. data/test/dummy/config/application.rb +31 -0
  43. data/test/dummy/config/boot.rb +5 -0
  44. data/test/dummy/config/environment.rb +5 -0
  45. data/test/dummy/config/environments/development.rb +37 -0
  46. data/test/dummy/config/environments/production.rb +83 -0
  47. data/test/dummy/config/environments/test.rb +45 -0
  48. data/test/dummy/config/initializers/assets.rb +1 -0
  49. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  50. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  51. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  52. data/test/dummy/config/initializers/inflections.rb +16 -0
  53. data/test/dummy/config/initializers/mime_types.rb +4 -0
  54. data/test/dummy/config/initializers/session_store.rb +3 -0
  55. data/test/dummy/config/initializers/simple_form.rb +161 -0
  56. data/test/dummy/config/initializers/simple_form_bootstrap.rb +107 -0
  57. data/test/dummy/config/initializers/wobapphelpers.rb +9 -0
  58. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  59. data/test/dummy/config/routes.rb +61 -0
  60. data/test/dummy/db/migrate/20140420155942_create_posts.rb +12 -0
  61. data/test/dummy/db/migrate/20140516164637_create_blogs.rb +12 -0
  62. data/test/dummy/db/schema.rb +33 -0
  63. data/test/dummy/lib/templates/rails/scaffold_controller/controller.rb +65 -0
  64. data/test/generators/install_generator_test.rb +29 -0
  65. data/test/generators/scaffold_templates_generator_test.rb +16 -0
  66. data/test/helpers/action_view_helper_test.rb +41 -0
  67. data/test/helpers/active_class_helper_test.rb +9 -0
  68. data/test/helpers/can_view_helper_test.rb +172 -0
  69. data/test/helpers/flash_helper_test.rb +11 -0
  70. data/test/helpers/form_legend_test.rb +29 -0
  71. data/test/helpers/icon_helper_test.rb +21 -0
  72. data/test/helpers/show_edit_delete_link_helper_test.rb +45 -0
  73. data/test/integration/helper_delivery_test.rb +28 -0
  74. data/test/responders/flash_test.rb +23 -0
  75. data/test/test_helper.rb +42 -0
  76. data/test/tmp/lib/templates/rails/scaffold_controller/controller.rb +66 -0
  77. data/test/translate_test.rb +10 -0
  78. data/test/wobapphelpers_test.rb +20 -0
  79. metadata +371 -0
@@ -0,0 +1 @@
1
+ Rails.application.config.assets.paths << Rails.root.join('node_modules')
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure sensitive parameters which will be filtered from the log file.
4
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, '\1en'
8
+ # inflect.singular /^(ox)en/i, '\1'
9
+ # inflect.irregular 'person', 'people'
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym 'RESTful'
16
+ # end
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.session_store :cookie_store, key: '_dummy_session'
@@ -0,0 +1,161 @@
1
+ # Use this setup block to configure all options available in SimpleForm.
2
+ SimpleForm.setup do |config|
3
+ # Wrappers are used by the form builder to generate a
4
+ # complete input. You can remove any component from the
5
+ # wrapper, change the order or even add your own to the
6
+ # stack. The options given below are used to wrap the
7
+ # whole input.
8
+ config.wrappers :default, class: :input,
9
+ hint_class: :field_with_hint, error_class: :field_with_errors do |b|
10
+ ## Extensions enabled by default
11
+ # Any of these extensions can be disabled for a
12
+ # given input by passing: `f.input EXTENSION_NAME => false`.
13
+ # You can make any of these extensions optional by
14
+ # renaming `b.use` to `b.optional`.
15
+
16
+ # Determines whether to use HTML5 (:email, :url, ...)
17
+ # and required attributes
18
+ b.use :html5
19
+
20
+ # Calculates placeholders automatically from I18n
21
+ # You can also pass a string as f.input placeholder: "Placeholder"
22
+ b.use :placeholder
23
+
24
+ ## Optional extensions
25
+ # They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
26
+ # to the input. If so, they will retrieve the values from the model
27
+ # if any exists. If you want to enable the lookup for any of those
28
+ # extensions by default, you can change `b.optional` to `b.use`.
29
+
30
+ # Calculates maxlength from length validations for string inputs
31
+ b.optional :maxlength
32
+
33
+ # Calculates pattern from format validations for string inputs
34
+ b.optional :pattern
35
+
36
+ # Calculates min and max from length validations for numeric inputs
37
+ b.optional :min_max
38
+
39
+ # Calculates readonly automatically from readonly attributes
40
+ b.optional :readonly
41
+
42
+ ## Inputs
43
+ b.use :label_input
44
+ b.use :hint, wrap_with: { tag: :span, class: :hint }
45
+ b.use :error, wrap_with: { tag: :span, class: :error }
46
+
47
+ ## full_messages_for
48
+ # If you want to display the full error message for the attribute, you can
49
+ # use the component :full_error, like:
50
+ #
51
+ # b.use :full_error, wrap_with: { tag: :span, class: :error }
52
+ end
53
+
54
+ # The default wrapper to be used by the FormBuilder.
55
+ config.default_wrapper = :default
56
+
57
+ # Define the way to render check boxes / radio buttons with labels.
58
+ # Defaults to :nested for bootstrap config.
59
+ # inline: input + label
60
+ # nested: label > input
61
+ config.boolean_style = :nested
62
+
63
+ # Default class for buttons
64
+ config.button_class = 'btn'
65
+
66
+ # Method used to tidy up errors. Specify any Rails Array method.
67
+ # :first lists the first message for each field.
68
+ # Use :to_sentence to list all errors for each field.
69
+ # config.error_method = :first
70
+
71
+ # Default tag used for error notification helper.
72
+ config.error_notification_tag = :div
73
+
74
+ # CSS class to add for error notification helper.
75
+ config.error_notification_class = 'error_notification'
76
+
77
+ # ID to add for error notification helper.
78
+ # config.error_notification_id = nil
79
+
80
+ # Series of attempts to detect a default label method for collection.
81
+ # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
82
+
83
+ # Series of attempts to detect a default value method for collection.
84
+ # config.collection_value_methods = [ :id, :to_s ]
85
+
86
+ # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
87
+ # config.collection_wrapper_tag = nil
88
+
89
+ # You can define the class to use on all collection wrappers. Defaulting to none.
90
+ # config.collection_wrapper_class = nil
91
+
92
+ # You can wrap each item in a collection of radio/check boxes with a tag,
93
+ # defaulting to :span. Please note that when using :boolean_style = :nested,
94
+ # SimpleForm will force this option to be a label.
95
+ # config.item_wrapper_tag = :span
96
+
97
+ # You can define a class to use in all item wrappers. Defaulting to none.
98
+ # config.item_wrapper_class = nil
99
+
100
+ # How the label text should be generated altogether with the required text.
101
+ # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
102
+
103
+ # You can define the class to use on all labels. Default is nil.
104
+ # config.label_class = nil
105
+
106
+ # You can define the class to use on all forms. Default is simple_form.
107
+ # config.form_class = :simple_form
108
+
109
+ # You can define which elements should obtain additional classes
110
+ # config.generate_additional_classes_for = [:wrapper, :label, :input]
111
+
112
+ # Whether attributes are required by default (or not). Default is true.
113
+ # config.required_by_default = true
114
+
115
+ # Tell browsers whether to use the native HTML5 validations (novalidate form option).
116
+ # These validations are enabled in SimpleForm's internal config but disabled by default
117
+ # in this configuration, which is recommended due to some quirks from different browsers.
118
+ # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
119
+ # change this configuration to true.
120
+ config.browser_validations = false
121
+
122
+ # Collection of methods to detect if a file type was given.
123
+ # config.file_methods = [ :mounted_as, :file?, :public_filename ]
124
+
125
+ # Custom mappings for input types. This should be a hash containing a regexp
126
+ # to match as key, and the input type that will be used when the field name
127
+ # matches the regexp as value.
128
+ # config.input_mappings = { /count/ => :integer }
129
+
130
+ # Custom wrappers for input types. This should be a hash containing an input
131
+ # type as key and the wrapper that will be used for all inputs with specified type.
132
+ # config.wrapper_mappings = { string: :prepend }
133
+
134
+ # Default priority for time_zone inputs.
135
+ # config.time_zone_priority = nil
136
+
137
+ # Default priority for country inputs.
138
+ # config.country_priority = nil
139
+
140
+ # When false, do not use translations for labels.
141
+ # config.translate_labels = true
142
+
143
+ # Automatically discover new inputs in Rails' autoload path.
144
+ # config.inputs_discovery = true
145
+
146
+ # Cache SimpleForm inputs discovery
147
+ # config.cache_discovery = !Rails.env.development?
148
+
149
+ # Default class for inputs
150
+ # config.input_class = nil
151
+
152
+ # Define the default class of the input wrapper of the boolean input.
153
+ config.boolean_label_class = 'checkbox'
154
+
155
+ # Defines if the default input wrapper class should be included in radio
156
+ # collection wrappers.
157
+ # config.include_default_input_wrapper_class = true
158
+
159
+ # Defines which i18n scope will be used in Simple Form.
160
+ # config.i18n_scope = 'simple_form'
161
+ end
@@ -0,0 +1,107 @@
1
+ # Use this setup block to configure all options available in SimpleForm.
2
+ SimpleForm.setup do |config|
3
+ config.error_notification_class = 'alert alert-danger'
4
+ config.button_class = 'btn btn-default'
5
+ config.boolean_label_class = nil
6
+
7
+ config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
8
+ b.use :html5
9
+ b.use :placeholder
10
+ b.use :label, class: 'control-label'
11
+
12
+ b.wrapper tag: 'div' do |ba|
13
+ ba.use :input, class: 'form-control'
14
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
15
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
16
+ end
17
+ end
18
+
19
+ config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
20
+ b.use :html5
21
+ b.use :placeholder
22
+ b.use :label, class: 'control-label'
23
+
24
+ b.wrapper tag: 'div' do |ba|
25
+ ba.use :input
26
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
27
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
28
+ end
29
+ end
30
+
31
+ config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
32
+ b.use :html5
33
+ b.use :placeholder
34
+
35
+ b.wrapper tag: 'div', class: 'checkbox' do |ba|
36
+ ba.use :label_input
37
+ end
38
+
39
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
40
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
41
+ end
42
+
43
+ config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
44
+ b.use :html5
45
+ b.use :placeholder
46
+ b.use :label_input
47
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
48
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
49
+ end
50
+
51
+ config.wrappers :horizontal_form, tag: 'div', class: 'form-group row', error_class: 'has-error' do |b|
52
+ b.use :html5
53
+ b.use :placeholder
54
+ b.use :label, class: 'col-sm-3 col-md-2 col-form-label'
55
+
56
+ b.wrapper tag: 'div', class: 'col-sm-9 col-md-10' do |ba|
57
+ ba.use :input, class: 'form-control'
58
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
59
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
60
+ end
61
+ end
62
+
63
+ config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
64
+ b.use :html5
65
+ b.use :placeholder
66
+ b.use :label, class: 'col-sm-3 col-md-2 control-label'
67
+
68
+ b.wrapper tag: 'div', class: 'col-sm-9 col-md-10' do |ba|
69
+ ba.use :input
70
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
71
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
72
+ end
73
+ end
74
+
75
+ config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
76
+ b.use :html5
77
+ b.use :placeholder
78
+
79
+ b.wrapper tag: 'div', class: 'offset-sm-3 col-sm-9 offset-md-2 col-md-10' do |wr|
80
+ wr.wrapper tag: 'div', class: 'checkbox' do |ba|
81
+ ba.use :label_input, class: 'col-sm-9 col-md-10'
82
+ end
83
+
84
+ wr.use :error, wrap_with: { tag: 'span', class: 'help-block' }
85
+ wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
86
+ end
87
+ end
88
+
89
+ config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
90
+ b.use :html5
91
+ b.use :placeholder
92
+
93
+ b.use :label, class: 'col-sm-3 col-md-2 control-label'
94
+
95
+ b.wrapper tag: 'div', class: 'col-sm-9 col-md-10' do |ba|
96
+ ba.use :input
97
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
98
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
99
+ end
100
+ end
101
+
102
+ # Wrappers for forms and inputs using the Bootstrap toolkit.
103
+ # Check the Bootstrap docs (http://getbootstrap.com)
104
+ # to learn about the different styles for forms and inputs,
105
+ # buttons and other elements.
106
+ config.default_wrapper = :horizontal_form
107
+ end
@@ -0,0 +1,9 @@
1
+ Wobapphelpers.setup do |config|
2
+ # show action links only if has ability to execute the action
3
+ # * :none : always present action links
4
+ # * :cancan1 : for cancancan '~>1.7.0' or cancan '~>1.6.0'
5
+ # * :cancan2 : for cancan '~>2.0.0', untested
6
+ #
7
+ # default:
8
+ # config.cancan = :none
9
+ end
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -0,0 +1,61 @@
1
+ Rails.application.routes.draw do
2
+ resources :blogs
3
+
4
+ resources :posts
5
+
6
+ # The priority is based upon order of creation: first created -> highest priority.
7
+ # See how all your routes lay out with "rake routes".
8
+
9
+ # You can have the root of your site routed with "root"
10
+ root 'home#index'
11
+ get '/home', to: "home#index", as: :home
12
+
13
+ # Example of regular route:
14
+ # get 'products/:id' => 'catalog#view'
15
+
16
+ # Example of named route that can be invoked with purchase_url(id: product.id)
17
+ # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
18
+
19
+ # Example resource route (maps HTTP verbs to controller actions automatically):
20
+ # resources :products
21
+
22
+ # Example resource route with options:
23
+ # resources :products do
24
+ # member do
25
+ # get 'short'
26
+ # post 'toggle'
27
+ # end
28
+ #
29
+ # collection do
30
+ # get 'sold'
31
+ # end
32
+ # end
33
+
34
+ # Example resource route with sub-resources:
35
+ # resources :products do
36
+ # resources :comments, :sales
37
+ # resource :seller
38
+ # end
39
+
40
+ # Example resource route with more complex sub-resources:
41
+ # resources :products do
42
+ # resources :comments
43
+ # resources :sales do
44
+ # get 'recent', on: :collection
45
+ # end
46
+ # end
47
+
48
+ # Example resource route with concerns:
49
+ # concern :toggleable do
50
+ # post 'toggle'
51
+ # end
52
+ # resources :posts, concerns: :toggleable
53
+ # resources :photos, concerns: :toggleable
54
+
55
+ # Example resource route within a namespace:
56
+ # namespace :admin do
57
+ # # Directs /admin/products/* to Admin::ProductsController
58
+ # # (app/controllers/admin/products_controller.rb)
59
+ # resources :products
60
+ # end
61
+ end
@@ -0,0 +1,12 @@
1
+ class CreatePosts < ActiveRecord::Migration[5.1]
2
+ def change
3
+ create_table :posts do |t|
4
+ t.string :subject
5
+ t.text :body
6
+ t.string :user
7
+ t.date :release
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ class CreateBlogs < ActiveRecord::Migration[5.1]
2
+ def change
3
+ create_table :blogs do |t|
4
+ t.string :subject
5
+ t.text :body
6
+ t.string :user
7
+ t.date :release
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,33 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(version: 20140516164637) do
14
+
15
+ create_table "blogs", force: :cascade do |t|
16
+ t.string "subject"
17
+ t.text "body"
18
+ t.string "user"
19
+ t.date "release"
20
+ t.datetime "created_at", null: false
21
+ t.datetime "updated_at", null: false
22
+ end
23
+
24
+ create_table "posts", force: :cascade do |t|
25
+ t.string "subject"
26
+ t.text "body"
27
+ t.string "user"
28
+ t.date "release"
29
+ t.datetime "created_at", null: false
30
+ t.datetime "updated_at", null: false
31
+ end
32
+
33
+ end