public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
redirect after successful comment

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@1226 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Tue Jun 13 09:38:22 -0700 2006
commit  8436e1c07713e462c92de00e93bf391fbebef013
tree    db61890034d402e37e50a4510eca374337dc368a
parent  dc76531138fc8fa346e60c3a28aa47cd47fdc3ec
...
4
5
6
 
7
 
8
9
10
...
4
5
6
7
8
9
10
11
12
0
@@ -4,7 +4,9 @@ class CommentSweeper < ArticleSweeper
0
   def after_save(record)
0
     @event.update_attributes :title => record.article.title, :body => record.body, :site => record.article.site,
0
       :article => record.article, :author => record.author, :comment => record if record.approved?
0
+ end
0
 
0
+ def after_update(record)
0
     return if controller.nil?
0
     expire_overview_feed!
0
     pages = CachedPage.find_by_reference(record.article)
...
1
 
2
 
 
 
 
 
3
4
5
6
7
8
 
9
10
11
...
23
24
25
26
27
28
29
30
31
32
33
34
35
 
 
 
 
 
36
 
 
 
 
 
 
 
 
 
 
 
 
 
37
...
1
2
3
4
5
6
7
8
9
10
11
12
13
 
14
15
16
17
...
29
30
31
 
 
 
 
 
 
 
 
 
 
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
0
@@ -1,11 +1,17 @@
0
 class CommentsController < ApplicationController
0
+ cache_sweeper :comment_sweeper
0
   verify :params => [:year, :month, :day, :permalink], :redirect_to => { :controller => 'mephisto', :action => 'list', :sections => [] }
0
+ before_filter :find_article
0
+
0
+ def show
0
+ show_article_with 'message' => 'Thank you for comment. Your comment requires approval from the blog author before showing up.'
0
+ end
0
 
0
   def create
0
     @article = site.articles.find_by_permalink(params[:year], params[:month], params[:day], params[:permalink])
0
     
0
     redirect_to(section_url(:sections => [])) and return unless @article
0
- if request.get? or params[:comment].blank?
0
+ if request.get? || params[:comment].blank?
0
       redirect_to(article_url(@article.hash_for_permalink)) and return
0
     end
0
 
0
@@ -23,15 +29,23 @@ class CommentsController < ApplicationController
0
       logger.info "Checking Akismet (#{Akismet.api_key}) for new comment on Article #{@article.id}. #{@comment.approved ? 'Approved' : 'Blocked'}"
0
     end
0
 
0
- assigns = @comment.save ?
0
- { 'message' => 'Thank you for comment. Your comment requires approval from the blog author before showing up.' } :
0
- { 'errors' => @comment.errors.full_messages }
0
-
0
- @comments = @article.comments.reject(&:new_record?).collect(&:to_liquid)
0
- @article = @article.to_liquid(:single)
0
- render_liquid_template_for(:single, assigns.merge('articles' => [@article],
0
- 'article' => @article,
0
- 'comments' => @comments))
0
-
0
+ if @comment.save
0
+ redirect_to comment_preview_url(@article.hash_for_permalink(:comment => @comment))
0
+ else
0
+ show_article_with 'errors' => @comment.errors.full_messages
0
+ end
0
   end
0
+
0
+ protected
0
+ def find_article
0
+ @article = site.articles.find_by_permalink(params[:year], params[:month], params[:day], params[:permalink])
0
+ end
0
+
0
+ def show_article_with(assigns)
0
+ @comments = @article.comments.reject(&:new_record?).collect(&:to_liquid)
0
+ @article = @article.to_liquid(:single)
0
+ render_liquid_template_for(:single, assigns.merge('articles' => [@article],
0
+ 'article' => @article,
0
+ 'comments' => @comments))
0
+ end
0
 end
...
14
15
16
17
 
18
19
 
 
 
 
20
21
22
...
14
15
16
 
17
18
 
19
20
21
22
23
24
25
0
@@ -14,9 +14,12 @@ ActionController::Routing::Routes.draw do |map|
0
   map.connect ':controller/:action/:id/:version', :version => nil,
0
       :controller => /account|(admin\/\w+)/
0
   
0
- map.comment ':year/:month/:day/:permalink/comment', :controller => 'comments', :action => 'create',
0
+ map.comment ':year/:month/:day/:permalink/comment', :controller => 'comments', :action => 'create',
0
       :year => /\d{4}/, :month => /\d{1,2}/, :day => /\d{1,2}/
0
-
0
+
0
+ map.comment_preview ':year/:month/:day/:permalink/comment/:comment', :controller => 'comments', :action => 'show',
0
+ :year => /\d{4}/, :month => /\d{1,2}/, :day => /\d{1,2}/
0
+
0
   map.with_options :controller => 'mephisto' do |m|
0
     m.article ':year/:month/:day/:permalink', :action => 'show',
0
       :year => /\d{4}/, :month => /\d{1,2}/, :day => /\d{1,2}/
...
29
30
31
32
33
34
 
35
36
37
...
46
47
48
49
50
51
 
52
53
54
...
29
30
31
 
 
 
32
33
34
35
...
44
45
46
 
 
 
47
48
49
50
0
@@ -29,9 +29,7 @@ class CommentsControllerTest < Test::Unit::TestCase
0
           :author_ip => '127.0.0.1'
0
         })
0
         assert_response :redirect
0
- assert_redirected_to @controller.url_for(contents(:welcome).hash_for_permalink(:controller => 'mephisto',
0
- :action => 'show',
0
- :anchor => "comment_#{assigns(:comment).id}"))
0
+ assert_redirected_to comment_preview_url(contents(:welcome).hash_for_permalink(:comment => assigns(:comment)))
0
         contents(:welcome).reload
0
       end
0
     end
0
@@ -46,9 +44,7 @@ class CommentsControllerTest < Test::Unit::TestCase
0
           :author => 'approved bob',
0
           :author_ip => '127.0.0.1'
0
         })
0
- assert_redirected_to @controller.url_for(contents(:cupcake_welcome).hash_for_permalink(:controller => 'mephisto',
0
- :action => 'show',
0
- :anchor => "comment_#{assigns(:comment).id}"))
0
+ assert_redirected_to comment_preview_url(contents(:cupcake_welcome).hash_for_permalink(:comment => assigns(:comment)))
0
         contents(:cupcake_welcome).reload
0
       end
0
     end

Comments

    No one has commented yet.