-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
51 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |