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 !
host of fixes and added support for comment preview
technoweenie (author)
Mon Feb 04 09:21:51 -0800 2008
commit  b0fadcd7955634ef0fc82c18a8b769c7d9cb89d4
tree    12a89c5278097f788f6b742fb22a91e21f3bb9cc
parent  963b29301a8e3c6b62557848575422dbad4a9245
...
62
63
64
 
65
66
67
...
62
63
64
65
66
67
68
0
@@ -62,6 +62,7 @@ class Admin::ArticlesController < Admin::BaseController
0
 
0
   def destroy
0
     @article.destroy
0
+ flash[:notice] = "The article: #{@article.title.inspect} was deleted."
0
     render :update do |page|
0
       page.redirect_to :action => 'index'
0
     end
...
55
56
57
 
 
58
59
60
...
55
56
57
58
59
60
61
62
0
@@ -55,6 +55,8 @@ class MephistoController < ApplicationController
0
       show_article_with 'errors' => @comment.errors.full_messages, 'submitted' => params[:comment]
0
     rescue Article::CommentNotAllowed
0
       show_article_with 'errors' => ["Commenting has been disabled on this article"]
0
+ rescue Comment::Previewing
0
+ show_article_with 'errors' => ["Previewing your comment"], 'submitted' => params[:comment]
0
     end
0
     
0
     def dispatch_comment
...
19
20
21
22
 
23
24
25
...
19
20
21
 
22
23
24
25
0
@@ -19,7 +19,7 @@ class ArticleDrop < BaseDrop
0
   end
0
 
0
   def comments
0
- @comments ||= liquify(*@source.comments.reject(&:new_record?))
0
+ @comments ||= liquify(*@source.comments) # .reject(&:new_record?) <-- show new comments as they're built as a preview
0
   end
0
   
0
   def sections
...
19
20
21
 
 
 
 
22
23
24
...
19
20
21
22
23
24
25
26
27
28
0
@@ -19,6 +19,10 @@ class CommentDrop < BaseDrop
0
     @url ||= absolute_url(@source.site.permalink_for(@source))
0
   end
0
 
0
+ def new_record
0
+ @source.new_record?
0
+ end
0
+
0
   def author_link
0
     @source.author_url.blank? ? "<span>#{@source.author}</span>" : %Q{<a href="#{author_url}">#{@source.author}</a>}
0
   end
...
12
13
14
15
 
16
 
 
 
 
 
 
 
 
 
 
17
18
19
...
80
81
82
83
 
84
85
86
...
12
13
14
 
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
...
90
91
92
 
93
94
95
96
0
@@ -12,8 +12,18 @@ class Comment < Content
0
   before_destroy :decrement_counter_cache
0
   belongs_to :article
0
   has_one :event, :dependent => :destroy
0
- attr_accessible :article, :article_id, :user_id, :user, :excerpt, :body, :author, :author_url, :author_email, :author_ip, :updater_id, :updater, :comment_age, :user_agent, :referrer
0
+ before_create :check_if_previewing
0
 
0
+ attr_accessible :article, :article_id, :user_id, :user, :excerpt, :body, :author, :author_url, :author_email, :author_ip, :updater_id, :updater, :comment_age, :user_agent, :referrer, :preview
0
+ attr_accessor :preview
0
+ class Previewing < StandardError; end
0
+
0
+ # If the view sends the "preview" accessor, we raise this
0
+ # error so the controller can simply rescue
0
+ def check_if_previewing
0
+ raise Comment::Previewing if preview
0
+ end
0
+
0
   def self.find_all_by_section(section, options = {})
0
     find :all, options.update(:conditions => ['contents.approved = ? and assigned_sections.section_id = ?', true, section.id],
0
       :select => 'contents.*', :joins => 'INNER JOIN assigned_sections ON assigned_sections.article_id = contents.article_id',
0
@@ -80,7 +90,7 @@ class Comment < Content
0
     end
0
 
0
     def check_comment_expiration
0
- raise Article::CommentNotAllowed unless article.accept_comments?
0
+ raise Article::CommentNotAllowed, "#{article.status} does not allow comments" unless article.accept_comments?
0
     end
0
 
0
     def update_counter_cache
...
44
45
46
 
 
47
 
48
49
50
...
44
45
46
47
48
49
50
51
52
53
0
@@ -44,7 +44,10 @@
0
             <li><%= link_to 'Sections', :controller => '/admin/sections' %></li>
0
             <li><%= link_to 'Design', :controller => '/admin/design' %></li>
0
             <li><%= link_to "Users", :controller => "users" %></li>
0
+ <% if false -%>
0
+ hidden because plugins are in for a change
0
             <li><%= link_to 'Plugins', :controller => '/admin/plugins' %></li>
0
+ <% end -%>
0
           <% Mephisto::Plugin.admin_tabs.each do |tab| -%>
0
             <li><%= link_to tab.first.to_s.tableize.humanize, tab.last %></li>
0
           <% end -%>
...
9
10
11
 
 
12
13
14
...
9
10
11
12
13
14
15
16
0
@@ -9,6 +9,8 @@ module Mephisto
0
         Thread.current[:comment_form_article] = value
0
       end
0
     
0
+ # Provides the required input, error, and form fields
0
+ # TODO: make this more accessible to users (let them mess it up, rather than forcing a structure on them)
0
       def render(context)
0
         return '' unless self.class.article.accept_comments?
0
         result = []
...
19
20
21
22
 
23
24
25
...
19
20
21
 
22
23
24
25
0
@@ -19,7 +19,7 @@ module Mephisto
0
       map.purge 'admin/articles/comments/purge', :controller => 'admin/comments', :action => 'destroy'
0
 
0
       map.resources :articles, :path_prefix => 'admin', :controller => 'admin/articles' do |r|
0
- r.resources :comments, :controller => 'admin/comments', :member => { :unapprove => :post, :approve => :post, :edit => :get }
0
+ r.resources :comments, :controller => 'admin/comments', :member => { :unapprove => :post, :approve => :post, :edit => :get, :preview => :post }
0
       end
0
 
0
       map.overview 'admin/overview.xml', :controller => 'admin/overview', :action => 'feed'

Comments

    No one has commented yet.