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 !
lots of fixes for the new restful articles/comments change
technoweenie (author)
Sun Feb 03 13:30:10 -0800 2008
commit  65a3c3ebcada7170b4628e11a5f6d39d3ad085b1
tree    430b8a08a09fbd02edf9467369c0f6ac9a234ddd
parent  d6e29a759244fc2dbbbecb2d59bbe63e027168b5
...
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
...
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
0
@@ -4,25 +4,30 @@ class Admin::CommentsController < Admin::BaseController
0
 
0
 private
0
 
0
- before_filter :find_site_article, :except => [ :close ]
0
+ before_filter :find_site_article, :except => [ :close, :index, :destroy ]
0
+ before_filter :find_optional_site_article, :only => [:index, :destroy]
0
   def find_site_article
0
     @article = site.articles.find params[:article_id]
0
   end
0
+
0
+ def find_optional_site_article
0
+ @article = site.articles.find params[:article_id] unless params[:article_id].blank?
0
+ end
0
 
0
   cache_sweeper :comment_sweeper, :only => [:approve, :unapprove, :destroy, :create]
0
 
0
 public
0
 
0
   def index
0
- @comments = if params[:article_id]
0
- @comment = Comment.new
0
- @articles = site.unapproved_comments.count :all, :group => :article, :order => '1 desc'
0
- @article.send case params[:filter]
0
+ @comment = Comment.new
0
+ @articles = site.unapproved_comments.count :all, :group => :article, :order => '1 desc'
0
+ params[:filter] = 'unapproved' if @article.nil?
0
+ @comments =
0
+ (@article || @site).send case params[:filter]
0
         when 'approved' then :comments
0
         when 'unapproved' then :unapproved_comments
0
         else :all_comments
0
       end
0
- end
0
   end
0
   
0
   def unapproved
...
6
7
8
 
9
10
11
...
6
7
8
9
10
11
12
0
@@ -6,6 +6,7 @@ class ApplicationController < ActionController::Base
0
   attr_reader :site
0
 
0
   auto_include!
0
+
0
   def self.inherited(klass)
0
     super
0
     klass.auto_include!
...
5
6
7
8
 
9
10
11
...
5
6
7
 
8
9
10
11
0
@@ -5,7 +5,7 @@
0
     <% if article.comments.size == 0 %>
0
       none
0
     <% else %>
0
- <%= link_to article.comments.size.to_s.rjust(2, '0'), { :controller => 'admin/comments', :action => 'comments', :id => article } %>
0
+ <%= link_to article.comments.size.to_s.rjust(2, '0'), article_comments_path(article) %>
0
     <% end %>
0
   </td>
0
   <td><span class="date"><%= published_at_for article %></span></td>
...
2
3
4
5
 
6
7
 
8
9
10
11
12
 
13
14
15
16
17
18
19
...
21
22
23
24
 
25
26
27
28
 
 
29
 
 
 
30
31
32
...
38
39
40
41
 
42
43
44
...
47
48
49
50
 
51
52
53
...
2
3
4
 
5
6
 
7
8
9
 
 
 
10
11
12
13
 
14
15
16
...
18
19
20
 
21
22
23
 
 
24
25
26
27
28
29
30
31
32
...
38
39
40
 
41
42
43
44
...
47
48
49
 
50
51
52
53
0
@@ -2,18 +2,15 @@
0
 <% content_for :action_nav do %>
0
 <div id="page-nav">
0
   <ul id="act-nav" class="clear">
0
- <% if controller.action_name == 'comments' && @comments.any? -%>
0
+ <% if controller.controller_name == 'comments' && controller.action_name == 'index' && @comments.size > 0 -%>
0
       <li><%= link_to_remote "Delete these #{@filter != 'all' ? @filter : ''} comments", :confirm => "Are you sure you wish to delete all #{@filter != 'all' ? @filter : ''} comments?",
