commontator 4.5.4 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/MIT-LICENSE +2 -1
- data/README.md +31 -34
- data/Rakefile +3 -2
- data/app/assets/stylesheets/commontator/application.css +1 -0
- data/app/assets/stylesheets/commontator/comments.css +1 -0
- data/app/assets/stylesheets/commontator/threads.css +13 -7
- data/{spec/dummy/tmp/cache/assets/test/sprockets/a473b3873e554893372a53d71f5e9879 → app/assets/stylesheets/commontator/threads.css~} +0 -0
- data/app/controllers/commontator/application_controller.rb +14 -14
- data/app/controllers/commontator/application_controller.rb~ +35 -0
- data/app/controllers/commontator/comments_controller.rb +8 -7
- data/app/controllers/commontator/comments_controller.rb~ +153 -0
- data/app/controllers/commontator/subscriptions_controller.rb +1 -0
- data/app/controllers/commontator/threads_controller.rb +7 -2
- data/app/helpers/commontator/application_helper.rb +1 -0
- data/app/mailers/commontator/subscriptions_mailer.rb +8 -10
- data/app/mailers/commontator/subscriptions_mailer.rb~ +44 -0
- data/app/models/commontator/comment.rb +14 -13
- data/app/models/commontator/comment.rb~ +119 -0
- data/app/models/commontator/subscription.rb +8 -4
- data/app/models/commontator/thread.rb +64 -43
- data/app/models/commontator/thread.rb~ +159 -0
- data/app/views/commontator/comments/_actions.html.erb +1 -0
- data/app/views/commontator/comments/_body.html.erb +2 -1
- data/app/views/commontator/comments/_form.html.erb +5 -1
- data/app/views/commontator/comments/_form.html.erb~ +39 -0
- data/app/views/commontator/comments/_list.html.erb +1 -1
- data/app/views/commontator/comments/_show.html.erb +5 -3
- data/app/views/commontator/comments/_show.html.erb~ +49 -0
- data/app/views/commontator/comments/_votes.html.erb +2 -1
- data/app/views/commontator/comments/_votes.html.erb~ +69 -0
- data/app/views/commontator/comments/cancel.js.erb +1 -0
- data/app/views/commontator/comments/create.js.erb +6 -4
- data/app/views/commontator/comments/create.js.erb~ +14 -0
- data/app/views/commontator/comments/delete.js.erb +1 -0
- data/app/views/commontator/comments/edit.js.erb +1 -0
- data/app/views/commontator/comments/new.js.erb +3 -1
- data/app/views/commontator/comments/new.js.erb~ +13 -0
- data/app/views/commontator/comments/update.js.erb +1 -0
- data/app/views/commontator/comments/vote.js.erb +1 -0
- data/app/views/commontator/shared/_thread.html.erb +4 -5
- data/app/views/commontator/subscriptions/_link.html.erb +2 -1
- data/app/views/commontator/subscriptions/_link.html.erb~ +16 -0
- data/app/views/commontator/subscriptions/subscribe.js.erb +1 -0
- data/app/views/commontator/subscriptions_mailer/comment_created.html.erb +1 -0
- data/app/views/commontator/threads/_reply.html.erb +4 -2
- data/app/views/commontator/threads/_reply.html.erb~ +19 -0
- data/app/views/commontator/threads/_show.html.erb +44 -9
- data/app/views/commontator/threads/_show.html.erb~ +95 -0
- data/app/views/commontator/threads/_show.js.erb +19 -0
- data/app/views/commontator/threads/show.js.erb +4 -4
- data/config/initializers/commontator.rb +169 -132
- data/config/initializers/commontator.rb~ +238 -0
- data/config/locales/commontator/en.yml +12 -3
- data/config/locales/commontator/en.yml~ +104 -0
- data/config/routes.rb +1 -0
- data/db/migrate/0_install_commontator.rb +9 -11
- data/db/migrate/0_install_commontator.rb~ +54 -0
- data/lib/commontator.rb +57 -16
- data/lib/commontator.rb~ +142 -0
- data/lib/commontator/acts_as_commontable.rb +12 -14
- data/lib/commontator/acts_as_commontator.rb +1 -16
- data/lib/commontator/commontable_config.rb +1 -0
- data/lib/commontator/commontator_config.rb +1 -0
- data/lib/commontator/controller_includes.rb +3 -3
- data/lib/commontator/engine.rb +1 -0
- data/lib/commontator/link_renderer.rb +29 -0
- data/lib/commontator/security_transgression.rb +1 -0
- data/lib/commontator/shared_helper.rb +7 -5
- data/lib/commontator/version.rb +2 -1
- data/lib/tasks/commontator_tasks.rake +1 -0
- data/spec/app/controllers/commontator/comments_controller_spec.rb +12 -11
- data/spec/app/controllers/commontator/subscriptions_controller_spec.rb +2 -1
- data/spec/app/controllers/commontator/threads_controller_spec.rb +2 -1
- data/spec/app/helpers/commontator/application_helper_spec.rb +2 -1
- data/spec/app/mailers/commontator/subscriptions_mailer_spec.rb +2 -1
- data/spec/app/models/commontator/comment_spec.rb +18 -11
- data/spec/app/models/commontator/comment_spec.rb~ +74 -0
- data/spec/app/models/commontator/subscription_spec.rb +18 -8
- data/spec/app/models/commontator/thread_spec.rb +28 -42
- data/spec/dummy/README.md +1 -0
- data/spec/dummy/Rakefile +1 -0
- data/spec/dummy/app/assets/javascripts/application.js +1 -0
- data/spec/dummy/app/assets/stylesheets/application.css +1 -0
- data/spec/dummy/app/controllers/application_controller.rb +1 -0
- data/spec/dummy/app/controllers/dummy_models_controller.rb +1 -0
- data/spec/dummy/app/helpers/application_helper.rb +1 -0
- data/spec/dummy/app/models/dummy_model.rb +1 -0
- data/spec/dummy/app/models/dummy_user.rb +7 -2
- data/spec/dummy/app/models/dummy_user.rb~ +16 -0
- data/spec/dummy/app/views/dummy_model/show.html.erb +1 -0
- data/spec/dummy/app/views/layouts/application.html.erb +1 -0
- data/spec/dummy/config.ru +1 -0
- data/spec/dummy/config/boot.rb +1 -0
- data/spec/dummy/config/database.yml +1 -0
- data/spec/dummy/config/environment.rb +1 -0
- data/spec/dummy/config/environments/development.rb +1 -0
- data/spec/dummy/config/environments/production.rb +1 -0
- data/spec/dummy/config/environments/test.rb +1 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +1 -0
- data/spec/dummy/config/initializers/commontator.rb +6 -1
- data/spec/dummy/config/initializers/commontator.rb~ +15 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +1 -0
- data/spec/dummy/config/initializers/inflections.rb +1 -0
- data/spec/dummy/config/initializers/mime_types.rb +1 -0
- data/spec/dummy/config/initializers/secret_token.rb +1 -0
- data/spec/dummy/config/initializers/session_store.rb +1 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +1 -0
- data/spec/dummy/config/routes.rb +1 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/1_create_dummy_models.rb +1 -0
- data/spec/dummy/db/migrate/2_create_dummy_users.rb +1 -0
- data/spec/dummy/db/migrate/3_acts_as_votable_migration.rb +1 -0
- data/spec/dummy/db/schema.rb +10 -13
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/public/404.html +1 -0
- data/spec/dummy/public/422.html +1 -0
- data/spec/dummy/public/500.html +1 -0
- data/spec/dummy/script/rails +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{72b63dddbc5c995f79af8e3c94904fd9 → 02d4b791eb831cf2057bf4703a1218d1} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{a77b1a9223d168112e1705c29220116f → 0f196a1a50363b0a076ec6e1ee5417f6} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a3fb9025f90ff05a6fd4afc7ded2692c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a41c8be5379abec3c0d0d98e2f0d5609 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c69ee3cc5796188d873574179290a6ef +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{f721383d531f067d82b071e14aed7a92 → e1f674c11941d62aac1764ef3a7134e4} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{d2244ccef8e05bb993f75715af0344cc → e85565206c3e5fdf9dfeb367c85557b1} +0 -0
- data/spec/lib/commontator/acts_as_commontable_spec.rb +3 -2
- data/spec/lib/commontator/acts_as_commontator_spec.rb +2 -5
- data/spec/lib/commontator/commontable_config_spec.rb +8 -5
- data/spec/lib/commontator/commontator_config_spec.rb +2 -1
- data/spec/lib/commontator/controller_includes_spec.rb +2 -1
- data/spec/lib/commontator/shared_helper_spec.rb +2 -1
- data/spec/lib/commontator_spec.rb +2 -1
- data/spec/{test_helper.rb → spec_helper.rb} +0 -0
- metadata +154 -135
- data/lib/commontator/remote_link_renderer.rb +0 -10
- data/spec/dummy/config/locales/en.yml +0 -23
- data/spec/dummy/log/development.log +0 -36
- data/spec/dummy/log/test.log +0 -22683
- data/spec/dummy/tmp/cache/assets/test/sprockets/afa63eb365bdf4f42584b17ac9176b9d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/decb63cac838a5314aa0c22a979f5ac9 +0 -0
data/lib/commontator.rb
CHANGED
@@ -13,32 +13,35 @@ module Commontator
|
|
13
13
|
# Can be set in initializer or passed as an option to acts_as_commontator
|
14
14
|
COMMONTATOR_ATTRIBUTES = [
|
15
15
|
:user_name_proc,
|
16
|
+
:user_link_proc,
|
16
17
|
:user_avatar_proc,
|
17
|
-
:user_email_proc
|
18
|
-
:user_link_proc
|
18
|
+
:user_email_proc
|
19
19
|
]
|
20
20
|
|
21
21
|
# Can be set in initializer or passed as an option to acts_as_commontable
|
22
22
|
COMMONTABLE_ATTRIBUTES = [
|
23
|
-
:
|
23
|
+
:comment_filter,
|
24
24
|
:thread_read_proc,
|
25
25
|
:thread_moderator_proc,
|
26
|
-
:
|
26
|
+
:comment_editing,
|
27
|
+
:comment_deletion,
|
28
|
+
:moderator_permissions,
|
27
29
|
:comment_voting,
|
28
|
-
:
|
30
|
+
:vote_count_proc,
|
29
31
|
:comment_order,
|
30
32
|
:comments_per_page,
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:comment_deletion,
|
34
|
-
:moderators_can_edit_comments,
|
35
|
-
:hide_deleted_comments,
|
36
|
-
:hide_closed_threads,
|
33
|
+
:thread_subscription,
|
34
|
+
:email_from_proc,
|
37
35
|
:commontable_name_proc,
|
38
36
|
:commontable_url_proc
|
39
37
|
]
|
40
38
|
|
41
39
|
DEPRECATED_ATTRIBUTES = [
|
40
|
+
[:moderators_can_edit_comments, :moderator_permissions],
|
41
|
+
[:hide_deleted_comments, :comment_filter],
|
42
|
+
[:hide_closed_threads, :thread_read_proc],
|
43
|
+
[:wp_link_renderer_proc],
|
44
|
+
[:voting_text_proc, :vote_count_proc],
|
42
45
|
[:user_name_clickable, :user_link_proc],
|
43
46
|
[:user_admin_proc, :thread_moderator_proc],
|
44
47
|
[:auto_subscribe_on_comment, :thread_subscription],
|
@@ -48,13 +51,13 @@ module Commontator
|
|
48
51
|
[:can_delete_old_comments, :comment_deletion],
|
49
52
|
[:can_subscribe_to_thread, :thread_subscription],
|
50
53
|
[:can_vote_on_comments, :comment_voting],
|
51
|
-
[:combine_upvotes_and_downvotes, :
|
54
|
+
[:combine_upvotes_and_downvotes, :vote_count_proc],
|
52
55
|
[:comments_order, :comment_order],
|
53
|
-
[:closed_threads_are_readable, :
|
54
|
-
[:deleted_comments_are_visible, :
|
56
|
+
[:closed_threads_are_readable, :thread_read_proc],
|
57
|
+
[:deleted_comments_are_visible, :comment_filter],
|
55
58
|
[:can_read_thread_proc, :thread_read_proc],
|
56
59
|
[:can_edit_thread_proc, :thread_moderator_proc],
|
57
|
-
[:admin_can_edit_comments, :
|
60
|
+
[:admin_can_edit_comments, :moderator_permissions],
|
58
61
|
[:subscription_email_enable_proc, :user_email_proc],
|
59
62
|
[:comment_name, 'config/locales'],
|
60
63
|
[:comment_create_verb_present, 'config/locales'],
|
@@ -65,6 +68,7 @@ module Commontator
|
|
65
68
|
[:subscription_email_to_proc, 'config/locales'],
|
66
69
|
[:subscription_email_from_proc, :email_from_proc],
|
67
70
|
[:subscription_email_subject_proc, 'config/locales'],
|
71
|
+
[:comments_ordered_by_votes, :comment_order],
|
68
72
|
[:current_user_method, :current_user_proc],
|
69
73
|
[:user_missing_name, 'config/locales'],
|
70
74
|
[:user_email_method, :user_email_proc],
|
@@ -95,7 +99,44 @@ module Commontator
|
|
95
99
|
yield self
|
96
100
|
warn "\n[COMMONTATOR] We recommend that you backup the config/initializers/commontator.rb file, rename or remove it, run rake commontator:install:initializers to copy the new default one, then configure it to your liking.\n" if @deprecated_method_called
|
97
101
|
end
|
102
|
+
|
103
|
+
def self.commontator_config(user)
|
104
|
+
(user && user.is_commontator) ? user.commontator_config : self
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.commontable_config(user)
|
108
|
+
(user && user.is_commontable) ? user.commontable_config : self
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.app_routes
|
112
|
+
Commontator::ApplicationController.app_routes
|
113
|
+
end
|
114
|
+
|
115
|
+
def self.commontator_name(user)
|
116
|
+
commontator_config(user).user_name_proc.call(user)
|
117
|
+
end
|
118
|
+
|
119
|
+
def self.commontator_link(user, routing_proxy = app_routes)
|
120
|
+
commontator_config(user).user_link_proc.call(user, routing_proxy)
|
121
|
+
end
|
122
|
+
|
123
|
+
def self.commontator_email(user, mailer = nil)
|
124
|
+
commontator_config(user).user_email_proc.call(user, mailer)
|
125
|
+
end
|
126
|
+
|
127
|
+
def self.commontator_avatar(user, view)
|
128
|
+
commontator_config(user).user_avatar_proc.call(user, view)
|
129
|
+
end
|
130
|
+
|
131
|
+
def self.commontable_name(commontable)
|
132
|
+
commontable_config(commontable).commontable_name_proc.call(commontable)
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.commontable_url(commontable, routing_proxy = app_routes)
|
136
|
+
commontable_config(commontable).commontable_url_proc.call(commontable, routing_proxy)
|
137
|
+
end
|
98
138
|
end
|
99
139
|
|
100
140
|
require 'commontator/acts_as_commontator'
|
101
|
-
require 'commontator/acts_as_commontable'
|
141
|
+
require 'commontator/acts_as_commontable'
|
142
|
+
|
data/lib/commontator.rb~
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
require 'commontator/engine'
|
2
|
+
require 'commontator/controller_includes'
|
3
|
+
|
4
|
+
module Commontator
|
5
|
+
# Attributes
|
6
|
+
|
7
|
+
# Can be set in initializer only
|
8
|
+
ENGINE_ATTRIBUTES = [
|
9
|
+
:current_user_proc,
|
10
|
+
:javascript_proc
|
11
|
+
]
|
12
|
+
|
13
|
+
# Can be set in initializer or passed as an option to acts_as_commontator
|
14
|
+
COMMONTATOR_ATTRIBUTES = [
|
15
|
+
:user_name_proc,
|
16
|
+
:user_link_proc,
|
17
|
+
:user_avatar_proc,
|
18
|
+
:user_email_proc
|
19
|
+
]
|
20
|
+
|
21
|
+
# Can be set in initializer or passed as an option to acts_as_commontable
|
22
|
+
COMMONTABLE_ATTRIBUTES = [
|
23
|
+
:comment_filter,
|
24
|
+
:thread_read_proc,
|
25
|
+
:thread_moderator_proc,
|
26
|
+
:comment_editing,
|
27
|
+
:comment_deletion,
|
28
|
+
:moderator_permissions,
|
29
|
+
:comment_voting,
|
30
|
+
:vote_count_proc,
|
31
|
+
:comment_order,
|
32
|
+
:comments_per_page,
|
33
|
+
:thread_subscription,
|
34
|
+
:email_from_proc,
|
35
|
+
:commontable_name_proc,
|
36
|
+
:commontable_url_proc
|
37
|
+
]
|
38
|
+
|
39
|
+
DEPRECATED_ATTRIBUTES = [
|
40
|
+
[:moderators_can_edit_comments, :moderator_permissions],
|
41
|
+
[:hide_deleted_comments, :comment_filter],
|
42
|
+
[:hide_closed_threads, :thread_read_proc],
|
43
|
+
[:wp_link_renderer_proc],
|
44
|
+
[:voting_text_proc, :vote_count_proc],
|
45
|
+
[:user_name_clickable, :user_link_proc],
|
46
|
+
[:user_admin_proc, :thread_moderator_proc],
|
47
|
+
[:auto_subscribe_on_comment, :thread_subscription],
|
48
|
+
[:can_edit_own_comments, :comment_editing],
|
49
|
+
[:can_edit_old_comments, :comment_editing],
|
50
|
+
[:can_delete_own_comments, :comment_deletion],
|
51
|
+
[:can_delete_old_comments, :comment_deletion],
|
52
|
+
[:can_subscribe_to_thread, :thread_subscription],
|
53
|
+
[:can_vote_on_comments, :comment_voting],
|
54
|
+
[:combine_upvotes_and_downvotes, :vote_count_proc],
|
55
|
+
[:comments_order, :comment_order],
|
56
|
+
[:closed_threads_are_readable, :thread_read_proc],
|
57
|
+
[:deleted_comments_are_visible, :comment_filter],
|
58
|
+
[:can_read_thread_proc, :thread_read_proc],
|
59
|
+
[:can_edit_thread_proc, :thread_moderator_proc],
|
60
|
+
[:admin_can_edit_comments, :moderator_permissions],
|
61
|
+
[:subscription_email_enable_proc, :user_email_proc],
|
62
|
+
[:comment_name, 'config/locales'],
|
63
|
+
[:comment_create_verb_present, 'config/locales'],
|
64
|
+
[:comment_create_verb_past, 'config/locales'],
|
65
|
+
[:comment_edit_verb_present, 'config/locales'],
|
66
|
+
[:comment_edit_verb_past, 'config/locales'],
|
67
|
+
[:timestamp_format, 'config/locales'],
|
68
|
+
[:subscription_email_to_proc, 'config/locales'],
|
69
|
+
[:subscription_email_from_proc, :email_from_proc],
|
70
|
+
[:subscription_email_subject_proc, 'config/locales'],
|
71
|
+
[:comments_ordered_by_votes, :comment_order],
|
72
|
+
[:current_user_method, :current_user_proc],
|
73
|
+
[:user_missing_name, 'config/locales'],
|
74
|
+
[:user_email_method, :user_email_proc],
|
75
|
+
[:user_name_method, :user_name_proc],
|
76
|
+
[:commontable_name, :commontable_name_proc],
|
77
|
+
[:commontable_id_method]
|
78
|
+
]
|
79
|
+
|
80
|
+
(ENGINE_ATTRIBUTES + COMMONTATOR_ATTRIBUTES + \
|
81
|
+
COMMONTABLE_ATTRIBUTES).each do |attribute|
|
82
|
+
mattr_accessor attribute
|
83
|
+
end
|
84
|
+
|
85
|
+
DEPRECATED_ATTRIBUTES.each do |deprecated, replacement|
|
86
|
+
define_singleton_method(deprecated) do
|
87
|
+
@deprecated_method_called = true
|
88
|
+
replacement_string = (replacement.nil? ? 'No replacement is available. You can safely remove it from your configuration file.' : "Use `#{replacement.to_s}` instead.")
|
89
|
+
warn "\n[COMMONTATOR] Deprecation: `config.#{deprecated.to_s}` is deprecated and has been disabled. #{replacement_string}\n"
|
90
|
+
end
|
91
|
+
|
92
|
+
define_singleton_method("#{deprecated.to_s}=") do |obj|
|
93
|
+
send(deprecated)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.configure
|
98
|
+
@deprecated_method_called = false
|
99
|
+
yield self
|
100
|
+
warn "\n[COMMONTATOR] We recommend that you backup the config/initializers/commontator.rb file, rename or remove it, run rake commontator:install:initializers to copy the new default one, then configure it to your liking.\n" if @deprecated_method_called
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.commontator_config(user)
|
104
|
+
(user && user.is_commontator) ? user.commontator_config : self
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.commontable_config(user)
|
108
|
+
(user && user.is_commontable) ? user.commontable_config : self
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.app_routes
|
112
|
+
Commontator::ApplicationController.app_routes
|
113
|
+
end
|
114
|
+
|
115
|
+
def self.commontator_name(user)
|
116
|
+
commontator_config(user).user_name_proc.call(user)
|
117
|
+
end
|
118
|
+
|
119
|
+
def self.commontator_link(user, routing_proxy = app_routes)
|
120
|
+
commontator_config(user).user_link_proc.call(user, routing_proxy)
|
121
|
+
end
|
122
|
+
|
123
|
+
def self.commontator_email(user, mailer = nil)
|
124
|
+
commontator_config(user).user_email_proc.call(user, mailer)
|
125
|
+
end
|
126
|
+
|
127
|
+
def self.commontator_avatar(user, view)
|
128
|
+
commontator_config(user).user_avatar_proc.call(user, view)
|
129
|
+
end
|
130
|
+
|
131
|
+
def self.commontable_name(commontable)
|
132
|
+
commontable_config(commontable).commontable_name_proc.call(commontable)
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.commontable_url(commontable, routing_proxy = app_routes)
|
136
|
+
commontable_config(commontable).commontable_url_proc.call(commontable, app_routes)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
require 'commontator/acts_as_commontator'
|
141
|
+
require 'commontator/acts_as_commontable'
|
142
|
+
|
@@ -19,23 +19,20 @@ module Commontator
|
|
19
19
|
has_many :comments, :class_name => 'Commontator::Comment', :through => :thread
|
20
20
|
|
21
21
|
has_many :subscriptions, :class_name => 'Commontator::Subscription', :through => :thread
|
22
|
-
|
22
|
+
|
23
23
|
validates_presence_of :thread
|
24
|
-
|
25
|
-
alias_method :
|
26
|
-
|
24
|
+
|
25
|
+
alias_method :relation_thread, :thread
|
26
|
+
|
27
27
|
def thread
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
self.thread.commontable = self
|
34
|
-
self.thread
|
35
|
-
end
|
28
|
+
@thread ||= relation_thread
|
29
|
+
if !@thread
|
30
|
+
@thread = Commontator::Thread.new
|
31
|
+
@thread.commontable = self
|
32
|
+
end
|
36
33
|
|
37
|
-
|
38
|
-
|
34
|
+
@thread.save if !@thread.persisted? && persisted?
|
35
|
+
@thread
|
39
36
|
end
|
40
37
|
end
|
41
38
|
end
|
@@ -46,3 +43,4 @@ module Commontator
|
|
46
43
|
end
|
47
44
|
|
48
45
|
ActiveRecord::Base.send :include, Commontator::ActsAsCommontable
|
46
|
+
|
@@ -18,22 +18,6 @@ module Commontator
|
|
18
18
|
has_many :comments, :as => :creator, :class_name => 'Commontator::Comment'
|
19
19
|
|
20
20
|
has_many :subscriptions, :as => :subscriber, :class_name => 'Commontator::Subscription', :dependent => :destroy
|
21
|
-
|
22
|
-
def commontator_name
|
23
|
-
commontator_config.user_name_proc.call(self)
|
24
|
-
end
|
25
|
-
|
26
|
-
def commontator_email(mailer = nil)
|
27
|
-
commontator_config.user_email_proc.call(self, mailer)
|
28
|
-
end
|
29
|
-
|
30
|
-
def commontator_link(main_app)
|
31
|
-
commontator_config.user_link_proc.call(self, main_app)
|
32
|
-
end
|
33
|
-
|
34
|
-
def commontator_avatar(view_context)
|
35
|
-
commontator_config.user_avatar_proc.call(self, view_context)
|
36
|
-
end
|
37
21
|
end
|
38
22
|
end
|
39
23
|
|
@@ -45,3 +29,4 @@ module Commontator
|
|
45
29
|
end
|
46
30
|
|
47
31
|
ActiveRecord::Base.send :include, Commontator::ActsAsCommontator
|
32
|
+
|
@@ -12,14 +12,14 @@ module Commontator
|
|
12
12
|
def commontator_thread_show(commontable)
|
13
13
|
user = Commontator.current_user_proc.call(self)
|
14
14
|
thread = commontable.thread
|
15
|
-
raise SecurityTransgression unless thread.can_be_read_by?(user)
|
15
|
+
raise Commontator::SecurityTransgression unless thread.can_be_read_by?(user)
|
16
16
|
thread.mark_as_read_for(user)
|
17
17
|
@commontator_page = params[:page] || 1
|
18
|
-
@commontator_per_page = params[:per_page]
|
19
|
-
thread.config.comments_per_page
|
18
|
+
@commontator_per_page = params[:per_page] || thread.config.comments_per_page
|
20
19
|
@commontator_thread_show = true
|
21
20
|
end
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
25
24
|
ActionController::Base.send :include, Commontator::ControllerIncludes
|
25
|
+
|
data/lib/commontator/engine.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'will_paginate/view_helpers/action_view'
|
2
|
+
|
3
|
+
module Commontator
|
4
|
+
class LinkRenderer < WillPaginate::ActionView::LinkRenderer
|
5
|
+
protected
|
6
|
+
|
7
|
+
def url(page)
|
8
|
+
@base_url_params ||= begin
|
9
|
+
url_params = merge_get_params(default_url_params)
|
10
|
+
merge_optional_params(url_params)
|
11
|
+
end
|
12
|
+
|
13
|
+
url_params = @base_url_params.dup
|
14
|
+
add_current_page_param(url_params, page)
|
15
|
+
|
16
|
+
routes_proxy = @options[:routes_proxy] || @template
|
17
|
+
routes_proxy.url_for(url_params)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def link(text, target, attributes = {})
|
23
|
+
attributes = attributes.merge('data-remote' => true) \
|
24
|
+
if @options[:remote]
|
25
|
+
super
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -9,15 +9,17 @@ module Commontator
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def commontator_gravatar_image_tag(user, border = 1, options = {})
|
12
|
+
email = Commontator.commontator_email(user) || ''
|
13
|
+
name = Commontator.commontator_name(user) || ''
|
14
|
+
|
12
15
|
base = request.ssl? ? "s://secure" : "://www"
|
13
|
-
hash = Digest::MD5.hexdigest(
|
16
|
+
hash = Digest::MD5.hexdigest(email)
|
14
17
|
url = "http#{base}.gravatar.com/avatar/#{hash}?#{options.to_query}"
|
15
18
|
|
16
|
-
name = user.commontator_name
|
17
|
-
|
18
19
|
image_tag(url, { :alt => name,
|
19
|
-
|
20
|
-
|
20
|
+
:title => name,
|
21
|
+
:border => border })
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
25
|
+
|
data/lib/commontator/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'acts_as_votable'
|
3
3
|
|
4
4
|
module Commontator
|
@@ -531,17 +531,17 @@ module Commontator
|
|
531
531
|
end
|
532
532
|
|
533
533
|
it "won't send mail if recipients empty" do
|
534
|
-
if defined?(
|
535
|
-
|
534
|
+
if defined?(Subscription::SubscriptionsMailer)
|
535
|
+
Subscription::SubscriptionsMailer.__send__(:initialize)
|
536
536
|
else
|
537
|
-
|
537
|
+
Subscription::SubscriptionsMailer = MiniTest::Mock.new
|
538
538
|
end
|
539
539
|
|
540
540
|
user2 = DummyUser.create
|
541
541
|
user2.can_read = true
|
542
542
|
|
543
543
|
email = MiniTest::Mock.new.expect(:deliver, nil)
|
544
|
-
|
544
|
+
Subscription::SubscriptionsMailer.expect(:comment_created, email, [Comment, [user2]])
|
545
545
|
|
546
546
|
@user.can_read = true
|
547
547
|
sign_in @user
|
@@ -550,15 +550,15 @@ module Commontator
|
|
550
550
|
post :create, :thread_id => @thread.id, :comment => attributes, :use_route => :commontator
|
551
551
|
assigns(:comment).errors.must_be_empty
|
552
552
|
|
553
|
-
proc {
|
553
|
+
proc { Subscription::SubscriptionsMailer.verify }.must_raise(MockExpectationError)
|
554
554
|
proc { email.verify }.must_raise(MockExpectationError)
|
555
555
|
end
|
556
556
|
|
557
557
|
it 'must send mail if recipients not empty' do
|
558
|
-
if defined?(
|
559
|
-
|
558
|
+
if defined?(Subscription::SubscriptionsMailer)
|
559
|
+
Subscription::SubscriptionsMailer.__send__(:initialize)
|
560
560
|
else
|
561
|
-
|
561
|
+
Subscription::SubscriptionsMailer = MiniTest::Mock.new
|
562
562
|
end
|
563
563
|
|
564
564
|
user2 = DummyUser.create
|
@@ -566,7 +566,7 @@ module Commontator
|
|
566
566
|
@thread.subscribe(user2)
|
567
567
|
|
568
568
|
email = MiniTest::Mock.new.expect(:deliver, nil)
|
569
|
-
|
569
|
+
Subscription::SubscriptionsMailer.expect(:comment_created, email, [Comment, [user2]])
|
570
570
|
|
571
571
|
@user.can_read = true
|
572
572
|
sign_in @user
|
@@ -575,8 +575,9 @@ module Commontator
|
|
575
575
|
post :create, :thread_id => @thread.id, :comment => attributes, :use_route => :commontator
|
576
576
|
assigns(:comment).errors.must_be_empty
|
577
577
|
|
578
|
-
|
578
|
+
Subscription::SubscriptionsMailer.verify
|
579
579
|
email.verify
|
580
580
|
end
|
581
581
|
end
|
582
582
|
end
|
583
|
+
|