refinerycms-blog 0.9.8.0.rc1 → 0.9.8.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Gemfile.lock +9 -0
- data/app/controllers/blog_posts_controller.rb +21 -1
- data/app/models/blog_comment.rb +17 -1
- data/app/models/blog_post.rb +8 -0
- data/app/views/admin/blog/comments/_comment.html.erb +17 -0
- data/app/views/admin/blog/comments/_sortable_list.html.erb +7 -0
- data/app/views/admin/blog/comments/index.html.erb +8 -4
- data/app/views/blog_posts/_categories.html.erb +0 -0
- data/app/views/blog_posts/_comments.html.erb +0 -0
- data/app/views/blog_posts/_side_bar.html.erb +1 -1
- data/app/views/blog_posts/show.html.erb +38 -0
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +22 -17
- data/generators/refinery_blog/refinery_blog_generator.rb +2 -1
- data/lib/gemspec.rb +2 -1
- data/lib/refinerycms-blog.rb +21 -1
- data/public/stylesheets/refinerycms-blog.css +3 -0
- data/rails/init.rb +2 -2
- metadata +28 -7
data/Gemfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
gem 'filters_spam', '~> 0.2'
|
data/Gemfile.lock
ADDED
@@ -2,6 +2,7 @@ class BlogPostsController < ApplicationController
|
|
2
2
|
|
3
3
|
before_filter :find_all_blog_posts, :find_all_blog_categories
|
4
4
|
before_filter :find_page
|
5
|
+
before_filter :find_blog_post, :only => [:show, :comment]
|
5
6
|
|
6
7
|
def index
|
7
8
|
# you can use meta fields from your model instead (e.g. browser_title)
|
@@ -10,15 +11,34 @@ class BlogPostsController < ApplicationController
|
|
10
11
|
end
|
11
12
|
|
12
13
|
def show
|
13
|
-
@
|
14
|
+
@blog_comment = BlogComment.new
|
14
15
|
|
15
16
|
# you can use meta fields from your model instead (e.g. browser_title)
|
16
17
|
# by swapping @page for @blogs in the line below:
|
17
18
|
present(@page)
|
18
19
|
end
|
19
20
|
|
21
|
+
def comment
|
22
|
+
if (@blog_comment = @blog_post.comments.create(params[:blog_comment])).valid?
|
23
|
+
if BlogComment::Moderation.enabled?
|
24
|
+
flash[:notice] = t('.comments.thank_you_moderated')
|
25
|
+
redirect_back_or_default blog_post_url(params[:id])
|
26
|
+
else
|
27
|
+
flash[:notice] = t('.comments.thank_you')
|
28
|
+
redirect_to blog_post_url(params[:id],
|
29
|
+
:anchor => "comment-#{@blog_comment.to_param}")
|
30
|
+
end
|
31
|
+
else
|
32
|
+
render :action => 'show'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
20
36
|
protected
|
21
37
|
|
38
|
+
def find_blog_post
|
39
|
+
@blog_post = BlogPost.live.find(params[:id])
|
40
|
+
end
|
41
|
+
|
22
42
|
def find_all_blog_posts
|
23
43
|
unless params[:category_id].present?
|
24
44
|
@blog_posts = BlogPost.live
|
data/app/models/blog_comment.rb
CHANGED
@@ -1,13 +1,29 @@
|
|
1
1
|
class BlogComment < ActiveRecord::Base
|
2
2
|
|
3
|
+
filters_spam :author_field => :name,
|
4
|
+
:email_field => :email,
|
5
|
+
:message_field => :body
|
6
|
+
|
3
7
|
belongs_to :post, :class_name => 'BlogPost'
|
4
8
|
|
5
|
-
acts_as_indexed :fields => [:name, :email, :
|
9
|
+
acts_as_indexed :fields => [:name, :email, :message]
|
10
|
+
|
11
|
+
alias_attribute :message, :body
|
12
|
+
|
13
|
+
validates_presence_of :name, :message
|
14
|
+
validates_format_of :email,
|
15
|
+
:with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
|
6
16
|
|
7
17
|
named_scope :unmoderated, :conditions => {:state => nil}
|
8
18
|
named_scope :approved, :conditions => {:state => 'approved'}
|
9
19
|
named_scope :rejected, :conditions => {:state => 'rejected'}
|
10
20
|
|
21
|
+
before_create do |comment|
|
22
|
+
unless BlogComment::Moderation.enabled?
|
23
|
+
comment.state = comment.spam? ? 'rejected' : 'approved'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
11
27
|
module Moderation
|
12
28
|
class << self
|
13
29
|
def enabled?
|
data/app/models/blog_post.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
<li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(comment) -%>">
|
2
|
+
<span class='title'>
|
3
|
+
<%=h comment.name %>
|
4
|
+
<span class="preview"> - <%= truncate(comment.message, :length => 75) %></span>
|
5
|
+
</span>
|
6
|
+
<span class='actions'>
|
7
|
+
<%= link_to refinery_icon_tag("application_go.png"), blog_post_url(comment.post,
|
8
|
+
:anchor => "comment-#{comment.to_param}"),
|
9
|
+
:title => t('.view_live'),
|
10
|
+
:target => "_blank" %>
|
11
|
+
<%= link_to refinery_icon_tag("application_edit.png"), edit_admin_blog_comment_path(comment),
|
12
|
+
:title => t('.edit') %>
|
13
|
+
<%= link_to refinery_icon_tag("delete.png"), admin_blog_comment_path(comment),
|
14
|
+
:class => "cancel confirm-delete",
|
15
|
+
:title => t('.delete') %>
|
16
|
+
</span>
|
17
|
+
</li>
|
@@ -3,24 +3,28 @@
|
|
3
3
|
<% if searching? %>
|
4
4
|
<h2><%= t('shared.admin.search.results_for', :query => params[:search]) %></h2>
|
5
5
|
<% if @blog_comments.any? %>
|
6
|
-
|
6
|
+
<%=# will_paginate @blog_comments
|
7
|
+
%>
|
7
8
|
|
8
9
|
<ul>
|
9
10
|
<%= render :partial => "blog_comments",
|
10
11
|
:collection => @blog_comments %>
|
11
12
|
</ul>
|
12
13
|
|
13
|
-
|
14
|
+
<%=# will_paginate @blog_comments
|
15
|
+
%>
|
14
16
|
<% else %>
|
15
17
|
<p><%= t('admin.search_no_results') %></p>
|
16
18
|
<% end %>
|
17
19
|
<% else %>
|
18
20
|
<% if @blog_comments.any? %>
|
19
|
-
|
21
|
+
<%=# will_paginate @blog_comments
|
22
|
+
%>
|
20
23
|
|
21
24
|
<%= render :partial => "sortable_list" %>
|
22
25
|
|
23
|
-
|
26
|
+
<%=# will_paginate @blog_comments
|
27
|
+
%>
|
24
28
|
<% else %>
|
25
29
|
<h3>
|
26
30
|
<%= t('.no_items_yet',
|
File without changes
|
File without changes
|
@@ -4,6 +4,7 @@
|
|
4
4
|
<%= @blog_post.body %>
|
5
5
|
|
6
6
|
<% if (categories = @blog_post.categories).any? %>
|
7
|
+
<hr />
|
7
8
|
<div class='post_categories'>
|
8
9
|
<span class='filed_in'><%= t('.filed_in') %></span>
|
9
10
|
<ul>
|
@@ -15,6 +16,43 @@
|
|
15
16
|
</ul>
|
16
17
|
</div>
|
17
18
|
<% end %>
|
19
|
+
|
20
|
+
<% if (comments = @blog_post.comments.approved).any? %>
|
21
|
+
<hr />
|
22
|
+
<h2><%= t('.comments.title') %></h2>
|
23
|
+
<% comments.each do |comment| %>
|
24
|
+
<div class='blog_comment_message'>
|
25
|
+
<p>
|
26
|
+
<%= comment.message.to_s.gsub("\r\n\r\n", "</p><p>").gsub("\r\n", "<br/>") %>
|
27
|
+
</p>
|
28
|
+
</div>
|
29
|
+
<p class='blog_comment_author'>
|
30
|
+
<%= t('.comments.by', :who => comment.name) %>
|
31
|
+
<%= t('.comments.time_ago', :time => time_ago_in_words(comment.created_at)) %>
|
32
|
+
</p>
|
33
|
+
<% end %>
|
34
|
+
<% end %>
|
35
|
+
|
36
|
+
<% if BlogPost.comments_allowed? %>
|
37
|
+
<hr />
|
38
|
+
<% form_for [:blog_post, @blog_comment] do |f| %>
|
39
|
+
<div class='field'>
|
40
|
+
<%= f.label :name %>
|
41
|
+
<%= f.text_field :name %>
|
42
|
+
</div>
|
43
|
+
<div class='field'>
|
44
|
+
<%= f.label :email %>
|
45
|
+
<%= f.text_field :email %>
|
46
|
+
</div>
|
47
|
+
<div class='field message_field'>
|
48
|
+
<%= f.label :message %>
|
49
|
+
<%= f.text_area :message, :rows => 6 %>
|
50
|
+
</div>
|
51
|
+
<div class='field form-actions'>
|
52
|
+
<%= f.submit t('.submit') %>
|
53
|
+
</div>
|
54
|
+
<% end %>
|
55
|
+
<% end %>
|
18
56
|
<% end %>
|
19
57
|
|
20
58
|
<% content_for :body_content_right do %>
|
data/config/locales/en.yml
CHANGED
@@ -55,7 +55,12 @@ en:
|
|
55
55
|
index:
|
56
56
|
read_more: Read more
|
57
57
|
show:
|
58
|
+
comments:
|
59
|
+
title: Comments
|
60
|
+
by: Posted by {{who}}
|
61
|
+
time_ago: '{{time}} ago'
|
58
62
|
other: Other Blog Posts
|
59
63
|
filed_in: Filed in
|
60
64
|
created_at_title: Publishing Date
|
61
65
|
created_at: Posted on {{when}}
|
66
|
+
submit: Send comment
|
data/config/routes.rb
CHANGED
@@ -1,20 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
if Rails.version < '3.0.0'
|
2
|
+
ActionController::Routing::Routes.draw do |map|
|
3
|
+
map.blog_post '/blog', :controller => :blog_posts, :action => :index
|
4
|
+
map.blog_post '/blog/:id', :controller => :blog_posts, :action => :show
|
5
|
+
map.blog_category '/blog/categories/:category_id', :controller => :blog_posts, :action => :index
|
6
|
+
map.blog_post_blog_comments '/blog/:id/comments', :controller => :blog_posts, :action => :comment
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
8
|
+
map.namespace(:admin, :path_prefix => 'refinery') do |admin|
|
9
|
+
admin.namespace :blog do |blog|
|
10
|
+
blog.resources :posts
|
11
|
+
blog.resources :categories
|
12
|
+
blog.resources :comments, :collection => {
|
13
|
+
:approved => :get,
|
14
|
+
:rejected => :get
|
15
|
+
}
|
16
|
+
blog.resources :settings, :collection => {
|
17
|
+
:notification_recipients => [:get, :post],
|
18
|
+
:moderation => :get
|
19
|
+
}
|
20
|
+
end
|
18
21
|
end
|
19
22
|
end
|
20
|
-
|
23
|
+
else
|
24
|
+
# route for rails3 here.
|
25
|
+
end
|
@@ -43,11 +43,12 @@ class RefineryBlogGenerator < Rails::Generator::NamedBase
|
|
43
43
|
},{
|
44
44
|
:table_name => 'blog_comments',
|
45
45
|
:attributes => [
|
46
|
+
Rails::Generator::GeneratedAttribute.new('blog_post_id', 'integer'),
|
47
|
+
Rails::Generator::GeneratedAttribute.new('spam', 'boolean'),
|
46
48
|
Rails::Generator::GeneratedAttribute.new('name', 'string'),
|
47
49
|
Rails::Generator::GeneratedAttribute.new('email', 'string'),
|
48
50
|
Rails::Generator::GeneratedAttribute.new('body', 'text'),
|
49
51
|
Rails::Generator::GeneratedAttribute.new('state', 'string'),
|
50
|
-
Rails::Generator::GeneratedAttribute.new('blog_post_id', 'integer')
|
51
52
|
], :id => true
|
52
53
|
},{
|
53
54
|
:table_name => 'blog_categories',
|
data/lib/gemspec.rb
CHANGED
@@ -17,7 +17,8 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.homepage = %q{http://refinerycms.com}
|
18
18
|
s.authors = %w(Resolve\\ Digital Neoteric\\ Design)
|
19
19
|
s.require_paths = %w(lib)
|
20
|
-
s.add_dependency
|
20
|
+
s.add_dependency 'refinerycms', '~> 0.9.7.13'
|
21
|
+
s.add_dependency 'filters_spam', '~> 0.2'
|
21
22
|
|
22
23
|
s.files = %w(
|
23
24
|
#{files.join("\n ")}
|
data/lib/refinerycms-blog.rb
CHANGED
@@ -1,8 +1,28 @@
|
|
1
|
+
require 'filters_spam' if defined?(Bundler)
|
2
|
+
|
1
3
|
module Refinery
|
2
4
|
module Blog
|
5
|
+
|
6
|
+
class Engine < Rails::Engine
|
7
|
+
initializer 'blog serves assets' do
|
8
|
+
app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
|
9
|
+
end
|
10
|
+
|
11
|
+
config.after_initialize do
|
12
|
+
Refinery::Plugin.register do |plugin|
|
13
|
+
plugin.name = "refinerycms_blog"
|
14
|
+
plugin.url = {:controller => '/admin/blog/posts', :action => 'index'}
|
15
|
+
plugin.menu_match = /^\/?(admin|refinery)\/blog\/?(posts|comments|categories)?/
|
16
|
+
plugin.activity = {
|
17
|
+
:class => BlogPost
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end if defined?(Rails::Engine)
|
22
|
+
|
3
23
|
class << self
|
4
24
|
def version
|
5
|
-
%q{0.9.8.0.
|
25
|
+
%q{0.9.8.0.rc2}
|
6
26
|
end
|
7
27
|
end
|
8
28
|
end
|
data/rails/init.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require File.expand_path('../../lib/refinerycms-blog', __FILE__)
|
2
|
+
|
1
3
|
Refinery::Plugin.register do |plugin|
|
2
4
|
plugin.name = "refinerycms_blog"
|
3
5
|
plugin.url = {:controller => '/admin/blog/posts', :action => 'index'}
|
@@ -5,6 +7,4 @@ Refinery::Plugin.register do |plugin|
|
|
5
7
|
plugin.activity = {
|
6
8
|
:class => BlogPost
|
7
9
|
}
|
8
|
-
|
9
|
-
plugin.directory = directory # tell refinery where this plugin is located
|
10
10
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinerycms-blog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 977940591
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
9
|
- 8
|
10
10
|
- 0
|
11
|
-
-
|
12
|
-
version: 0.9.8.0.
|
11
|
+
- rc2
|
12
|
+
version: 0.9.8.0.rc2
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Resolve Digital
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2010-08-
|
21
|
+
date: 2010-08-31 00:00:00 +12:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
@@ -29,15 +29,30 @@ dependencies:
|
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
hash:
|
32
|
+
hash: 1
|
33
33
|
segments:
|
34
34
|
- 0
|
35
35
|
- 9
|
36
36
|
- 7
|
37
|
-
-
|
38
|
-
version: 0.9.7.
|
37
|
+
- 13
|
38
|
+
version: 0.9.7.13
|
39
39
|
type: :runtime
|
40
40
|
version_requirements: *id001
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: filters_spam
|
43
|
+
prerelease: false
|
44
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ~>
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
hash: 15
|
50
|
+
segments:
|
51
|
+
- 0
|
52
|
+
- 2
|
53
|
+
version: "0.2"
|
54
|
+
type: :runtime
|
55
|
+
version_requirements: *id002
|
41
56
|
description: A really straightforward open source Ruby on Rails blog engine designed for integration with RefineryCMS.
|
42
57
|
email: info@refinerycms.com
|
43
58
|
executables: []
|
@@ -62,6 +77,8 @@ files:
|
|
62
77
|
- app/views/admin/blog/categories/edit.html.erb
|
63
78
|
- app/views/admin/blog/categories/index.html.erb
|
64
79
|
- app/views/admin/blog/categories/new.html.erb
|
80
|
+
- app/views/admin/blog/comments/_comment.html.erb
|
81
|
+
- app/views/admin/blog/comments/_sortable_list.html.erb
|
65
82
|
- app/views/admin/blog/comments/index.html.erb
|
66
83
|
- app/views/admin/blog/posts/_form.html.erb
|
67
84
|
- app/views/admin/blog/posts/_post.html.erb
|
@@ -70,6 +87,8 @@ files:
|
|
70
87
|
- app/views/admin/blog/posts/index.html.erb
|
71
88
|
- app/views/admin/blog/posts/new.html.erb
|
72
89
|
- app/views/admin/blog/settings/notification_recipients.html.erb
|
90
|
+
- app/views/blog_posts/_categories.html.erb
|
91
|
+
- app/views/blog_posts/_comments.html.erb
|
73
92
|
- app/views/blog_posts/_side_bar.html.erb
|
74
93
|
- app/views/blog_posts/index.html.erb
|
75
94
|
- app/views/blog_posts/show.html.erb
|
@@ -77,6 +96,8 @@ files:
|
|
77
96
|
- config/locales/nb.yml
|
78
97
|
- config/locales/nl.yml
|
79
98
|
- config/routes.rb
|
99
|
+
- Gemfile
|
100
|
+
- Gemfile.lock
|
80
101
|
- generators/refinery_blog/refinery_blog_generator.rb
|
81
102
|
- generators/refinery_blog/templates/migration.rb
|
82
103
|
- generators/refinery_blog/templates/seed.rb
|