commontator 0.2.0 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -81,10 +81,18 @@ Follow the steps below to add commontator to your models and views:
81
81
  ```ruby
82
82
  acts_as_commontable
83
83
  ```
84
+
85
+ 2. Controllers
86
+
87
+ Add the following line to the controller(s) that handle the views where you want to display comments:
88
+
89
+ ```ruby
90
+ helper Commontator::CommontatorHelper
91
+ ```
84
92
 
85
- 2. Views
93
+ 3. Views
86
94
 
87
- Add the following line to any view where you want to display comments:
95
+ Add the following line to any view where you would like to display comments:
88
96
 
89
97
  ```erb
90
98
  <%= commontator_thread_link(commontable) %>
@@ -1,6 +1,5 @@
1
1
  module Commontator
2
2
  class Comment < ActiveRecord::Base
3
-
4
3
  belongs_to :commontator, :polymorphic => true
5
4
  belongs_to :deleter, :polymorphic => true
6
5
  belongs_to :thread
@@ -79,6 +78,5 @@ module Commontator
79
78
  can_be_voted_on? && !thread.is_closed? &&\
80
79
  thread.can_be_read_by?(user) && user != commontator
81
80
  end
82
-
83
81
  end
84
82
  end
@@ -14,9 +14,9 @@ module Commontator
14
14
  commontable.try(:commontable_config)
15
15
  end
16
16
 
17
- def comments
17
+ def ordered_comments
18
18
  (!commontable.blank? && config.comments_can_be_voted_on && config.comments_ordered_by_votes) ? \
19
- super.order("cached_votes_down - cached_votes_up") : super
19
+ comments.order("cached_votes_down - cached_votes_up") : comments
20
20
  end
21
21
 
22
22
  def subscribers
@@ -10,13 +10,15 @@ module Commontator
10
10
 
11
11
  attr_accessible :is_closed
12
12
 
13
+ alias_method :default_comments, :comments
14
+
13
15
  def config
14
16
  commontable.try(:commontable_config)
15
17
  end
16
18
 
17
- def comments
19
+ def ordered_comments
18
20
  (!commontable.blank? && config.comments_can_be_voted_on && config.comments_ordered_by_votes) ? \
19
- super.order("cached_votes_down - cached_votes_up") : super
21
+ default_comments.order("cached_votes_down - cached_votes_up") : default_comments
20
22
  end
21
23
 
22
24
  def subscribers
@@ -7,7 +7,7 @@
7
7
  </span>
8
8
 
9
9
  <div id="thread_<%= thread.id %>_comment_list_div" class="thread_comment_list">
10
- <% thread.comments.each do |comment| %>
10
+ <% thread.ordered_comments.each do |comment| %>
11
11
  <% next unless comment.can_be_read_by?(@commontator) %>
12
12
  <%= render :partial => 'commontator/comments/show',
13
13
  :locals => {:comment => comment} %>
@@ -8,7 +8,7 @@
8
8
 
9
9
  <div id="thread_<%= thread.id %>_comment_list_div" class="thread_comment_list">
10
10
  <% thread.comments.each do |comment| %>
11
- <% next unless comment.can_be_read_by?(@commontator)is_deleted? && !thread.config.deleted_comments_are_visible %>
11
+ <% next unless comment.can_be_read_by?(@commontator) %>
12
12
  <%= render :partial => 'commontator/comments/show',
13
13
  :locals => {:comment => comment} %>
14
14
  <% end %>
@@ -9,11 +9,11 @@ Commontator.configure do |config|
9
9
  config.current_user_method = 'current_user'
10
10
 
11
11
  # Proc that is called when a view wants to set the page heading.
12
- # Default: Proc.new {}
12
+ # Default: nil
13
13
  config.heading_proc = nil
14
14
 
15
15
  # Proc that is called after any javascript runs (e.g. to clear flash notices)
16
- # Default: Proc.new {}
16
+ # Default: nil
17
17
  config.javascript_proc = nil
18
18
 
19
19
 
@@ -59,10 +59,15 @@ Commontator.configure do |config|
59
59
  config.commontable_name = 'commontable'
60
60
 
61
61
  # Proc that returns the subscription email subject
62
- # Default: Proc.new {}
63
- config.subscription_email_subject_proc = Proc.new {|params| \
62
+ # Default:
63
+ # Proc.new do |params|
64
+ # "#{params[:commontator_name]} #{params[:config].comment_create_verb_past} a " + \
65
+ # "#{params[:config].comment_name} on #{params[:commontable_name]} ##{params[:commontable_id]}"
66
+ # end
67
+ config.subscription_email_subject_proc = Proc.new do |params|
64
68
  "#{params[:commontator_name]} #{params[:config].comment_create_verb_past} a " + \
65
- "#{params[:config].comment_name} on #{params[:commontable_name]} ##{params[:commontable_id]}"}
69
+ "#{params[:config].comment_name} on #{params[:commontable_name]} ##{params[:commontable_id]}"
70
+ end
66
71
 
67
72
  # The format of the timestamps used by Commontator
68
73
  # Default: '%b %d %Y, %I:%M %p'
@@ -9,12 +9,12 @@ Commontator.configure do |config|
9
9
  config.current_user_method = 'current_user'
10
10
 
11
11
  # Proc that is called when a view wants to set the page heading.
12
- # Default: Proc.new {}
13
- config.heading_proc = nil
12
+ # Default: nil
13
+ config.heading_proc = Proc.new{|string| }
14
14
 
15
15
  # Proc that is called after any javascript runs (e.g. to clear flash notices)
16
- # Default: Proc.new {}
17
- config.javascript_proc = nil
16
+ # Default: nil
17
+ config.javascript_proc = Proc.new{}
18
18
 
19
19
 
20
20
  # Commontator (User model) Configuration
@@ -59,10 +59,15 @@ Commontator.configure do |config|
59
59
  config.commontable_name = 'commontable'
60
60
 
61
61
  # Proc that returns the subscription email subject
62
- # Default: Proc.new {}
63
- config.subscription_email_subject_proc = Proc.new {|params| \
62
+ # Default:
63
+ # Proc.new do |params|
64
+ # "#{params[:commontator_name]} #{params[:config].comment_create_verb_past} a " + \
65
+ # "#{params[:config].comment_name} on #{params[:commontable_name]} ##{params[:commontable_id]}"
66
+ # end
67
+ config.subscription_email_subject_proc = Proc.new do |params|
64
68
  "#{params[:commontator_name]} #{params[:config].comment_create_verb_past} a " + \
65
- "#{params[:config].comment_name} on #{params[:commontable_name]} ##{params[:commontable_id]}"}
69
+ "#{params[:config].comment_name} on #{params[:commontable_name]} ##{params[:commontable_id]}"
70
+ end
66
71
 
67
72
  # The format of the timestamps used by Commontator
68
73
  # Default: '%b %d %Y, %I:%M %p'
@@ -107,7 +112,7 @@ Commontator.configure do |config|
107
112
  # Whether comments should be ordered by vote score
108
113
  # instead of by order posted
109
114
  # Default: false
110
- config.comments_order_by_votes = false
115
+ config.comments_ordered_by_votes = false
111
116
 
112
117
  # Whether users can read threads closed by admins
113
118
  # Default: true
@@ -1,3 +1,3 @@
1
1
  module Commontator
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module Commontator
2
- VERSION = "0.1.46"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -5,9 +5,12 @@ namespace :commontator do
5
5
  desc "Copy initializers from commontator to application"
6
6
  task :initializers do
7
7
  Dir.glob(File.expand_path('../../../config/initializers/*.rb', __FILE__)) do |file|
8
- next if File.exists?(File.expand_path(File.basename(file), 'config/initializers'))
9
- cp file, 'config/initializers', :verbose => false
10
- print "Copied initializer #{File.basename(file)} from commontator\n"
8
+ if File.exists?(File.expand_path(File.basename(file), 'config/initializers'))
9
+ print "NOTE: Initializer #{File.basename(file)} from commontator has been skipped. Initializer with the same name already exists.\n"
10
+ else
11
+ cp file, 'config/initializers', :verbose => false
12
+ print "Copied initializer #{File.basename(file)} from commontator\n"
13
+ end
11
14
  end
12
15
  end
13
16
  end
@@ -5,9 +5,12 @@ namespace :commontator do
5
5
  desc "Copy initializers from commontator to application"
6
6
  task :initializers do
7
7
  Dir.glob(File.expand_path('../../../config/initializers/*.rb', __FILE__)) do |file|
8
- next if File.exists?(File.expand_path(File.basename(file), 'config/initializers'))
9
- cp file, 'config/initializers', :verbose => false
10
- print "Copied initializer #{File.basename(file)} from commontator\n"
8
+ if File.exists?(File.expand_path(File.basename(file), 'config/initializers'))
9
+ print "NOTE: Initializer #{File.basename(file)} from commontator has been skipped. Initializer with the same name already exists."
10
+ else
11
+ cp file, 'config/initializers', :verbose => false
12
+ print "Copied initializer #{File.basename(file)} from commontator\n"
13
+ end
11
14
  end
12
15
  end
13
16
  end
@@ -32,7 +35,6 @@ namespace :commontator do
32
35
  desc "Copy assets, views, mailers, helpers, controllers and models from commontator to application"
33
36
  task :copy do
34
37
  COPY_TASKS.each do |path|
35
- name = path
36
38
  Rake::Task["commontator:copy:#{File.basename(path)}"].invoke
37
39
  end
38
40
  end
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ mount Commontator::Engine => "/commontator"
3
+ end
Binary file
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended to check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(:version => 20120710213148) do
14
+ ActiveRecord::Schema.define(:version => 1) do
15
15
 
16
16
  create_table "commontator_comments", :force => true do |t|
17
17
  t.text "body"
@@ -274,3 +274,71 @@ Connecting to database specified by database.yml
274
274
  Connecting to database specified by database.yml
275
275
  Connecting to database specified by database.yml
276
276
  Connecting to database specified by database.yml
277
+ Connecting to database specified by database.yml
278
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
279
+ Migrating to InstallCommontator (1)
280
+  (0.0ms) select sqlite_version(*)
281
+  (0.0ms) begin transaction
282
+  (0.2ms) CREATE TABLE "commontator_comments" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "body" text, "commontator_id" integer, "commontator_type" varchar(255), "deleted_at" datetime, "deleter_id" integer, "deleter_type" varchar(255), "thread_id" integer, "cached_votes_total" integer DEFAULT 0, "cached_votes_up" integer DEFAULT 0, "cached_votes_down" integer DEFAULT 0, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
283
+ SQLite3::SQLException: table "commontator_comments" already exists: CREATE TABLE "commontator_comments" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "body" text, "commontator_id" integer, "commontator_type" varchar(255), "deleted_at" datetime, "deleter_id" integer, "deleter_type" varchar(255), "thread_id" integer, "cached_votes_total" integer DEFAULT 0, "cached_votes_up" integer DEFAULT 0, "cached_votes_down" integer DEFAULT 0, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
284
+  (0.1ms) rollback transaction
285
+ Connecting to database specified by database.yml
286
+  (0.1ms) select sqlite_version(*)
287
+  (288.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
288
+  (0.1ms) PRAGMA index_list("schema_migrations")
289
+  (237.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
290
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
291
+ Migrating to InstallCommontator (1)
292
+  (0.0ms) begin transaction
293
+  (0.5ms) CREATE TABLE "commontator_comments" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "body" text, "commontator_id" integer, "commontator_type" varchar(255), "deleted_at" datetime, "deleter_id" integer, "deleter_type" varchar(255), "thread_id" integer, "cached_votes_total" integer DEFAULT 0, "cached_votes_up" integer DEFAULT 0, "cached_votes_down" integer DEFAULT 0, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
294
+  (0.2ms) CREATE TABLE "commontator_subscriptions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "subscriber_id" integer, "subscriber_type" varchar(255), "thread_id" integer, "is_unread" boolean, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
295
+  (0.2ms) CREATE TABLE "commontator_threads" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "commontable_id" integer, "commontable_type" varchar(255), "closed_at" datetime, "closer_id" integer, "closer_type" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
296
+  (0.0ms) PRAGMA index_list("commontator_comments")
297
+  (0.1ms) CREATE INDEX "index_c_c_on_c_id_and_c_type_and_t_id" ON "commontator_comments" ("commontator_id", "commontator_type", "thread_id")
298
+  (0.0ms) PRAGMA index_list("commontator_comments")
299
+  (0.0ms) PRAGMA index_info('index_c_c_on_c_id_and_c_type_and_t_id')
300
+  (0.2ms) CREATE INDEX "index_commontator_comments_on_thread_id" ON "commontator_comments" ("thread_id")
301
+  (0.0ms) PRAGMA index_list("commontator_subscriptions")
302
+  (0.2ms) CREATE UNIQUE INDEX "index_c_s_on_s_id_and_s_type_and_t_id" ON "commontator_subscriptions" ("subscriber_id", "subscriber_type", "thread_id")
303
+  (0.0ms) PRAGMA index_list("commontator_subscriptions")
304
+  (0.0ms) PRAGMA index_info('index_c_s_on_s_id_and_s_type_and_t_id')
305
+  (0.1ms) CREATE INDEX "index_commontator_subscriptions_on_thread_id" ON "commontator_subscriptions" ("thread_id")
306
+  (0.0ms) PRAGMA index_list("commontator_threads")
307
+  (0.1ms) CREATE INDEX "index_commontator_threads_on_commontable_id_and_commontable_type" ON "commontator_threads" ("commontable_id", "commontable_type")
308
+  (0.0ms) PRAGMA index_list("commontator_comments")
309
+  (0.0ms) PRAGMA index_info('index_commontator_comments_on_thread_id')
310
+  (0.0ms) PRAGMA index_info('index_c_c_on_c_id_and_c_type_and_t_id')
311
+  (0.2ms) CREATE INDEX "index_commontator_comments_on_cached_votes_total" ON "commontator_comments" ("cached_votes_total")
312
+  (0.0ms) PRAGMA index_list("commontator_comments")
313
+  (0.0ms) PRAGMA index_info('index_commontator_comments_on_cached_votes_total')
314
+  (0.0ms) PRAGMA index_info('index_commontator_comments_on_thread_id')
315
+  (0.0ms) PRAGMA index_info('index_c_c_on_c_id_and_c_type_and_t_id')
316
+  (0.2ms) CREATE INDEX "index_commontator_comments_on_cached_votes_up" ON "commontator_comments" ("cached_votes_up")
317
+  (0.1ms) PRAGMA index_list("commontator_comments")
318
+  (0.0ms) PRAGMA index_info('index_commontator_comments_on_cached_votes_up')
319
+  (0.0ms) PRAGMA index_info('index_commontator_comments_on_cached_votes_total')
320
+  (0.0ms) PRAGMA index_info('index_commontator_comments_on_thread_id')
321
+  (0.0ms) PRAGMA index_info('index_c_c_on_c_id_and_c_type_and_t_id')
322
+  (0.2ms) CREATE INDEX "index_commontator_comments_on_cached_votes_down" ON "commontator_comments" ("cached_votes_down")
323
+  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('1')
324
+  (362.6ms) commit transaction
325
+  (0.4ms) select sqlite_version(*)
326
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
327
+  (0.0ms) PRAGMA index_list("commontator_comments")
328
+  (0.0ms) PRAGMA index_info('index_commontator_comments_on_cached_votes_down')
329
+  (0.0ms) PRAGMA index_info('index_commontator_comments_on_cached_votes_up')
330
+  (0.0ms) PRAGMA index_info('index_commontator_comments_on_cached_votes_total')
331
+  (0.0ms) PRAGMA index_info('index_commontator_comments_on_thread_id')
332
+  (0.0ms) PRAGMA index_info('index_c_c_on_c_id_and_c_type_and_t_id')
333
+  (0.0ms) PRAGMA index_list("commontator_subscriptions")
334
+  (0.0ms) PRAGMA index_info('index_commontator_subscriptions_on_thread_id')
335
+  (0.0ms) PRAGMA index_info('index_c_s_on_s_id_and_s_type_and_t_id')
336
+  (0.0ms) PRAGMA index_list("commontator_threads")
337
+  (0.0ms) PRAGMA index_info('index_commontator_threads_on_commontable_id_and_commontable_type')
338
+ Connecting to database specified by database.yml
339
+ Connecting to database specified by database.yml
340
+ Connecting to database specified by database.yml
341
+ Connecting to database specified by database.yml
342
+ Connecting to database specified by database.yml
343
+ SQLite3::SQLException: no such column: a: SELECT "commontator_comments".* FROM "commontator_comments" WHERE "commontator_comments"."thread_id" = 1 ORDER BY a
344
+ Connecting to database specified by database.yml
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commontator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-10 00:00:00.000000000 Z
12
+ date: 2012-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -152,7 +152,7 @@ files:
152
152
  - config/routes.rb~
153
153
  - config/routes.rb
154
154
  - db/migrate/0_install_commontator.rb~
155
- - db/migrate/0_install.rb
155
+ - db/migrate/0_install_commontator.rb
156
156
  - lib/commontator.rb
157
157
  - lib/commontator.rb~
158
158
  - lib/tasks/commontator_tasks.rake~
@@ -195,9 +195,8 @@ files:
195
195
  - test/dummy/README.rdoc
196
196
  - test/dummy/log/development.log
197
197
  - test/dummy/db/development.sqlite3
198
- - test/dummy/db/test.sqlite3
199
198
  - test/dummy/db/schema.rb
200
- - test/dummy/db/migrate/1_install.commontator.rb
199
+ - test/dummy/db/migrate/1_install_commontator.commontator.rb
201
200
  - test/dummy/Rakefile
202
201
  - test/dummy/script/rails
203
202
  - test/dummy/app/assets/stylesheets/application.css
@@ -222,6 +221,7 @@ files:
222
221
  - test/dummy/config/boot.rb
223
222
  - test/dummy/config/application.rb
224
223
  - test/dummy/config/environment.rb
224
+ - test/dummy/config/routes.rb~
225
225
  - test/dummy/config/environments/test.rb
226
226
  - test/dummy/config/environments/production.rb
227
227
  - test/dummy/config/environments/development.rb
@@ -275,9 +275,8 @@ test_files:
275
275
  - test/dummy/README.rdoc
276
276
  - test/dummy/log/development.log
277
277
  - test/dummy/db/development.sqlite3
278
- - test/dummy/db/test.sqlite3
279
278
  - test/dummy/db/schema.rb
280
- - test/dummy/db/migrate/1_install.commontator.rb
279
+ - test/dummy/db/migrate/1_install_commontator.commontator.rb
281
280
  - test/dummy/Rakefile
282
281
  - test/dummy/script/rails
283
282
  - test/dummy/app/assets/stylesheets/application.css
@@ -302,6 +301,7 @@ test_files:
302
301
  - test/dummy/config/boot.rb
303
302
  - test/dummy/config/application.rb
304
303
  - test/dummy/config/environment.rb
304
+ - test/dummy/config/routes.rb~
305
305
  - test/dummy/config/environments/test.rb
306
306
  - test/dummy/config/environments/production.rb
307
307
  - test/dummy/config/environments/development.rb
Binary file