muck-comments 0.1.0 → 0.1.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.
Files changed (35) hide show
  1. data/README.rdoc +13 -1
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/app/controllers/muck/comments_controller.rb +16 -1
  5. data/app/views/activity_templates/_comment.html.erb +1 -0
  6. data/app/views/comments/_form.html.erb +1 -1
  7. data/locales/en.yml +2 -1
  8. data/muck-comments.gemspec +27 -3
  9. data/pkg/muck-comments-0.1.1.gem +0 -0
  10. data/rdoc/classes/ActionController/Routing/RouteSet.html +148 -0
  11. data/rdoc/classes/ActionController/Routing.html +107 -0
  12. data/rdoc/classes/ActionController.html +107 -0
  13. data/rdoc/classes/ActiveRecord/Acts/MuckComment/ClassMethods.html +160 -0
  14. data/rdoc/classes/ActiveRecord/Acts/MuckComment/InstanceMethods.html +178 -0
  15. data/rdoc/classes/ActiveRecord/Acts/MuckComment/SingletonMethods.html +212 -0
  16. data/rdoc/classes/ActiveRecord.html +105 -0
  17. data/rdoc/classes/Acts/CommentableWithThreading/ClassMethods.html +149 -0
  18. data/rdoc/classes/Acts/CommentableWithThreading/InstanceMethods.html +234 -0
  19. data/rdoc/classes/Acts/CommentableWithThreading/SingletonMethods.html +189 -0
  20. data/rdoc/classes/MuckComments/Tasks.html +146 -0
  21. data/rdoc/classes/MuckComments.html +111 -0
  22. data/rdoc/created.rid +1 -0
  23. data/rdoc/files/README_rdoc.html +161 -0
  24. data/rdoc/files/lib/active_record/acts/muck_comment_rb.html +101 -0
  25. data/rdoc/files/lib/acts_as_commentable_with_threading_rb.html +107 -0
  26. data/rdoc/files/lib/muck_comments/initialize_routes_rb.html +101 -0
  27. data/rdoc/files/lib/muck_comments/tasks_rb.html +110 -0
  28. data/rdoc/files/lib/muck_comments_rb.html +115 -0
  29. data/rdoc/fr_class_index.html +38 -0
  30. data/rdoc/fr_file_index.html +32 -0
  31. data/rdoc/fr_method_index.html +41 -0
  32. data/rdoc/index.html +24 -0
  33. data/rdoc/rdoc-style.css +208 -0
  34. metadata +27 -3
  35. data/pkg/muck-comments-0.1.0.gem +0 -0
data/README.rdoc CHANGED
@@ -25,7 +25,7 @@ This let's you add any other methods to the comment model that you see fit.
25
25
  === Comment controller
26
26
  Override the comments controller to change the the security model. For example:
27
27
 
28
- class Muck::CommentsController < ApplicationController
28
+ class CommentsController < Muck::CommentsController
29
29
 
30
30
  before_filter :login_required # require the user to be logged in to make a comment
31
31
 
@@ -38,6 +38,18 @@ Override the comments controller to change the the security model. For example:
38
38
 
39
39
  end
40
40
 
41
+ === Comment partial
42
+ When calling create in the comments controller with :format => 'json' the resulting json will include an 'html' field that contains
43
+ a rendered version of the comment html. To facilitate this process be sure to create a partial called '_comment.html.erb' under a directory
44
+ with the same name as the parent object. The partial will be passed an object 'comment_owner' that references the parent object.
45
+
46
+ For example, for an object 'activity' that acts_as_commentable create a partial 'activities/_comment.html.erb'. The contents might look like this:
47
+
48
+ <div id="<%= comment.dom_id %>">
49
+ <span class="user"><%= link_to comment_owner.user, comment_owner.user %></span>
50
+ <p><%= h comment.body %></p>
51
+ </div>
52
+
41
53
 
42
54
 
43
55
  Copyright (c) 2009 Justin Ball, released under the MIT license
data/Rakefile CHANGED
@@ -18,7 +18,7 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
18
18
  rdoc.rdoc_dir = 'rdoc'
19
19
  rdoc.title = 'MuckComments'
20
20
  rdoc.options << '--line-numbers' << '--inline-source'
21
- rdoc.rdoc_files.include('README')
21
+ rdoc.rdoc_files.include('README*')
22
22
  rdoc.rdoc_files.include('lib/**/*.rb')
23
23
  end
24
24
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -12,7 +12,7 @@ class Muck::CommentsController < ApplicationController
12
12
  format.html do
13
13
  redirect_back_or_default(@parent)
14
14
  end
15
- format.json { render :json => { :success => true, :comment => @comment } }
15
+ format.json { render :json => { :success => true, :comment => @comment, :parent_id => @parent.id, :html => get_parent_comment_html(@parent) } }
16
16
  end
17
17
  rescue ActiveRecord::RecordInvalid => ex
