Browse Source

Moved to new router style.

Martin Edenhofer 11 years ago
parent
commit
04854f8b07

+ 3 - 0
config/application.rb

@@ -82,5 +82,8 @@ module Zammad
     # Enable threaded mode
     config.threadsafe!
 
+    # catch all router files
+    config.paths['config/routes'] += Dir[Rails.root.join("config/routes/*.rb")]
+
   end
 end

+ 1 - 8
config/routes.rb

@@ -8,11 +8,4 @@ Zammad::Application.routes.draw do
   # just remember to delete public/index.html.
   root :to => 'init#index', :via => :get
 
-  # load routes from external files
-  dir = File.expand_path('../', __FILE__)
-  files = Dir.glob( "#{dir}/routes/*.rb" )
-  for file in files
-    load file
-    ExtraRoutes.add(self, Rails.configuration.api_path)
-  end
-end
+end

+ 4 - 6
config/routes/activity_stream.rb

@@ -1,8 +1,6 @@
-module ExtraRoutes
-  def add(map, api_path)
+Zammad::Application.routes.draw do
+  api_path = Rails.configuration.api_path
 
-    map.match api_path + '/activity_stream',   :to => 'activity#activity_stream', :via => :get
+  match api_path + '/activity_stream',   :to => 'activity#activity_stream', :via => :get
 
-  end
-  module_function :add
-end
+end

+ 14 - 15
config/routes/auth.rb

@@ -1,19 +1,18 @@
-module ExtraRoutes
-  def add(map, api_path)
+Zammad::Application.routes.draw do
+  api_path = Rails.configuration.api_path
 
-    # omniauth
-    map.match '/auth/:provider/callback',       :to => 'sessions#create_omniauth',:via => [:post, :get, :puts, :delete]
+  # omniauth
+  match '/auth/:provider/callback',       :to => 'sessions#create_omniauth',:via => [:post, :get, :puts, :delete]
 
-    # sso
-    map.match '/auth/sso',                      :to => 'sessions#create_sso',     :via => [:post, :get]
+  # sso
+  match '/auth/sso',                      :to => 'sessions#create_sso',     :via => [:post, :get]
 
-    # sessions
-    map.match api_path + '/signin',        :to => 'sessions#create',         :via => :post
-    map.match api_path + '/signshow',      :to => 'sessions#show',           :via => :get
-    map.match api_path + '/signout',       :to => 'sessions#destroy',        :via => [:get, :delete]
+  # sessions
+  match api_path + '/signin',        :to => 'sessions#create',         :via => :post
+  match api_path + '/signshow',      :to => 'sessions#show',           :via => :get
+  match api_path + '/signout',       :to => 'sessions#destroy',        :via => [:get, :delete]
 
-    map.match api_path + '/sessions',      :to => 'sessions#list',           :via => :get
-    map.match api_path + '/sessions/:id',  :to => 'sessions#delete',         :via => :delete
-  end
-  module_function :add
-end
+  match api_path + '/sessions',      :to => 'sessions#list',           :via => :get
+  match api_path + '/sessions/:id',  :to => 'sessions#delete',         :via => :delete
+
+end

+ 8 - 10
config/routes/channel.rb

@@ -1,13 +1,11 @@
-module ExtraRoutes
-  def add(map, api_path)
+Zammad::Application.routes.draw do
+  api_path = Rails.configuration.api_path
 
-    # channels
-    map.match api_path + '/channels',                       :to => 'channels#index',   :via => :get
-    map.match api_path + '/channels/:id',                   :to => 'channels#show',    :via => :get
-    map.match api_path + '/channels',                       :to => 'channels#create',  :via => :post
-    map.match api_path + '/channels/:id',                   :to => 'channels#update',  :via => :put
-    map.match api_path + '/channels/:id',                   :to => 'channels#destroy', :via => :delete
+  # channels
+  match api_path + '/channels',                       :to => 'channels#index',   :via => :get
+  match api_path + '/channels/:id',                   :to => 'channels#show',    :via => :get
+  match api_path + '/channels',                       :to => 'channels#create',  :via => :post
+  match api_path + '/channels/:id',                   :to => 'channels#update',  :via => :put
+  match api_path + '/channels/:id',                   :to => 'channels#destroy', :via => :delete
 
