rails_page_comment 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -20
  3. data/Rakefile +34 -34
  4. data/app/assets/javascripts/rails_page_comment/application.js +13 -13
  5. data/app/assets/javascripts/rails_page_comment/page_comments.js +2 -2
  6. data/app/assets/stylesheets/rails_page_comment/application.css +15 -15
  7. data/app/assets/stylesheets/rails_page_comment/page_comments.css +4 -4
  8. data/app/assets/stylesheets/scaffold.css +56 -56
  9. data/app/controllers/rails_page_comment/application_controller.rb +11 -4
  10. data/app/controllers/rails_page_comment/page_comments_controller.rb +69 -62
  11. data/app/helpers/rails_page_comment/application_helper.rb +4 -4
  12. data/app/helpers/rails_page_comment/page_comments_helper.rb +4 -4
  13. data/app/mailers/rails_page_comment/notify_changes.rb +15 -0
  14. data/app/models/rails_page_comment/page_comment.rb +4 -4
  15. data/app/views/layouts/rails_page_comment/application.html.erb +14 -14
  16. data/app/views/rails_page_comment/notify_changes/notice_changes.html.erb +2 -0
  17. data/app/views/rails_page_comment/page_comments/_form.html.erb +13 -13
  18. data/app/views/rails_page_comment/page_comments/index.html.erb +27 -27
  19. data/app/views/rails_page_comment/page_comments/show.html.erb +14 -14
  20. data/config/routes.rb +5 -5
  21. data/db/migrate/20141105030748_create_rails_page_comment_page_comments.rb +10 -10
  22. data/lib/generators/rails_page_comment/install_generator.rb +51 -51
  23. data/lib/generators/rails_page_comment/mailer_views_generator.rb +36 -0
  24. data/lib/generators/rails_page_comment/templates/active_record/rails_page_comment/page_comment.rb +3 -3
  25. data/lib/generators/rails_page_comment/templates/mailer/notice_changes.html.erb +2 -0
  26. data/lib/generators/rails_page_comment/templates/rails_page_comment.rb +20 -7
  27. data/lib/rails_page_comment.rb +38 -20
  28. data/lib/rails_page_comment/controller_additions.rb +38 -34
  29. data/lib/rails_page_comment/controller_resource.rb +52 -52
  30. data/lib/rails_page_comment/engine.rb +10 -10
  31. data/lib/rails_page_comment/version.rb +3 -3
  32. data/lib/tasks/rails_page_comment_tasks.rake +4 -4
  33. data/test/controllers/rails_page_comment/page_comments_controller_test.rb +51 -51
  34. data/test/dummy/README.rdoc +28 -28
  35. data/test/dummy/Rakefile +6 -6
  36. data/test/dummy/app/assets/javascripts/application.js +13 -13
  37. data/test/dummy/app/assets/stylesheets/application.css +15 -15
  38. data/test/dummy/app/controllers/application_controller.rb +5 -5
  39. data/test/dummy/app/helpers/application_helper.rb +2 -2
  40. data/test/dummy/app/views/layouts/application.html.erb +14 -14
  41. data/test/dummy/bin/bundle +3 -3
  42. data/test/dummy/bin/rails +4 -4
  43. data/test/dummy/bin/rake +4 -4
  44. data/test/dummy/config.ru +4 -4
  45. data/test/dummy/config/application.rb +23 -23
  46. data/test/dummy/config/boot.rb +5 -5
  47. data/test/dummy/config/database.yml +25 -25
  48. data/test/dummy/config/environment.rb +5 -5
  49. data/test/dummy/config/environments/development.rb +37 -37
  50. data/test/dummy/config/environments/production.rb +82 -82
  51. data/test/dummy/config/environments/test.rb +39 -39
  52. data/test/dummy/config/initializers/assets.rb +8 -8
  53. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -7
  54. data/test/dummy/config/initializers/cookies_serializer.rb +2 -2
  55. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -4
  56. data/test/dummy/config/initializers/inflections.rb +16 -16
  57. data/test/dummy/config/initializers/mime_types.rb +4 -4
  58. data/test/dummy/config/initializers/session_store.rb +3 -3
  59. data/test/dummy/config/initializers/wrap_parameters.rb +14 -14
  60. data/test/dummy/config/locales/en.yml +23 -23
  61. data/test/dummy/config/routes.rb +4 -4
  62. data/test/dummy/config/secrets.yml +22 -22
  63. data/test/dummy/public/404.html +67 -67
  64. data/test/dummy/public/422.html +67 -67
  65. data/test/dummy/public/500.html +66 -66
  66. data/test/fixtures/rails_page_comment/page_comments.yml +9 -9
  67. data/test/helpers/rails_page_comment/page_comments_helper_test.rb +6 -6
  68. data/test/integration/navigation_test.rb +10 -10
  69. data/test/mailers/previews/rails_page_comment/notify_changes_preview.rb +6 -0
  70. data/test/mailers/rails_page_comment/notify_changes_test.rb +9 -0
  71. data/test/models/rails_page_comment/page_comment_test.rb +9 -9
  72. data/test/rails_page_comment_test.rb +7 -7
  73. data/test/test_helper.rb +15 -15
  74. metadata +11 -4
  75. data/README.rdoc +0 -45
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4aa94be8d319a8caa4d8f6c65637473b0c5cc601
4
- data.tar.gz: 97f909835fa5786c4b6a5013130f5fa9a29c5765
3
+ metadata.gz: f2712d7c96e20a50db0c262e44fd07fa688cefe3
4
+ data.tar.gz: d630366e37841f9311ce2bf327e183b412d5f8b5
5
5
  SHA512:
