the_comments 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. data/.rvmrc.example +1 -0
  2. data/.travis.yml +5 -0
  3. data/README.md +105 -425
  4. data/app/assets/javascripts/the_comments.js.coffee +12 -9
  5. data/app/assets/javascripts/the_comments_manage.js.coffee +19 -49
  6. data/app/assets/stylesheets/the_comments.css.scss +20 -29
  7. data/app/controllers/_templates_/comments_controller.rb +44 -0
  8. data/app/controllers/concerns/controller.rb +216 -0
  9. data/app/helpers/render_comments_tree_helper.rb +4 -7
  10. data/app/models/_templates_/comment.rb +38 -0
  11. data/app/models/concerns/comment.rb +103 -0
  12. data/app/models/concerns/comment_states.rb +80 -0
  13. data/app/models/concerns/commentable.rb +69 -0
  14. data/app/models/concerns/user.rb +52 -0
  15. data/app/views/the_comments/_tree.html.erb +3 -0
  16. data/app/views/the_comments/haml/_additional_info.html.haml +13 -0
  17. data/app/views/the_comments/{_comment.html.haml → haml/_comment.html.haml} +0 -0
  18. data/app/views/the_comments/haml/_comment_body.html.haml +20 -0
  19. data/app/views/the_comments/haml/_comment_edit.html.haml +26 -0
  20. data/app/views/the_comments/{_form.html.haml → haml/_form.html.haml} +8 -6
  21. data/app/views/the_comments/haml/_manage_controls.html.haml +27 -0
  22. data/app/views/the_comments/haml/_sidebar.html.haml +28 -0
  23. data/app/views/the_comments/haml/_tree.html.haml +4 -0
  24. data/app/views/the_comments/haml/index.html.haml +18 -0
  25. data/app/views/the_comments/haml/manage.html.haml +25 -0
  26. data/app/views/the_comments/haml/my_comments.html.haml +28 -0
  27. data/app/views/the_comments/slim/_additional_info.html.slim +13 -0
  28. data/app/views/the_comments/slim/_comment.html.slim +1 -0
  29. data/app/views/the_comments/slim/_comment_body.html.slim +20 -0
  30. data/app/views/the_comments/slim/_comment_edit.html.slim +26 -0
  31. data/app/views/the_comments/slim/_form.html.slim +27 -0
  32. data/app/views/the_comments/slim/_manage_controls.html.slim +27 -0
  33. data/app/views/the_comments/slim/_sidebar.html.slim +28 -0
  34. data/app/views/the_comments/slim/_tree.html.slim +4 -0
  35. data/app/views/the_comments/slim/index.html.slim +18 -0
  36. data/app/views/the_comments/slim/manage.html.slim +25 -0
  37. data/app/views/the_comments/slim/my_comments.html.slim +28 -0
  38. data/{lib/generators/the_comments/templates → config/initializers}/the_comments.rb +3 -0
  39. data/config/locales/en.yml +39 -14
  40. data/config/locales/ru.yml +67 -0
  41. data/config/routes.rb +17 -13
  42. data/db/migrate/20130101010101_change_user.rb +18 -0
  43. data/db/migrate/20130101010102_create_comments.rb +50 -0
  44. data/db/migrate/20130101010103_change_commentable.rb +13 -0
  45. data/docs/admin_ui_installation.md +145 -0
  46. data/docs/advanced_installation.md +182 -0
  47. data/docs/comment_api.md +58 -0
  48. data/docs/commentable_api.md +59 -0
  49. data/docs/config_file.md +27 -0
  50. data/docs/content_preprocessors.md +73 -0
  51. data/docs/customazation_of_views.md +30 -0
  52. data/docs/denormalization_and_recent_comments.md +40 -0
  53. data/docs/documentation.md +28 -0
  54. data/docs/mountable_routes.md +80 -0
  55. data/docs/pagination.md +123 -0
  56. data/docs/screencast.jpg +0 -0
  57. data/docs/user_api.md +75 -0
  58. data/docs/what_is_comcoms.md +63 -0
  59. data/docs/whats_wrong_with_other_gems.md +18 -0
  60. data/docs/where_is_example_application.md +37 -0
  61. data/gem_version.rb +3 -0
  62. data/lib/generators/the_comments/USAGE +31 -20
  63. data/lib/generators/the_comments/the_comments_generator.rb +35 -18
  64. data/lib/generators/the_comments/views_generator.rb +52 -16
  65. data/lib/the_comments/config.rb +14 -1
  66. data/lib/the_comments/version.rb +1 -3
  67. data/lib/the_comments.rb +10 -0
  68. data/spec/dummy_app/.gitignore +17 -0
  69. data/spec/dummy_app/.rspec +1 -0
  70. data/spec/dummy_app/.ruby-gemset +1 -0
  71. data/spec/dummy_app/.ruby-version +1 -0
  72. data/spec/dummy_app/Gemfile +43 -0
  73. data/spec/dummy_app/README.md +50 -0
  74. data/spec/dummy_app/Rakefile +6 -0
  75. data/spec/dummy_app/app/assets/images/.keep +0 -0
  76. data/spec/dummy_app/app/assets/javascripts/admin_panel.js +5 -0
  77. data/spec/dummy_app/app/assets/javascripts/application.js +16 -0
  78. data/spec/dummy_app/app/assets/stylesheets/admin_panel.css +3 -0
  79. data/spec/dummy_app/app/assets/stylesheets/app.css.scss +4 -0
  80. data/spec/dummy_app/app/assets/stylesheets/application.css +16 -0
  81. data/spec/dummy_app/app/controllers/application_controller.rb +7 -0
  82. data/{lib/generators/the_comments/templates → spec/dummy_app/app/controllers}/comments_controller.rb +3 -1
  83. data/spec/dummy_app/app/controllers/concerns/.keep +0 -0
  84. data/spec/dummy_app/app/controllers/posts_controller.rb +13 -0
  85. data/spec/dummy_app/app/controllers/users_controller.rb +7 -0
  86. data/spec/dummy_app/app/helpers/application_helper.rb +2 -0
  87. data/spec/dummy_app/app/mailers/.keep +0 -0
  88. data/spec/dummy_app/app/models/.keep +0 -0
  89. data/spec/dummy_app/app/models/comment.rb +32 -0
  90. data/spec/dummy_app/app/models/concerns/.keep +0 -0
  91. data/spec/dummy_app/app/models/post.rb +17 -0
  92. data/spec/dummy_app/app/models/user.rb +21 -0
  93. data/spec/dummy_app/app/views/layouts/admin.html.haml +25 -0
  94. data/spec/dummy_app/app/views/layouts/application.html.haml +20 -0
  95. data/spec/dummy_app/app/views/posts/index.html.haml +22 -0
  96. data/spec/dummy_app/app/views/posts/show.html.haml +7 -0
  97. data/spec/dummy_app/bin/bundle +3 -0
  98. data/spec/dummy_app/bin/rails +4 -0
  99. data/spec/dummy_app/bin/rake +4 -0
  100. data/spec/dummy_app/config/application.rb +23 -0
  101. data/spec/dummy_app/config/boot.rb +4 -0
  102. data/spec/dummy_app/config/database.yml +11 -0
  103. data/spec/dummy_app/config/environment.rb +5 -0
  104. data/spec/dummy_app/config/environments/development.rb +29 -0
  105. data/spec/dummy_app/config/environments/production.rb +80 -0
  106. data/spec/dummy_app/config/environments/test.rb +36 -0
  107. data/spec/dummy_app/config/initializers/backtrace_silencers.rb +7 -0
  108. data/spec/dummy_app/config/initializers/filter_parameter_logging.rb +4 -0
  109. data/spec/dummy_app/config/initializers/inflections.rb +16 -0
  110. data/spec/dummy_app/config/initializers/mime_types.rb +5 -0
  111. data/spec/dummy_app/config/initializers/secret_token.rb +12 -0
  112. data/spec/dummy_app/config/initializers/session_store.rb +3 -0
  113. data/spec/dummy_app/config/initializers/sorcery.rb +437 -0
  114. data/spec/dummy_app/config/initializers/the_comments.rb +13 -0
  115. data/spec/dummy_app/config/initializers/wrap_parameters.rb +14 -0
  116. data/spec/dummy_app/config/locales/en.yml +23 -0
  117. data/spec/dummy_app/config/routes.rb +15 -0
  118. data/spec/dummy_app/config.ru +4 -0
  119. data/spec/dummy_app/db/migrate/20130712061503_sorcery_core.rb +16 -0
  120. data/spec/dummy_app/db/migrate/20130712065951_create_posts.rb +11 -0
  121. data/spec/dummy_app/db/migrate/20131027185332_change_user.the_comments_engine.rb +19 -0
  122. data/spec/dummy_app/db/migrate/20131027185333_create_comments.the_comments_engine.rb +51 -0
  123. data/spec/dummy_app/db/migrate/20131027185334_change_commentable.the_comments_engine.rb +14 -0
  124. data/spec/dummy_app/db/schema.rb +74 -0
  125. data/spec/dummy_app/db/seeds.rb +42 -0
  126. data/spec/dummy_app/lib/assets/.keep +0 -0
  127. data/spec/dummy_app/lib/tasks/.keep +0 -0
  128. data/spec/dummy_app/lib/tasks/app_bootstrap.rake +15 -0
  129. data/spec/dummy_app/log/.keep +0 -0
  130. data/spec/dummy_app/public/404.html +58 -0
  131. data/spec/dummy_app/public/422.html +58 -0
  132. data/spec/dummy_app/public/500.html +57 -0
  133. data/spec/dummy_app/public/favicon.ico +0 -0
  134. data/spec/dummy_app/public/robots.txt +5 -0
  135. data/spec/dummy_app/spec/factories/post.rb +6 -0
  136. data/spec/dummy_app/spec/factories/user.rb +6 -0
  137. data/spec/dummy_app/spec/models/user_counters_spec.rb +339 -0
  138. data/spec/dummy_app/spec/spec_helper.rb +29 -0
  139. data/spec/dummy_app/test/controllers/.keep +0 -0
  140. data/spec/dummy_app/test/fixtures/.keep +0 -0
  141. data/spec/dummy_app/test/helpers/.keep +0 -0
  142. data/spec/dummy_app/test/integration/.keep +0 -0
  143. data/spec/dummy_app/test/mailers/.keep +0 -0
  144. data/spec/dummy_app/test/models/.keep +0 -0
  145. data/spec/dummy_app/test/test_helper.rb +15 -0
  146. data/spec/dummy_app/vendor/assets/javascripts/.keep +0 -0
  147. data/spec/dummy_app/vendor/assets/stylesheets/.keep +0 -0
  148. data/views_converter.rb +16 -0
  149. metadata +223 -45
  150. data/app/controllers/concerns/the_comments_controller.rb +0 -229
  151. data/app/controllers/concerns/the_comments_ip_controller.rb +0 -17
  152. data/app/controllers/concerns/the_comments_user_agent_controller.rb +0 -15
  153. data/app/models/concerns/the_comments_base.rb +0 -69
  154. data/app/models/concerns/the_comments_black_ip.rb +0 -9
  155. data/app/models/concerns/the_comments_black_user_agent.rb +0 -9
  156. data/app/models/concerns/the_comments_commentable.rb +0 -66
  157. data/app/models/concerns/the_comments_states.rb +0 -65
  158. data/app/models/concerns/the_comments_user.rb +0 -32
  159. data/app/views/ip_black_lists/index.html.haml +0 -17
  160. data/app/views/the_comments/_comment_body.html.haml +0 -30
  161. data/app/views/the_comments/_manage_controls.html.haml +0 -4
  162. data/app/views/the_comments/_tree.html.haml +0 -4
  163. data/app/views/the_comments/index.html.haml +0 -19
  164. data/app/views/the_comments/manage.html.haml +0 -29
  165. data/app/views/user_agent_black_lists/index.html.haml +0 -17
  166. data/db/migrate/20130101010101_create_comments.rb +0 -90
  167. data/lib/generators/the_comments/templates/ip_black_list.rb +0 -3
  168. data/lib/generators/the_comments/templates/ip_black_lists_controller.rb +0 -10
  169. data/lib/generators/the_comments/templates/the_comments_black_ip.rb +0 -9
  170. data/lib/generators/the_comments/templates/the_comments_black_user_agent.rb +0 -9
  171. data/lib/generators/the_comments/templates/user_agent_black_list.rb +0 -3
  172. data/lib/generators/the_comments/templates/user_agent_black_lists_controller.rb +0 -10
@@ -0,0 +1,7 @@
1
+ %h3= @post.title
2
+ %p= @post.content
3
+
4
+ %p
5
+ Comments count: #{@post.comments_sum}
6
+
7
+ = render partial: 'the_comments/tree', locals: { commentable: @post, comments_tree: @comments }
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,23 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ # Require the gems listed in Gemfile, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(:default, Rails.env)
8
+
9
+ module App
10
+ class Application < Rails::Application
11
+ # Settings in config/environments/* take precedence over those specified here.
12
+ # Application configuration should go into files in config/initializers
13
+ # -- all .rb files in that directory are automatically loaded.
14
+
15
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
16
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
17
+ # config.time_zone = 'Central Time (US & Canada)'
18
+
19
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
20
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
21
+ # config.i18n.default_locale = :de
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
@@ -0,0 +1,11 @@
1
+ development:
2
+ adapter: sqlite3
3
+ database: db/development.db
4
+ pool: 5
5
+ timeout: 5000
6
+
7
+ test:
8
+ adapter: sqlite3
9
+ database: db/test.db
10
+ pool: 5
11
+ timeout: 5000
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ App::Application.initialize!
@@ -0,0 +1,29 @@
1
+ App::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports and disable caching.
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send.
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger.
20
+ config.active_support.deprecation = :log
21
+
22
+ # Raise an error on page load if there are pending migrations
23
+ config.active_record.migration_error = :page_load
24
+
25
+ # Debug mode disables concatenation and preprocessing of assets.
26
+ # This option may cause significant delays in view rendering with a large
27
+ # number of complex assets.
28
+ config.assets.debug = true
29
+ end
@@ -0,0 +1,80 @@
1
+ App::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # Code is not reloaded between requests.
5
+ config.cache_classes = true
6
+
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both thread web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
14
+ config.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
+ # Add `rack-cache` to your Gemfile before enabling this.
19
+ # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
20
+ # config.action_dispatch.rack_cache = true
21
+
22
+ # Disable Rails's static asset server (Apache or nginx will already do this).
23
+ config.serve_static_assets = false
24
+
25
+ # Compress JavaScripts and CSS.
26
+ config.assets.js_compressor = :uglifier
27
+ # config.assets.css_compressor = :sass
28
+
29
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
30
+ config.assets.compile = false
31
+
32
+ # Generate digests for assets URLs.
33
+ config.assets.digest = true
34
+
35
+ # Version of your assets, change this if you want to expire all your assets.
36
+ config.assets.version = '1.0'
37
+
38
+ # Specifies the header that your server uses for sending files.
39
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
40
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
41
+
42
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
43
+ # config.force_ssl = true
44
+
45
+ # Set to :debug to see everything in the log.
46
+ config.log_level = :info
47
+
48
+ # Prepend all log lines with the following tags.
49
+ # config.log_tags = [ :subdomain, :uuid ]
50
+
51
+ # Use a different logger for distributed setups.
52
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
53
+
54
+ # Use a different cache store in production.
55
+ # config.cache_store = :mem_cache_store
56
+
57
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
58
+ # config.action_controller.asset_host = "http://assets.example.com"
59
+
60
+ # Precompile additional assets.
61
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
62
+ # config.assets.precompile += %w( search.js )
63
+
64
+ # Ignore bad email addresses and do not raise email delivery errors.
65
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
66
+ # config.action_mailer.raise_delivery_errors = false
67
+
68
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
69
+ # the I18n.default_locale when a translation can not be found).
70
+ config.i18n.fallbacks = true
71
+
72
+ # Send deprecation notices to registered listeners.
73
+ config.active_support.deprecation = :notify
74
+
75
+ # Disable automatic flushing of the log to improve performance.
76
+ # config.autoflush_log = false
77
+
78
+ # Use default logging formatter so that PID and timestamp are not suppressed.
79
+ config.log_formatter = ::Logger::Formatter.new
80
+ end
@@ -0,0 +1,36 @@
1
+ App::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Do not eager load code on boot. This avoids loading your whole application
11
+ # just for the purpose of running a single test. If you are using a tool that
12
+ # preloads Rails for running tests, you may have to set it to true.
13
+ config.eager_load = false
14
+
15
+ # Configure static asset server for tests with Cache-Control for performance.
16
+ config.serve_static_assets = true
17
+ config.static_cache_control = "public, max-age=3600"
18
+
19
+ # Show full error reports and disable caching.
20
+ config.consider_all_requests_local = true
21
+ config.action_controller.perform_caching = false
22
+
23
+ # Raise exceptions instead of rendering exception templates.
24
+ config.action_dispatch.show_exceptions = false
25
+
26
+ # Disable request forgery protection in test environment.
27
+ config.action_controller.allow_forgery_protection = false
28
+
29
+ # Tell Action Mailer not to deliver emails to the real world.
30
+ # The :test delivery method accumulates sent emails in the
31
+ # ActionMailer::Base.deliveries array.
32
+ config.action_mailer.delivery_method = :test
33
+
34
+ # Print deprecation notices to the stderr.
35
+ config.active_support.deprecation = :stderr
36
+ end
@@ -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,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,5 @@
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
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,12 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure your secret_key_base is kept private
11
+ # if you're sharing your code publicly.
12
+ App::Application.config.secret_key_base = '27b186570a6fd4b0fbbb16c50a61dc99cb695db28beadceed09ee5717dbb1cd1b75042e548cc595fd1a2465a5313006f54f27b169856fb4db1db0ff50c9ae756'
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ App::Application.config.session_store :cookie_store, key: '_app_session'