Skip to content

Commit

Permalink
routing change to match cms 1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
GBH committed Nov 5, 2013
1 parent 1c47b90 commit facada0
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 51 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ComfyBlog
[![Gem Version](https://badge.fury.io/rb/comfy_blog.png)](http://rubygems.org/gems/comfy_blog) [![Build Status](https://secure.travis-ci.org/comfy/comfy-blog.png)](http://travis-ci.org/comfy/comfy-blog) [![Dependency Status](https://gemnasium.com/comfy/comfy-blog.png)](https://gemnasium.com/comfy/comfy-blog) [![Code Climate](https://codeclimate.com/github/comfy/comfy-blog.png)](https://codeclimate.com/github/comfy/comfy-blog) [![Coverage Status](https://coveralls.io/repos/comfy/comfy-blog/badge.png?branch=master)](https://coveralls.io/r/comfy/comfy-blog)

ComfyBlog is an simple blog management engine for [ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa) (for version >= 1.10).
ComfyBlog is an simple blog management engine for [ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa) (for version >= 1.11).

## Features

Expand All @@ -13,7 +13,7 @@ ComfyBlog is an simple blog management engine for [ComfortableMexicanSofa](https
Add gem definition to your Gemfile:

```ruby
gem 'comfy_blog', '~> 1.0.0'
gem 'comfy_blog', '~> 1.1.0'
```

Then from the Rails project's root run:
Expand All @@ -25,8 +25,8 @@ Then from the Rails project's root run:
Take a look inside your `config/routes.rb` file and you should see following lines there:

```ruby
ComfyBlog::Routing.admin :path => 'admin'
ComfyBlog::Routing.content :path => 'blog'
comfy_route :blog_admin, :path => 'admin'
comfy_route :blog, :path => 'blog'
```

You should also find view templates in `/app/views/blog` folder. Feel free to adjust them as you see fit.
Expand Down
2 changes: 1 addition & 1 deletion comfy_blog.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.require_paths = ['lib']

s.add_dependency 'comfortable_mexican_sofa', '>= 1.10.0'
s.add_dependency 'comfortable_mexican_sofa', '>= 1.11.0'
end
8 changes: 4 additions & 4 deletions config/blog_routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ComfyBlog::Application.routes.draw do
ComfortableMexicanSofa::Routing.admin
ComfyBlog::Routing.admin
ComfyBlog::Routing.content
ComfortableMexicanSofa::Routing.content :sitemap => true
comfy_route :cms_admin
comfy_route :blog_admin
comfy_route :blog
comfy_route :cms, :sitemap => true
end
18 changes: 18 additions & 0 deletions lib/comfy_blog/routes/blog.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class ActionDispatch::Routing::Mapper

def comfy_route_blog(options = {})
options[:path] ||= 'blog'
path = ['(:cms_path)', options[:path], '(:blog_path)'].join('/')

namespace :blog, :path => path, :constraints => {:blog_path => /\w[a-z0-9_-]*/} do
with_options :constraints => {:year => /\d{4}/, :month => /\d{1,2}/} do |o|
o.get ':year' => 'posts#index', :as => :posts_of_year
o.get ':year/:month' => 'posts#index', :as => :posts_of_month
o.get ':year/:month/:slug' => 'posts#show', :as => :posts_dated
end
post ':slug/comments' => 'comments#create', :as => :comments
get ':slug' => 'posts#serve', :as => :post
get '/' => 'posts#serve', :as => :posts
end
end
end
18 changes: 18 additions & 0 deletions lib/comfy_blog/routes/blog_admin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class ActionDispatch::Routing::Mapper

def comfy_route_blog_admin(options = {})
options[:path] ||= 'admin'
path = [options[:path], 'sites', ':site_id'].join('/')

scope :module => :admin do
namespace :blog, :as => :admin, :path => path, :except => [:show] do
resources :blogs do
resources :posts
resources :comments, :only => [:index, :destroy] do
patch :toggle_publish, :on => :member
end
end
end
end
end
end
40 changes: 2 additions & 38 deletions lib/comfy_blog/routing.rb
Original file line number Diff line number Diff line change
@@ -1,38 +1,2 @@
module ComfyBlog::Routing

def self.admin(options = {})
options[:path] ||= 'admin'
path = [options[:path], 'sites', ':site_id'].join('/')

Rails.application.routes.draw do
scope :module => :admin do
namespace :blog, :as => :admin, :path => path, :except => [:show] do
resources :blogs do
resources :posts
resources :comments, :only => [:index, :destroy] do
patch :toggle_publish, :on => :member
end
end
end
end
end
end

def self.content(options = {})
options[:path] ||= 'blog'
path = ['(:cms_path)', options[:path], '(:blog_path)'].join('/')

Rails.application.routes.draw do
namespace :blog, :path => path, :constraints => {:blog_path => /\w[a-z0-9_-]*/} do
with_options :constraints => {:year => /\d{4}/, :month => /\d{1,2}/} do |o|
o.get ':year' => 'posts#index', :as => :posts_of_year
o.get ':year/:month' => 'posts#index', :as => :posts_of_month
o.get ':year/:month/:slug' => 'posts#show', :as => :posts_dated
end
post ':slug/comments' => 'comments#create', :as => :comments
get ':slug' => 'posts#serve', :as => :post
get '/' => 'posts#serve', :as => :posts
end
end
end
end
require_relative 'routes/blog_admin'
require_relative 'routes/blog'
4 changes: 2 additions & 2 deletions lib/generators/comfy/blog/blog_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def generate_initialization
end

def generate_routing
route_string = " ComfyBlog::Routing.admin :path => '/admin'\n"
route_string << " ComfyBlog::Routing.content :path => '/blog'\n"
route_string = " comfy_route :blog_admin, :path => '/admin'\n"
route_string << " comfy_route :blog, :path => '/blog'\n"
route route_string[2..-1]
end

Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/generators/blog/routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Test::Application.routes.draw do

ComfyBlog::Routing.admin :path => '/admin'
ComfyBlog::Routing.content :path => '/blog'
comfy_route :blog_admin, :path => '/admin'
comfy_route :blog, :path => '/blog'

end

0 comments on commit facada0

Please sign in to comment.