commontator 0.1.46 → 0.2.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.
@@ -1,11 +1,11 @@
1
1
  module Commontator
2
2
  class CommontatorConfig
3
- Commontator::COMMONTATOR_CONFIG.keys.each do |attribute|
3
+ Commontator::COMMONTATOR_ATTRIBUTES.each do |attribute|
4
4
  cattr_accessor attribute
5
5
  end
6
6
 
7
7
  def initialize(options = {})
8
- Commontator::COMMONTATOR_CONFIG.keys.each do |attribute|
8
+ Commontator::COMMONTATOR_ATTRIBUTES.each do |attribute|
9
9
  self.send attribute.to_s + '=', options[attribute] || Commontator.send(attribute)
10
10
  end
11
11
  end
@@ -0,0 +1,13 @@
1
+ module Commontator
2
+ class CommontatorConfig
3
+ Commontator::COMMONTATOR_ATTRIBUTES.keys.each do |attribute|
4
+ cattr_accessor attribute
5
+ end
6
+
7
+ def initialize(options = {})
8
+ Commontator::COMMONTATOR_ATTRIBUTES.keys.each do |attribute|
9
+ self.send attribute.to_s + '=', options[attribute] || Commontator.send(attribute)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module Commontator
2
- VERSION = "0.1.46"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module Commontator
2
- VERSION = "0.1.45"
2
+ VERSION = "0.1.46"
3
3
  end