0
- :url => { :action => 'destroy_comment', :id => @article }, :with => "ArticleForm.getAvailableComments().toQueryString('comment')"
0
+ :url => { :controller => 'comments', :action => 'destroy', :id => @article }, :with => "ArticleForm.getAvailableComments().toQueryString('comment')"
0
         %></li>
0
     <% end -%>
0
- <% if (admin? || @article.user_id == current_user.id) && controller.action_name != 'comments' -%>
0
- <li><%= link_to_remote 'Delete this article', :url => {:action => 'destroy', :id => @article}, :confirm => 'Are you sure you want to delete this article?' %></li>
0
- <% unless @article.comment_age == -1 -%>
0
+ <% if @article && (admin? || @article.user_id == current_user.id) && @article.comment_age != -1 -%>
0
     <li id="close-article-comments"><%= link_to_remote 'Close comments for this article',
0
       :url => { :controller => 'admin/comments', :action => 'close', :id => @article } %></li>
0
   <% end -%>
0
- <% end -%>
0
   <% if controller.action_name == 'edit' -%>
0
     <li><%= link_to('Preview', {:action => 'show', :id => @article}, {:target => '_blank'}) %></li>
0
   <% end -%>
0
@@ -21,12 +18,15 @@
0
       <a class="trigger" id="cog" href="#">&nbsp;</a>
0
       <div id="optgroup" style="display: none">
0
         <ul id="options">
0
- <% unless @article.new_record? -%>
0
+ <% unless @article.nil? || @article.new_record? -%>
0
           <li><%= link_to 'Edit this article', :controller => 'articles', :action => 'edit', :id => @article, :version => nil %></li>
0
         <% end -%>
0
- <% if @article.comments.any? && controller.action_name != 'comments' -%>
0
- <li><%= link_to "View comments", :controller => 'articles', :action => 'comments', :id => @article %></li>
0
+ <% if @article && @article.comments.size > 0 && !(controller.controller_name == 'comments' && controller.action_name == 'index') -%>
0
+ <li><%= link_to "View comments", :controller => 'comments', :action => 'index', :article_id => @article %></li>
0
         <% end %>
0
+ <% if @article && (admin? || @article.user_id == current_user.id) -%>
0
+ <li><%= link_to_remote 'Delete this article', article_path(@article), :method => :delete, :confirm => 'Are you sure you want to delete this article?' %></li>
0
+ <% end -%>
0
         </ul>
0
       </div>
0
     </li>
0
@@ -38,7 +38,7 @@
0
     <li><a href="#">&nbsp;</a></li>
0
   </ul>
0
   <ul id="attributes">
0
- <% unless controller.action_name == 'comments' %>
0
+ <% if @article && controller.controller_name == 'articles' && controller.action_name == 'edit' %>
0
     <li><label for="search">Revision:</label></li>
0
     <li>
0
       <select name="filter" id="revisionnum">
0
@@ -47,7 +47,7 @@
0
       </select>
0
     </li>
0
     <% end %>
0
- <% if controller.action_name == 'comments' -%>
0
+ <% if controller.controller_name == 'comments' && controller.action_name == 'index' -%>
0
     <li><label for="comments_view">Show comments:</label></li>
0
     <li>
0
       <select id="comments-view">
...
1
2
3
 
 
 
 
 
 
 
4
 
5
6
 
7
8
9
...
38
39
40
41
42
 
 
43
44
45
...
1
2
 
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
...
46
47
48
 
 
49
50
51
52
53
0
@@ -1,9 +1,17 @@
0
 <%= render :partial => "admin/articles/page_nav" %>
0
 
