public
Description: Radiant Comments
Clone URL: git://github.com/artofmission/radiant-comments.git
Search Repo:
Importing comments extension to Git
artofmission (author)
Mon May 05 12:09:19 -0700 2008
commit  1eea36faa17498ffe00b8073b31a0ed977ee50f6
tree    a4a2aceece6e1439219188a259c18d01fe15188e
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
0
@@ -0,0 +1,24 @@
0
+= 0.0.4
0
+* Added additional options and formatting to admin interface [rch]
0
+* Added comment approval options [rch]
0
+* Comments must now be approved before they will show up [rch]
0
+
0
+= 0.0.3
0
+* Changed dependency from admin_parts to shards. [hcf]
0
+* Added the snippets to a migration, so that the users no longer have to do this manually. [hcf]
0
+* Changed filter_id from integer to string to make it similar to radiant core. [hcf]
0
+* Removed the 'Comments' tab, and moved the functionality to the 'Pages' tab instead using shards. [hcf]
0
+* Added support for filters in comments, through the comment:filter_box_tag tag. [hcf]
0
+* Simplified the comment snippets. [hcf]
0
+
0
+= 0.0.2
0
+
0
+* Added Akismet support.
0
+* Added admin tools for moderating comments.
0
+* Added destroy dependency to Page#Comments association.
0
+* Added no_login_required to CommentsController. Comment should no longer force login when posted.
0
+
0
+= 0.0.1
0
+
0
+* Basic comment functionality in place
0
+
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
0
@@ -0,0 +1,20 @@
0
+Copyright (c) 2007 Ryan Heneise
0
+
0
+Permission is hereby granted, free of charge, to any person obtaining
0
+a copy of this software and associated documentation files (the
0
+"Software"), to deal in the Software without restriction, including
0
+without limitation the rights to use, copy, modify, merge, publish,
0
+distribute, sublicense, and/or sell copies of the Software, and to
0
+permit persons to whom the Software is furnished to do so, subject to
0
+the following conditions:
0
+
0
+The above copyright notice and this permission notice shall be
0
+included in all copies or substantial portions of the Software.
0
+
0
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
0
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
0
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
0
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0
\ No newline at end of file
0
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
0
@@ -0,0 +1,93 @@
0
+= Radiant Comments Extension
0
+
0
+== WARNING
0
+
0
+This extension is incompatible with the latest version of the Shards extension. Use at your own risk. If you get it working, PLEASE SUBMIT A PATCH!
0
+
0
+Adds blog-like comment functionality to Radiant.
0
+
0
+== Patches
0
+
0
+This software "works for me", but it may not work for you, depending on your particular environment or setup. Feel free to modify it in any way. If you do make changes that would be useful to others, please send a patch to ryan at artofmission (dot you-know-what), and I will see that it gets applied.
0
+
0
+== Dependencies
0
+
0
+* Requires Radiant 0.6.1 or greater.
0
+* Requires the Shards extension (http://dev.radiantcms.org/svn/radiant/trunk/extensions/shards)
0
+* Requires will_paginate Rails plugin (svn://errtheblog.com/svn/plugins/will_paginate)
0
+
0
+== Usage
0
+
0
+Remember to run the migration. This _WILL_ delete any snippets named 'comment', 'comments' and 'comment_form' if these exist.
0
+
0
+ rake radiant:extensions:comments:migrate
0
+
0
+The Shards extension must be loaded before Comments. To do this, add the following line to config/environment.rb:
0
+
0
+ config.extensions = [ :shards, :all ]
0
+
0
+To enable spam protection, you will need to add your Akismet key to app/models/comments.rb:
0
+
0
+ @akismet = Akismet.new('enter-your-key-here', 'enter-your-domain-here')
0
+
0
+=== In your layout:
0
+
0
+ <r:snippet name="comments" />
0
+
0
+=== Snippets
0
+
0
+The snippets "comments", "comment" and "comment_form" are created by the migration. These can be found under snippets, and can be customised after your needs. The snippets are the following:
0
+
0
+=== Snippet: comments
0
+
0
+<r:if_comments>
0
+ <h2>Comments</h2>
0
+ <r:comments:each>
0
+ <r:snippet name="comment" />
0
+ </r:comments:each>
0
+</r:if_comments>
0
+<r:snippet name="comment_form" />
0
+
0
+
0
+=== Snippet: comment
0
+
0
+<div class="comment">
0
+ <span class="number"><r:index />.</span>
0
+ <span class="by_line">
0
+ <r:author_link /> wrote:
0
+ </span>
0
+ <div class="message">
0
+ <r:content />
0
+ </div>
0
+</div>
0
+
0
+=== Snippet: comment_form
0
+
0
+<r:if_comments_enabled>
0
+ <r:comments:form>
0
+ <h2>Post a Comment</h2>
0
+ <p>
0
+ <label>Name</label>
0
+ <r:author_field class="textbox" />
0
+ </p>
0
+ <p>
0
+ <label>E-mail <small>(not shown)</small></label>
0
+ <r:author_email_field class="textbox" />
0
+ </p>
0
+ <p>
0
+ <label>Website</label>
0
+ <r:author_url_field class="textbox" />
0
+ </p>
0
+ <p>
0
+ <label>Text Filter</label>
0
+ <r:text_filter_field />
0
+ </p>
0
+ <p>
0
+ <label>Message</label>
0
+ <r:content_field rows="9" cols="40" />
0
+ </p>
0
+ <div class="buttons">
0
+ <input type="submit" value="Post Comment" />
0
+ </div>
0
+ </r:comments:form>
0
+</r:if_comments_enabled>
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
0
@@ -0,0 +1,25 @@
0
+require 'rake'
0
+require 'rake/testtask'
0
+require 'rake/rdoctask'
0
+
0
+desc 'Default: run unit tests.'
0
+task :default => :test
0
+
0
+desc 'Test the Comments extension.'
0
+Rake::TestTask.new(:test) do |t|
0
+ t.libs << 'lib'
0
+ t.pattern = 'test/**/*_test.rb'
0
+ t.verbose = true
0
+end
0
+
0
+desc 'Generate documentation for the Comments extension.'
0
+Rake::RDocTask.new(:rdoc) do |rdoc|
0
+ rdoc.rdoc_dir = 'rdoc'
0
+ rdoc.title = 'CommentsExtension'
0
+ rdoc.options << '--line-numbers' << '--inline-source'
0
+ rdoc.rdoc_files.include('README')
0
+ rdoc.rdoc_files.include('lib/**/*.rb')
0
+end
0
+
0
+# Load any custom rakefiles for extension
0
+Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
0
\ No newline at end of file
0
...
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
0
@@ -0,0 +1,13 @@
0
+= TODO:
0
+
0
+* Write Tests.
0
+* Email administrator when a comment is posted.
0
+* Handle validation messages.
0
+* Add user notification message when a comment is posted.
0
+
0
+
0
+= DONE
0
+* Add text filter to comment body.
0
+* Remove scaffolding and improve admin interface.
0
+* Implement Akismet filter.
0
+* Validate inputs and -handle error messages-.
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
0
@@ -0,0 +1,76 @@
0
+class Admin::CommentsController < ApplicationController
0
+
0
+ def index
0
+ conditions = case params[:status]
0
+ when "approved"
0
+ "comments.approved_at IS NOT NULL"
0
+ when "unapproved"
0
+ "comments.approved_at IS NULL"
0
+ else
0
+ nil
0
+ end
0
+ @page = Page.find(params[:page_id]) if params[:page_id]
0
+ @comments = @page.nil? ? Comment.paginate(:page => params[:page], :order => "created_at DESC", :conditions => conditions) : @page.comments.paginate(:page => params[:page], :conditions => conditions)
0
+ end
0
+
0
+ def destroy
0
+ @comment = Comment.find(params[:id])
0
+ @comment.destroy
0
+ announce_comment_removed
0
+ ResponseCache.instance.expire_response(@comment.page.url)
0
+ #redirect_to admin_page_comments_path(@comment.page)
0
+ redirect_to :back
0
+ end
0
+
0
+ def edit
0
+ @comment = Comment.find(params[:id])
0
+ end
0
+
0
+ def update
0
+ @comment = Comment.find(params[:id])
0
+ begin
0
+
0
+ TextFilter.descendants.each do |filter|
0
+ @comment.content_html = filter.filter(@comment.content) if filter.filter_name == @comment.filter_id
0
+ end
0
+ @comment.update_attributes(params[:comment])
0
+ ResponseCache.instance.clear #expire_response(page.url)
0
+ flash[:notice] = "Comment Saved"
0
+ redirect_to :action => :index
0
+ rescue Exception => e
0
+ flash[:notice] = "There was an error saving the comment"
0
+ end
0
+ end
0
+
0
+ def enable
0
+ @page = Page.find(params[:page_id])
0
+ @page.enable_comments = 1
0
+ @page.update
0
+ flash[:notice] = "Comments has been enabled for #{@page.title}"
0
+ redirect_to page_index_path
0
+ end
0
+
0
+ def approve
0
+ @comment = Comment.find(params[:id])
0
+ @comment.approve!
0
+ ResponseCache.instance.expire_response(@comment.page.url)
0
+ flash[:notice] = "Comment was successfully approved on page #{@comment.page.title}"
0
+ redirect_to :back
0
+ end
0
+
0
+ def unapprove
0
+ @comment = Comment.find(params[:id])
0
+ @comment.unapprove!
0
+ ResponseCache.instance.expire_response(@comment.page.url)
0
+ flash[:notice] = "Comment was successfully unapproved on page #{@comment.page.title}"
0
+ redirect_to :back
0
+ end
0
+
0
+
0
+ protected
0
+
0
+ def announce_comment_removed
0
+ flash[:notice] = "The comment was successfully removed from the site."
0
+ end
0
+
0
+end
0
\ No newline at end of file
...
 
 
0
...
1
2
3
0
@@ -0,0 +1,2 @@
0
+class Admin::PageController < ApplicationController
0
+end
0
\ No newline at end of file
...
 
 
0
...
1
2
3
0
@@ -0,0 +1,2 @@
0
+class ApplicationController < ActionController::Base
0
+end
0
\ No newline at end of file
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
0
@@ -0,0 +1,32 @@
0
+class CommentsController < ApplicationController
0
+
0
+ no_login_required
0
+
0
+ def create
0
+
0
+ @page = Page.find(params[:page_id])
0
+
0
+ @comment = Comment.new do |c|
0
+ c.page = @page
0
+ c.author = params[:comment][:author]
0
+ c.author_email = params[:comment][:author_email]
0
+ c.author_url = params[:comment][:author_url]
0
+ c.content = params[:comment][:content]
0
+ c.filter_id = params[:comment][:filter_id]
0
+ c.request = request
0
+ end
0
+
0
+ TextFilter.descendants.each do |filter|
0
+ @comment.content_html = filter.filter(@comment.content) if filter.filter_name == @comment.filter_id
0
+ end
0
+
0
+ if !@comment.is_spam?
0
+ @comment.save
0
+ # ResponseCache.instance.clear #expire_response(page.url)
0
+ CommentMailer.deliver_comment_notification
0
+ end
0
+
0
+ redirect_to "#{@page.url}#comment_#{@comment.id}" and return
0
+ end
0
+
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
0
@@ -0,0 +1,49 @@
0
+class Comment < ActiveRecord::Base
0
+ belongs_to :page, :counter_cache => true
0
+ validates_presence_of :author, :author_email, :content
0
+
0
+ def self.per_page
0
+ 50
0
+ end
0
+
0
+ def request=(request)
0
+ self.author_ip = request.remote_ip
0
+ self.user_agent = request.env['HTTP_USER_AGENT']
0
+ self.referrer = request.env['HTTP_REFERER']
0
+ end
0
+
0
+ # Akismet Spam Filter
0
+ # Marks a content item as spam unless it checks out with Akismet
0
+ def is_spam?
0
+ # You'll need to get your own Akismet API key from www.akismet.com
0
+ @akismet = Akismet.new('123456789', 'http://yourblog.wordpress.com')
0
+ return nil unless @akismet.verifyAPIKey
0
+
0
+ return true if @akismet.commentCheck(
0
+ self.author_ip, # remote IP
0
+ self.user_agent, # user agent
0
+ self.referrer, # http referer
0
+ self.page.url, # permalink
0
+ 'comment', # comment type
0
+ self.author, # author name
0
+ self.author_email, # author email
0
+ self.author_url, # author url
0
+ self.content, # comment text
0
+ {}) # other
0
+ return false
0
+ end
0
+
0
+ def approved?
0
+ return true if approved_at
0
+ return false
0
+ end
0
+
0
+ def approve!
0
+ self.update_attribute(:approved_at, Time.now)
0
+ end
0
+
0
+ def unapprove!
0
+ self.update_attribute(:approved_at, nil)
0
+ end
0
+
0
+end
...
 
 
 
 
 
 
 
 
 
 
0
...
1
2
3
4
5
6
7
8
9
10
11
0
@@ -0,0 +1,10 @@
0
+class CommentMailer < ActionMailer::Base
0
+
0
+ def comment_notification(sent_at = Time.now)
0
+ @subject = "[ AS Website ] New comment posted requires approval"
0
+ @body = {}
0
+ @recipients = "admin@example.com"
0
+ @from = "admin@example.com"
0
+ @sent_on = sent_at
0
+ end
0
+end
0
\ No newline at end of file
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
0
@@ -0,0 +1,28 @@
0
+<tr class="<%= "approved" if comment.approved? %>">
0
+ <td>
0
+ <a name="comment_<%= comment.id %>"></a>
0
+ <cite>
0
+ <span class="grey">Posted</span> <%= comment.created_at.to_formatted_s(:long) %>
0
+ <span class="grey">by</span> <%= content_tag(:strong, link_to(comment.author, comment.author_url)) if comment.author_url %>
0
+ <%= " <span class=\"grey\">(#{link_to(comment.author_email, "mailto:#{comment.author_email}")})</span>" if comment.author_email %>
0
+ <span class="grey">on</span> <strong><%= link_to(h(comment.page.title), comment.page.url) %></strong>
0
+
0
+ <%= content_tag(:span, "#{image_tag("/images/admin/accept.png")} approved", :class => "green") if comment.approved? %>
0
+
0
+ </cite>
0
+
0
+ <blockquote><%= comment.content %></blockquote>
0
+ </td>
0
+ <td class="controls right">
0
+ <div class="nowrap">
0
+ <%= link_to("approve", approve_admin_comment_path(comment)) unless comment.approved? %>
0
+ <%= link_to("unapprove", unapprove_admin_comment_path(comment)) if comment.approved? %>
0
+ </div>
0
+ <div>
0
+ <%= link_to "remove", admin_comment_path(:id => comment.id), :method => :delete, :confirm => "Are you sure?" %>
0
+ </div>
0
+ <div>
0
+ <%= link_to "edit", edit_admin_comment_path(:id => comment.id) %>
0
+ </div>
0
+ </td>
0
+</tr>
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
0
@@ -0,0 +1,44 @@
0
+<div id="comment_form_container">
0
+
0
+ <table border="0">
0
+
0
+ <tr>
0
+ <th><label for="comment_author">Comment Author Name</label></th>
0
+ <td><%= f.text_field :author, :class => "regular" %></td>
0
+ </tr>
0
+
0
+ <tr>
0
+ <th><label for="comment_author_url">Comment Author URL</label></th>
0
+ <td><%= f.text_field :author_url, :class => "regular" %></td>
0
+ </tr>
0
+
0
+ <tr>
0
+ <th><label for="comment_author_email">Comment Author Email</label></th>
0
+ <td><%= f.text_field :author_email, :class => "regular" %></td>
0
+ </tr>
0
+
0
+ <tr>
0
+ <th><label for="comment">Comment</label></th>
0
+ <td><%= f.text_area :content, :rows => 10, :class => "regular" %></td>
0
+ </tr>
0
+
0
+ <tr>
0
+ <th>
0
+ <label for="comment_filter_id">Filter</label>
0
+ </th>
0
+ <td>
0
+ <%= f.select :filter_id, [['<none>', '']] + TextFilter.descendants.map { |s| s.filter_name }.sort %>
0
+
0
+
0
+ </td>
0
+ </tr>
0
+
0
+ </table>
0
+
0
+ <%= submit_tag("Save comment", :class => "button", :id => "comment_submit_button") %>
0
+
0
+ <%= f.hidden_field :page_id %>
0
+
0
+
0
+
0
+</div>
...
 
 
 
 
 
...
1
2
3
4
5
0
@@ -0,0 +1,5 @@
0
+<h1>Edit comment by <%= @comment.author %></h1>
0
+
0
+<% form_for :comment, @comment, :url => admin_comment_path(@comment), :html => {:method => :put} do |f| %>
0
+ <%= render :partial => "form", :locals => {:f => f} %>
0
+<% end %>
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
0
@@ -0,0 +1,22 @@
0
+<h1><%= @page.nil? ? "#{params[:status].titleize if params[:status]} Comments" : "#{@page.comments_count} #{pluralize(@page.comments_count, "Comment")} on #{link_to(@page.title, page_edit_url(@page.id))}" %></h1>
0
+
0
+<p class="comment-nav">
0
+ View:
0
+ <%= content_tag :span, link_to_unless_current("All Comments", :status => "all", :page_id => params[:page_id]) %>
0
+ <%= content_tag :span, link_to_unless_current("Approved Comments", :status => "approved", :page_id => params[:page_id]) %>
0
+ <%= content_tag :span, link_to_unless_current("Unapproved Comments", :status => "unapproved", :page_id => params[:page_id]) %>
0
+</p>
0
+
0
+<table id="comments" class="index" border="0" cellspacing="0" cellpadding="0">
0
+ <tbody>
0
+ <%= render :partial => "comment", :collection => (@comments) %>
0
+ </tbody>
0
+</table>
0
+
0
+<%= will_paginate @comments %>
0
+
0
+<script type="text/javascript">
0
+// <![CDATA[
0
+ new RuledTable('comments');
0
+// ]]>
0
+</script>
0
\ No newline at end of file
...
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
0
@@ -0,0 +1,8 @@
0
+<p style="clear:left">
0
+ <label for="page_enable_comments">Allow Comments on this page?</label>
0
+ <%= check_box "page", "enable_comments" %>
0
+
0
+ <small>
0
+ <%= link_to "Currently #{@page.comments_count} &mdash; View comments", admin_page_comments_path(:page_id => @page.id) unless @page.new_record? or @page.comments_count < 1 %>
0
+ </small>
0
+</p>
...
 
0
...
1
2
0
@@ -0,0 +1 @@
0
+ <th class="comments">Comments</th>
0
\ No newline at end of file
...
 
 
 
 
 
 
 
 
 
 
 
0
...
1
2
3
4
5
6
7
8
9
10
11
12
0
@@ -0,0 +1,11 @@
0
+ <td class="comment_link"><small>
0
+
0
+ <% if page.enable_comments %>
0
+ <%= link_to "#{page.comments_count} comments", admin_page_comments_path(:page_id => page.id) %>
0
+
0
+ <% else %>
0
+ <%= link_to "Enable", admin_page_comments_path(:page_id => page.id, :action => :enable) %>
0
+ <% end %>
0
+
0
+
0
+ </small></td>
0
\ No newline at end of file
...
 
 
 
0
...
1
2
3
4
0
@@ -0,0 +1,3 @@
0
+A new comment has been posted on the AS Website. Comments require your approval before they will become visible.
0
+
0
+http://as.biola.edu/admin/comments?status=unapproved
0
\ No newline at end of file
...
 
0
...
1
2
0
@@ -0,0 +1 @@
0
+<%= comment.inspect %>
0
\ No newline at end of file
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
0
@@ -0,0 +1,23 @@
0
+<h1>Comment Form</h1>
0
+
0
+<div id="comment_form_container">
0
+
0
+<fieldset class="comment_form">
0
+
0
+ <a name="comment_form"></a>
0
+
0
+ <%= f.text_field :author, :label => "Your Name (as you'd like it to appear on this comment)", :class => "regular" %>
0
+
0
+ <%= f.text_field :author_url %>
0
+
0
+ <%= f.text_field :author_email %>
0
+
0
+ <%= f.text_area :content, :label => "Your comment", :rows => 5, :class => "regular" %>
0
+
0
+ <%= submit_tag("Save comment", :class => "button", :id => "comment_submit_button") %>
0
+
0
+ <%= f.hidden_field :page_id %>
0
+
0
+</fieldset>
0
+
0
+</div>
0
\ No newline at end of file
...
 
 
 
 
 
0
...
1
2
3
4
5
6
0
@@ -0,0 +1,5 @@
0
+<h1>Comment Form</h1>
0
+
0
+<% form_for :comment, @comment, :url => {:controller => :comments, :action => :create} do |f| %>
0
+ <%= render :partial => "comments/form", :locals => {:f => f} %>
0
+<% end %>
0
\ No newline at end of file
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
0
@@ -0,0 +1,40 @@
0
+#require 'page_extender'
0
+require_dependency 'application'
0
+
0
+class CommentsExtension < Radiant::Extension
0
+ version "0.0.3"
0
+ description "Adds blog-like comments and comment functionality to pages."
0
+ url "http://svn.artofmission.com/svn/plugins/radiant/extensions/comments/"
0
+
0
+ define_routes do |map|
0
+ map.resources :comments, :path_prefix => "/pages/:page_id", :controller => "comments" # Regular routes for comments
0
+ map.with_options(:controller => 'admin/comments') do |comments|
0
+ comments.resources :comments, :path_prefix => "/admin", :name_prefix => "admin_", :member => {:approve => :get, :unapprove => :get} # Admin routes for comments
0
+ comments.admin_page_comments 'admin/pages/:page_id/comments;:action' # This route allows us to nicely pull up comments for a particular page
0
+ comments.admin_page_comment 'admin/pages/:page_id/comments/:id;:action' # This route pulls up a particular comment for a particular page
0
+ end
0
+ end
0
+
0
+ def activate
0
+ Page.send :include, CommentTags
0
+ Comment
0
+
0
+ Page.class_eval do
0
+ has_many :comments, :dependent => :destroy
0
+ has_many :approved_comments, :class_name => "Comment", :conditions => "comments.approved_at IS NOT NULL"
0
+ has_many :unapproved_comments, :class_name => "Comment", :conditions => "comments.approved_at IS NULL"
0
+ end
0
+
0
+ if admin.respond_to? :page
0
+ admin.page.edit.add :parts_bottom, "edit_comments_enabled", :before => "edit_timestamp"
0
+ # admin.page.index.add :sitemap_head, "index_head_view_comments"
0
+ # admin.page.index.add :node_row, "index_view_comments"
0
+ end
0
+
0
+ admin.tabs.add "Comments", "/admin/comments?status=unapproved", :visibility => [:all]
0
+ end
0
+
0
+ def deactivate
0
+ end
0
+
0
+end
0
\ No newline at end of file
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
0
@@ -0,0 +1,48 @@
0
+class CreateComments < ActiveRecord::Migration
0
+ def self.up
0
+ create_table :comments do |t|
0
+