18
18
  if @comment
@@ -37,6 +37,11 @@ class Muck::CommentsController < ApplicationController
37
37
  flash[:notice] = t('muck.comments.comment_removed')
38
38
  redirect_back_or_default(current_user)
39
39
  end
40
+ format.js do
41
+ render(:update) do |page|
42
+ page << "jQuery('##{@comment.dom_id}').fadeOut();"
43
+ end
44
+ end
40
45
  format.json { render :json => { :success => true, :message => t("muck.comments.comment_removed"), :comment_id => @comment.id } }
41
46
  end
42
47
  end
@@ -68,6 +73,16 @@ class Muck::CommentsController < ApplicationController
68
73
  end
69
74
  end
70
75
 
76
+ def get_parent_comment_html(parent)
77
+ old_format = @template.template_format
78
+ @template.template_format = :html
79
+ comment = render_to_string(:partial => "#{parent.class.to_s.tableize}/comment", :locals => {:comment_owner => parent})
80
+ @template.template_format = old_format
81
+ comment
82
+ rescue ActionView::MissingTemplate
83
+ I18n.t('muck.comments.missing_comment_template_error', :partial => "#{parent.class.to_s.tableize}/comment")
84
+ end
85
+
71
86
  def has_permission_to_comment(user, parent)
72
87
  parent.can_comment?(user)
73
88
  end
@@ -1,6 +1,7 @@
1
1
  <div class="activity activity-status-update delete-container" id="<%= activity.dom_id %>">
2
2
  <div class="actor-icon"><%= icon activity.source %></div>
3
3
  <div class="activity-content">
4
+ <% #TODO build out comment activity template %>
4
5
  <p><span class="actor"><%= link_to activity.source.display_name, activity.source %></span> <%= activity.content %></p>
5
6
  <span class="activity-time"><%= t("muck.activities.time_ago", :time_in_words => time_ago_in_words(activity.created_at)) %></span>
6
7
  <%= delete_activity(activity, :image) %>
@@ -2,6 +2,6 @@
2
2
  <% form_for(:comment, :url => new_comment_path_with_parent(parent), :html => { :id => "#{parent.dom_id}_comment_form", :class => "comment-form"} ) do |f| -%>
3
3
  <%= f.text_area :body, :class => 'min' %>
4
4
  <%= hidden_field_tag :parent_comment_id, comment.id unless comment.blank? -%>
5
- <%= f.submit t('muck.comments.add_comment'), :class => "button" %>
5
+ <%= f.submit t('muck.comments.add_comment'), :class => "button comment-submit", :id => "comment_submit_#{parent.dom_id}" %>
6
6
  <% end -%>
7
7
  </div>
data/locales/en.yml CHANGED
@@ -5,4 +5,5 @@ en:
5
5
  missing_parent_id_error: "Please specify a parent object"
6
6
  comment_removed: "Comment successfully removed."
7
7
  create_error: "Could not create the comment {{errors}}"
8
- add_comment: "Comment"
8
+ add_comment: "Comment"
9
+ missing_comment_template_error: "Could not find a partial named {{partial}}. Please create a comment partial and try again."
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{muck-comments}
5
- s.version = "0.1.0"
5
+ s.version = "0.1.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Justin Ball"]
9
- s.date = %q{2009-06-13}
9
+ s.date = %q{2009-06-16}
10
10
  s.description = %q{The comment engine for the muck system.}
11
11
  s.email = %q{justinball@gmail.com}