6
- metadata.gz: 567e00422086e310d9114ded43d4b4f1e2bfb45b02916aa6accf13bf4de5d34945cc870fd5f7fb5e42a110e1aa01c48c08e66d7fa8e549c1c506b76e3dcb3d69
7
- data.tar.gz: 012955440e9107f065a3082071c2ba36055411ec3ee904f8b881d3e9b7a77b67dec9cc9af5333beb8e94b0f230ef412f5918a3159c90f8b66ae4f465af4d381a
6
+ metadata.gz: 7c3be91df60dd1f5b62608943828ba8fc4f311e7c0faa4cfe2a7f06c3bb6fcb5f22175155cf982b3220643c188018d48d8a039c781a993db637f21985a8ec6ad
7
+ data.tar.gz: d5af75793ae6b1534340fbdfab714bae3166376dcf3ff56cd7ff693c5cf664ca5140b83c3dfec442b20595914922d3badf97088fdc0bdbebb0949a8dbd8b4cd5
data/MIT-LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- Copyright 2014 YOURNAME
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.
1
+ Copyright 2014 YOURNAME
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/Rakefile CHANGED
@@ -1,34 +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 = 'RailsPageComment'
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("../test/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
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 = 'RailsPageComment'
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("../test/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
@@ -1,13 +1,13 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file.
9
- //
10
- // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
- // about supported directives.
12
- //
13
- //= require_tree .
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -1,2 +1,2 @@
1
- // Place all the behaviors and hooks related to the matching controller here.
2
- // All this logic will automatically be available in application.js.
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -1,15 +1,15 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any styles
10
- * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
- * file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -1,4 +1,4 @@
1
- /*
2
- Place all the styles related to the matching controller here.
3
- They will automatically be included in application.css.
4
- */
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -1,56 +1,56 @@
1
- body { background-color: #fff; color: #333; }
2
-
3
- body, p, ol, ul, td {
4
- font-family: verdana, arial, helvetica, sans-serif;
5
- font-size: 13px;
6
- line-height: 18px;
7
- }
8
-
9
- pre {
10
- background-color: #eee;
11
- padding: 10px;
12
- font-size: 11px;
13
- }
14
-
15
- a { color: #000; }
16
- a:visited { color: #666; }
17
- a:hover { color: #fff; background-color:#000; }
18
-
19
- div.field, div.actions {
20
- margin-bottom: 10px;
21
- }
22
-
23
- #notice {
24
- color: green;
25
- }
26
-
27
- .field_with_errors {
28
- padding: 2px;
29
- background-color: red;
30
- display: table;
31
- }
32
-
33
- #error_explanation {
34
- width: 450px;
35
- border: 2px solid red;
36
- padding: 7px;
37
- padding-bottom: 0;
38
- margin-bottom: 20px;
39
- background-color: #f0f0f0;
40
- }
41
-
42
- #error_explanation h2 {
43
- text-align: left;
44
- font-weight: bold;
45
- padding: 5px 5px 5px 15px;
46
- font-size: 12px;
47
- margin: -7px;
48
- margin-bottom: 0px;
49
- background-color: #c00;
50
- color: #fff;
51
- }
52
-
53
- #error_explanation ul li {
54
- font-size: 12px;
55
- list-style: square;
56
- }
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -1,4 +1,11 @@
1
- module RailsPageComment
2
- class ApplicationController < ActionController::Base
3
- end
4
- end
1
+ module RailsPageComment
2
+ class ApplicationController < ActionController::Base
3
+
4
+ before_filter :mailer_set_url_options
5
+
6
+ def mailer_set_url_options
7
+ ActionMailer::Base.default_url_options[:host] = request.host_with_port
8
+ end
9
+
10
+ end
11
+ end
@@ -1,62 +1,69 @@
1
- require_dependency "rails_page_comment/application_controller"
2
-
3
- module RailsPageComment
4
- class PageCommentsController < ApplicationController
5
- before_action :set_page_comment, only: [:show, :edit, :update, :destroy]
6
-
7
- # GET /page_comments
8
- def index
9
- @page_comments = PageComment.all
10
- end
11
-
12
- # GET /page_comments/1
13
- def show
14
- end
15
-
16
- # GET /page_comments/new
17
- def new
18
- @page_comment = PageComment.new
19
- end
20
-
21
- # GET /page_comments/1/edit
22
- def edit
23
- end
24
-
25
- # POST /page_comments
26
- def create
27
- @page_comment = PageComment.new(create_page_comment_params)
28
- if @page_comment.save
29
- render :edit
30
- else
31
- render :nothing => true
32
- end
33
- end
34
-
35
- # PATCH/PUT /page_comments/1
36
- def update
37
- if @page_comment.update(update_page_comment_params)
38
- render :edit
39
- else
40
- render :edit
41
- end
42
- end
43
-
44
-
45
- private
46
- # Use callbacks to share common setup or constraints between actions.
47
- def set_page_comment
48
- @page_comment = PageComment.find(params[:id])
49
- end
50
-
51
- # Only allow a trusted parameter "white list" through.
52
- def create_page_comment_params
53
- params.require(:page_comment).permit(:content, :page_uri)
54
- end
55
-
56
- # Only allow a trusted parameter "white list" through.
57
- def update_page_comment_params
58
- params.require(:page_comment).permit(:content)
59
- end
60
-
61
- end
62
- end
1
+ require_dependency "rails_page_comment/application_controller"
2
+
3
+ module RailsPageComment
4
+ class PageCommentsController < ApplicationController
5
+ before_action :set_page_comment, only: [:show, :edit, :update, :destroy]
6
+
7
+ # GET /page_comments
8
+ def index
9
+ @page_comments = PageComment.all
10
+ end
11
+
12
+ # GET /page_comments/1
13
+ def show
14
+ end
15
+
16
+ # GET /page_comments/new
17
+ def new
18
+ @page_comment = PageComment.new
19
+ end
20
+
21
+ # GET /page_comments/1/edit
22
+ def edit
23
+ end
24
+
25
+ # POST /page_comments
26
+ def create
27
+ @page_comment = PageComment.new(create_page_comment_params)
28
+ if @page_comment.save
29
+ render :edit
30
+ else
31
+ render :nothing => true
32
+ end
33
+ end
34
+
35
+ # PATCH/PUT /page_comments/1
36
+ def update
37
+ @page_comment.attributes = update_page_comment_params
38
+ if @page_comment.valid?
39
+ if @page_comment.changed?
40
+ RailsPageComment.notify_changes_method_name.each do |m|
41
+ self.class.notify_changes_class.send(m, @page_comment).deliver
42
+ end
43
+ end
44
+ @page_comment.save
45
+ render :edit
46
+ else
47
+ render :edit
48
+ end
49
+ end
50
+
51
+
52
+ private
53
+ # Use callbacks to share common setup or constraints between actions.
54
+ def set_page_comment
55
+ @page_comment = PageComment.find(params[:id])
56
+ end
57
+
58
+ # Only allow a trusted parameter "white list" through.
59
+ def create_page_comment_params
60
+ params.require(:page_comment).permit(:content, :page_uri)
61
+ end
62
+
63
+ # Only allow a trusted parameter "white list" through.
64
+ def update_page_comment_params
65
+ params.require(:page_comment).permit(:content, :page_uri)
66
+ end
67
+
68
+ end
69
+ end