-  end
-  module_function :add
 end

+ 7 - 9
config/routes/email_address.rb

@@ -1,12 +1,10 @@
-module ExtraRoutes
-  def add(map, api_path)
+Zammad::Application.routes.draw do
+  api_path = Rails.configuration.api_path
 
-    # groups
-    map.match api_path + '/email_addresses',                :to => 'email_addresses#index',  :via => :get
-    map.match api_path + '/email_addresses/:id',            :to => 'email_addresses#show',   :via => :get
-    map.match api_path + '/email_addresses',                :to => 'email_addresses#create', :via => :post
-    map.match api_path + '/email_addresses/:id',            :to => 'email_addresses#update', :via => :put
+  # groups
+  match api_path + '/email_addresses',                :to => 'email_addresses#index',  :via => :get
+  match api_path + '/email_addresses/:id',            :to => 'email_addresses#show',   :via => :get
+  match api_path + '/email_addresses',                :to => 'email_addresses#create', :via => :post
+  match api_path + '/email_addresses/:id',            :to => 'email_addresses#update', :via => :put
 
-  end
-  module_function :add
 end

+ 5 - 7
config/routes/getting_started.rb

@@ -1,9 +1,7 @@
-module ExtraRoutes
-  def add(map, api_path)
+Zammad::Application.routes.draw do
+  api_path = Rails.configuration.api_path
 
-    # getting_started
-    map.match api_path + '/getting_started',       :to => 'getting_started#index', :via => :get
+  # getting_started
+  match api_path + '/getting_started',       :to => 'getting_started#index', :via => :get
 
-  end
-  module_function :add
-end
+end

+ 7 - 9
config/routes/group.rb

@@ -1,12 +1,10 @@
-module ExtraRoutes
-  def add(map, api_path)
+Zammad::Application.routes.draw do
+  api_path = Rails.configuration.api_path
 
-    # groups
-    map.match api_path + '/groups',                     :to => 'groups#index',  :via => :get
-    map.match api_path + '/groups/:id',                 :to => 'groups#show',   :via => :get
-    map.match api_path + '/groups',                     :to => 'groups#create', :via => :post
-    map.match api_path + '/groups/:id',                 :to => 'groups#update', :via => :put
+  # groups
+  match api_path + '/groups',                     :to => 'groups#index',  :via => :get
+  match api_path + '/groups/:id',                 :to => 'groups#show',   :via => :get
+  match api_path + '/groups',                     :to => 'groups#create', :via => :post
+  match api_path + '/groups/:id',                 :to => 'groups#update', :via => :put
 
-  end
-  module_function :add
 end

+ 7 - 9
config/routes/link.rb

@@ -1,11 +1,9 @@
-module ExtraRoutes
-  def add(map, api_path)
+Zammad::Application.routes.draw do
+  api_path = Rails.configuration.api_path
 
-    # links
-    map.match api_path + '/links',             :to => 'links#index',   :via => :get
-    map.match api_path + '/links/add',         :to => 'links#add',     :via => :get
-    map.match api_path + '/links/remove',      :to => 'links#remove',  :via => :get
+  # links
+  match api_path + '/links',             :to => 'links#index',   :via => :get
+  match api_path + '/links/add',         :to => 'links#add',     :via => :get
+  match api_path + '/links/remove',      :to => 'links#remove',  :via => :get
 
-  end
-  module_function :add
-end
+end

+ 6 - 8
config/routes/message.rb

@@ -1,10 +1,8 @@
-module ExtraRoutes
-  def add(map, api_path)
+Zammad::Application.routes.draw do
+  api_path = Rails.configuration.api_path
 
-    # messages
-    map.match api_path + '/message_send',           :to => 'long_polling#message_send', :via => [ :get, :post ]
-    map.match api_path + '/message_receive',        :to => 'long_polling#message_receive', :via => [ :get, :post ]
+  # messages
+  match api_path + '/message_send',           :to => 'long_polling#message_send', :via => [ :get, :post ]
+  match api_path + '/message_receive',        :to => 'long_polling#message_receive', :via => [ :get, :post ]
 
-  end
-  module_function :add
-end
+end

Some files were not shown because too many files changed in this diff