0
-<h3 style="border-bottom:1px solid #ccc;padding:5px">Comments on <%= link_to @article.title, edit_article_path(@article), :style => 'border:none' %> <span class="right"><%= @article.published? ? link_to(image_tag('/images/mephisto/icons/24-zoom-in.png', :style => 'vertical-align: middle'), @site.permalink_for(@article), :style => 'border:none;') : '&nbsp;' %></span></h3>
0
+<h3 style="border-bottom:1px solid #ccc;padding:5px">
0
+<% if @article -%>
0
+Comments on <%= link_to @article.title, edit_article_path(@article), :style => 'border:none' %> <span class="right"><%= @article.published? ? link_to(image_tag('/images/mephisto/icons/24-zoom-in.png', :style => 'vertical-align: middle'), @site.permalink_for(@article), :style => 'border:none;') : '&nbsp;' %></span>
0
+<% else -%>
0
+Comments for all articles
0
+<% end -%>
0
+</h3>
0
 
0
+<% if @article -%>
0
   <%= link_to_function "New comment", "$('new-comment-form').toggle()" %>
0
   <div id="new-comment-form" style="display:none"><%= render :partial => "new_comment" %></div>
0
+<% end -%>
0
 
0
 <ul class="pagelist commentlist" id="comment-list">
0
   <% if @comments.any? %>
0
@@ -38,8 +46,8 @@
0
     <h3>Comments awaiting your approval</h3>
0
     <ul class="slist">
0
     <% @articles.each do |article, count| -%>
0
- <% if article.title != @article.title -%>
0
- <li><%= link_to "<strong>(#{count})</strong> #{h(article.title)}", :controller => 'articles', :action => 'comments', :id => article.id, :filter => :unapproved %></li>
0
+ <% if @article.nil? || article.title != @article.title -%>
0
+ <li><%= link_to "<strong>(#{count})</strong> #{h(article.title)}", :controller => 'comments', :action => 'index', :article_id => article.id, :filter => :unapproved %></li>
0
     <% end -%>
0
     <% end -%>
0
     </ul>
...
11
12
13
14
 
15
16
 
17
18
 
19
20
21
 
 
22
23
24
...
11
12
13
 
14
15
 
16
17
 
18
19
 
 
20
21
22
23
24
0
@@ -11,14 +11,14 @@
0
     &mdash; <%=h event.author %>
0
   </span>
0
  
0
- <% if event.comment %>
0
+ <% if event.comment -%>
0
   <% if event.comment.approved? -%>
0
- <%= link_to_remote 'Unapprove', :url => { :controller => 'admin/articles', :action => 'unapprove', :id => event.article_id, :comment => event.comment_id } %> |
0
+ <%= link_to_remote 'Unapprove', :url => unapprove_article_comment_path(event.article_id, event.coment_id) %> |
0
     <% else -%>
0
- <%= link_to_remote 'Approve', :url => { :controller => 'admin/articles', :action => 'approve', :id => event.article_id, :comment => event.comment_id } %> |
0
+ <%= link_to_remote 'Approve', :url => approve_article_comment_path(event.article_id, event.coment_id) %> |
0
     <% end -%>
0
- <%= link_to_remote 'Delete', :url => { :controller => 'admin/articles', :action => 'destroy_comment', :id => event.article_id, :comment => event.comment_id } %>
0
- <% end %>
0
+ <%= link_to_remote 'Delete', :url => article_comment_path(event.article_id, event.coment_id), :method => :delete %>
0
+ <% end -%>
0
   </div>
0
 </li>
0
 <% end -%>
...
9
10
11
12
 
13
14
15
...
9
10
11
 
12
13
14
15
0
@@ -9,7 +9,7 @@
0
     <li><%= link_to "Upload asset", new_asset_path %></li>
0
     
0
   <% if @articles.any? -%>
0
- <li><%= link_to "Moderate Comments", :controller => 'comments' %></li>
0
+ <li><%= link_to "Moderate Comments", moderate_path %></li>
0
   <% end -%>
0
   </ul>
0
 </div>
...
15
16
17
 
 
 
18
19
20
...
15
16
17
18
19
20
21
22
23
0
@@ -15,6 +15,9 @@ module Mephisto
0
         m.images 'images/:path.:ext', :dir => 'images'
0
       end
0
 
0
+ map.moderate 'admin/articles/comments', :controller => 'admin/comments', :action => 'index'
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
       end

Comments

    No one has commented yet.