Skip to content

Commit

Permalink
A number of minor fixes and enhancements.
Browse files Browse the repository at this point in the history
* Clear the whole cache since purging individual responses doesn't seem to work.
* Only redirect after POST when comment is approved. Otherwise, render a transient
  response with the comment selected.
* Use our nice named scopes in the tags.
  • Loading branch information
seancribbs committed Aug 19, 2009
1 parent 5fb225b commit 3dbbc09
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
3 changes: 1 addition & 2 deletions app/controllers/admin/comments_controller.rb
Expand Up @@ -114,8 +114,7 @@ def announce_comment_removed
def clear_single_page_cache(comment)
if comment && comment.page
unless defined?(ResponseCache)
Radiant::Cache::EntityStore.new.purge(comment.page.url)
Radiant::Cache::MetaStore.new.purge(comment.page.url)
Radiant::Cache.clear
else
ResponseCache.instance.clear
end
Expand Down
14 changes: 8 additions & 6 deletions lib/comment_page_extensions.rb
Expand Up @@ -21,17 +21,19 @@ def process_with_comments(request, response)
comment = self.comments.build(request.parameters[:comment])
comment.request = self.request = request
comment.save!

# Purge the cache
Radiant::Cache.clear

if Radiant::Config['comments.notification'] == "true"
if comment.approved? || Radiant::Config['comments.notify_unapproved'] == "true"
CommentMailer.deliver_comment_notification(comment)
end
end
absolute_url = "#{request.protocol}#{request.host_with_port}#{relative_url_for(url, request)}#comment-#{comment.id}"
response.redirect(absolute_url, 303)
return
if comment.approved?
absolute_url = "#{request.protocol}#{request.host_with_port}#{relative_url_for(url, request)}#comment-#{comment.id}"
response.redirect(absolute_url, 303)
return
else
self.selected_comment = comment
end
rescue ActiveRecord::RecordInvalid
self.last_comment = comment
end
Expand Down
2 changes: 1 addition & 1 deletion lib/comment_tags.rb
Expand Up @@ -291,7 +291,7 @@ module CommentTags
}
tag "recent_comments:each" do |tag|
limit = tag.attr['limit'] || 10
comments = Comment.find(:all, :conditions => "comments.approved_at IS NOT NULL", :order => "created_at DESC", :limit => limit)
comments = Comment.approved.recent.all(:limit => limit)
result = []
comments.each_with_index do |comment, index|
tag.locals.comment = comment
Expand Down

0 comments on commit 3dbbc09

Please sign in to comment.