Move some of the Refinery::Setting's over to Refinery::Blog.
This commit is contained in:
parent
6cfebfae84
commit
34fd7b7b89
11 changed files with 32 additions and 36 deletions
|
@ -22,7 +22,7 @@ module Refinery
|
||||||
post.custom_teaser.html_safe
|
post.custom_teaser.html_safe
|
||||||
else
|
else
|
||||||
truncate(post.body, {
|
truncate(post.body, {
|
||||||
:length => Refinery::Setting.find_or_set(:blog_post_teaser_length, 250),
|
:length => Refinery::Blog.post_teaser_length,
|
||||||
:preserve_html_tags => true
|
:preserve_html_tags => true
|
||||||
}).html_safe
|
}).html_safe
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Refinery
|
||||||
@comment = comment
|
@comment = comment
|
||||||
mail :subject => Blog::Comment::Notification.subject,
|
mail :subject => Blog::Comment::Notification.subject,
|
||||||
:recipients => Blog::Comment::Notification.recipients,
|
:recipients => Blog::Comment::Notification.recipients,
|
||||||
:from => "\"#{Refinery::Core.config.site_name}\" <no-reply@#{request.domain}>"
|
:from => "\"#{Refinery::Core.site_name}\" <no-reply@#{request.domain}>"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,16 +10,16 @@ module Refinery
|
||||||
validates :title, :presence => true, :uniqueness => true
|
validates :title, :presence => true, :uniqueness => true
|
||||||
|
|
||||||
has_friendly_id :title, :use_slug => true,
|
has_friendly_id :title, :use_slug => true,
|
||||||
:default_locale => (::Refinery::I18n.default_frontend_locale rescue :en),
|
:default_locale => (Refinery::I18n.default_frontend_locale rescue :en),
|
||||||
:approximate_ascii => Refinery::Setting.find_or_set(:approximate_ascii, false, :scoping => 'blog'),
|
:approximate_ascii => Refinery::Blog.approximate_ascii,
|
||||||
:strip_non_ascii => Refinery::Setting.find_or_set(:strip_non_ascii, false, :scoping => 'blog')
|
:strip_non_ascii => Refinery::Blog.strip_non_ascii
|
||||||
|
|
||||||
def post_count
|
def post_count
|
||||||
posts.select(&:live?).count
|
posts.select(&:live?).count
|
||||||
end
|
end
|
||||||
|
|
||||||
# how many items to show per page
|
# how many items to show per page
|
||||||
self.per_page = Refinery::Setting.find_or_set(:blog_posts_per_page, 10)
|
self.per_page = Refinery::Blog.posts_per_page
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,7 +31,7 @@ module Refinery
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.per_page = Refinery::Setting.find_or_set(:blog_comments_per_page, 10)
|
self.per_page = Refinery::Blog.comments_per_page
|
||||||
|
|
||||||
def avatar_url(options = {})
|
def avatar_url(options = {})
|
||||||
options = {:size => 60}
|
options = {:size => 60}
|
||||||
|
|
|
@ -23,22 +23,22 @@ module Refinery
|
||||||
validates :title, :presence => true, :uniqueness => true
|
validates :title, :presence => true, :uniqueness => true
|
||||||
validates :body, :presence => true
|
validates :body, :presence => true
|
||||||
|
|
||||||
validates :source_url, :url => { :if => 'Refinery::Blog.config.validate_source_url',
|
validates :source_url, :url => { :if => 'Refinery::Blog.validate_source_url',
|
||||||
:update => true,
|
:update => true,
|
||||||
:allow_nil => true,
|
:allow_nil => true,
|
||||||
:allow_blank => true,
|
:allow_blank => true,
|
||||||
:verify => [:resolve_redirects]}
|
:verify => [:resolve_redirects]}
|
||||||
|
|
||||||
has_friendly_id :friendly_id_source, :use_slug => true,
|
has_friendly_id :friendly_id_source, :use_slug => true,
|
||||||
:default_locale => (::Refinery::I18n.default_frontend_locale rescue :en),
|
:default_locale => (Refinery::I18n.default_frontend_locale rescue :en),
|
||||||
:approximate_ascii => Refinery::Setting.find_or_set(:approximate_ascii, false, :scoping => 'blog'),
|
:approximate_ascii => Refinery::Blog.approximate_ascii,
|
||||||
:strip_non_ascii => Refinery::Setting.find_or_set(:strip_non_ascii, false, :scoping => 'blog')
|
:strip_non_ascii => Refinery::Blog.strip_non_ascii
|
||||||
|
|
||||||
attr_accessible :title, :body, :custom_teaser, :tag_list, :draft, :published_at, :custom_url, :author
|
attr_accessible :title, :body, :custom_teaser, :tag_list, :draft, :published_at, :custom_url, :author
|
||||||
attr_accessible :browser_title, :meta_keywords, :meta_description, :user_id, :category_ids
|
attr_accessible :browser_title, :meta_keywords, :meta_description, :user_id, :category_ids
|
||||||
attr_accessible :source_url, :source_url_title
|
attr_accessible :source_url, :source_url_title
|
||||||
|
|
||||||
self.per_page = Refinery::Setting.find_or_set(:blog_posts_per_page, 10)
|
self.per_page = Refinery::Blog.posts_per_page
|
||||||
|
|
||||||
def next
|
def next
|
||||||
self.class.next(self).first
|
self.class.next(self).first
|
||||||
|
@ -108,17 +108,8 @@ module Refinery
|
||||||
end
|
end
|
||||||
|
|
||||||
module ShareThis
|
module ShareThis
|
||||||
DEFAULT_KEY = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
def self.enabled?
|
||||||
|
Refinery::Blog.share_this_key != "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||||
class << self
|
|
||||||
def key
|
|
||||||
Refinery::Setting.find_or_set(:share_this_key, Blog::Post::ShareThis::DEFAULT_KEY, :scoping => 'blog')
|
|
||||||
end
|
|
||||||
|
|
||||||
def enabled?
|
|
||||||
key = Blog::Post::ShareThis.key
|
|
||||||
key.present? and key != Blog::Post::ShareThis::DEFAULT_KEY
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,6 @@
|
||||||
<%=raw t('.comment_ends') %>
|
<%=raw t('.comment_ends') %>
|
||||||
|
|
||||||
<%=raw t('.closing_line') %>,
|
<%=raw t('.closing_line') %>,
|
||||||
<%=raw Refinery::Core.config.site_name %>
|
<%=raw Refinery::Core.site_name %>
|
||||||
|
|
||||||
<%=raw t('.ps') %>
|
<%=raw t('.ps') %>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<% content_for :body_content_left do %>
|
<% content_for :body_content_left do %>
|
||||||
<%= raw @page.content_for(::Refinery::Pages.config.default_parts.first.to_sym) if ::Refinery::Pages.config.default_parts.any? %>
|
<%= raw @page.content_for(Refinery::Pages.default_parts.first.to_sym) if Refinery::Pages.default_parts.any? %>
|
||||||
|
|
||||||
<% if @posts.any? %>
|
<% if @posts.any? %>
|
||||||
<section id="blog_posts">
|
<section id="blog_posts">
|
||||||
|
@ -12,8 +12,8 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% content_for :body_content_right_prepend do -%>
|
<% content_for :body_content_right_prepend do -%>
|
||||||
<%= raw @page.content_for(::Refinery::Pages.config.default_parts.second.to_sym) %>
|
<%= raw @page.content_for(Refinery::Pages.default_parts.second.to_sym) %>
|
||||||
<% end if ::Refinery::Pages.config.default_parts.many? -%>
|
<% end if Refinery::Pages.default_parts.many? -%>
|
||||||
<%= render :partial => '/refinery/blog/shared/body_content_right' %>
|
<%= render :partial => '/refinery/blog/shared/body_content_right' %>
|
||||||
|
|
||||||
<%= render :partial => "/refinery/content_page" %>
|
<%= render :partial => "/refinery/content_page" %>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
xml.instruct! :xml, :version => "1.0"
|
xml.instruct! :xml, :version => "1.0"
|
||||||
xml.rss :version => "2.0" do
|
xml.rss :version => "2.0" do
|
||||||
xml.channel do
|
xml.channel do
|
||||||
xml.title Refinery::Core.config.site_name
|
xml.title Refinery::Core.site_name
|
||||||
xml.description Refinery::Core.config.site_name + " Blog Posts"
|
xml.description Refinery::Core.site_name + " Blog Posts"
|
||||||
xml.link refinery.blog_root_url
|
xml.link refinery.blog_root_url
|
||||||
|
|
||||||
@posts.each do |post|
|
@posts.each do |post|
|
||||||
|
|
|
@ -14,7 +14,7 @@ if defined?(Refinery::Page) and !Refinery::Page.exists?(:link_url => '/blog')
|
||||||
:menu_match => "^/blogs?(\/|\/.+?|)$"
|
:menu_match => "^/blogs?(\/|\/.+?|)$"
|
||||||
)
|
)
|
||||||
|
|
||||||
Refinery::Pages.config.default_parts.each do |default_page_part|
|
Refinery::Pages.default_parts.each do |default_page_part|
|
||||||
page.parts.create(:title => default_page_part, :body => nil)
|
page.parts.create(:title => default_page_part, :body => nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,8 +2,15 @@ module Refinery
|
||||||
module Blog
|
module Blog
|
||||||
include ActiveSupport::Configurable
|
include ActiveSupport::Configurable
|
||||||
|
|
||||||
config_accessor :validate_source_url
|
config_accessor :validate_source_url, :comments_per_page, :posts_per_page,
|
||||||
|
:post_teaser_length, :approximate_ascii, :strip_non_ascii, :share_this_key
|
||||||
|
|
||||||
self.validate_source_url = false
|
self.validate_source_url = false
|
||||||
|
self.comments_per_page = 10
|
||||||
|
self.posts_per_page = 10
|
||||||
|
self.post_teaser_length = 250
|
||||||
|
self.approximate_ascii = false
|
||||||
|
self.strip_non_ascii = false
|
||||||
|
self.share_this_key = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -224,9 +224,8 @@ module Refinery
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".validate_source_url?" do
|
describe ".validate_source_url?" do
|
||||||
context "with Refinery::Setting validate_source_url set to true" do
|
context "with Refinery::Blog.validate_source_url set to true" do
|
||||||
before do
|
before do
|
||||||
Refinery::Setting.set(:validate_source_url, { :scoping => 'blog', :value => true })
|
|
||||||
Refinery::Blog.validate_source_url = true
|
Refinery::Blog.validate_source_url = true
|
||||||
end
|
end
|
||||||
it "should have canonical url" do
|
it "should have canonical url" do
|
||||||
|
@ -234,9 +233,8 @@ module Refinery
|
||||||
p.source_url.should include('www')
|
p.source_url.should include('www')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
context "with Refinery::Setting validate_source_url set to false" do
|
context "with Refinery::Blog.validate_source_url set to false" do
|
||||||
before do
|
before do
|
||||||
Refinery::Setting.set(:validate_source_url, { :scoping => 'blog', :value => false })
|
|
||||||
Refinery::Blog.validate_source_url = false
|
Refinery::Blog.validate_source_url = false
|
||||||
end
|
end
|
||||||
it "should have original url" do
|
it "should have original url" do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue