Compare commits
1 commit
master
...
rails2-sta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a666d4a73 |
10 changed files with 58 additions and 169 deletions
|
|
@ -3,41 +3,21 @@ class Blog::PostsController < BlogController
|
||||||
before_filter :find_all_blog_posts, :except => [:archive]
|
before_filter :find_all_blog_posts, :except => [:archive]
|
||||||
before_filter :find_blog_post, :only => [:show, :comment, :update_nav]
|
before_filter :find_blog_post, :only => [:show, :comment, :update_nav]
|
||||||
|
|
||||||
respond_to :html, :js, :rss if Rails.version >= '3.0.0'
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
if Rails.version < '3.0.0'
|
# TODO: respond_to block
|
||||||
# TODO: respond_to block
|
|
||||||
else
|
|
||||||
respond_with (@blog_posts) do |format|
|
|
||||||
format.html
|
|
||||||
format.rss
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@blog_comment = BlogComment.new
|
@blog_comment = BlogComment.new
|
||||||
|
|
||||||
if Rails.version < '3.0.0'
|
# TODO: respond_to block
|
||||||
# TODO: respond_to block
|
|
||||||
else
|
|
||||||
respond_with (@blog_post) do |format|
|
|
||||||
format.html { present(@page) }
|
|
||||||
format.js { render :partial => 'post', :layout => false }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def comment
|
def comment
|
||||||
if (@blog_comment = @blog_post.comments.create(params[:blog_comment])).valid?
|
if (@blog_comment = @blog_post.comments.create(params[:blog_comment])).valid?
|
||||||
if BlogComment::Moderation.enabled? or @blog_comment.ham?
|
if BlogComment::Moderation.enabled? or @blog_comment.ham?
|
||||||
begin
|
begin
|
||||||
if Rails.version < '3.0.0'
|
Blog::CommentMailer.deliver_notification(@blog_comment, request)
|
||||||
Blog::CommentMailer.deliver_notification(@blog_comment, request)
|
|
||||||
else
|
|
||||||
Blog::CommentMailer.notification(@blog_comment, request).deliver
|
|
||||||
end
|
|
||||||
rescue
|
rescue
|
||||||
logger.warn "There was an error delivering a blog comment notification.\n#{$!}\n"
|
logger.warn "There was an error delivering a blog comment notification.\n#{$!}\n"
|
||||||
end
|
end
|
||||||
|
|
@ -63,11 +43,7 @@ class Blog::PostsController < BlogController
|
||||||
:page => params[:page],
|
:page => params[:page],
|
||||||
:per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
|
:per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
|
||||||
})
|
})
|
||||||
if Rails.version < '3.0.0'
|
# TODO: respond_to block
|
||||||
# TODO: respond_to block
|
|
||||||
else
|
|
||||||
respond_with (@blog_posts)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
|
||||||
|
|
@ -14,15 +14,9 @@ class BlogComment < ActiveRecord::Base
|
||||||
validates_format_of :email,
|
validates_format_of :email,
|
||||||
:with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
|
:with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
|
||||||
|
|
||||||
if Rails.version < '3.0.0'
|
named_scope :unmoderated, :conditions => {:state => nil}
|
||||||
named_scope :unmoderated, :conditions => {:state => nil}
|
named_scope :approved, :conditions => {:state => 'approved'}
|
||||||
named_scope :approved, :conditions => {:state => 'approved'}
|
named_scope :rejected, :conditions => {:state => 'rejected'}
|
||||||
named_scope :rejected, :conditions => {:state => 'rejected'}
|
|
||||||
else
|
|
||||||
scope :unmoderated, :conditions => {:state => nil}
|
|
||||||
scope :approved, :conditions => {:state => 'approved'}
|
|
||||||
scope :rejected, :conditions => {:state => 'rejected'}
|
|
||||||
end
|
|
||||||
|
|
||||||
def approve!
|
def approve!
|
||||||
self.update_attribute(:state, 'approved')
|
self.update_attribute(:state, 'approved')
|
||||||
|
|
|
||||||
|
|
@ -10,33 +10,14 @@ class BlogPost < ActiveRecord::Base
|
||||||
|
|
||||||
has_friendly_id :title, :use_slug => true
|
has_friendly_id :title, :use_slug => true
|
||||||
|
|
||||||
if Rails.version < '3.0.0'
|
named_scope :by_archive, lambda { |archive_date| {:conditions => ['published_at between ? and ?', archive_date.beginning_of_month, archive_date.end_of_month], :order => "published_at DESC"} }
|
||||||
named_scope :by_archive, lambda { |archive_date| {:conditions => ['published_at between ? and ?', archive_date.beginning_of_month, archive_date.end_of_month], :order => "published_at DESC"} }
|
|
||||||
else
|
|
||||||
scope :by_archive, lambda { |archive_date|
|
|
||||||
where(['published_at between ? and ?', archive_date.beginning_of_month, archive_date.end_of_month]).order("published_at DESC")
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
if Rails.version < '3.0.0'
|
named_scope :all_previous, :conditions => ['published_at <= ?', Time.now.beginning_of_month], :order => "published_at DESC"
|
||||||
named_scope :all_previous, :conditions => ['published_at <= ?', Time.now.beginning_of_month], :order => "published_at DESC"
|
|
||||||
else
|
|
||||||
scope :all_previous, where(['published_at <= ?', Time.now.beginning_of_month]).order("published_at DESC")
|
|
||||||
end
|
|
||||||
|
|
||||||
if Rails.version < '3.0.0'
|
named_scope :live, lambda { {:conditions => ["published_at < ? and draft = ?", Time.now, false], :order => "published_at DESC"} }
|
||||||
named_scope :live, lambda { {:conditions => ["published_at < ? and draft = ?", Time.now, false], :order => "published_at DESC"} }
|
|
||||||
else
|
|
||||||
scope :live, lambda { where( "published_at < ? and draft = ?", Time.now, false).order("published_at DESC") }
|
|
||||||
end
|
|
||||||
|
|
||||||
if Rails.version < '3.0.0'
|
named_scope :previous, lambda { |i| { :conditions => ["published_at < ?", i.published_at], :order => "published_at DESC", :limit => 1 } }
|
||||||
named_scope :previous, lambda { |i| { :conditions => ["published_at < ?", i.published_at], :order => "published_at DESC", :limit => 1 } }
|
named_scope :next, lambda { |i| { :condtions => ["published_at > ?", i.published_at], :order => "published_at ASC", :limit => 1 } }
|
||||||
named_scope :next, lambda { |i| { :condtions => ["published_at > ?", i.published_at], :order => "published_at ASC", :limit => 1 } }
|
|
||||||
else
|
|
||||||
scope :previous, lambda { |i| where(["published_at < ?", i.published_at]).order("published_at DESC").limit(1) }
|
|
||||||
scope :next, lambda { |i| where(["published_at > ?", i.published_at]).order("published_at ASC").limit(1) }
|
|
||||||
end
|
|
||||||
|
|
||||||
def next
|
def next
|
||||||
self.class.next(self).first
|
self.class.next(self).first
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,5 @@
|
||||||
<% form_for [:admin, @blog_category] do |f| -%>
|
<% form_for [:admin, @blog_category] do |f| -%>
|
||||||
<% if Rails.version < '3.0.0'%>
|
<%= f.error_messages %>
|
||||||
<%= f.error_messages %>
|
|
||||||
<% else %>
|
|
||||||
<%= render :partial => "/shared/admin/error_messages",
|
|
||||||
:locals => {
|
|
||||||
:object => f.object,
|
|
||||||
:include_object_name => true
|
|
||||||
} %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<div class='field'>
|
<div class='field'>
|
||||||
<%= f.label :title -%>
|
<%= f.label :title -%>
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,5 @@
|
||||||
<% form_for [:admin, @blog_post] do |f| -%>
|
<% form_for [:admin, @blog_post] do |f| -%>
|
||||||
<% if Rails.version < '3.0.0'%>
|
<%= f.error_messages %>
|
||||||
<%= f.error_messages %>
|
|
||||||
<% else %>
|
|
||||||
<%= render :partial => "/shared/admin/error_messages",
|
|
||||||
:locals => {
|
|
||||||
:object => f.object,
|
|
||||||
:include_object_name => true
|
|
||||||
} %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<div class='field'>
|
<div class='field'>
|
||||||
<%= f.label :title -%>
|
<%= f.label :title -%>
|
||||||
|
|
|
||||||
|
|
@ -23,26 +23,15 @@
|
||||||
|
|
||||||
<h2><%= t('.comments.add') %></h2>
|
<h2><%= t('.comments.add') %></h2>
|
||||||
<% form_for [:blog_post, @blog_comment] do |f| %>
|
<% form_for [:blog_post, @blog_comment] do |f| %>
|
||||||
<% if Rails.version < '3.0.0'%>
|
<%= f.error_messages %>
|
||||||
<%= f.error_messages %>
|
|
||||||
<% else %>
|
|
||||||
<%= render :partial => "/shared/admin/error_messages",
|
|
||||||
:locals => {
|
|
||||||
:object => f.object,
|
|
||||||
:include_object_name => true
|
|
||||||
} %>
|
|
||||||
<% end %>
|
|
||||||
<div class='field'>
|
<div class='field'>
|
||||||
<%= f.label :name %>
|
<%= f.label :name %>
|
||||||
<%= f.text_field :name %>
|
<%= f.text_field :name %>
|
||||||
</div>
|
</div>
|
||||||
<div class='field'>
|
<div class='field'>
|
||||||
<%= f.label :email %>
|
<%= f.label :email %>
|
||||||
<% if Rails.version > '3.0.0' %>
|
<%= f.text_field :email %>
|
||||||
<%= f.email_field :email %>
|
|
||||||
<% else %>
|
|
||||||
<%= f.text_field :email %>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
</div>
|
||||||
<div class='field message_field'>
|
<div class='field message_field'>
|
||||||
<%= f.label :message %>
|
<%= f.label :message %>
|
||||||
|
|
|
||||||
|
|
@ -1,75 +1,33 @@
|
||||||
if Rails.version < '3.0.0'
|
ActionController::Routing::Routes.draw do |map|
|
||||||
ActionController::Routing::Routes.draw do |map|
|
map.namespace(:blog) do |blog|
|
||||||
map.namespace(:blog) do |blog|
|
blog.rss_feed 'feed.rss', :controller => 'posts', :action => 'index', :format => 'rss'
|
||||||
blog.rss_feed 'feed.rss', :controller => 'posts', :action => 'index', :format => 'rss'
|
blog.root :controller => "posts", :action => 'index'
|
||||||
blog.root :controller => "posts", :action => 'index'
|
blog.post ':id', :controller => "posts", :action => 'show'
|
||||||
blog.post ':id', :controller => "posts", :action => 'show'
|
blog.category 'categories/:id', :controller => "categories", :action => 'show'
|
||||||
blog.category 'categories/:id', :controller => "categories", :action => 'show'
|
blog.post_blog_comments ':id/comments', :controller => 'posts', :action => 'comment'
|
||||||
blog.post_blog_comments ':id/comments', :controller => 'posts', :action => 'comment'
|
|
||||||
|
|
||||||
## what is the rails2 syntax for this? sorry ;__;
|
## TODO: what is the rails2 syntax for this? sorry ;__;
|
||||||
# get 'archive/:year/:month', :to => 'posts#archive', :as => 'archive_blog_posts'
|
# get 'archive/:year/:month', :to => 'posts#archive', :as => 'archive_blog_posts'
|
||||||
end
|
|
||||||
|
|
||||||
map.namespace(:admin, :path_prefix => 'refinery') do |admin|
|
|
||||||
admin.namespace :blog do |blog|
|
|
||||||
blog.resources :posts
|
|
||||||
|
|
||||||
blog.resources :categories
|
|
||||||
|
|
||||||
blog.resources :comments, :collection => {
|
|
||||||
:approved => :get,
|
|
||||||
:rejected => :get
|
|
||||||
}, :member => {
|
|
||||||
:approved => :get,
|
|
||||||
:rejected => :get
|
|
||||||
}
|
|
||||||
|
|
||||||
blog.resources :settings, :collection => {
|
|
||||||
:notification_recipients => [:get, :post],
|
|
||||||
:moderation => :get
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
else
|
|
||||||
Refinery::Application.routes.draw do
|
|
||||||
scope(:path => 'blog', :module => 'blog') do
|
|
||||||
root :to => 'posts#index', :as => 'blog_root'
|
|
||||||
match 'feed.rss', :to => 'posts#index.rss', :as => 'blog_rss_feed'
|
|
||||||
match ':id', :to => 'posts#show', :as => 'blog_post'
|
|
||||||
match 'categories/:id', :to => 'categories#show', :as => 'blog_category'
|
|
||||||
match ':id/comments', :to => 'posts#comment', :as => 'blog_post_blog_comments'
|
|
||||||
get 'archive/:year/:month', :to => 'posts#archive', :as => 'archive_blog_posts'
|
|
||||||
end
|
|
||||||
|
|
||||||
scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
|
map.namespace(:admin, :path_prefix => 'refinery') do |admin|
|
||||||
scope(:path => 'blog', :as => 'blog', :module => 'blog') do
|
admin.namespace :blog do |blog|
|
||||||
root :to => 'posts#index'
|
blog.resources :posts
|
||||||
resources :posts
|
|
||||||
|
|
||||||
resources :categories
|
blog.resources :categories
|
||||||
|
|
||||||
resources :comments do
|
blog.resources :comments, :collection => {
|
||||||
collection do
|
:approved => :get,
|
||||||
get :approved
|
:rejected => :get
|
||||||
get :rejected
|
}, :member => {
|
||||||
end
|
:approved => :get,
|
||||||
member do
|
:rejected => :get
|
||||||
get :approved
|
}
|
||||||
get :rejected
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
resources :settings do
|
blog.resources :settings, :collection => {
|
||||||
collection do
|
:notification_recipients => [:get, :post],
|
||||||
get :notification_recipients
|
:moderation => :get
|
||||||
post :notification_recipients
|
}
|
||||||
|
|
||||||
get :moderation
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
||||||
s.homepage = %q{http://refinerycms.com}
|
s.homepage = %q{http://refinerycms.com}
|
||||||
s.authors = %w(Resolve\\ Digital Neoteric\\ Design)
|
s.authors = %w(Resolve\\ Digital Neoteric\\ Design)
|
||||||
s.require_paths = %w(lib)
|
s.require_paths = %w(lib)
|
||||||
s.add_dependency 'refinerycms', '>= 0.9.7.13'
|
s.add_dependency 'refinerycms', '~> 0.9.7.13'
|
||||||
s.add_dependency 'filters_spam', '~> 0.2'
|
s.add_dependency 'filters_spam', '~> 0.2'
|
||||||
|
|
||||||
s.files = %w(
|
s.files = %w(
|
||||||
|
|
|
||||||
12
readme.md
12
readme.md
|
|
@ -1,28 +1,28 @@
|
||||||
# About
|
# Refinery CMS Blog - Rails 2 branch
|
||||||
|
|
||||||
Simple blog engine for [Refinery CMS](http://refinerycms.com). It supports posts, categories and comments.
|
Simple blog engine for [Refinery CMS](http://refinerycms.com). It supports posts, categories and comments.
|
||||||
|
|
||||||
|
Refinery CMS Blog supports Rails 3 on the [master branch](http://github.com/resolve/refinerycms-blog).
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
|
||||||
* Comment moderation
|
* Comment moderation
|
||||||
* [ShareThis.com](http://sharethis.com) support on posts. Set your key in Refinery's settings area to enable this.
|
* [ShareThis.com](http://sharethis.com) support on posts. Set your key in Refinery's settings area to enable this.
|
||||||
|
|
||||||
# Install
|
## Install
|
||||||
|
|
||||||
Open up your ``Gemfile`` and add at the bottom this line
|
Open up your ``Gemfile`` and add at the bottom this line
|
||||||
|
|
||||||
gem 'refinerycms-blog', '= 1.0.rc16'
|
gem 'refinerycms-blog', '= 1.0.rc16'
|
||||||
|
|
||||||
|
Please note 1.0.rc16 is the last version of Refinery CMS Blog to support Rails 2.
|
||||||
|
|
||||||
Now run ``bundle install``
|
Now run ``bundle install``
|
||||||
|
|
||||||
Next to install the blog plugin run (for Rails 2):
|
Next to install the blog plugin run (for Rails 2):
|
||||||
|
|
||||||
ruby script/generate refinerycms_blog
|
ruby script/generate refinerycms_blog
|
||||||
|
|
||||||
Or, for Rails 3:
|
|
||||||
|
|
||||||
rails generate refinerycms_blog
|
|
||||||
|
|
||||||
Finally migrate your database and you're done.
|
Finally migrate your database and you're done.
|
||||||
|
|
||||||
rake db:migrate
|
rake db:migrate
|
||||||
|
|
@ -2,13 +2,13 @@ Gem::Specification.new do |s|
|
||||||
s.name = %q{refinerycms-blog}
|
s.name = %q{refinerycms-blog}
|
||||||
s.version = %q{1.0.rc16}
|
s.version = %q{1.0.rc16}
|
||||||
s.description = %q{A really straightforward open source Ruby on Rails blog engine designed for integration with RefineryCMS.}
|
s.description = %q{A really straightforward open source Ruby on Rails blog engine designed for integration with RefineryCMS.}
|
||||||
s.date = %q{2010-11-22}
|
s.date = %q{2010-12-01}
|
||||||
s.summary = %q{Ruby on Rails blogging engine for RefineryCMS.}
|
s.summary = %q{Ruby on Rails blogging engine for RefineryCMS.}
|
||||||
s.email = %q{info@refinerycms.com}
|
s.email = %q{info@refinerycms.com}
|
||||||
s.homepage = %q{http://refinerycms.com}
|
s.homepage = %q{http://refinerycms.com}
|
||||||
s.authors = %w(Resolve\ Digital Neoteric\ Design)
|
s.authors = %w(Resolve\ Digital Neoteric\ Design)
|
||||||
s.require_paths = %w(lib)
|
s.require_paths = %w(lib)
|
||||||
s.add_dependency 'refinerycms', '>= 0.9.7.13'
|
s.add_dependency 'refinerycms', '~> 0.9.7.13'
|
||||||
s.add_dependency 'filters_spam', '~> 0.2'
|
s.add_dependency 'filters_spam', '~> 0.2'
|
||||||
|
|
||||||
s.files = %w(
|
s.files = %w(
|
||||||
|
|
@ -87,6 +87,13 @@ Gem::Specification.new do |s|
|
||||||
config/locales/nb.yml
|
config/locales/nb.yml
|
||||||
config/locales/nl.yml
|
config/locales/nl.yml
|
||||||
config/routes.rb
|
config/routes.rb
|
||||||
|
features
|
||||||
|
features/support
|
||||||
|
features/support/factories
|
||||||
|
features/support/factories/blog_categories.rb
|
||||||
|
features/support/factories/blog_comments.rb
|
||||||
|
features/support/factories/blog_posts.rb
|
||||||
|
features/support/paths.rb
|
||||||
Gemfile
|
Gemfile
|
||||||
Gemfile.lock
|
Gemfile.lock
|
||||||
generators
|
generators
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue