commontator 0.3.10 → 0.4.1

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.
data/README.md CHANGED
@@ -11,7 +11,7 @@ There are 4 steps you must follow to install commontator:
11
11
  Add this line to your application's Gemfile:
12
12
 
13
13
  ```ruby
14
- gem 'commontator', '~> 0.2.0'
14
+ gem 'commontator', '~> 0.4.0'
15
15
  ```
16
16
 
17
17
  And then execute:
@@ -2,16 +2,18 @@ module Commontator
2
2
  module CommentsHelper
3
3
  def commontator_name(comment)
4
4
  commontator = comment.commontator
5
+ return Commontator.commontator_missing_name if commontator.nil?
5
6
  config = commontator.commontator_config
6
- config.commontator_name_method.blank? ? config.anonymous_name : \
7
- commontator.send(config.commontator_name_method)
7
+ config.commontator_name_method.blank? ? config.commontator_missing_name : \
8
+ commontator.send(config.commontator_name_method)
8
9
  end
9
10
 
10
11
  def deleter_name(comment)
11
12
  deleter = comment.deleter
13
+ return Commontator.commontator_missing_name if deleter.nil?
12
14
  config = deleter.commontator_config
13
- config.commontator_name_method.blank? ? config.anonymous_name : \
14
- deleter.send(config.commontator_name_method)
15
+ config.commontator_name_method.blank? ? config.commontator_missing_name : \
16
+ deleter.send(config.commontator_name_method)
15
17
  end
16
18
 
17
19
  def comment_timestamp(comment)
@@ -23,6 +25,7 @@ module Commontator
23
25
 
24
26
  def gravatar_url(comment, options = {})
25
27
  commontator = comment.commontator
28
+ return '' if commontator.nil?
26
29
  config = commontator.commontator_config
27
30
 
28
31
  options[:secure] ||= request.ssl?
@@ -36,6 +39,7 @@ module Commontator
36
39
 
37
40
  def gravatar_image(comment, options = {})
38
41
  commontator = comment.commontator
42
+ return '' if commontator.nil?
39
43
  config = commontator.commontator_config
40
44
  name = commontator.send(config.commontator_name_method)