@@ -0,0 +1,38 @@
1
+ COPY_TASKS = ['assets/images', 'assets/stylesheets', 'views', 'mailers', 'helpers', 'controllers', 'models']
2
+
3
+ namespace :commontator do
4
+ namespace :install do
5
+ desc "Copy initializers from commontator to application"
6
+ task :initializers do
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"
11
+ end
12
+ end
13
+ end
14
+
15
+ namespace :copy do
16
+ COPY_TASKS.each do |path|
17
+ name = File.basename(path)
18
+ desc "Copy #{name} from commontator to application"
19
+ task name.to_sym do
20
+ cp_r File.expand_path("../../../app/#{path}/commontator", __FILE__), "app/#{path}", :verbose => false
21
+ print "Copied #{name} from commontator\n"
22
+ end
23
+ end
24
+ end
25
+
26
+ desc "Copy initializers and migrations from commontator to application"
27
+ task :install do
28
+ Rake::Task["commontator:install:initializers"].invoke
29
+ Rake::Task["commontator:install:migrations"].invoke
30
+ end
31
+
32
+ desc "Copy assets, views, mailers, helpers, controllers and models from commontator to application"
33
+ task :copy do
34
+ COPY_TASKS.each do |path|
35
+ Rake::Task["commontator:copy:#{File.basename(path)}"].invoke
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,39 @@
1
+ COPY_TASKS = ['assets/images', 'assets/stylesheets', 'views', 'mailers', 'helpers', 'controllers', 'models']
2
+
3
+ namespace :commontator do
4
+ namespace :install do
5
+ desc "Copy initializers from commontator to application"
6
+ task :initializers do
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"
11
+ end
12
+ end
13
+ end
14
+
15
+ namespace :copy do
16
+ COPY_TASKS.each do |path|
17
+ name = File.basename(path)
18
+ desc "Copy #{name} from commontator to application"
19
+ task name.to_sym do
20
+ cp_r File.expand_path("../../../app/#{path}/commontator", __FILE__), "app/#{path}", :verbose => false
21
+ print "Copied #{name} from commontator\n"
22
+ end
23
+ end
24
+ end
25
+
26
+ desc "Copy initializers and migrations from commontator to application"
27
+ task :install do
28
+ Rake::Task["commontator:install:initializers"].invoke
29
+ Rake::Task["commontator:install:migrations"].invoke
30
+ end
31
+
32
+ desc "Copy assets, views, mailers, helpers, controllers and models from commontator to application"
33
+ task :copy do
34
+ COPY_TASKS.each do |path|
35
+ name = path
36
+ Rake::Task["commontator:copy:#{File.basename(path)}"].invoke
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,164 @@
1
+ # Change the settings below to suit your needs
2
+ # All settings are initially set to their default values
3
+ Commontator.configure do |config|
4
+
5
+ # Engine Configuration
6
+
7
+ # Method called on ApplicationController to return the current user
8
+ # Default: 'current_user'
9
+ config.current_user_method = 'current_user'
10
+
11
+ # Proc that is called when a view wants to set the page heading.
12
+ # Default: Proc.new {}
13
+ config.heading_proc = nil
14
+
15
+ # Proc that is called after any javascript runs (e.g. to clear flash notices)
16
+ # Default: Proc.new {}
17
+ config.javascript_proc = nil
18
+
19
+
20
+ # Commontator (User model) Configuration
21
+
22
+ # Whether the commontator's name is clickable in the comment view
23
+ # Default: false
24
+ config.commontator_name_clickable = false
25
+
26
+ # The method that return the commontator's email address
27
+ # Default: 'email'
28
+ config.commontator_email_method = 'email'
29
+
30
+ # The method that return the commontator's name
31
+ # Default: '' (Anonymous)
32
+ config.commontator_name_method = ''
33
+
34
+ # Method that returns true if the commontator is an admin for all threads
35
+ # Admins can always delete other users' comments and close threads
36
+ # Default: '' (no admins)
37
+ config.is_admin_method = ''
38
+
39
+
40
+ # Commontable (Commentable model) Configuration
41
+
42
+ # What a comment is called in your application
43
+ # Default: 'comment'
44
+ config.comment_name = 'comment'
45
+
46
+ # Verb used when creating comments (present)
47
+ # Default: 'post'
48
+ config.comment_create_verb_present = 'post'
49
+
50
+ # Verb used when creating comments (past)
51
+ # Default: 'posted'
52
+ config.comment_create_verb_past = 'posted'
53
+
54
+ # What a commontable is called in your application
55
+ # If you have multiple commontable models,
56
+ # you might want to pass this configuration value
57
+ # as an argument to acts_as_commontable in each one
58
+ # Default: 'commontable'
59
+ config.commontable_name = 'commontable'
60
+
61
+ # Proc that returns the subscription email subject
62
+ # Default: Proc.new {}
63
+ config.subscription_email_subject_proc = Proc.new {|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
+
67
+ # The format of the timestamps used by Commontator
68
+ # Default: '%b %d %Y, %I:%M %p'
69
+ config.timestamp_format = '%b %d %Y, %I:%M %p'
70
+
71
+ # Whether admins can edit other users' comments
72
+ # Default: false
73
+ config.admin_can_edit_comments = false
74
+
75
+ # Whether users automatically subscribe to a thread when commenting
76
+ # Default: false
77
+ config.auto_subscribe_on_comment = false
78
+
79
+ # Whether users can edit their own comments
80
+ # Default: true
81
+ config.can_edit_own_comments = true
82
+
83
+ # Whether users can edit their own comments
84
+ # after someone posted a newer comment
85
+ # Default: false
86
+ config.can_edit_old_comments = false
87
+
88
+ # Whether users can delete their own comments
89
+ # Default: false
90
+ config.can_delete_own_comments = false
91
+
92
+ # Whether users can delete their own comments
93
+ # after someone posted a newer comment
94
+ # Default: false
95
+ config.can_delete_old_comments = false
96
+
97
+ # Whether users can manually subscribe or unsubscribe to threads
98
+ # Default: true
99
+ config.can_subscribe_to_thread = true
100
+
101
+ # Whether users can vote on other users' comments
102
+ # Note: requires acts_as_votable gem installed
103
+ # and configured for your application
104
+ # Default: false
105
+ config.comments_can_be_voted_on = false
106
+
107
+ # Whether comments should be ordered by vote score
108
+ # instead of by order posted
109
+ # Default: false
110
+ config.comments_ordered_by_votes = false
111
+
112
+ # Whether users can read threads closed by admins
113
+ # Default: true
114
+ config.closed_threads_are_readable = true
115
+
116
+ # Whether comments deleted by admins can be seen
117
+ # (the content will still be hidden)
118
+ # Default: true
119
+ config.deleted_comments_are_visible = true
120
+
121
+ # Method called on commontable to return its id
122
+ # Default: 'id'
123
+ config.commontable_id_method = 'id'
124
+
125
+ # Method called on commontable and passed user as argument
126
+ # If true, that user is an admin for that particular commontable's thread
127
+ # Default: '' (no thread-specific admins)
128
+ config.can_edit_thread_method = ''
129
+
130
+ # Method called on commontable and passed user as argument
131
+ # If true, that user is allowed to read that commontable's thread
132
+ # Default: '' (no read restrictions)
133
+ config.can_read_thread_method = ''
134
+
135
+ # Method called on commontable when a comment is created
136
+ # Passed user, comment as arguments
137
+ # Default: '' (no callback)
138
+ config.comment_created_callback = ''
139
+
140
+ # Method called on commontable when a comment is edited
141
+ # Passed user, comment as arguments
142
+ # Default: '' (no callback)
143
+ config.comment_edited_callback = ''
144
+
145
+ # Method called on commontable when a comment is deleted
146
+ # Passed user, comment as arguments
147
+ # Default: '' (no callback)
148
+ config.comment_deleted_callback = ''
149
+
150
+ # Method called on commontable when a thread is closed
151
+ # Passed user as argument
152
+ # Default: '' (no callback)
153
+ config.thread_closed_callback = ''
154
+
155
+ # Method called on commontable when a thread is subscribed to
156
+ # Passed user as argument
157
+ # Default: '' (no callback)
158
+ config.subscribe_callback = ''
159
+
160
+ # Method called on commontable when a thread is unsubscribed to
161
+ # Passed user as argument
162
+ # Default: '' (no callback)
163
+ config.unsubscribe_callback = ''
164
+ end
Binary file
@@ -0,0 +1,49 @@
1
+ # This migration comes from commontator (originally 0)
2
+ class InstallCommontator < ActiveRecord::Migration
3
+ def change
4
+ create_table "commontator_comments" do |t|
5
+ t.text "body"
6
+ t.integer "commontator_id"
7
+ t.string "commontator_type"
8
+ t.datetime "deleted_at"
9
+ t.integer "deleter_id"
10
+ t.string "deleter_type"
11
+ t.integer "thread_id"
12
+
13
+ t.integer "cached_votes_total", :default => 0
14
+ t.integer "cached_votes_up", :default => 0
15
+ t.integer "cached_votes_down", :default => 0
16
+
17
+ t.timestamps
18
+ end
19
+
20
+ create_table "commontator_subscriptions" do |t|
21
+ t.integer "subscriber_id"
22
+ t.string "subscriber_type"
23
+ t.integer "thread_id"
24
+ t.boolean "is_unread"
25
+
26
+ t.timestamps
27
+ end
28
+
29
+ create_table "commontator_threads" do |t|
30
+ t.integer "commontable_id"
31
+ t.string "commontable_type"
32
+ t.datetime "closed_at"
33
+ t.integer "closer_id"
34
+ t.string "closer_type"
35
+
36
+ t.timestamps
37
+ end
38
+
39
+ add_index :commontator_comments, [:commontator_id, :commontator_type, :thread_id], :name => "index_c_c_on_c_id_and_c_type_and_t_id"
40
+ add_index :commontator_comments, :thread_id
41
+ add_index :commontator_subscriptions, [:subscriber_id, :subscriber_type, :thread_id], :unique => true, :name => "index_c_s_on_s_id_and_s_type_and_t_id"
42
+ add_index :commontator_subscriptions, :thread_id
43
+ add_index :commontator_threads, [:commontable_id, :commontable_type]
44
+
45
+ add_index :commontator_comments, :cached_votes_total
46
+ add_index :commontator_comments, :cached_votes_up
47
+ add_index :commontator_comments, :cached_votes_down
48
+ end
49
+ end
@@ -11,6 +11,51 @@
11
11
  #
12
12
  # It's strongly recommended to check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(:version => 0) do
14
+ ActiveRecord::Schema.define(:version => 20120710213148) do
15
+
16
+ create_table "commontator_comments", :force => true do |t|
17
+ t.text "body"
18
+ t.integer "commontator_id"
19
+ t.string "commontator_type"
20
+ t.datetime "deleted_at"
21
+ t.integer "deleter_id"
22
+ t.string "deleter_type"
23
+ t.integer "thread_id"
24
+ t.integer "cached_votes_total", :default => 0
25
+ t.integer "cached_votes_up", :default => 0
26
+ t.integer "cached_votes_down", :default => 0
27
+ t.datetime "created_at", :null => false
28
+ t.datetime "updated_at", :null => false
29
+ end
30
+
31
+ add_index "commontator_comments", ["cached_votes_down"], :name => "index_commontator_comments_on_cached_votes_down"
32
+ add_index "commontator_comments", ["cached_votes_total"], :name => "index_commontator_comments_on_cached_votes_total"
33
+ add_index "commontator_comments", ["cached_votes_up"], :name => "index_commontator_comments_on_cached_votes_up"
34
+ add_index "commontator_comments", ["commontator_id", "commontator_type", "thread_id"], :name => "index_c_c_on_c_id_and_c_type_and_t_id"
35
+ add_index "commontator_comments", ["thread_id"], :name => "index_commontator_comments_on_thread_id"
36
+
37
+ create_table "commontator_subscriptions", :force => true do |t|
38
+ t.integer "subscriber_id"
39
+ t.string "subscriber_type"
40
+ t.integer "thread_id"
41
+ t.boolean "is_unread"
42
+ t.datetime "created_at", :null => false
43
+ t.datetime "updated_at", :null => false
44
+ end
45
+
46
+ add_index "commontator_subscriptions", ["subscriber_id", "subscriber_type", "thread_id"], :name => "index_c_s_on_s_id_and_s_type_and_t_id", :unique => true
47
+ add_index "commontator_subscriptions", ["thread_id"], :name => "index_commontator_subscriptions_on_thread_id"
48
+
49
+ create_table "commontator_threads", :force => true do |t|
50
+ t.integer "commontable_id"
51
+ t.string "commontable_type"
52
+ t.datetime "closed_at"
53
+ t.integer "closer_id"
54
+ t.string "closer_type"
55
+ t.datetime "created_at", :null => false
56
+ t.datetime "updated_at", :null => false
57
+ end
58
+
59
+ add_index "commontator_threads", ["commontable_id", "commontable_type"], :name => "index_commontator_threads_on_commontable_id_and_commontable_type"
15
60
 
16
61
  end
@@ -202,3 +202,75 @@ Connecting to database specified by database.yml
202
202
  Connecting to database specified by database.yml
203
203
  Connecting to database specified by database.yml
204
204
  Connecting to database specified by database.yml
205
+ Connecting to database specified by database.yml
206
+ Connecting to database specified by database.yml
207
+ Connecting to database specified by database.yml
208
+ Connecting to database specified by database.yml
209
+ Connecting to database specified by database.yml
210
+ Connecting to database specified by database.yml
211
+ Connecting to database specified by database.yml
212
+ Connecting to database specified by database.yml
213
+ Connecting to database specified by database.yml
214
+ Connecting to database specified by database.yml
215
+ Connecting to database specified by database.yml
216
+ Connecting to database specified by database.yml
217
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
218
+ Migrating to InstallCommontator (20120710213148)
219
+  (0.0ms) select sqlite_version(*)
220
+  (0.0ms) begin transaction
221
+  (0.6ms) 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)
222
+  (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) 
223
+  (0.3ms) 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)
224
+  (0.0ms) PRAGMA index_list("commontator_comments")
225
+  (0.2ms) CREATE INDEX "index_c_c_on_c_id_and_c_type_and_t_id" ON "commontator_comments" ("commontator_id", "commontator_type", "thread_id")
226
+  (0.0ms) PRAGMA index_list("commontator_comments")
227
+  (0.0ms) PRAGMA index_info('index_c_c_on_c_id_and_c_type_and_t_id')
228
+  (0.1ms) CREATE INDEX "index_commontator_comments_on_thread_id" ON "commontator_comments" ("thread_id")
229
+  (0.0ms) PRAGMA index_list("commontator_subscriptions")
230
+  (0.3ms) CREATE UNIQUE INDEX "index_c_s_on_s_id_and_s_type_and_t_id" ON "commontator_subscriptions" ("subscriber_id", "subscriber_type", "thread_id")
231
+  (0.0ms) PRAGMA index_list("commontator_subscriptions")
232
+  (0.0ms) PRAGMA index_info('index_c_s_on_s_id_and_s_type_and_t_id')
233
+  (0.1ms) CREATE INDEX "index_commontator_subscriptions_on_thread_id" ON "commontator_subscriptions" ("thread_id")
234
+  (0.0ms) PRAGMA index_list("commontator_threads")
235
+  (0.2ms) CREATE INDEX "index_commontator_threads_on_commontable_id_and_commontable_type" ON "commontator_threads" ("commontable_id", "commontable_type")
236
+  (0.0ms) PRAGMA index_list("commontator_comments")
237
+  (0.0ms) PRAGMA index_info('index_commontator_comments_on_thread_id')
238
+  (0.0ms) PRAGMA index_info('index_c_c_on_c_id_and_c_type_and_t_id')
239
+  (0.1ms) CREATE INDEX "index_commontator_comments_on_cached_votes_total" ON "commontator_comments" ("cached_votes_total")
240
+  (0.0ms) PRAGMA index_list("commontator_comments")
241
+  (0.0ms) PRAGMA index_info('index_commontator_comments_on_cached_votes_total')
242
+  (0.0ms) PRAGMA index_info('index_commontator_comments_on_thread_id')
243
+  (0.0ms) PRAGMA index_info('index_c_c_on_c_id_and_c_type_and_t_id')
244
+  (0.1ms) CREATE INDEX "index_commontator_comments_on_cached_votes_up" ON "commontator_comments" ("cached_votes_up")
245
+  (0.1ms) PRAGMA index_list("commontator_comments")
246
+  (0.0ms) PRAGMA index_info('index_commontator_comments_on_cached_votes_up')
247
+  (0.0ms) PRAGMA index_info('index_commontator_comments_on_cached_votes_total')
248
+  (0.0ms) PRAGMA index_info('index_commontator_comments_on_thread_id')
249
+  (0.0ms) PRAGMA index_info('index_c_c_on_c_id_and_c_type_and_t_id')
250
+  (0.1ms) CREATE INDEX "index_commontator_comments_on_cached_votes_down" ON "commontator_comments" ("cached_votes_down")
251
+  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('20120710213148')
252
+  (339.0ms) commit transaction
253
+  (0.4ms) select sqlite_version(*)
254
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
255
+  (0.1ms) PRAGMA index_list("commontator_comments")
256
+  (0.0ms) PRAGMA index_info('index_commontator_comments_on_cached_votes_down')
257
+  (0.0ms) PRAGMA index_info('index_commontator_comments_on_cached_votes_up')
258
+  (0.0ms) PRAGMA index_info('index_commontator_comments_on_cached_votes_total')
259
+  (0.0ms) PRAGMA index_info('index_commontator_comments_on_thread_id')
260
+  (0.0ms) PRAGMA index_info('index_c_c_on_c_id_and_c_type_and_t_id')
261
+  (0.0ms) PRAGMA index_list("commontator_subscriptions")
262
+  (0.0ms) PRAGMA index_info('index_commontator_subscriptions_on_thread_id')
263
+  (0.0ms) PRAGMA index_info('index_c_s_on_s_id_and_s_type_and_t_id')
264
+  (0.0ms) PRAGMA index_list("commontator_threads")
265
+  (0.0ms) PRAGMA index_info('index_commontator_threads_on_commontable_id_and_commontable_type')
266
+ Connecting to database specified by database.yml
267
+ Connecting to database specified by database.yml
268
+ Connecting to database specified by database.yml
269
+ Connecting to database specified by database.yml
270
+ Connecting to database specified by database.yml
271
+ Connecting to database specified by database.yml
272
+ Connecting to database specified by database.yml
273
+ Connecting to database specified by database.yml
274
+ Connecting to database specified by database.yml
275
+ Connecting to database specified by database.yml
276
+ Connecting to database specified by database.yml