aboutsummaryrefslogtreecommitdiffstats
path: root/config/routes.rb
blob: 2cb472384045955986e7a275f7faf52bed86b518 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
if Rails.version < '3.0.0'
  ActionController::Routing::Routes.draw do |map|
    map.namespace(:blog) do |blog|
      blog.rss_feed 'feed.rss', :controller => 'posts', :action => 'index', :format => 'rss'
      blog.root :controller => "posts", :action => 'index'
      blog.post ':id', :controller => "posts", :action => 'show'
      blog.category 'categories/:id', :controller => "categories", :action => 'show'
      blog.post_blog_comments ':id/comments', :controller => 'posts', :action => 'comment'

      ## what is the rails2 syntax for this? sorry ;__;
      # get 'archive/:year/:month', :to => 'posts#archive', :as => 'archive_blog_posts'
    end

    map.namespace(:admin, :path_prefix => 'refinery') do |admin|
      admin.namespace :blog do |blog|
        blog.resources :posts

        blog.resources :categories

        blog.resources :comments, :collection => {
          :approved => :get,
          :rejected => :get
        }, :member => {
          :approved => :get,
          :rejected => :get
        }

        blog.resources :settings, :collection => {
          :notification_recipients => [:get, :post],
          :moderation => :get
        }
      end
    end
  end
else
  Refinery::Application.routes.draw do
    scope(:path => 'blog', :module => 'blog') do
      root :to => 'posts#index', :as => 'blog_root'
      match 'feed.rss', :to => 'posts#index.rss', :as => 'blog_rss_feed'
      match ':id', :to => 'posts#show', :as => 'blog_post'
      match 'categories/:id', :to => 'categories#show', :as => 'blog_category'
      match ':id/comments', :to => 'posts#comment', :as => 'blog_post_blog_comments'
      get 'archive/:year/:month', :to => 'posts#archive', :as => 'archive_blog_posts'
    end

    scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
      scope(:path => 'blog', :as => 'blog', :module => 'blog') do
        root :to => 'posts#index'
        resources :posts

        resources :categories

        resources :comments do
          collection do
            get :approved
            get :rejected
          end
          member do
            get :approved
            get :rejected
          end
        end

        resources :settings do
          collection do
            get :notification_recipients
            post :notification_recipients

            get :moderation
          end
        end
      end
    end
  end
end