commontator 4.5.4 → 4.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +5 -13
  2. data/MIT-LICENSE +2 -1
  3. data/README.md +31 -34
  4. data/Rakefile +3 -2
  5. data/app/assets/stylesheets/commontator/application.css +1 -0
  6. data/app/assets/stylesheets/commontator/comments.css +1 -0
  7. data/app/assets/stylesheets/commontator/threads.css +13 -7
  8. data/{spec/dummy/tmp/cache/assets/test/sprockets/a473b3873e554893372a53d71f5e9879 → app/assets/stylesheets/commontator/threads.css~} +0 -0
  9. data/app/controllers/commontator/application_controller.rb +14 -14
  10. data/app/controllers/commontator/application_controller.rb~ +35 -0
  11. data/app/controllers/commontator/comments_controller.rb +8 -7
  12. data/app/controllers/commontator/comments_controller.rb~ +153 -0
  13. data/app/controllers/commontator/subscriptions_controller.rb +1 -0
  14. data/app/controllers/commontator/threads_controller.rb +7 -2
  15. data/app/helpers/commontator/application_helper.rb +1 -0
  16. data/app/mailers/commontator/subscriptions_mailer.rb +8 -10
  17. data/app/mailers/commontator/subscriptions_mailer.rb~ +44 -0
  18. data/app/models/commontator/comment.rb +14 -13
  19. data/app/models/commontator/comment.rb~ +119 -0
  20. data/app/models/commontator/subscription.rb +8 -4
  21. data/app/models/commontator/thread.rb +64 -43
  22. data/app/models/commontator/thread.rb~ +159 -0
  23. data/app/views/commontator/comments/_actions.html.erb +1 -0
  24. data/app/views/commontator/comments/_body.html.erb +2 -1
  25. data/app/views/commontator/comments/_form.html.erb +5 -1
  26. data/app/views/commontator/comments/_form.html.erb~ +39 -0
  27. data/app/views/commontator/comments/_list.html.erb +1 -1
  28. data/app/views/commontator/comments/_show.html.erb +5 -3
  29. data/app/views/commontator/comments/_show.html.erb~ +49 -0
  30. data/app/views/commontator/comments/_votes.html.erb +2 -1
  31. data/app/views/commontator/comments/_votes.html.erb~ +69 -0
  32. data/app/views/commontator/comments/cancel.js.erb +1 -0
  33. data/app/views/commontator/comments/create.js.erb +6 -4
  34. data/app/views/commontator/comments/create.js.erb~ +14 -0
  35. data/app/views/commontator/comments/delete.js.erb +1 -0
  36. data/app/views/commontator/comments/edit.js.erb +1 -0
  37. data/app/views/commontator/comments/new.js.erb +3 -1
  38. data/app/views/commontator/comments/new.js.erb~ +13 -0
  39. data/app/views/commontator/comments/update.js.erb +1 -0
  40. data/app/views/commontator/comments/vote.js.erb +1 -0
  41. data/app/views/commontator/shared/_thread.html.erb +4 -5
  42. data/app/views/commontator/subscriptions/_link.html.erb +2 -1
  43. data/app/views/commontator/subscriptions/_link.html.erb~ +16 -0
  44. data/app/views/commontator/subscriptions/subscribe.js.erb +1 -0
  45. data/app/views/commontator/subscriptions_mailer/comment_created.html.erb +1 -0
  46. data/app/views/commontator/threads/_reply.html.erb +4 -2
  47. data/app/views/commontator/threads/_reply.html.erb~ +19 -0
  48. data/app/views/commontator/threads/_show.html.erb +44 -9
  49. data/app/views/commontator/threads/_show.html.erb~ +95 -0
  50. data/app/views/commontator/threads/_show.js.erb +19 -0
  51. data/app/views/commontator/threads/show.js.erb +4 -4
  52. data/config/initializers/commontator.rb +169 -132
  53. data/config/initializers/commontator.rb~ +238 -0
  54. data/config/locales/commontator/en.yml +12 -3
  55. data/config/locales/commontator/en.yml~ +104 -0
  56. data/config/routes.rb +1 -0
  57. data/db/migrate/0_install_commontator.rb +9 -11
  58. data/db/migrate/0_install_commontator.rb~ +54 -0
  59. data/lib/commontator.rb +57 -16
  60. data/lib/commontator.rb~ +142 -0
  61. data/lib/commontator/acts_as_commontable.rb +12 -14
  62. data/lib/commontator/acts_as_commontator.rb +1 -16
  63. data/lib/commontator/commontable_config.rb +1 -0
  64. data/lib/commontator/commontator_config.rb +1 -0
  65. data/lib/commontator/controller_includes.rb +3 -3
  66. data/lib/commontator/engine.rb +1 -0
  67. data/lib/commontator/link_renderer.rb +29 -0
  68. data/lib/commontator/security_transgression.rb +1 -0
  69. data/lib/commontator/shared_helper.rb +7 -5
  70. data/lib/commontator/version.rb +2 -1
  71. data/lib/tasks/commontator_tasks.rake +1 -0
  72. data/spec/app/controllers/commontator/comments_controller_spec.rb +12 -11
  73. data/spec/app/controllers/commontator/subscriptions_controller_spec.rb +2 -1
  74. data/spec/app/controllers/commontator/threads_controller_spec.rb +2 -1
  75. data/spec/app/helpers/commontator/application_helper_spec.rb +2 -1
  76. data/spec/app/mailers/commontator/subscriptions_mailer_spec.rb +2 -1
  77. data/spec/app/models/commontator/comment_spec.rb +18 -11
  78. data/spec/app/models/commontator/comment_spec.rb~ +74 -0
  79. data/spec/app/models/commontator/subscription_spec.rb +18 -8
  80. data/spec/app/models/commontator/thread_spec.rb +28 -42
  81. data/spec/dummy/README.md +1 -0
  82. data/spec/dummy/Rakefile +1 -0
  83. data/spec/dummy/app/assets/javascripts/application.js +1 -0
  84. data/spec/dummy/app/assets/stylesheets/application.css +1 -0
  85. data/spec/dummy/app/controllers/application_controller.rb +1 -0
  86. data/spec/dummy/app/controllers/dummy_models_controller.rb +1 -0
  87. data/spec/dummy/app/helpers/application_helper.rb +1 -0
  88. data/spec/dummy/app/models/dummy_model.rb +1 -0
  89. data/spec/dummy/app/models/dummy_user.rb +7 -2
  90. data/spec/dummy/app/models/dummy_user.rb~ +16 -0
  91. data/spec/dummy/app/views/dummy_model/show.html.erb +1 -0
  92. data/spec/dummy/app/views/layouts/application.html.erb +1 -0
  93. data/spec/dummy/config.ru +1 -0
  94. data/spec/dummy/config/boot.rb +1 -0
  95. data/spec/dummy/config/database.yml +1 -0
  96. data/spec/dummy/config/environment.rb +1 -0
  97. data/spec/dummy/config/environments/development.rb +1 -0
  98. data/spec/dummy/config/environments/production.rb +1 -0
  99. data/spec/dummy/config/environments/test.rb +1 -0
  100. data/spec/dummy/config/initializers/backtrace_silencers.rb +1 -0
  101. data/spec/dummy/config/initializers/commontator.rb +6 -1
  102. data/spec/dummy/config/initializers/commontator.rb~ +15 -0
  103. data/spec/dummy/config/initializers/filter_parameter_logging.rb +1 -0
  104. data/spec/dummy/config/initializers/inflections.rb +1 -0
  105. data/spec/dummy/config/initializers/mime_types.rb +1 -0
  106. data/spec/dummy/config/initializers/secret_token.rb +1 -0
  107. data/spec/dummy/config/initializers/session_store.rb +1 -0
  108. data/spec/dummy/config/initializers/wrap_parameters.rb +1 -0
  109. data/spec/dummy/config/routes.rb +1 -0
  110. data/spec/dummy/db/development.sqlite3 +0 -0
  111. data/spec/dummy/db/migrate/1_create_dummy_models.rb +1 -0
  112. data/spec/dummy/db/migrate/2_create_dummy_users.rb +1 -0
  113. data/spec/dummy/db/migrate/3_acts_as_votable_migration.rb +1 -0
  114. data/spec/dummy/db/schema.rb +10 -13
  115. data/spec/dummy/db/test.sqlite3 +0 -0
  116. data/spec/dummy/public/404.html +1 -0
  117. data/spec/dummy/public/422.html +1 -0
  118. data/spec/dummy/public/500.html +1 -0
  119. data/spec/dummy/script/rails +1 -0
  120. data/spec/dummy/tmp/cache/assets/test/sprockets/{72b63dddbc5c995f79af8e3c94904fd9 → 02d4b791eb831cf2057bf4703a1218d1} +0 -0
  121. data/spec/dummy/tmp/cache/assets/test/sprockets/{a77b1a9223d168112e1705c29220116f → 0f196a1a50363b0a076ec6e1ee5417f6} +0 -0
  122. data/spec/dummy/tmp/cache/assets/test/sprockets/a3fb9025f90ff05a6fd4afc7ded2692c +0 -0
  123. data/spec/dummy/tmp/cache/assets/test/sprockets/a41c8be5379abec3c0d0d98e2f0d5609 +0 -0
  124. data/spec/dummy/tmp/cache/assets/test/sprockets/c69ee3cc5796188d873574179290a6ef +0 -0
  125. data/spec/dummy/tmp/cache/assets/test/sprockets/{f721383d531f067d82b071e14aed7a92 → e1f674c11941d62aac1764ef3a7134e4} +0 -0
  126. data/spec/dummy/tmp/cache/assets/test/sprockets/{d2244ccef8e05bb993f75715af0344cc → e85565206c3e5fdf9dfeb367c85557b1} +0 -0
  127. data/spec/lib/commontator/acts_as_commontable_spec.rb +3 -2
  128. data/spec/lib/commontator/acts_as_commontator_spec.rb +2 -5
  129. data/spec/lib/commontator/commontable_config_spec.rb +8 -5
  130. data/spec/lib/commontator/commontator_config_spec.rb +2 -1
  131. data/spec/lib/commontator/controller_includes_spec.rb +2 -1
  132. data/spec/lib/commontator/shared_helper_spec.rb +2 -1
  133. data/spec/lib/commontator_spec.rb +2 -1
  134. data/spec/{test_helper.rb → spec_helper.rb} +0 -0
  135. metadata +154 -135
  136. data/lib/commontator/remote_link_renderer.rb +0 -10
  137. data/spec/dummy/config/locales/en.yml +0 -23
  138. data/spec/dummy/log/development.log +0 -36
  139. data/spec/dummy/log/test.log +0 -22683
  140. data/spec/dummy/tmp/cache/assets/test/sprockets/afa63eb365bdf4f42584b17ac9176b9d +0 -0
  141. data/spec/dummy/tmp/cache/assets/test/sprockets/decb63cac838a5314aa0c22a979f5ac9 +0 -0
@@ -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
- :email_from_proc,
23
+ :comment_filter,
24
24
  :thread_read_proc,
25
25
  :thread_moderator_proc,
26
- :thread_subscription,
26
+ :comment_editing,
27
+ :comment_deletion,
28
+ :moderator_permissions,
27
29
  :comment_voting,
28
- :voting_text_proc,
30
+ :vote_count_proc,
29
31
  :comment_order,
30
32
  :comments_per_page,
31
- :wp_link_renderer_proc,
32
- :comment_editing,
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, :voting_text_proc],
54
+ [:combine_upvotes_and_downvotes, :vote_count_proc],
52
55
  [:comments_order, :comment_order],
53
- [:closed_threads_are_readable, :hide_closed_threads],
54
- [:deleted_comments_are_visible, :hide_deleted_comments],
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, :moderators_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
+
@@ -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 :thread_raw, :thread
26
-
24
+
25
+ alias_method :relation_thread, :thread
26
+
27
27
  def thread
28
- raw = thread_raw
29
- return raw unless raw.nil?
30
- return Commontator::Thread.find_or_create_by_commontable_type_and_commontable_id(self.class.name, id) \
31
- unless id.nil?
32
- self.thread = Commontator::Thread.new
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
- def commontable_name
38
- commontable_config.commontable_name_proc.call(self)
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
+
@@ -11,3 +11,4 @@ module Commontator
11
11
  end
12
12
  end
13
13
  end
14
+
@@ -11,3 +11,4 @@ module Commontator
11
11
  end
12
12
  end
13
13
  end
14
+
@@ -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
+
@@ -6,3 +6,4 @@ module Commontator
6
6
  config.i18n.load_path += Dir[root.join('config', 'locales', '**', '*.{rb,yml}')]
7
7
  end
8
8
  end
9
+
@@ -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
+
@@ -2,3 +2,4 @@ module Commontator
2
2
  class SecurityTransgression < StandardError
3
3
  end
4
4
  end
5
+
@@ -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(user.commontator_email)
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
- :title => name,
20
- :border => border })
20
+ :title => name,
21
+ :border => border })
21
22
  end
22
23
  end
23
24
  end
25
+
@@ -1,3 +1,4 @@
1
1
  module Commontator
2
- VERSION = "4.5.4"
2
+ VERSION = "4.6.0"
3
3
  end
4
+
@@ -42,3 +42,4 @@ namespace :commontator do
42
42
  end
43
43
  end
44
44
  end
45
+
@@ -1,4 +1,4 @@
1
- require 'test_helper'
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?(CommentsController::SubscriptionsMailer)
535
- CommentsController::SubscriptionsMailer.__send__(:initialize)
534
+ if defined?(Subscription::SubscriptionsMailer)
535
+ Subscription::SubscriptionsMailer.__send__(:initialize)
536
536
  else
537
- CommentsController::SubscriptionsMailer = MiniTest::Mock.new
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
- CommentsController::SubscriptionsMailer.expect(:comment_created, email, [Comment, [user2]])
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 { CommentsController::SubscriptionsMailer.verify }.must_raise(MockExpectationError)
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?(CommentsController::SubscriptionsMailer)
559
- CommentsController::SubscriptionsMailer.__send__(:initialize)
558
+ if defined?(Subscription::SubscriptionsMailer)
559
+ Subscription::SubscriptionsMailer.__send__(:initialize)
560
560
  else
561
- CommentsController::SubscriptionsMailer = MiniTest::Mock.new
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
- CommentsController::SubscriptionsMailer.expect(:comment_created, email, [Comment, [user2]])
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
- CommentsController::SubscriptionsMailer.verify
578
+ Subscription::SubscriptionsMailer.verify
579
579
  email.verify
580
580
  end
581
581
  end
582
582
  end
583
+