commenteux 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +49 -0
  4. data/Rakefile +34 -0
  5. data/app/assets/javascripts/commenteux/application.js.coffee +72 -0
  6. data/app/controllers/commenteux/application_controller.rb +3 -0
  7. data/app/controllers/commenteux/notes_controller.rb +63 -0
  8. data/app/helpers/commenteux/application_helper.rb +4 -0
  9. data/app/helpers/commenteux/notes_helper.rb +11 -0
  10. data/app/views/commenteux/notes/index.html.erb +31 -0
  11. data/app/views/commenteux/notes/new.html.erb +31 -0
  12. data/config/cucumber.yml +8 -0
  13. data/config/initializers/simple_form.rb +145 -0
  14. data/config/initializers/simple_form_bootstrap.rb +45 -0
  15. data/config/locales/simple_form.en.yml +26 -0
  16. data/config/routes.rb +7 -0
  17. data/lib/commenteux/engine.rb +5 -0
  18. data/lib/commenteux/version.rb +3 -0
  19. data/lib/commenteux.rb +4 -0
  20. data/lib/tasks/cucumber.rake +65 -0
  21. data/lib/tasks/notes_tasks.rake +4 -0
  22. data/lib/templates/erb/scaffold/_form.html.erb +13 -0
  23. data/spec/controllers/commenteux/notes_controller_spec.rb +95 -0
  24. data/spec/dummy/README.rdoc +28 -0
  25. data/spec/dummy/Rakefile +6 -0
  26. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  27. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  28. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  29. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  30. data/spec/dummy/app/models/comment.rb +15 -0
  31. data/spec/dummy/app/models/dummy_model.rb +3 -0
  32. data/spec/dummy/app/models/user.rb +3 -0
  33. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  34. data/spec/dummy/bin/bundle +3 -0
  35. data/spec/dummy/bin/rails +4 -0
  36. data/spec/dummy/bin/rake +4 -0
  37. data/spec/dummy/config/application.rb +32 -0
  38. data/spec/dummy/config/boot.rb +5 -0
  39. data/spec/dummy/config/database.yml +45 -0
  40. data/spec/dummy/config/environment.rb +5 -0
  41. data/spec/dummy/config/environments/development.rb +29 -0
  42. data/spec/dummy/config/environments/production.rb +80 -0
  43. data/spec/dummy/config/environments/test.rb +36 -0
  44. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  45. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  46. data/spec/dummy/config/initializers/inflections.rb +16 -0
  47. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  48. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  49. data/spec/dummy/config/initializers/session_store.rb +3 -0
  50. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  51. data/spec/dummy/config/locales/en.yml +23 -0
  52. data/spec/dummy/config/routes.rb +5 -0
  53. data/spec/dummy/config.ru +4 -0
  54. data/spec/dummy/db/migrate/20140311235439_create_dummy_models.rb +10 -0
  55. data/spec/dummy/db/migrate/20140312000846_create_comments.rb +20 -0
  56. data/spec/dummy/db/schema.rb +37 -0
  57. data/spec/dummy/log/development.log +3249 -0
  58. data/spec/dummy/log/test.log +1333 -0
  59. data/spec/dummy/public/404.html +58 -0
  60. data/spec/dummy/public/422.html +58 -0
  61. data/spec/dummy/public/500.html +57 -0
  62. data/spec/dummy/public/favicon.ico +0 -0
  63. data/spec/dummy/tmp/cache/assets/development/sprockets/078e8a1b7bb61498dbae0070239e8f4c +0 -0
  64. data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  65. data/spec/dummy/tmp/cache/assets/development/sprockets/170c21adaedf3190ec389a68d1eb6151 +0 -0
  66. data/spec/dummy/tmp/cache/assets/development/sprockets/1957ff8c0d834428d5beca5bf51669b2 +0 -0
  67. data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  68. data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  69. data/spec/dummy/tmp/cache/assets/development/sprockets/6e1da15bffb0094059fbe56ddb206c07 +0 -0
  70. data/spec/dummy/tmp/cache/assets/development/sprockets/9fbd3d6762f09cbefd55f6775cf9bebe +0 -0
  71. data/spec/dummy/tmp/cache/assets/development/sprockets/af00b28760a09c0a6fd6fe584cbb839d +0 -0
  72. data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  73. data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  74. data/spec/dummy/tmp/cache/assets/development/sprockets/e03f14f32457f143247847a1d28529eb +0 -0
  75. data/spec/dummy/tmp/cache/assets/development/sprockets/eaa5f4faca3d7f7b7dd6889cc842471d +0 -0
  76. data/spec/dummy/tmp/cache/assets/development/sprockets/ec516d6bcfdc219883f1ddb03b5a635b +0 -0
  77. data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  78. data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  79. data/spec/dummy/tmp/cache/assets/test/sprockets/170c21adaedf3190ec389a68d1eb6151 +0 -0
  80. data/spec/dummy/tmp/cache/assets/test/sprockets/1957ff8c0d834428d5beca5bf51669b2 +0 -0
  81. data/spec/dummy/tmp/cache/assets/test/sprockets/1961e9a889917e26f9b92f7e3678b9d8 +0 -0
  82. data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  83. data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  84. data/spec/dummy/tmp/cache/assets/test/sprockets/6e1da15bffb0094059fbe56ddb206c07 +0 -0
  85. data/spec/dummy/tmp/cache/assets/test/sprockets/9fbd3d6762f09cbefd55f6775cf9bebe +0 -0
  86. data/spec/dummy/tmp/cache/assets/test/sprockets/af00b28760a09c0a6fd6fe584cbb839d +0 -0
  87. data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  88. data/spec/dummy/tmp/cache/assets/test/sprockets/d72f8bdb1dcb7ea80d1869cb2c6ebbd3 +0 -0
  89. data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  90. data/spec/dummy/tmp/cache/assets/test/sprockets/db2a42fb4a2ea58dddbe086ea7cbd8c3 +0 -0
  91. data/spec/dummy/tmp/cache/assets/test/sprockets/e03f14f32457f143247847a1d28529eb +0 -0
  92. data/spec/dummy/tmp/cache/assets/test/sprockets/eaa5f4faca3d7f7b7dd6889cc842471d +0 -0
  93. data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  94. data/spec/fabricators/dummy_models_fabricator.rb +3 -0
  95. data/spec/helpers/commenteux/notes_helper_spec.rb +15 -0
  96. data/spec/spec_helper.rb +48 -0
  97. metadata +271 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dfdd40532498372caf8dfdee9783ebea2413ffe9