12
12
  s.extra_rdoc_files = [
@@ -47,9 +47,33 @@ Gem::Specification.new do |s|
47
47
  "locales/en.yml",
48
48
  "locales/en.yml",
49
49
  "muck-comments.gemspec",
50
- "pkg/muck-comments-0.1.0.gem",
50
+ "pkg/muck-comments-0.1.1.gem",
51
51
  "rails/init.rb",
52
52
  "rails/init.rb",
53
+ "rdoc/classes/ActionController.html",
54
+ "rdoc/classes/ActionController/Routing.html",
55
+ "rdoc/classes/ActionController/Routing/RouteSet.html",
56
+ "rdoc/classes/ActiveRecord.html",
57
+ "rdoc/classes/ActiveRecord/Acts/MuckComment/ClassMethods.html",
58
+ "rdoc/classes/ActiveRecord/Acts/MuckComment/InstanceMethods.html",
59
+ "rdoc/classes/ActiveRecord/Acts/MuckComment/SingletonMethods.html",
60
+ "rdoc/classes/Acts/CommentableWithThreading/ClassMethods.html",
61
+ "rdoc/classes/Acts/CommentableWithThreading/InstanceMethods.html",
62
+ "rdoc/classes/Acts/CommentableWithThreading/SingletonMethods.html",
63
+ "rdoc/classes/MuckComments.html",
64
+ "rdoc/classes/MuckComments/Tasks.html",
65
+ "rdoc/created.rid",
66
+ "rdoc/files/README_rdoc.html",
67
+ "rdoc/files/lib/active_record/acts/muck_comment_rb.html",
68
+ "rdoc/files/lib/acts_as_commentable_with_threading_rb.html",
69
+ "rdoc/files/lib/muck_comments/initialize_routes_rb.html",
70
+ "rdoc/files/lib/muck_comments/tasks_rb.html",
71
+ "rdoc/files/lib/muck_comments_rb.html",
72
+ "rdoc/fr_class_index.html",
73
+ "rdoc/fr_file_index.html",
74
+ "rdoc/fr_method_index.html",
75
+ "rdoc/index.html",
76
+ "rdoc/rdoc-style.css",
53
77
  "tasks/muck_comments_tasks.rake",
54
78
  "tasks/muck_comments_tasks.rake",
55
79
  "test/db/database.yml",
Binary file
@@ -0,0 +1,148 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: ActionController::Routing::RouteSet</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">ActionController::Routing::RouteSet</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../../files/lib/muck_comments/initialize_routes_rb.html">
59
+ lib/muck_comments/initialize_routes.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Object
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+
82
+
83
+ </div>
84
+
85
+ <div id="method-list">
86
+ <h3 class="section-bar">Methods</h3>
87
+
88
+ <div class="name-list">
89
+ <a href="#M000001">load_routes_with_muck_comments!</a>&nbsp;&nbsp;
90
+ </div>
91
+ </div>
92
+
93
+ </div>
94
+
95
+
96
+ <!-- if includes -->
97
+
98
+ <div id="section">
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+ <!-- if method_list -->
108
+ <div id="methods">
109
+ <h3 class="section-bar">Public Instance methods</h3>
110
+
111
+ <div id="method-M000001" class="method-detail">
112
+ <a name="M000001"></a>
113
+
114
+ <div class="method-heading">
115
+ <a href="#M000001" class="method-signature">
116
+ <span class="method-name">load_routes_with_muck_comments!</span><span class="method-args">()</span>
117
+ </a>
118
+ </div>
119
+
120
+ <div class="method-description">
121
+ <p><a class="source-toggle" href="#"
122
+ onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
123
+ <div class="method-source-code" id="M000001-source">
124
+ <pre>
125
+ <span class="ruby-comment cmt"># File lib/muck_comments/initialize_routes.rb, line 2</span>
126
+ 2: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">load_routes_with_muck_comments!</span>
127
+ 3: <span class="ruby-identifier">muck_comments_routes</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-keyword kw">__FILE__</span>), <span class="ruby-operator">*</span><span class="ruby-node">%w[.. .. config muck_comments_routes.rb]</span>)
128
+ 4: <span class="ruby-identifier">add_configuration_file</span>(<span class="ruby-identifier">muck_comments_routes</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">configuration_files</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">muck_comments_routes</span>
129
+ 5: <span class="ruby-identifier">load_routes_without_muck_comments!</span>
130
+ 6: <span class="ruby-keyword kw">end</span>
131
+ </pre>
132
+ </div>
133
+ </div>
134
+ </div>
135
+
136
+
137
+ </div>
138
+
139
+
140
+ </div>
141
+
142
+
143
+ <div id="validator-badges">
144
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
145
+ </div>
146
+
147
+ </body>
148
+ </html>
@@ -0,0 +1,107 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Module: ActionController::Routing</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">ActionController::Routing</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ </td>
59
+ </tr>
60
+
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+
72
+
73
+ </div>
74
+
75
+
76
+ </div>
77
+
78
+
79
+ <!-- if includes -->
80
+
81
+ <div id="section">
82
+
83
+ <div id="class-list">
84
+ <h3 class="section-bar">Classes and Modules</h3>
85
+
86
+ Class <a href="Routing/RouteSet.html" class="link">ActionController::Routing::RouteSet</a><br />
87
+
88
+ </div>
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+ <!-- if method_list -->
97
+
98
+
99
+ </div>
100
+
101
+
102
+ <div id="validator-badges">
103
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
104
+ </div>
105
+
106
+ </body>
107
+ </html>
@@ -0,0 +1,107 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Module: ActionController</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">ActionController</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ </td>
59
+ </tr>
60
+
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+
72
+
73
+ </div>
74
+
75
+
76
+ </div>
77
+
78
+
79
+ <!-- if includes -->
80
+
81
+ <div id="section">
82
+
83
+ <div id="class-list">
84
+ <h3 class="section-bar">Classes and Modules</h3>
85
+
86
+ Module <a href="ActionController/Routing.html" class="link">ActionController::Routing</a><br />
87
+
88
+ </div>
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+ <!-- if method_list -->
97
+
98
+
99
+ </div>
100
+
101
+
102
+ <div id="validator-badges">
103
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
104
+ </div>
105
+
106
+ </body>
107
+ </html>