Permalink
Browse files

Now supporting FriendlyId 4

  • Loading branch information...
1 parent 837ddfe commit 594dd8ca96f9a0e06dd28d2176653855e39a43e2 @parndt parndt committed Feb 27, 2012
View
@@ -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'
@@ -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 @@ class Category < ActiveRecord::Base
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
@@ -4,6 +4,8 @@
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 @@ class Post < ActiveRecord::Base
: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
@@ -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
@@ -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
@@ -3,14 +3,12 @@ module Blog
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

0 comments on commit 594dd8c

Please sign in to comment.