4
+ data.tar.gz: c02f5d0f734bc82860da0082c2ca6a7e9cb2be5b
5
+ SHA512:
6
+ metadata.gz: eced13cb7a48a25157c18831c422e30ef426178e22e77c5948ceb07cdefe7a537c55e008a77e2a1692680d258a4e1568a074f1aa79c5dbdbd35cae8033fd4cd1
7
+ data.tar.gz: 12a6cf53d04707222abe0253d93591bd5f52a033f3a6bb0482f5c56caedae8f3fe098b591b8694d9edab17b3e06a2e2af8436e8959ec29721c8d6216095ca4df
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 Groupe Fungo inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,49 @@
1
+ = Commenteux
2
+
3
+ This is a mountable gem that add a presentation layer to act_as_commentable.
4
+
5
+ Mount this gem into your app to automatically have access to screens that list and create comments on any of your resources.
6
+ Those screen will be inserted in your current app layout. You can call the routes of the gem with ajax passing a parent
7
+ div where you want the response to ben inserted.
8
+
9
+ Note that the presentation layer is based on bootstrap.
10
+
11
+ Note that you must have act_as_commentable installed and ready in your desired resource.
12
+
13
+ == Installation :
14
+
15
+ Add the following line to your Gemfile
16
+
17
+ === Rails 4
18
+
19
+ gem 'commenteux'
20
+
21
+ == Usage
22
+
23
+ Make your ActiveRecord model act as commentable:
24
+
25
+ class Post < ActiveRecord::Base
26
+ acts_as_commentable
27
+ end
28
+
29
+ Mount the commenteux gem in your routes:
30
+
31
+ mount Commenteux::Engine => "/"
32
+
33
+ Call url of commenteux screens, for exemple, like that:
34
+
35
+ <%= link_to "<i class='icon-file-text text-blue'></i> Notes".html_safe, "/commenteux/client::contract/#{@contract.id}?parent_div=ajax_target", :id => "notes_tab", :data => {:remote => true} %>
36
+
37
+ == Credits
38
+
39
+ jackdempsey - The creator of act_as_commentable.
40
+
41
+ == Contributors
42
+
43
+ seurdge, rgagnon
44
+
45
+ == More
46
+
47
+ http://www.groupefungo.ca
48
+
49
+
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Commenteux'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,72 @@
1
+
2
+ $ () ->
3
+
4
+ $(document).delegate '#new_notes_link', 'click', (e) ->
5
+ console.log('new_notes_link click')
6
+ event.stopPropagation()
7
+ event.preventDefault()
8
+ parent= $(@).data('parent')
9
+ resource = $(@).data('resource')
10
+ id = $(@).data('id')
11
+ console.log('parent_div = ' + parent)
12
+ console.log('resource = ' + resource)
13
+ console.log('resource_id = ' + id)
14
+ $.ajax
15
+ url: "/commenteux/" + resource + "/" + id + "/new"
16
+ type: "get"
17
+ dataType: "html"
18
+ data:
19
+ "parent_div": parent
20
+ success: (returnData) ->
21
+ console.log('success')
22
+ console.log("#" + parent)
23
+ console.log(returnData)
24
+ if parent
25
+ $("#" + parent ).html(returnData)
26
+ else
27
+ console.log('no parent')
28
+ $('body').html(returnData)
29
+ @
30
+ error: (e) ->
31
+ alert(e)
32
+ @
33
+ @
34
+
35
+ $(document).delegate '#new_comments', 'ajax:success', (e, data, status, xhr) ->
36
+ console.log('new_comments ajax success')
37
+ parent = $('#new_comments').attr('data-parent')
38
+ if parent
39
+ $('#' + parent).html(xhr.responseText)
40
+ else
41
+ $('body').html(xhr.responseText)
42
+
43
+ $(document).delegate '#new_notes_cancelled', 'click', (e) ->
44
+ console.log('new_notes_cancelled click')
45
+ event.stopPropagation()
46
+ event.preventDefault()
47
+ parent= $(@).data('parent')
48
+ resource = $(@).data('resource')
49
+ id = $(@).data('id')
50
+ console.log('parent_div = ' + parent)
51
+ console.log('resource = ' + resource)
52
+ console.log('resource_id = ' + id)
53
+ $.ajax
54
+ url: "/commenteux/" + resource + "/" + id + "?parent_div=" + parent
55
+ type: "get"
56
+ dataType: "html"
57
+ data:
58
+ "parent_div": parent
59
+ success: (returnData) ->
60
+ console.log('success')
61
+ console.log("#" + parent)
62
+ console.log(returnData)
63
+ if parent
64
+ $("#" + parent ).html(returnData)
65
+ else
66
+ console.log('no parent')
67
+ $('body').html(returnData)
68
+ @
69
+ error: (e) ->
70
+ alert(e)
71
+ @
72
+ @
@@ -0,0 +1,3 @@
1
+ class Commenteux::ApplicationController < ApplicationController
2
+ #Nécessaire pour hériter de La,pplication controller de l'application hôte
3
+ end
@@ -0,0 +1,63 @@
1
+ require_dependency "commenteux/application_controller"
2
+
3
+ module Commenteux
4
+ class NotesController < ApplicationController
5
+
6
+ def comments_params
7
+ comments_permit_fields = [:title, :comment, :user_id]
8
+ params.require(:comments).permit(
9
+ comments_permit_fields)
10
+ end
11
+
12
+ def index
13
+ resource = fetch_resource
14
+ @comments = resource.comments.all
15
+ @parent_div = params[:parent_div]
16
+
17
+ if request.xhr?
18
+ render :layout => false
19
+ end
20
+
21
+ end
22
+
23
+ def fetch_resource
24
+ @resource = params[:resource]
25
+ @class_name = classify_namespace(params[:resource])
26
+ @resourceKlass = eval(@class_name)
27
+ @resource_id = params[:resource_id]
28
+ @resourceKlass.find(@resource_id)
29
+ end
30
+
31
+ def classify_namespace(const)
32
+ const = const.classify
33
+ if const.include?('::')
34
+ new_const = ''
35
+ splitted = const.split('::')
36
+ for str in splitted do
37
+ new_const = new_const + str.classify + '::'
38
+ end
39
+ const = new_const[0..(new_const.length - 3)]
40
+ end
41
+ const
42
+ end
43
+
44
+ def new
45
+ resource = fetch_resource
46
+ @comments = resource.comments.new
47
+ @parent_div = params[:parent_div]
48
+
49
+ if request.xhr?
50
+ render :layout => false
51
+ end
52
+
53
+ end
54
+
55
+ def create
56
+ resource = fetch_resource
57
+ resource.comments.create(comments_params)
58
+ @parent_div = params[:parent_div]
59
+ redirect_to "/commenteux/#{@resource.downcase}/#{@resource_id}?parent_div=" + @parent_div
60
+ end
61
+
62
+ end
63
+ end
@@ -0,0 +1,4 @@
1
+ module Commenteux
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,11 @@
1
+ module Commenteux
2
+ module NotesHelper
3
+
4
+ def user_lookup(user_id)
5
+ if user_id
6
+ User.find(user_id).name
7
+ end
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,31 @@
1
+ <%= javascript_include_tag 'commenteux/application' %>
2
+
3
+ <table class="table">
4
+ <thead>
5
+ <tr>
6
+ <th>Commentaire</th>
7
+ <th>Fait par</th>
8
+ <th>Date</th>
9
+ </tr>
10
+ </thead>
11
+
12
+ <% @comments.each do |comment| %>
13
+ <tr>
14
+ <td>
15
+ <%= comment.comment %>
16
+ </td>
17
+ <td>
18
+ <%= user_lookup(comment.user_id) %>
19
+ </td>
20
+ <td>
21
+ <%= comment.created_at %>
22
+ </td>
23
+ </tr>
24
+ <% end %>
25
+ </table>
26
+ <br/>
27
+
28
+ <%= link_to "Nouveau", "#", :id => "new_notes_link", :class => 'btn btn-primary',
29
+ :data => {:parent => @parent_div,
30
+ :resource => @resource.downcase,
31
+ :id => @resource_id } %>
@@ -0,0 +1,31 @@
1
+ <%= simple_form_for @comments, as: 'comments', url: "/commenteux/#{@resource.downcase}/#{@resource_id}?parent_div=#{@parent_div}",
2
+ :remote => true, :data => {:parent => @parent_div}, wrapper: :bootstrap do |c| %>
3
+
4
+ <div style="display:none">
5
+ <%= c.input :title %>
6
+ </div>
7
+ <%= c.input :comment, :label => 'Commentaire' %>
8
+ <% if defined? current_user %>
9
+ <div style="display:none">
10
+ <%= c.input :user_id, input_html: {value: current_user.id} %>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="form-actions form-actions-padding-sm">
15
+ <div class="row">
16
+ <div class="col-md-10 col-md-offset-5">
17
+
18
+ <button class="btn btn-primary" type="submit" id='save'>
19
+ Enregistrer
20
+ </button>
21
+
22
+ <%= link_to "Annuler", "#", :id => "new_notes_cancelled", :class => 'btn',
23
+ :data => {:parent => @parent_div,
24
+ :resource => @resource.downcase,
25
+ :id => @resource_id } %>
26
+
27
+ </div>
28
+ </div>
29
+ </div>
30
+
31
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
+ std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
5
+ %>
6
+ default: <%= std_opts %> features
7
+ wip: --tags @wip:3 --wip features
8
+ rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
@@ -0,0 +1,145 @@
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
+ end
47
+
48
+ # The default wrapper to be used by the FormBuilder.
49
+ config.default_wrapper = :default
50
+
51
+ # Define the way to render check boxes / radio buttons with labels.
52
+ # Defaults to :nested for bootstrap config.
53
+ # inline: input + label
54
+ # nested: label > input
55
+ config.boolean_style = :nested
56
+
57
+ # Default class for buttons
58
+ config.button_class = 'btn'
59
+
60
+ # Method used to tidy up errors. Specify any Rails Array method.
61
+ # :first lists the first message for each field.
62
+ # Use :to_sentence to list all errors for each field.
63
+ # config.error_method = :first
64
+
65
+ # Default tag used for error notification helper.
66
+ config.error_notification_tag = :div
67
+
68
+ # CSS class to add for error notification helper.
69
+ config.error_notification_class = 'alert alert-error'
70
+
71
+ # ID to add for error notification helper.
72
+ # config.error_notification_id = nil
73
+
74
+ # Series of attempts to detect a default label method for collection.
75
+ # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
76
+
77
+ # Series of attempts to detect a default value method for collection.
78
+ # config.collection_value_methods = [ :id, :to_s ]
79
+
80
+ # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
81
+ # config.collection_wrapper_tag = nil
82
+
83
+ # You can define the class to use on all collection wrappers. Defaulting to none.
84
+ # config.collection_wrapper_class = nil
85
+
86
+ # You can wrap each item in a collection of radio/check boxes with a tag,
87
+ # defaulting to :span. Please note that when using :boolean_style = :nested,
88
+ # SimpleForm will force this option to be a label.
89
+ # config.item_wrapper_tag = :span
90
+
91
+ # You can define a class to use in all item wrappers. Defaulting to none.
92
+ # config.item_wrapper_class = nil
93
+
94
+ # How the label text should be generated altogether with the required text.
95
+ # config.label_text = lambda { |label, required| "#{required} #{label}" }
96
+
97
+ # You can define the class to use on all labels. Default is nil.
98
+ config.label_class = 'control-label'
99
+
100
+ # You can define the class to use on all forms. Default is simple_form.
101
+ # config.form_class = :simple_form
102
+
103
+ # You can define which elements should obtain additional classes
104
+ # config.generate_additional_classes_for = [:wrapper, :label, :input]
105
+
106
+ # Whether attributes are required by default (or not). Default is true.
107
+ # config.required_by_default = true
108
+
109
+ # Tell browsers whether to use the native HTML5 validations (novalidate form option).
110
+ # These validations are enabled in SimpleForm's internal config but disabled by default
111
+ # in this configuration, which is recommended due to some quirks from different browsers.
112
+ # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
113
+ # change this configuration to true.
114
+ config.browser_validations = false
115
+
116
+ # Collection of methods to detect if a file type was given.
117
+ # config.file_methods = [ :mounted_as, :file?, :public_filename ]
118
+
119
+ # Custom mappings for input types. This should be a hash containing a regexp
120
+ # to match as key, and the input type that will be used when the field name
121
+ # matches the regexp as value.
122
+ # config.input_mappings = { /count/ => :integer }
123
+
124
+ # Custom wrappers for input types. This should be a hash containing an input
125
+ # type as key and the wrapper that will be used for all inputs with specified type.
126
+ # config.wrapper_mappings = { string: :prepend }
127
+
128
+ # Default priority for time_zone inputs.
129
+ # config.time_zone_priority = nil
130
+
131
+ # Default priority for country inputs.
132
+ # config.country_priority = nil
133
+
134
+ # When false, do not use translations for labels.
135
+ # config.translate_labels = true
136
+
137
+ # Automatically discover new inputs in Rails' autoload path.
138
+ # config.inputs_discovery = true
139
+
140
+ # Cache SimpleForm inputs discovery
141
+ # config.cache_discovery = !Rails.env.development?
142
+
143
+ # Default class for inputs
144
+ # config.input_class = nil
145
+ end
@@ -0,0 +1,45 @@
1
+ # Use this setup block to configure all options available in SimpleForm.
2
+ SimpleForm.setup do |config|
3
+ config.wrappers :bootstrap, tag: 'div', class: 'control-group', error_class: 'error' do |b|
4
+ b.use :html5
5
+ b.use :placeholder
6
+ b.use :label
7
+ b.wrapper tag: 'div', class: 'controls' do |ba|
8
+ ba.use :input
9
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
10
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
11
+ end
12
+ end
13
+
14
+ config.wrappers :prepend, tag: 'div', class: "control-group", error_class: 'error' do |b|
15
+ b.use :html5
16
+ b.use :placeholder
17
+ b.use :label
18
+ b.wrapper tag: 'div', class: 'controls' do |input|
19
+ input.wrapper tag: 'div', class: 'input-prepend' do |prepend|
20
+ prepend.use :input
21
+ end
22
+ input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
23
+ input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
24
+ end
25
+ end
26
+
27
+ config.wrappers :append, tag: 'div', class: "control-group", error_class: 'error' do |b|
28
+ b.use :html5
29
+ b.use :placeholder
30
+ b.use :label
31
+ b.wrapper tag: 'div', class: 'controls' do |input|
32
+ input.wrapper tag: 'div', class: 'input-append' do |append|
33
+ append.use :input
34
+ end
35
+ input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
36
+ input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
37
+ end
38
+ end
39
+
40
+ # Wrappers for forms and inputs using the Twitter Bootstrap toolkit.
41
+ # Check the Bootstrap docs (http://twitter.github.com/bootstrap)
42
+ # to learn about the different styles for forms and inputs,
43
+ # buttons and other elements.
44
+ config.default_wrapper = :bootstrap
45
+ end
@@ -0,0 +1,26 @@
1
+ en:
2
+ simple_form:
3
+ "yes": 'Yes'
4
+ "no": 'No'
5
+ required:
6
+ text: 'required'
7
+ mark: '*'
8
+ # You can uncomment the line below if you need to overwrite the whole required html.
9
+ # When using html, text and mark won't be used.
10
+ # html: '<abbr title="required">*</abbr>'
11
+ error_notification:
12
+ default_message: "Please review the problems below:"
13
+ # Labels and hints examples
14
+ # labels:
15
+ # defaults:
16
+ # password: 'Password'
17
+ # user:
18
+ # new:
19
+ # email: 'E-mail to sign in.'
20
+ # edit:
21
+ # email: 'E-mail.'
22
+ # hints:
23
+ # defaults:
24
+ # username: 'User name to sign in.'
25
+ # password: 'No special characters, please.'
26
+
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ Commenteux::Engine.routes.draw do
2
+
3
+ get '/commenteux/:resource/:resource_id', to: 'notes#index'
4
+ get '/commenteux/:resource/:resource_id/new', to: 'notes#new'
5
+ post '/commenteux/:resource/:resource_id', to: 'notes#create'
6
+
7
+ end
@@ -0,0 +1,5 @@
1
+ module Commenteux
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Commenteux
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module Commenteux
2
+ VERSION = "1.0.0"
3
+ end
data/lib/commenteux.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "commenteux/engine"
2
+
3
+ module Commenteux
4
+ end
@@ -0,0 +1,65 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+
8
+ unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
9
+
10
+ vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
11
+ $LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
12
+
13
+ begin
14
+ require 'cucumber/rake/task'
15
+
16
+ namespace :cucumber do
17
+ Cucumber::Rake::Task.new({:ok => 'test:prepare'}, 'Run features that should pass') do |t|
18
+ t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
19
+ t.fork = true # You may get faster startup if you set this to false
20
+ t.profile = 'default'
21
+ end
22
+
23
+ Cucumber::Rake::Task.new({:wip => 'test:prepare'}, 'Run features that are being worked on') do |t|
24
+ t.binary = vendored_cucumber_bin
25
+ t.fork = true # You may get faster startup if you set this to false
26
+ t.profile = 'wip'
27
+ end
28
+
29
+ Cucumber::Rake::Task.new({:rerun => 'test:prepare'}, 'Record failing features and run only them if any exist') do |t|
30
+ t.binary = vendored_cucumber_bin
31
+ t.fork = true # You may get faster startup if you set this to false
32
+ t.profile = 'rerun'
33
+ end
34
+
35
+ desc 'Run all features'
36
+ task :all => [:ok, :wip]
37
+
38
+ task :statsetup do
39
+ require 'rails/code_statistics'
40
+ ::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
41
+ ::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
42
+ end
43
+ end
44
+ desc 'Alias for cucumber:ok'
45
+ task :cucumber => 'cucumber:ok'
46
+
47
+ task :default => :cucumber
48
+
49
+ task :features => :cucumber do
50
+ STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
51
+ end
52
+
53
+ # In case we don't have the generic Rails test:prepare hook, append a no-op task that we can depend upon.
54
+ task 'test:prepare' do
55
+ end
56
+
57
+ task :stats => 'cucumber:statsetup'
58
+ rescue LoadError
59
+ desc 'cucumber rake task not available (cucumber not installed)'
60
+ task :cucumber do
61
+ abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
62
+ end
63
+ end
64
+
65
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :commenteux do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,13 @@
1
+ <%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
2
+ <%%= f.error_notification %>
3
+
4
+ <div class="form-inputs">
5
+ <%- attributes.each do |attribute| -%>
6
+ <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
7
+ <%- end -%>
8
+ </div>
9
+
10
+ <div class="form-actions">
11
+ <%%= f.button :submit %>
12
+ </div>
13
+ <%% end %>