aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/helpers/refinery/blog/posts_helper.rb2
-rw-r--r--app/mailers/refinery/blog/comment_mailer.rb2
-rw-r--r--app/models/refinery/blog/category.rb8
-rw-r--r--app/models/refinery/blog/comment.rb2
-rw-r--r--app/models/refinery/blog/post.rb23
-rw-r--r--app/views/refinery/blog/comment_mailer/notification.html.erb2
-rw-r--r--app/views/refinery/blog/posts/index.html.erb6
-rw-r--r--app/views/refinery/blog/posts/index.rss.builder4
-rw-r--r--db/seeds.rb2
-rw-r--r--lib/refinery/blog/configuration.rb11
-rw-r--r--spec/models/refinery/blog/post_spec.rb6
11 files changed, 32 insertions, 36 deletions
diff --git a/app/helpers/refinery/blog/posts_helper.rb b/app/helpers/refinery/blog/posts_helper.rb
index ee19cec..4847ab2 100644
--- a/app/helpers/refinery/blog/posts_helper.rb
+++ b/app/helpers/refinery/blog/posts_helper.rb
@@ -22,7 +22,7 @@ module Refinery
post.custom_teaser.html_safe
else
truncate(post.body, {
- :length => Refinery::Setting.find_or_set(:blog_post_teaser_length, 250),
+ :length => Refinery::Blog.post_teaser_length,
:preserve_html_tags => true
}).html_safe
end
diff --git a/app/mailers/refinery/blog/comment_mailer.rb b/app/mailers/refinery/blog/comment_mailer.rb
index 5b0ce7a..d868354 100644
--- a/app/mailers/refinery/blog/comment_mailer.rb
+++ b/app/mailers/refinery/blog/comment_mailer.rb
@@ -6,7 +6,7 @@ module Refinery
@comment = comment
mail :subject => Blog::Comment::Notification.subject,
: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
diff --git a/app/models/refinery/blog/category.rb b/app/models/refinery/blog/category.rb
index dc85b50..55557c5 100644
--- a/app/models/refinery/blog/category.rb
+++ b/app/models/refinery/blog/category.rb
@@ -10,16 +10,16 @@ module Refinery
validates :title, :presence => true, :uniqueness => true
has_friendly_id :title, :use_slug => true,
- :default_locale => (::Refinery::I18n.default_frontend_locale rescue :en),
- :approximate_ascii => Refinery::Setting.find_or_set(:approximate_ascii, false, :scoping => 'blog'),
- :strip_non_ascii => Refinery::Setting.find_or_set(:strip_non_ascii, false, :scoping => 'blog')
+ :default_locale => (Refinery::I18n.default_frontend_locale rescue :en),
+ :approximate_ascii => Refinery::Blog.approximate_ascii,
+ :strip_non_ascii => Refinery::Blog.strip_non_ascii
def post_count
posts.select(&:live?).count
end
# 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
diff --git a/app/models/refinery/blog/comment.rb b/app/models/refinery/blog/comment.rb
index d2e9028..9187306 100644
--- a/app/models/refinery/blog/comment.rb
+++ b/app/models/refinery/blog/comment.rb
@@ -31,7 +31,7 @@ module Refinery
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 = {})
options = {:size => 60}
diff --git a/app/models/refinery/blog/post.rb b/app/models/refinery/blog/post.rb
index 5c1c6c5..822ddf7 100644
--- a/app/models/refinery/blog/post.rb
+++ b/app/models/refinery/blog/post.rb
@@ -23,22 +23,22 @@ module Refinery
validates :title, :presence => true, :uniqueness => 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,
:allow_nil => true,
:allow_blank => true,
:verify => [:resolve_redirects]}
has_friendly_id :friendly_id_source, :use_slug => true,
- :default_locale => (::Refinery::I18n.default_frontend_locale rescue :en),
- :approximate_ascii => Refinery::Setting.find_or_set(:approximate_ascii, false, :scoping => 'blog'),
- :strip_non_ascii => Refinery::Setting.find_or_set(:strip_non_ascii, false, :scoping => 'blog')
+ :default_locale => (Refinery::I18n.default_frontend_locale rescue :en),
+ :approximate_ascii => Refinery::Blog.approximate_ascii,
+ :strip_non_ascii => Refinery::Blog.strip_non_ascii
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 :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
self.class.next(self).first
@@ -108,17 +108,8 @@ module Refinery
end
module ShareThis
- DEFAULT_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
+ def self.enabled?
+ Refinery::Blog.share_this_key != "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
end
end
diff --git a/app/views/refinery/blog/comment_mailer/notification.html.erb b/app/views/refinery/blog/comment_mailer/notification.html.erb
index a129d34..8bf642e 100644
--- a/app/views/refinery/blog/comment_mailer/notification.html.erb
+++ b/app/views/refinery/blog/comment_mailer/notification.html.erb
@@ -12,6 +12,6 @@
<%=raw t('.comment_ends') %>
<%=raw t('.closing_line') %>,
-<%=raw Refinery::Core.config.site_name %>
+<%=raw Refinery::Core.site_name %>
<%=raw t('.ps') %>
diff --git a/app/views/refinery/blog/posts/index.html.erb b/app/views/refinery/blog/posts/index.html.erb
index 36c007b..2e8837c 100644
--- a/app/views/refinery/blog/posts/index.html.erb
+++ b/app/views/refinery/blog/posts/index.html.erb
@@ -1,5 +1,5 @@
<% 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? %>
<section id="blog_posts">
@@ -12,8 +12,8 @@
<% end %>
<% content_for :body_content_right_prepend do -%>
- <%= raw @page.content_for(::Refinery::Pages.config.default_parts.second.to_sym) %>
-<% end if ::Refinery::Pages.config.default_parts.many? -%>
+ <%= raw @page.content_for(Refinery::Pages.default_parts.second.to_sym) %>
+<% end if Refinery::Pages.default_parts.many? -%>
<%= render :partial => '/refinery/blog/shared/body_content_right' %>
<%= render :partial => "/refinery/content_page" %>
diff --git a/app/views/refinery/blog/posts/index.rss.builder b/app/views/refinery/blog/posts/index.rss.builder
index 867c6d6..8ffacd4 100644
--- a/app/views/refinery/blog/posts/index.rss.builder
+++ b/app/views/refinery/blog/posts/index.rss.builder
@@ -1,8 +1,8 @@
xml.instruct! :xml, :version => "1.0"
xml.rss :version => "2.0" do
xml.channel do
- xml.title Refinery::Core.config.site_name
- xml.description Refinery::Core.config.site_name + " Blog Posts"
+ xml.title Refinery::Core.site_name
+ xml.description Refinery::Core.site_name + " Blog Posts"
xml.link refinery.blog_root_url
@posts.each do |post|
diff --git a/db/seeds.rb b/db/seeds.rb
index ebc06e7..eee5a4b 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -14,7 +14,7 @@ if defined?(Refinery::Page) and !Refinery::Page.exists?(:link_url => '/blog')
: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)
end
end
diff --git a/lib/refinery/blog/configuration.rb b/lib/refinery/blog/configuration.rb
index aa1264a..5780a3e 100644
--- a/lib/refinery/blog/configuration.rb
+++ b/lib/refinery/blog/configuration.rb
@@ -2,8 +2,15 @@ module Refinery
module Blog
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.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 \ No newline at end of file
+end
diff --git a/spec/models/refinery/blog/post_spec.rb b/spec/models/refinery/blog/post_spec.rb
index fb7e3b1..1d0a3e7 100644
--- a/spec/models/refinery/blog/post_spec.rb
+++ b/spec/models/refinery/blog/post_spec.rb
@@ -224,9 +224,8 @@ module Refinery
end
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
- Refinery::Setting.set(:validate_source_url, { :scoping => 'blog', :value => true })
Refinery::Blog.validate_source_url = true
end
it "should have canonical url" do
@@ -234,9 +233,8 @@ module Refinery
p.source_url.should include('www')
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
- Refinery::Setting.set(:validate_source_url, { :scoping => 'blog', :value => false })
Refinery::Blog.validate_source_url = false
end
it "should have original url" do