aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Arndt <parndt@gmail.com>2012-02-27 17:08:37 +1300
committerPhilip Arndt <parndt@gmail.com>2012-02-27 17:08:37 +1300
commit594dd8ca96f9a0e06dd28d2176653855e39a43e2 (patch)
treedbac325e354b3266428fd0444a708173766266fa
parent837ddfe42bfd906f79e2a28608dd6af988511e64 (diff)
downloadrefinerycms-blog-594dd8ca96f9a0e06dd28d2176653855e39a43e2.tar.gz
refinerycms-blog-594dd8ca96f9a0e06dd28d2176653855e39a43e2.tar.bz2
refinerycms-blog-594dd8ca96f9a0e06dd28d2176653855e39a43e2.zip
Now supporting FriendlyId 4
-rw-r--r--Gemfile2
-rw-r--r--app/models/refinery/blog/category.rb7
-rw-r--r--app/models/refinery/blog/post.rb7
-rw-r--r--db/migrate/20120227022021_add_slug_to_posts_and_categories.rb9
-rw-r--r--lib/generators/refinery/blog/templates/config/initializers/refinery/blog.rb.erb4
-rw-r--r--lib/refinery/blog/configuration.rb4
6 files changed, 16 insertions, 17 deletions
diff --git a/Gemfile b/Gemfile
index d0e48d8..b10a845 100644
--- a/Gemfile
+++ b/Gemfile
@@ -2,6 +2,8 @@ source "http://rubygems.org"
gemspec
+gem 'friendly_id', :git => 'git://github.com/norman/friendly_id.git'
+
git 'git://github.com/resolve/refinerycms.git' do
gem 'refinerycms'
diff --git a/app/models/refinery/blog/category.rb b/app/models/refinery/blog/category.rb
index 55557c5..05e6994 100644
--- a/app/models/refinery/blog/category.rb
+++ b/app/models/refinery/blog/category.rb
@@ -1,6 +1,8 @@
module Refinery
module Blog
class Category < ActiveRecord::Base
+ extend FriendlyId
+ friendly_id :title, :use => [:slugged]
has_many :categorizations, :dependent => :destroy, :foreign_key => :blog_category_id
has_many :posts, :through => :categorizations, :source => :blog_post
@@ -9,11 +11,6 @@ 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::Blog.approximate_ascii,
- :strip_non_ascii => Refinery::Blog.strip_non_ascii
-
def post_count
posts.select(&:live?).count
end
diff --git a/app/models/refinery/blog/post.rb b/app/models/refinery/blog/post.rb
index 75911b9..b078272 100644
--- a/app/models/refinery/blog/post.rb
+++ b/app/models/refinery/blog/post.rb
@@ -4,6 +4,8 @@ require 'seo_meta'
module Refinery
module Blog
class Post < ActiveRecord::Base
+ extend FriendlyId
+ friendly_id :friendly_id_source, :use => [:slugged]
is_seo_meta if self.table_exists?
@@ -28,11 +30,6 @@ module Refinery
: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::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
diff --git a/db/migrate/20120227022021_add_slug_to_posts_and_categories.rb b/db/migrate/20120227022021_add_slug_to_posts_and_categories.rb
new file mode 100644
index 0000000..87d1291
--- /dev/null
+++ b/db/migrate/20120227022021_add_slug_to_posts_and_categories.rb
@@ -0,0 +1,9 @@
+class AddSlugToPostsAndCategories < ActiveRecord::Migration
+ def change
+ add_column Refinery::Blog::Post.table_name, :slug, :string
+ add_index Refinery::Blog::Post.table_name, :slug
+
+ add_column Refinery::Blog::Category.table_name, :slug, :string
+ add_index Refinery::Blog::Category.table_name, :slug
+ end
+end \ No newline at end of file
diff --git a/lib/generators/refinery/blog/templates/config/initializers/refinery/blog.rb.erb b/lib/generators/refinery/blog/templates/config/initializers/refinery/blog.rb.erb
index 8a2bc8e..ac340d7 100644
--- a/lib/generators/refinery/blog/templates/config/initializers/refinery/blog.rb.erb
+++ b/lib/generators/refinery/blog/templates/config/initializers/refinery/blog.rb.erb
@@ -7,9 +7,5 @@ Refinery::Blog.configure do |config|
# config.post_teaser_length = <%= Refinery::Blog.post_teaser_length.inspect %>
- # config.approximate_ascii = <%= Refinery::Blog.approximate_ascii.inspect %>
-
- # config.strip_non_ascii = <%= Refinery::Blog.strip_non_ascii.inspect %>
-
# config.share_this_key = <%= Refinery::Blog.share_this_key.inspect %>
end
diff --git a/lib/refinery/blog/configuration.rb b/lib/refinery/blog/configuration.rb
index 5780a3e..0f00501 100644
--- a/lib/refinery/blog/configuration.rb
+++ b/lib/refinery/blog/configuration.rb
@@ -3,14 +3,12 @@ module Refinery
include ActiveSupport::Configurable
config_accessor :validate_source_url, :comments_per_page, :posts_per_page,
- :post_teaser_length, :approximate_ascii, :strip_non_ascii, :share_this_key
+ :post_teaser_length, :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