41
45
  image_tag(gravatar_url(comment, options),
@@ -2,16 +2,18 @@ module Commontator
2
2
  module CommentsHelper
3
3
  def commontator_name(comment)
4
4
  commontator = comment.commontator
5
+ return Commontator.commontator_missing_name if commontator.nil?
5
6
  config = commontator.commontator_config
6
- config.commontator_name_method.blank? ? config.anonymous_name : \
7
- commontator.send(config.commontator_name_method)
7
+ config.commontator_name_method.blank? ? config.commontator_missing_name : \
8
+ commontator.send(config.commontator_name_method
8
9
  end
9
10
 
10
11
  def deleter_name(comment)
11
12
  deleter = comment.deleter
13
+ return Commontator.commontator_missing_name if deleter.nil?
12
14
  config = deleter.commontator_config
13
- config.commontator_name_method.blank? ? config.anonymous_name : \
14
- deleter.send(config.commontator_name_method)
15
+ config.commontator_name_method.blank? ? config.commontator_missing_name : \
16
+ deleter.send(config.commontator_name_method)
15
17
  end
16
18
 
17
19
  def comment_timestamp(comment)
@@ -23,6 +25,7 @@ module Commontator
23
25
 
24
26
  def gravatar_url(comment, options = {})
25
27
  commontator = comment.commontator
28
+ return '' if commontator.nil?
26
29
  config = commontator.commontator_config
27
30
 
28
31
  options[:secure] ||= request.ssl?
@@ -36,6 +39,7 @@ module Commontator
36
39
 
37
40
  def gravatar_image(comment, options = {})
38
41
  commontator = comment.commontator
42
+ return '' if commontator.nil?
39
43
  config = commontator.commontator_config
40
44
  name = commontator.send(config.commontator_name_method)
41
45
  image_tag(gravatar_url(comment, options),
@@ -43,16 +47,5 @@ module Commontator
43
47
  :title => name,
44
48
  :border => 1 })
45
49
  end
46
-
47
- def refresh_comment_actions(thread)
48
- output = ""
49
- thread.comments.each do |comment|
50
- output << "$('#comment_#{comment.id.to_s}_actions_span').html('" + \
51
- escape_javascript(
52
- render :partial => :actions,
53
- :locals => { :comment => comment }) + "');\n\n"
54
- end
55
- output.slice(0..-3).html_safe
56
- end
57
50
  end
58
51
  end
@@ -13,9 +13,10 @@ module Commontator
13
13
 
14
14
  def closer_name(thread)
15
15
  closer = thread.closer
16
+ return Commontator.commontator_missing_name if closer.nil?
16
17
  config = closer.commontator_config
17
- config.commontator_name_method.blank? ? config.anonymous_name : \
18
- closer.send(config.commontator_name_method)
18
+ config.commontator_name_method.blank? ? config.commontator_missing_name : \
19
+ closer.send(config.commontator_name_method)
19
20
  end
20
21
  end
21
22
  end
@@ -1,9 +1,5 @@
1
1
  module Commontator
2
2
  module ThreadsHelper
3
- def commontable_url(thread)
4
- thread.config.commontable_url_proc.call(main_app, thread.commontable)
5
- end
6
-
7
3
  def commontable_name(thread)
8
4
  config = thread.config
9
5
  config.commontable_name.blank? ? \
@@ -17,9 +13,10 @@ module Commontator
17
13
 
18
14
  def closer_name(thread)
19
15
  closer = thread.closer
16
+ return Commontator.commontator_missing_name if closer.nil?
20
17
  config = closer.commontator_config
21
- config.commontator_name_method.blank? ? config.anonymous_name : \
22
- closer.send(config.commontator_name_method)
18
+ config.commontator_name_method.blank? ? config.commontator_no_name : \
19
+ closer.send(config.commontator_name_method)
23
20
  end
24
21
  end
25
22
  end
@@ -5,13 +5,8 @@ module Commontator
5
5
  belongs_to :thread
6
6
 
7
7
  has_one :commontable, :through => :thread
8
- #has_one :subthread, :class_name => "Commontator::Thread",
9
- # :as => :commontable,
10
- # :dependent => :destroy
11
-
12
- #before_validation :build_subthread, :on => :create
13
- validates_presence_of :commontator, :thread#, :subthread
14
- #validates_uniqueness_of :subthread
8
+
9
+ validates_presence_of :commontator, :thread
15
10
 
16
11
  attr_accessible :body
17
12
 
@@ -64,9 +64,9 @@ module Commontator
64
64
  end
65
65
 
66
66
  def can_be_deleted_by?(user)
67
- !thread.is_closed? &&\
67
+ (!thread.is_closed? &&\
68
68
  ((user == commontator && thread.config.can_delete_own_comments) &&\
69
- (thread.comments.last == self || thread.config.can_delete_old_comments)) ||\
69
+ (thread.comments.last == self || thread.config.can_delete_old_comments))) ||\
70
70
  thread.can_be_edited_by?(user)
71
71
  end
72
72
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  <div id="comment_<%= comment.id.to_s %>_div" class="comment" style="clear:both">
6
6
  <span id="comment_<%= comment.id.to_s %>_commontator_span" class="comment_commontator">
7
- <% if commontator.commontator_config.commontator_name_clickable %>
7
+ <% if !commontator.nil? && commontator.commontator_config.commontator_name_clickable %>
8
8
  <%= link_to commontator_name(comment), main_app.polymorphic_path(comment.commontator) %>
9
9
  <% else %>
10
10
  <%= commontator_name(comment) %>
@@ -1,12 +1,10 @@
1
1
  <% # Clients of this partial must supply the following variables:
2
2
  # comment
3
3
  %>
4
-
5
- <% enable_votes = comment.can_be_voted_on? %>
6
4
 
7
5
  <div id="comment_<%= comment.id.to_s %>_div" class="comment" style="clear:both">
8
6
  <span id="comment_<%= comment.id.to_s %>_commontator_span" class="comment_commontator">
9
- <% if commontator.commontator_config.commontator_name_clickable %>
7
+ <% if !commontator.nil? && commontator.commontator_config.commontator_name_clickable && %>
10
8
  <%= link_to commontator_name(comment), main_app.polymorphic_path(comment.commontator) %>
11
9
  <% else %>
12
10
  <%= commontator_name(comment) %>
@@ -28,12 +26,10 @@
28
26
  <%= gravatar_image comment %>
29
27
  </span>
30
28
 
31
- <% if enable_votes %>
32
- <span id="comment_<%= comment.id.to_s %>_votes_span" class="comment_votes">
33
- <%= render :partial => 'commontator/comments/votes',
34
- :locals => {:comment => comment} %>
35
- </span>
36
- <% end %>
29
+ <span id="comment_<%= comment.id.to_s %>_votes_span" class="comment_votes">
30
+ <%= render :partial => 'commontator/comments/votes',
31
+ :locals => {:comment => comment} %>
32
+ </span>
37
33
 
38
34
  <div id="comment_<%= comment.id.to_s %>_body_div" class="comment_body">
39
35
  <%= render :partial => 'commontator/comments/body',
@@ -17,6 +17,10 @@ Commontator.configure do |config|
17
17
 
18
18
 
19
19
  # Commontator (User model) Configuration
20
+
21
+ # The name used if the commontator's name cannot be retrieved
22
+ # Default: 'Anonymous'
23
+ config.commontator_missing_name = 'Anonymous'
20
24
 
21
25
  # Whether the commontator's name is clickable in the comment view
22
26
  # Default: false
@@ -27,7 +31,7 @@ Commontator.configure do |config|
27
31
  config.commontator_email_method = 'email'
28
32
 
29
33
  # The method that return the commontator's name
30
- # Default: '' (Anonymous)
34
+ # Default: '' (use missing name)
31
35
  config.commontator_name_method = ''
32
36
 
33
37
  # Method that returns true if the commontator is an admin for all threads
@@ -17,6 +17,10 @@ Commontator.configure do |config|
17
17
 
18
18
 
19
19
  # Commontator (User model) Configuration
20
+
21
+ # The name used if the commontator's name cannot be retrieved
22
+ # Default: 'Anonymous'
23
+ config.commontator_missing_name = 'Anonymous'
20
24
 
21
25
  # Whether the commontator's name is clickable in the comment view
22
26
  # Default: false
@@ -27,7 +31,7 @@ Commontator.configure do |config|
27
31
  config.commontator_email_method = 'email'
28
32
 
29
33
  # The method that return the commontator's name
30
- # Default: '' (Anonymous)
34
+ # Default: ''
31
35
  config.commontator_name_method = ''
32
36
 
33
37
  # Method that returns true if the commontator is an admin for all threads
@@ -57,7 +61,8 @@ Commontator.configure do |config|
57
61
  # Default: 'commontable'
58
62
  config.commontable_name = 'commontable'
59
63
 
60
- # Proc that returns the url to the thread's view (defaults to the commontable show url)
64
+ # Proc that returns the commontable url that contains the thread
65
+ # (defaults to the commontable show url)
61
66
  # Main application's routes can be accessed using main_app object
62
67
  # Default: lambda { |main_app, commontable| main_app.polymorphic_url(commontable) }
63
68
  config.commontable_url_proc = lambda { |main_app, commontable| main_app.polymorphic_url(commontable) }
data/lib/commontator.rb CHANGED
@@ -9,6 +9,7 @@ module Commontator
9
9
 
10
10
  # Can be set in initializer or passed as an option to acts_as_commontator
11
11
  COMMONTATOR_ATTRIBUTES = [
12
+ :commontator_missing_name,
12
13
  :commontator_name_clickable,
13
14
  :commontator_email_method,
14
15
  :commontator_name_method,
data/lib/commontator.rb~ CHANGED
@@ -9,6 +9,7 @@ module Commontator
9
9
 
10
10
  # Can be set in initializer or passed as an option to acts_as_commontator
11
11
  COMMONTATOR_ATTRIBUTES = [
12
+ :commontator_no_name,
12
13
  :commontator_name_clickable,
13
14
  :commontator_email_method,
14
15
  :commontator_name_method,
@@ -21,7 +22,7 @@ module Commontator
21
22
  :comment_create_verb_present,
22
23
  :comment_create_verb_past,
23
24
  :commontable_name,
24
- :thread_url_proc,
25
+ :commontable_url_proc,
25
26
  :subscription_email_subject_proc,
26
27
  :timestamp_format,
27
28
  :admin_can_edit_comments,
@@ -9,7 +9,7 @@ module Commontator
9
9
  module ClassMethods
10
10
  def acts_as_commontable(options = {})
11
11
  class_eval do
12
- has_one :thread, :as => :commontable, :class_name => 'Commontator::Thread', :dependent => :destroy
12
+ has_one :thread, :as => :commontable, :class_name => 'Commontator::Thread'
13
13
  has_many :comments, :class_name => 'Commontator::Comment', :through => :thread
14
14
  has_many :subscriptions, :class_name => 'Commontator::Subscription', :through => :thread
15
15
 
@@ -32,9 +32,6 @@ module Commontator
32
32
  end
33
33
 
34
34
  alias_method :acts_as_commentable, :acts_as_commontable
35
- def acts_as_commentable(options = {})
36
- acts_as_commontable(options)
37
- end
38
35
  end
39
36
  end
40
37
  end
@@ -9,7 +9,7 @@ module Commontator
9
9
  module ClassMethods
10
10
  def acts_as_commontator(options = {})
11
11
  class_eval do
12
- has_many :comments, :as => :commontator, :class_name => 'Commontator::Comment', :dependent => :destroy
12
+ has_many :comments, :as => :commontator, :class_name => 'Commontator::Comment'
13
13
  has_many :subscriptions, :as => :subscriber, :class_name => 'Commontator::Subscription', :dependent => :destroy
14
14
 
15
15
  cattr_accessor :commontator_config
@@ -19,17 +19,8 @@ module Commontator
19
19
  end
20
20
 
21
21
  alias_method :acts_as_commonter, :acts_as_commontator
22
- def acts_as_commonter(options = {})
23
- acts_as_commontator(options)
24
- end
25
-
26
- def acts_as_commentator(options = {})
27
- acts_as_commontator(options)
28
- end
29
-
30
- def acts_as_commenter(options = {})
31
- acts_as_commontator(options)
32
- end
22
+ alias_method :acts_as_commentator, :acts_as_commontator
23
+ alias_method :acts_as_commenter, :acts_as_commontator
33
24
  end
34
25
  end
35
26
  end
@@ -1,3 +1,3 @@
1
1
  module Commontator
2
- VERSION = "0.3.10"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module Commontator
2
- VERSION = "0.3.9"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -17,6 +17,10 @@ Commontator.configure do |config|
17
17
 
18
18
 
19
19
  # Commontator (User model) Configuration
20
+
21
+ # The name used if the commontator's name cannot be retrieved
22
+ # Default: 'Anonymous'
23
+ config.commontator_missing_name = 'Anonymous'
20
24
 
21
25
  # Whether the commontator's name is clickable in the comment view
22
26
  # Default: false
@@ -27,7 +31,7 @@ Commontator.configure do |config|
27
31
  config.commontator_email_method = 'email'
28
32
 
29
33
  # The method that return the commontator's name
30
- # Default: '' (Anonymous)
34
+ # Default: '' (use missing name)
31
35
  config.commontator_name_method = ''
32
36
 
33
37
  # Method that returns true if the commontator is an admin for all threads
@@ -17,6 +17,10 @@ Commontator.configure do |config|
17
17
 
18
18
 
19
19
  # Commontator (User model) Configuration
20
+
21
+ # The name used if the commontator's name cannot be retrieved
22
+ # Default: 'Anonymous'
23
+ config.commontator_missing_name = 'Anonymous'
20
24
 
21
25
  # Whether the commontator's name is clickable in the comment view
22
26
  # Default: false
@@ -27,7 +31,7 @@ Commontator.configure do |config|
27
31
  config.commontator_email_method = 'email'
28
32
 
29
33
  # The method that return the commontator's name
30
- # Default: '' (Anonymous)
34
+ # Default: ''
31
35
  config.commontator_name_method = ''
32
36
 
33
37
  # Method that returns true if the commontator is an admin for all threads
@@ -57,7 +61,8 @@ Commontator.configure do |config|
57
61
  # Default: 'commontable'
58
62
  config.commontable_name = 'commontable'
59
63
 
60
- # Proc that returns the url to the thread's view (defaults to the commontable show url)
64
+ # Proc that returns the commontable url that contains the thread
65
+ # (defaults to the commontable show url)
61
66
  # Main application's routes can be accessed using main_app object
62
67
  # Default: lambda { |main_app, commontable| main_app.polymorphic_url(commontable) }
63
68
  config.commontable_url_proc = lambda { |main_app, commontable| main_app.polymorphic_url(commontable) }
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.3.10
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: