spud_blog 0.9.9 → 0.9.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/assets/stylesheets/spud/admin/posts.css +7 -1
- data/app/controllers/spud/admin/post_comments_controller.rb +32 -5
- data/app/controllers/spud/admin/posts_controller.rb +1 -1
- data/app/models/spud_post.rb +2 -0
- data/app/views/spud/admin/post_comments/index.html.erb +47 -0
- data/app/views/spud/admin/posts/index.html.erb +7 -2
- data/config/routes.rb +30 -25
- data/lib/spud_blog/version.rb +1 -1
- metadata +5 -4
@@ -1,14 +1,21 @@
|
|
1
1
|
class Spud::Admin::PostCommentsController < Spud::Admin::ApplicationController
|
2
2
|
|
3
3
|
respond_to :html, :xml, :json
|
4
|
-
|
4
|
+
layout 'spud/admin/detail'
|
5
|
+
belongs_to_spud_app :blog_posts
|
6
|
+
before_filter :find_comment, :only => [:show, :edit, :update, :destroy, :approve, :spam]
|
7
|
+
add_breadcrumb 'Blog Posts', :spud_admin_posts_path
|
8
|
+
add_breadcrumb 'Comments', :spud_admin_post_comments_path
|
9
|
+
|
5
10
|
|
6
11
|
def index
|
12
|
+
@page_name = "Comments"
|
7
13
|
if params[:post_id]
|
8
14
|
@post_comments = SpudPost.find(params[:post_id]).comments
|
9
15
|
else
|
10
|
-
@post_comments =
|
16
|
+
@post_comments = SpudPostComment
|
11
17
|
end
|
18
|
+
@post_comments = @post_comments.paginate :page => params[:page]
|
12
19
|
respond_with @post_comments
|
13
20
|
end
|
14
21
|
|
@@ -21,15 +28,35 @@ class Spud::Admin::PostCommentsController < Spud::Admin::ApplicationController
|
|
21
28
|
end
|
22
29
|
|
23
30
|
def update
|
24
|
-
|
31
|
+
|
25
32
|
end
|
26
33
|
|
27
34
|
def create
|
28
35
|
|
29
36
|
end
|
30
37
|
|
31
|
-
def
|
38
|
+
def approve
|
39
|
+
|
40
|
+
if Spud::Blog.enable_rakismet && @post_comment.spam
|
41
|
+
@post_comment.ham!
|
42
|
+
end
|
43
|
+
@post_comment.update_attributes(:spam => false)
|
44
|
+
redirect_to request.referer || spud_admin_post_comments_path
|
45
|
+
end
|
32
46
|
|
47
|
+
def spam
|
48
|
+
if Spud::Blog.enable_rakismet && !@post_comment.spam
|
49
|
+
@post_comment.spam!
|
50
|
+
end
|
51
|
+
@post_comment.update_attributes(:spam => true)
|
52
|
+
redirect_to request.referer || spud_admin_post_comments_path
|
53
|
+
end
|
54
|
+
|
55
|
+
def destroy
|
56
|
+
if !@post_comment.destroy
|
57
|
+
flash[:error] = "Whoops! Something odd happened while trying to delete that comment. Thats not fun. please try again."
|
58
|
+
end
|
59
|
+
respond_with @post_comment, :location => request.referer || spud_admin_post_comments_path
|
33
60
|
end
|
34
61
|
|
35
62
|
private
|
@@ -38,4 +65,4 @@ class Spud::Admin::PostCommentsController < Spud::Admin::ApplicationController
|
|
38
65
|
@post_comment = SpudPostComment.find(params[:id])
|
39
66
|
end
|
40
67
|
|
41
|
-
end
|
68
|
+
end
|
@@ -8,7 +8,7 @@ class Spud::Admin::PostsController < Spud::Admin::ApplicationController
|
|
8
8
|
cache_sweeper :spud_post_sweeper, :only => [:create, :update, :destroy]
|
9
9
|
|
10
10
|
def index
|
11
|
-
@posts = SpudPost.where(:is_news => false).order('published_at desc').includes(:
|
11
|
+
@posts = SpudPost.where(:is_news => false).order('published_at desc').includes(:visible_comments, :spam_comments, :author).paginate(:page => params[:page], :per_page => 15)
|
12
12
|
respond_with @posts
|
13
13
|
end
|
14
14
|
|
data/app/models/spud_post.rb
CHANGED
@@ -8,6 +8,7 @@ class SpudPost < ActiveRecord::Base
|
|
8
8
|
belongs_to :author, :class_name => 'SpudUser', :foreign_key => 'spud_user_id'
|
9
9
|
has_many :comments, :class_name => 'SpudPostComment'
|
10
10
|
has_many :visible_comments, :class_name => 'SpudPostComment',:conditions => {:spam => [nil,false]}
|
11
|
+
has_many :spam_comments, :class_name => "SpudPostComment", :conditions => {:spam => true}
|
11
12
|
has_many :spud_permalinks,:as => :attachment
|
12
13
|
has_many :spud_post_sites, :dependent => :destroy
|
13
14
|
|
@@ -77,6 +78,7 @@ class SpudPost < ActiveRecord::Base
|
|
77
78
|
return records.collect{ |r| Date.new(r[:published_year].to_i, r[:published_month].to_i) }
|
78
79
|
rescue Exception => e
|
79
80
|
logger.fatal "Exception occurred while fetching post archive dates:\n #{e.to_s}"
|
81
|
+
return []
|
80
82
|
end
|
81
83
|
end
|
82
84
|
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<%= content_for :data_controls do %>
|
2
|
+
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<%=content_for :detail do %>
|
6
|
+
<table class="admin-table">
|
7
|
+
<thead>
|
8
|
+
<tr>
|
9
|
+
|
10
|
+
<th>Author</th>
|
11
|
+
<th>Comment</th>
|
12
|
+
<th>Attached To</th>
|
13
|
+
<th>Status</th>
|
14
|
+
<th> </th>
|
15
|
+
</tr>
|
16
|
+
</thead>
|
17
|
+
<tbody>
|
18
|
+
<% @post_comments.each do |comment| %>
|
19
|
+
<tr>
|
20
|
+
<td><%= comment.author %></td>
|
21
|
+
<td>
|
22
|
+
<span class='submitted-on'>Submitted: <%=timestamp(comment.created_at)%></span>
|
23
|
+
<%= comment.content %>
|
24
|
+
</td>
|
25
|
+
<td><%= link_to comment.post.title, blog_post_path(comment.post.url_name)%></td>
|
26
|
+
<td>
|
27
|
+
<% if comment.spam %>
|
28
|
+
Spam
|
29
|
+
<% else %>
|
30
|
+
Approved
|
31
|
+
<% end %>
|
32
|
+
</td>
|
33
|
+
<td align="right">
|
34
|
+
<%= link_to 'Approve', approve_spud_admin_post_comment_path(comment), :class => 'btn btn-success btn-small' %>
|
35
|
+
<%= link_to 'Spam', spam_spud_admin_post_comment_path(comment), :class => 'btn btn-warning btn-small' %>
|
36
|
+
<%= link_to 'Delete', spud_admin_post_comment_path(comment), :method => :delete, :confirm => 'Are you sure you want to delete this comment?', :class => 'btn btn-danger btn-small' %>
|
37
|
+
</td>
|
38
|
+
</tr>
|
39
|
+
<%end%>
|
40
|
+
</tbody>
|
41
|
+
</table>
|
42
|
+
<div class="spud_admin_pagination">
|
43
|
+
<%= will_paginate @post_comments%>
|
44
|
+
</div>
|
45
|
+
|
46
|
+
|
47
|
+
<%end%>
|
@@ -1,5 +1,6 @@
|
|
1
1
|
<%= content_for :data_controls do %>
|
2
2
|
<%= link_to "Manage Categories", spud_admin_post_categories_path, :class => 'btn spud_blog_manage_categories', :title => 'Manage Categories' %>
|
3
|
+
<%= link_to "Manage Comments", spud_admin_post_comments_path, :class => 'btn', :title => 'Manage Comments' %>
|
3
4
|
<%= link_to "New Post", new_spud_admin_post_path, :class => "btn btn-primary", :title => "New Post" %>
|
4
5
|
<% end %>
|
5
6
|
|
@@ -12,7 +13,7 @@
|
|
12
13
|
<th>Published At</th>
|
13
14
|
<th>Comments</th>
|
14
15
|
<th> </th>
|
15
|
-
</tr>
|
16
|
+
</tr>
|
16
17
|
</thead>
|
17
18
|
<tbody>
|
18
19
|
<% @posts.each do |post| %>
|
@@ -27,7 +28,11 @@
|
|
27
28
|
</td>
|
28
29
|
<td><%= post.author.full_name %></td>
|
29
30
|
<td><%= link_to(post.published_at.strftime('%m/%d/%Y'), blog_post_path(post.url_name)) %></td>
|
30
|
-
<td
|
31
|
+
<td>
|
32
|
+
Approved: <%=link_to post.visible_comments.count, spud_admin_post_post_comments_path(:post_id => post.id) %>
|
33
|
+
<br/>
|
34
|
+
Spam: <%=link_to post.spam_comments.count, spud_admin_post_post_comments_path(:post_id => post.id) %>
|
35
|
+
</td>
|
31
36
|
<td align="right">
|
32
37
|
<%= link_to 'Delete', spud_admin_post_path(post), :method => :delete, :confirm => 'Are you sure you want to delete this post?', :class => 'btn btn-danger' %>
|
33
38
|
</td>
|
data/config/routes.rb
CHANGED
@@ -6,7 +6,12 @@ Rails.application.routes.draw do
|
|
6
6
|
resources :post_comments, :path => 'comments', :only => :index
|
7
7
|
end
|
8
8
|
resources :news_posts
|
9
|
-
resources :post_comments, :except => :new
|
9
|
+
resources :post_comments, :except => [:new, :create, :edit, :update] do
|
10
|
+
member do
|
11
|
+
get 'approve'
|
12
|
+
get 'spam'
|
13
|
+
end
|
14
|
+
end
|
10
15
|
resources :post_categories
|
11
16
|
end
|
12
17
|
namespace :blog do
|
@@ -18,21 +23,21 @@ Rails.application.routes.draw do
|
|
18
23
|
scope Spud::Blog.config.blog_path do
|
19
24
|
|
20
25
|
# Blog Post Categories
|
21
|
-
get 'category/:category_url_name(/page/:page)',
|
22
|
-
:controller => 'blog',
|
23
|
-
:action => 'category',
|
26
|
+
get 'category/:category_url_name(/page/:page)',
|
27
|
+
:controller => 'blog',
|
28
|
+
:action => 'category',
|
24
29
|
:as => 'blog_category',
|
25
30
|
:defaults => {:page => 1}
|
26
|
-
get 'category/:category_url_name/:archive_date(/page/:page)',
|
27
|
-
:controller => 'blog',
|
28
|
-
:action => 'category',
|
31
|
+
get 'category/:category_url_name/:archive_date(/page/:page)',
|
32
|
+
:controller => 'blog',
|
33
|
+
:action => 'category',
|
29
34
|
:as => 'blog_category_archive',
|
30
35
|
:defaults => {:page => 1}
|
31
36
|
|
32
37
|
# Blog Post Archives
|
33
|
-
get 'archive/:archive_date(/page/:page)',
|
34
|
-
:controller => 'blog',
|
35
|
-
:action => 'archive',
|
38
|
+
get 'archive/:archive_date(/page/:page)',
|
39
|
+
:controller => 'blog',
|
40
|
+
:action => 'archive',
|
36
41
|
:as => 'blog_archive',
|
37
42
|
:defaults => {:page => 1}
|
38
43
|
|
@@ -40,8 +45,8 @@ Rails.application.routes.draw do
|
|
40
45
|
post '/', :controller => 'blog', :action => 'filter'
|
41
46
|
|
42
47
|
# Blog Posts
|
43
|
-
get '/(page/:page)',
|
44
|
-
:controller => 'blog',
|
48
|
+
get '/(page/:page)',
|
49
|
+
:controller => 'blog',
|
45
50
|
:action => 'index',
|
46
51
|
:as => 'blog',
|
47
52
|
:defaults => {:page => 1}
|
@@ -55,35 +60,35 @@ Rails.application.routes.draw do
|
|
55
60
|
scope Spud::Blog.config.news_path do
|
56
61
|
|
57
62
|
# News Post Categories
|
58
|
-
get 'category/:category_url_name(/page/:page)',
|
59
|
-
:controller => 'news',
|
63
|
+
get 'category/:category_url_name(/page/:page)',
|
64
|
+
:controller => 'news',
|
60
65
|
:action => 'category',
|
61
66
|
:as => 'news_category',
|
62
67
|
:defaults => {:page => 1}
|
63
|
-
get 'category/:category_url_name/:archive_date(/page/:page)',
|
64
|
-
:controller => 'news',
|
65
|
-
:action => 'category',
|
68
|
+
get 'category/:category_url_name/:archive_date(/page/:page)',
|
69
|
+
:controller => 'news',
|
70
|
+
:action => 'category',
|
66
71
|
:as => 'news_category_archive',
|
67
72
|
:defaults => {:page => 1}
|
68
|
-
|
73
|
+
|
69
74
|
# News Post Archives
|
70
|
-
get 'archive/:archive_date(/page/:page)',
|
75
|
+
get 'archive/:archive_date(/page/:page)',
|
71
76
|
:controller => 'news',
|
72
|
-
:action => 'archive',
|
77
|
+
:action => 'archive',
|
73
78
|
:as => 'news_archive',
|
74
79
|
:defaults => {:page => 1}
|
75
80
|
|
76
81
|
# Category/Archive filtering
|
77
82
|
post '/', :controller => 'news', :action => 'filter'
|
78
|
-
|
83
|
+
|
79
84
|
# News Posts
|
80
|
-
get '/(page/:page)',
|
81
|
-
:controller => 'news',
|
82
|
-
:action => 'index',
|
85
|
+
get '/(page/:page)',
|
86
|
+
:controller => 'news',
|
87
|
+
:action => 'index',
|
83
88
|
:as => 'news',
|
84
89
|
:defaults => {:page => 1}
|
85
90
|
resources :news_posts, :path => '/', :controller => 'news', :only => [:show]
|
86
91
|
end
|
87
92
|
end
|
88
93
|
|
89
|
-
end
|
94
|
+
end
|
data/lib/spud_blog/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spud_blog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -291,6 +291,7 @@ files:
|
|
291
291
|
- app/views/spud/admin/post_categories/edit.html.erb
|
292
292
|
- app/views/spud/admin/post_categories/index.html.erb
|
293
293
|
- app/views/spud/admin/post_categories/new.html.erb
|
294
|
+
- app/views/spud/admin/post_comments/index.html.erb
|
294
295
|
- app/views/spud/admin/posts/_category.html.erb
|
295
296
|
- app/views/spud/admin/posts/_form.html.erb
|
296
297
|
- app/views/spud/admin/posts/edit.html.erb
|
@@ -338,7 +339,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
338
339
|
version: '0'
|
339
340
|
segments:
|
340
341
|
- 0
|
341
|
-
hash: -
|
342
|
+
hash: -4012554368175872547
|
342
343
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
343
344
|
none: false
|
344
345
|
requirements:
|
@@ -347,7 +348,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
347
348
|
version: '0'
|
348
349
|
segments:
|
349
350
|
- 0
|
350
|
-
hash: -
|
351
|
+
hash: -4012554368175872547
|
351
352
|
requirements: []
|
352
353
|
rubyforge_project:
|
353
354
|
rubygems_version: 1.8.24
|