commontator 4.0.1 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -5
  3. data/app/controllers/commontator/comments_controller.rb +6 -6
  4. data/app/controllers/commontator/subscriptions_controller.rb +2 -2
  5. data/app/controllers/commontator/threads_controller.rb +2 -2
  6. data/app/views/commontator/comments/_actions.html.erb +1 -1
  7. data/app/views/commontator/comments/_votes.html.erb +4 -4
  8. data/app/views/commontator/shared/_thread.html.erb +1 -1
  9. data/app/views/commontator/subscriptions/_link.html.erb +1 -1
  10. data/app/views/commontator/threads/_show.html.erb +1 -1
  11. data/config/routes.rb +9 -9
  12. data/lib/commontator/version.rb +1 -1
  13. data/spec/app/controllers/commontator/comments_controller_spec.rb +40 -40
  14. data/spec/app/controllers/commontator/subscriptions_controller_spec.rb +12 -12
  15. data/spec/app/controllers/commontator/threads_controller_spec.rb +12 -12
  16. data/spec/dummy/db/test.sqlite3 +0 -0
  17. data/spec/dummy/log/test.log +4176 -0
  18. metadata +4 -91
  19. data/app/controllers/commontator/application_controller.rb~ +0 -27
  20. data/app/controllers/commontator/comments_controller.rb~ +0 -144
  21. data/app/controllers/commontator/subscriptions_controller.rb~ +0 -32
  22. data/app/controllers/commontator/threads_controller.rb~ +0 -42
  23. data/app/mailers/commontator/subscriptions_mailer.rb~ +0 -50
  24. data/app/models/commontator/comment.rb~ +0 -104
  25. data/app/models/commontator/subscription.rb~ +0 -18
  26. data/app/models/commontator/thread.rb~ +0 -124
  27. data/app/models/commontator/tree.rb~ +0 -123
  28. data/app/views/commontator/comments/_actions.html.erb~ +0 -30
  29. data/app/views/commontator/comments/_body.html.erb~ +0 -8
  30. data/app/views/commontator/comments/_form.html.erb~ +0 -38
  31. data/app/views/commontator/comments/_show.html.erb~ +0 -44
  32. data/app/views/commontator/comments/_votes.html.erb~ +0 -57
  33. data/app/views/commontator/comments/delete.js.erb~ +0 -17
  34. data/app/views/commontator/shared/_thread.html.erb~ +0 -20
  35. data/app/views/commontator/subscriptions/_link.html.erb~ +0 -16
  36. data/app/views/commontator/threads/_show.html.erb~ +0 -62
  37. data/config/initializers/commontator.rb~ +0 -171
  38. data/config/routes.rb~ +0 -22
  39. data/db/migrate/0_install.rb~ +0 -50
  40. data/lib/commontator.rb~ +0 -61
  41. data/lib/commontator/acts_as_commontable.rb~ +0 -45
  42. data/lib/commontator/acts_as_commontator.rb~ +0 -31
  43. data/lib/commontator/controller_includes.rb~ +0 -22
  44. data/lib/commontator/security_transgression.rb~ +0 -3
  45. data/lib/commontator/shared_helper.rb~ +0 -42
  46. data/lib/commontator/version.rb~ +0 -3
  47. data/lib/tasks/commontator_tasks.rake~ +0 -42
  48. data/spec/app/controllers/commontator/comments_controller_spec.rb~ +0 -563
  49. data/spec/app/controllers/commontator/subscriptions_controller_spec.rb~ +0 -99
  50. data/spec/app/controllers/commontator/threads_controller_spec.rb~ +0 -121
  51. data/spec/app/helpers/commontator/application_helper_spec.rb~ +0 -9
  52. data/spec/app/helpers/commontator/threads_helper_spec.rb~ +0 -17
  53. data/spec/app/mailers/commontator/subscriptions_mailer_spec.rb~ +0 -30
  54. data/spec/app/models/commontator/comment_observer_spec.rb~ +0 -27
  55. data/spec/app/models/commontator/comment_spec.rb~ +0 -61
  56. data/spec/app/models/commontator/subscription_spec.rb~ +0 -28
  57. data/spec/app/models/commontator/thread_spec.rb~ +0 -130
  58. data/spec/dummy/README.md~ +0 -3
  59. data/spec/dummy/Rakefile~ +0 -7
  60. data/spec/dummy/config.ru~ +0 -4
  61. data/spec/dummy/config/application.rb~ +0 -23
  62. data/spec/dummy/config/environment.rb~ +0 -5
  63. data/spec/dummy/config/environments/development.rb~ +0 -31
  64. data/spec/dummy/config/environments/production.rb~ +0 -67
  65. data/spec/dummy/config/environments/test.rb~ +0 -31
  66. data/spec/dummy/config/initializers/secret_token.rb~ +0 -12
  67. data/spec/lib/commontator/acts_as_commontable_spec.rb~ +0 -26
  68. data/spec/lib/commontator/acts_as_commontator_spec.rb~ +0 -25
  69. data/spec/lib/commontator/commontable_config_spec.rb~ +0 -26
  70. data/spec/lib/commontator/commontator_config_spec.rb~ +0 -26
  71. data/spec/lib/commontator/controller_includes_spec.rb~ +0 -15
  72. data/spec/lib/commontator/shared_helper_spec.rb~ +0 -16
  73. data/spec/lib/commontator_spec.rb~ +0 -23
  74. data/spec/minitest_helper.rb~ +0 -35
  75. data/spec/spec_helper.rb~ +0 -36
  76. data/spec/test_helper.rb~ +0 -37
@@ -1,30 +0,0 @@
1
- <% # Clients of this partial must supply the following variables:
2
- # comment
3
- # user
4
- %>
5
-
6
- <% can_edit = comment.can_be_edited_by?(user)
7
- can_delete = comment.can_be_deleted_by?(user) %>
8
-
9
- <% if can_edit %>
10
- <%= link_to 'Edit', commontator.edit_comment_path(comment),
11
- :id => "comment_#{comment.id.to_s}_edit_link",
12
- :class => "comment_edit_link",
13
- :remote => true %>
14
- <% end %>
15
-
16
- &nbsp;
17
-
18
- <% if can_delete %>
19
- <% is_deleted = comment.is_deleted? %>
20
- <% del_string = is_deleted ? "undelete" : "delete" %>
21
- <%= link_to del_string.capitalize,
22
- commontator.polymorphic_path([del_string, comment]),
23
- :confirm => (!is_deleted ? \
24
- "Are you sure you want to delete this " + \
25
- "#{comment.thread.config.comment_name}?" : nil),
26
- :method => :put,
27
- :id => "comment_#{comment.id.to_s}_#{del_string}_link",
28
- :class => "comment_#{del_string}_link",
29
- :remote => true %>
30
- <% end %>
@@ -1,8 +0,0 @@
1
- <% # Clients of this partial must provide the following variable:
2
- # comment
3
- %>
4
-
5
- <%= simple_format comment.is_deleted? ? \
6
- comment.thread.config.comment_name.capitalize + \
7
- ' deleted by ' + commontator_name(comment.deleter) : \
8
- comment.body %>
@@ -1,38 +0,0 @@
1
- <% # Clients of this partial must provide the following variables:
2
- # comment
3
- #
4
- # Additionally, they can override the following variables:
5
- thread ||= nil
6
- no_remote ||= false
7
- %>
8
-
9
- <% config = comment.thread.config %>
10
-
11
- <% if comment.errors.any? %>
12
- <div class="comment_error_explanation">
13
- <h3>This <%= config.comment_name %> could not be
14
- <%= comment.id.blank? ? config.comment_create_verb_past : 'updated' %> because of the following error<%= comment.errors.count == 1 ? '' : 's' %>:</h3>
15
-
16
- <ul>
17
- <% comment.errors.full_messages.each do |msg| %>
18
- <li><%= msg %></li>
19
- <% end %>
20
- </ul>
21
- </div>
22
- <% end %>
23
-
24
- <%= form_for([commontator, thread, comment],
25
- :remote => !no_remote) do |f| %>
26
-
27
- <div class="comment_form_field">
28
- <%= f.text_area :body, :rows => '7' %>
29
- </div>
30
-
31
- <div class="comment_form_actions">
32
- <%= f.submit (comment.id.blank? ? \
33
- config.comment_create_verb_present : \
34
- 'update').capitalize + \
35
- ' ' + config.comment_name %>
36
- </div>
37
-
38
- <% end %>
@@ -1,44 +0,0 @@
1
- <% # Clients of this partial must supply the following variables:
2
- # comment
3
- # user
4
- %>
5
-
6
- <div id="comment_<%= comment.id.to_s %>_div" class="comment">
7
- <span id="comment_<%= comment.id.to_s %>_commontator_span" class="comment_commontator">
8
- <% if !user.nil? && user.commontator_config.user_name_clickable %>
9
- <%= link_to commontator_name(comment.creator), main_app.polymorphic_path(comment.creator) %>
10
- <% else %>
11
- <%= commontator_name(comment.creator) %>
12
- <% end %>
13
- &nbsp;&nbsp;
14
- <span id="comment_<%= comment.id.to_s %>_timestamp_span" class="comment_timestamp">
15
- <%= comment.timestamp %><%= " by #{commontator_name(comment.editor)}" %>
16
- </span>
17
- </span>
18
-
19
- <span id="comment_<%= comment.id.to_s %>_actions_span" class="comment_actions">
20
- <%= render :partial => 'commontator/comments/actions',
21
- :locals => {:comment => comment,
22
- :user => user} %>
23
- </span>
24
-
25
- <br clear="all"/>
26
-
27
- <span id="comment_<%= comment.id.to_s %>_gravatar_image_span" class="comment_gravatar_image">
28
- <%= commontator_gravatar_image comment.creator %>
29
- </span>
30
-
31
- <span id="comment_<%= comment.id.to_s %>_votes_span" class="comment_votes">
32
- <%= render :partial => 'commontator/comments/votes',
33
- :locals => {:comment => comment,
34
- :user => user} %>
35
- </span>
36
-
37
- <div id="comment_<%= comment.id.to_s %>_body_div" class="comment_body">
38
- <%= render :partial => 'commontator/comments/body',
39
- :locals => {:comment => comment} %>
40
- </div>
41
-
42
- </div>
43
-
44
- <br clear="all"/>
@@ -1,57 +0,0 @@
1
- <% # Clients of this partial must provide the following variable:
2
- # comment
3
- # user
4
- %>
5
-
6
- <% if comment.can_be_voted_on? %>
7
- <% can_vote = comment.can_be_voted_on_by?(user) %>
8
- <% vote = comment.get_vote_by(user) %>
9
-
10
- <span id="comment_<%= comment.id %>_upvote_span" class="comment_upvote">
11
- <% if can_vote && (vote.blank? || !vote.vote_flag) %>
12
- <%= form_tag commontator.upvote_comment_path(comment),
13
- :method => :put,
14
- :remote => true do %>
15
- <%= image_submit_tag "commontator/upvote.png",
16
- :onmouseover => "this.src='/assets/commontator/upvote_hover.png'",
17
- :onmouseout => "this.src='/assets/commontator/upvote.png'" %>
18
- <% end %>
19
- <% elsif can_vote %>
20
- <%= form_tag commontator.unvote_comment_path(comment),
21
- :method => :put,
22
- :remote => true do %>
23
- <%= image_submit_tag "commontator/upvote_hover.png",
24
- :onmouseover => "this.src='/assets/commontator/upvote.png'",
25
- :onmouseout => "this.src='/assets/commontator/upvote_hover.png'" %>
26
- <% end %>
27
- <% else %>
28
- <%= image_tag "commontator/upvote_hover.png" %>
29
- <% end %>
30
- </span>
31
-
32
- <span id="comment_<%= comment.id %>_vote_count_span" class="comment_vote_count">
33
- <p>+ <%= comment.upvotes.size %><br><br>- <%= comment.downvotes.size %></p>
34
- </span>
35
-
36
- <span id="comment_<%= comment.id %>_downvote_span" class="comment_downvote">
37
- <% if can_vote && (vote.blank? || vote.vote_flag) %>
38
- <%= form_tag commontator.downvote_comment_path(comment),
39
- :method => :put,
40
- :remote => true do %>
41
- <%= image_submit_tag "commontator/downvote.png",
42
- :onmouseover => "this.src='/assets/commontator/downvote_hover.png'",
43
- :onmouseout => "this.src='/assets/commontator/downvote.png'" %>
44
- <% end %>
45
- <% elsif can_vote %>
46
- <%= form_tag commontator.unvote_comment_path(comment),
47
- :method => :put,
48
- :remote => true do %>
49
- <%= image_submit_tag "commontator/downvote_hover.png",
50
- :onmouseover => "this.src='/assets/commontator/downvote.png'",
51
- :onmouseout => "this.src='/assets/commontator/downvote_hover.png'" %>
52
- <% end %>
53
- <% else %>
54
- <%= image_tag "commontator/downvote_hover.png" %>
55
- <% end %>
56
- </span>
57
- <% end %>
@@ -1,17 +0,0 @@
1
- $("#comment_<%= @comment.id.to_s %>_body_div").html("<%= escape_javascript(
2
- render :partial => 'body', :locals => {:comment => @comment}) %>");
3
-
4
- $("#comment_<%= @comment.id.to_s %>_timestamp_span").html("<%= escape_javascript(
5
- @comment.timestamp + (@comment.is_modified? ? " by #{commontator_name(comment.editor)}" : '')) %>");
6
-
7
- $("#comment_<%= @comment.id.to_s %>_actions_span").html("<%= escape_javascript(
8
- render :partial => 'actions',
9
- :locals => {:comment => @comment,
10
- :user => @user}) %>");
11
-
12
- $("#comment_<%= @comment.id %>_votes_span").html("<%= escape_javascript(
13
- render :partial => 'votes',
14
- :locals => {:comment => @comment,
15
- :user => @user}) %>");
16
-
17
- <%= javascript_proc %>
@@ -1,20 +0,0 @@
1
- <% # Clients of this partial must supply the following variables:
2
- # thread
3
- # user
4
- %>
5
-
6
- <% subscription = thread.subscription_for(user) %>
7
-
8
- <% if thread.can_be_read_by?(user) %>
9
- <%= stylesheet_link_tag "commontator/application.CSS", :media => "all" %>
10
-
11
- <div id="thread_<%= thread.id %>_div" class="thread" style="display: none;">
12
- <% if @commontator_thread_show %>
13
- <%= render :partial => 'commontator/threads/show', :locals => {:thread => thread,
14
- :user => user} %>
15
- <% else %>
16
- <%= link_to "Show #{thread.config.comment_name.pluralize} (#{subscription ? subscription.unread + '/' + thread.comments.count : thread.comments.count})", \
17
- commontator.thread_path(thread), :remote => true %>
18
- <% end %>
19
- </div>
20
- <% end %>
@@ -1,16 +0,0 @@
1
- <% # Clients of this partial must supply the following variable:
2
- # thread
3
- # user
4
- %>
5
-
6
- <% is_subscribed = thread.is_subscribed?(user) %>
7
- <% sub_string = is_subscribed ? "unsubscribe" : "subscribe" %>
8
- <%= link_to sub_string.capitalize,
9
- commontator.polymorphic_path([sub_string, thread]),
10
- :confirm => (is_subscribed ? \
11
- "Are you sure you want to unsubscribe from this thread?" : \
12
- nil),
13
- :method => :put,
14
- :id => "thread_#{thread.id.to_s}_#{sub_string}_link",
15
- :class => "thread_#{sub_string}_link",
16
- :remote => true %>
@@ -1,62 +0,0 @@
1
- <% # Clients of this partial must supply the following variables:
2
- # thread
3
- # user
4
- %>
5
-
6
- <% can_subscribe = thread.can_subscribe?(user) %>
7
- <% can_edit = thread.can_be_edited_by?(user) %>
8
-
9
- <span id="thread_<%= thread.id.to_s %>_header_span" class="thread_header">
10
- <%= thread.config.comment_name.capitalize.pluralize + (thread.is_closed? ? ' (closed)' : '') %>
11
- </span>
12
-
13
- <span id="thread_<%= thread.id.to_s %>_actions_span" class="thread_actions">
14
- <% if can_subscribe %>
15
- <span id="thread_<%= thread.id.to_s %>_subscription_span" class="thread_subscription">
16
- <%= render :partial => 'commontator/subscriptions/link',
17
- :locals => {:thread => thread,
18
- :user => user} %>
19
- </span>
20
- <% end %>
21
-
22
- &nbsp;
23
-
24
- <% if can_edit %>
25
- <% is_closed = thread.is_closed? %>
26
- <% close_string = is_closed ? "reopen" : "close" %>
27
- <%= link_to close_string.capitalize,
28
- commontator.polymorphic_path([close_string, thread]),
29
- :confirm => (!is_closed ? \
30
- 'Are you sure you want to close this thread?' : nil),
31
- :method => :put,
32
- :id => "thread_#{thread.id.to_s}_#{close_string}_link",
33
- :class => "thread_#{close_string}_link",
34
- :remote => true %>
35
- <% end %>
36
- </span>
37
-
38
- <div id="thread_<%= thread.id.to_s %>_comment_list_div" class="thread_comment_list">
39
- <% thread.ordered_comments.each do |comment| %>
40
- <% next unless comment.can_be_read_by?(user) %>
41
- <%= render :partial => 'commontator/comments/show',
42
- :locals => {:comment => comment,
43
- :user => user} %>
44
- <% end %>
45
- </div>
46
-
47
- <br/>
48
-
49
- <% if thread.is_closed? %>
50
-
51
- <p><%= thread.config.comment_name.capitalize.pluralize %> cannot be <%= thread.config.comment_create_verb_past %> at this time.</p>
52
-
53
- <% else %>
54
-
55
- <div id="thread_<%= thread.id %>_new_comment_div" class="thread_new_comment"></div>
56
-
57
- <span id="thread_<%= thread.id %>_new_comment_link_span" class="thread_new_comment_link">
58
- <%= link_to thread.config.comment_create_verb_present.capitalize + ' ' + thread.config.comment_name,
59
- commontator.new_thread_comment_path(thread), :remote => true %>
60
- </span>
61
-
62
- <% end %>
@@ -1,171 +0,0 @@
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
- # Engine Configuration
5
-
6
- # Name of the ApplicationController helper method that returns the current user
7
- # Default: 'current_user'
8
- config.current_user_method = 'current_user'
9
-
10
- # Proc that is called after any javascript runs (e.g. to display/clear flash messages)
11
- # It is passed the view_context object (self from the view template), so you should be able to
12
- # access anything you normally could in a view template (by using, e.g. view.flash)
13
- # However, be aware that it does not have access to the main application's helpers
14
- # Should return a string containing JS to be appended to all Commontator JS responses
15
- # Default: lambda { |view| '$("#error_explanation").remove();' }
16
- config.javascript_proc = lambda { |view| '$("#error_explanation").remove();' }
17
-
18
-
19
- # User (acts_as_commontator) Configuration
20
-
21
- # The name used if the user's name cannot be retrieved
22
- # Default: 'Anonymous'
23
- config.user_missing_name = 'Anonymous'
24
-
25
- # Whether the comment creator's name is clickable in the comment view
26
- # If enabled, the link will point to the comment creator's show page
27
- # Default: false
28
- config.user_name_clickable = false
29
-
30
- # The method that returns the user's email address
31
- # Default: 'email'
32
- config.user_email_method = 'email'
33
-
34
- # The method that returns the user's name
35
- # Default: '' (use user_missing_name)
36
- config.user_name_method = ''
37
-
38
- # Proc called with user as argument that returns true if the user is an admin
39
- # Admins can always delete other users' comments and close threads
40
- # Note: user can be nil
41
- # Default: lambda { |user| false } (no admins)
42
- config.user_admin_proc = lambda { |user| false }
43
-
44
- # Proc called with user as argument that returns true
45
- # if the user should receive subscription emails
46
- # Default: lambda { |user| true } (always receive subscription emails)
47
- config.subscription_email_enable_proc = lambda { |user| true }
48
-
49
-
50
- # Commontable (acts_as_commontable) Configuration
51
-
52
- # What a comment is called in your application
53
- # Default: 'comment'
54
- config.comment_name = 'comment'
55
-
56
- # Verb used when creating comments (present)
57
- # Default: 'post'
58
- config.comment_create_verb_present = 'post'
59
-
60
- # Verb used when creating comments (past)
61
- # Default: 'posted'
62
- config.comment_create_verb_past = 'posted'
63
-
64
- # Verb used when editing comments (present)
65
- # Default: 'modify'
66
- config.comment_edit_verb_present = 'modify'
67
-
68
- # Verb used when editing comments (past)
69
- # Default: 'modified'
70
- config.comment_edit_verb_past = 'modified'
71
-
72
- # What a commontable is called in your application
73
- # If you have multiple commontable models,
74
- # you will want to pass this configuration value
75
- # as an argument to acts_as_commontable in each one
76
- # Default: 'commontable'
77
- config.commontable_name = 'commontable'
78
-
79
- # The format of the timestamps used by Commontator
80
- # Default: '%b %d %Y, %I:%M %p'
81
- config.timestamp_format = '%b %d %Y, %I:%M %p'
82
-
83
- # Whether admins can edit other users' comments
84
- # Default: false
85
- config.admin_can_edit_comments = false
86
-
87
- # Whether users automatically subscribe to a thread when commenting
88
- # Default: false
89
- config.auto_subscribe_on_comment = false
90
-
91
- # Whether users can edit their own comments
92
- # Default: true
93
- config.can_edit_own_comments = true
94
-
95
- # Whether users can edit their own comments
96
- # after someone posted a newer comment
97
- # Default: false
98
- config.can_edit_old_comments = false
99
-
100
- # Whether users can delete their own comments
101
- # Default: true
102
- config.can_delete_own_comments = true
103
-
104
- # Whether users can delete their own comments
105
- # after someone posted a newer comment
106
- # Default: false
107
- config.can_delete_old_comments = false
108
-
109
- # Whether users can manually subscribe or unsubscribe to threads
110
- # Default: true
111
- config.can_subscribe_to_thread = true
112
-
113
- # Whether users can vote on other users' comments
114
- # Note: requires acts_as_votable gem installed
115
- # and configured for your application
116
- # Default: false
117
- config.can_vote_on_comments = false
118
-
119
- # Whether comments should be ordered by vote score
120
- # instead of by order posted
121
- # Default: false
122
- config.comments_ordered_by_votes = false
123
-
124
- # Whether users can read threads closed by moderators
125
- # Default: true
126
- config.closed_threads_are_readable = true
127
-
128
- # Whether comments deleted by moderators can be seen
129
- # (the content will still be hidden)
130
- # Default: true
131
- config.deleted_comments_are_visible = true
132
-
133
- # The method which returns the commontable's id, sent to users in email messages
134
- # Default: 'id'
135
- config.commontable_id_method = 'id'
136
-
137
- # Proc called with thread and user as arguments
138
- # If it returns true, that user is a moderator for that particular thread
139
- # and is given admin-like capabilities for that thread only
140
- # Note: user can be nil
141
- # Default: lambda { |thread, user| false } (no thread-specific moderators)
142
- config.can_edit_thread_proc = lambda { |thread, user| false }
143
-
144
- # Proc called with thread and user as arguments
145
- # If it returns true, that user is allowed to read that thread
146
- # Note: user can be nil
147
- # Default: lambda { |thread, user| true } (no read restrictions)
148
- config.can_read_thread_proc = lambda { |thread, user| true }
149
-
150
- # Proc that returns the commontable url that contains the thread
151
- # (defaults to the commontable show url)
152
- # Main application's routes can be accessed using main_app object
153
- # Default: lambda { |main_app, commontable| main_app.polymorphic_url(commontable) }
154
- config.commontable_url_proc = lambda { |main_app, commontable| main_app.polymorphic_url(commontable) }
155
-
156
- # Proc that returns the subscription email 'from' address
157
- # Default:
158
- # lambda { |params| 'no-reply@example.com' }
159
- config.subscription_email_from_proc = lambda { |params| 'no-reply@example.com' }
160
-
161
- # Proc that returns the subscription email 'subject' string
162
- # Default:
163
- # lambda do |params|
164
- # "#{params[:creator_name]} #{params[:config].comment_create_verb_past} a " + \
165
- # "#{params[:config].comment_name} on #{params[:commontable_name]} #{params[:commontable_id]}"
166
- # end
167
- config.subscription_email_subject_proc = lambda do |params|
168
- "#{params[:creator_name]} #{params[:config].comment_create_verb_past} a " + \
169
- "#{params[:config].comment_name} on #{params[:commontable_name]} #{params[:commontable_id]}"
170
- end
171
- end