From 6767970bab4b32bdedba0183d3524ba020fd7108 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 20 Aug 2013 22:37:39 +0200 Subject: [PATCH 01/10] Capture js errors of clients. --- test/browser_test_helper.rb | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 903ae87cb..f07e7c4ef 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -52,11 +52,35 @@ class TestCase < Test::Unit::TestCase end end local_browser.manage.timeouts.implicit_wait = 3 # seconds + + browser_instance_js_on_start(local_browser) + end + + def browser_instance_js_on_start(instance) + instance.execute_script(' + window.jsErrors = []; + window.onerror = function(errorMessage) { + window.jsErrors.push(errorMessage); + };'); + end + + def browser_instance_js_on_teardown(instance) + result = instance.execute_script( 'return window.jsErrors;' ) + if result + puts 'JS ERRORS: ' + result.inspect + else + puts 'JS ERRORS: -none-' + end end def teardown return if !@browsers + # show js errors + @browsers.each{ |local_browser| + browser_instance_js_on_teardown(local_browser) + } + # only shut down browser type once on local webdriver tests # otherwise this error will happen "Errno::ECONNREFUSED: Connection refused - connect(2)" if !ENV['REMOTE_URL'] @@ -160,7 +184,7 @@ class TestCase < Test::Unit::TestCase end def browser_element_action(test, action, instance) -puts "NOTICE #{Time.now.to_s}: " + action.inspect + puts "NOTICE #{Time.now.to_s}: " + action.inspect sleep 0.1 if action[:css] if action[:css].match '###stack###' From 07677f297cd4a18ec36ac67874e82d14c70e6a3a Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 20 Aug 2013 23:11:59 +0200 Subject: [PATCH 02/10] Fixed race condition of loading collections. --- app/assets/javascripts/app/lib/app_post/auth.js.coffee | 8 ++++---- .../javascripts/app/lib/app_post/task_manager.js.coffee | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/app/lib/app_post/auth.js.coffee b/app/assets/javascripts/app/lib/app_post/auth.js.coffee index cc728c952..9a29ab087 100644 --- a/app/assets/javascripts/app/lib/app_post/auth.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/auth.js.coffee @@ -83,6 +83,10 @@ class App.Auth for key, value of data.session App.Session.set( key, value ) + # refresh default collections + for key, value of data.default_collections + App[key].refresh( value, options: { clear: true } ) + App.Event.trigger( 'auth', data.session ) # init of i18n @@ -93,10 +97,6 @@ class App.Auth locale = window.navigator.userLanguage || window.navigator.language || 'en' App.i18n.set( locale ) - # refresh default collections - for key, value of data.default_collections - App[key].refresh( value, options: { clear: true } ) - App.Event.trigger( 'auth:login', data.session ) App.Event.trigger( 'ui:rerender' ) diff --git a/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee b/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee index 421559059..32c82f955 100644 --- a/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee @@ -371,7 +371,7 @@ class _taskManagerSingleton extends App.Controller # reopen tasks App.Event.trigger 'taskbar:init' - task_count = 0 + task_count = 1 for task in @allTasks task_count += 1 console.log('START', task) From aeb288d5e5f107e52bea097e6cab81cf23687e5a Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 21 Aug 2013 01:54:16 +0200 Subject: [PATCH 03/10] Fixed race conditions. --- .../controllers/agent_ticket_create.js.coffee | 7 +++++- .../app/controllers/ticket_zoom.js.coffee | 23 +++++++++---------- .../app/lib/app_post/task_manager.js.coffee | 18 +++++++-------- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee index 93498db1a..a9be66fb5 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee @@ -57,7 +57,12 @@ class App.TicketCreate extends App.Controller meta: => text = App.i18n.translateInline( @article_attributes['title'] ) - subject = @el.find('[name=subject]').val() + if !@_initMetaDone + @_initMetaDone = true + state = App.TaskManager.get(@task_key).state + subject = state['subject'] + else + subject = @el.find('[name=subject]').val() if subject text = "#{text}: #{subject}" meta = diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee index 3b7b8aae5..d6d6633af 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee @@ -35,16 +35,18 @@ class App.TicketZoom extends App.Controller ) meta: => - return if !@ticket - ticket = App.Ticket.retrieve( @ticket.id ) meta = url: @url() - head: ticket.title - title: '#' + ticket.number + ' - ' + ticket.title - id: ticket.id + head: '???' + title: '???' + id: @ticket_id + if @ticket + meta.head = @ticket.title + meta.title = '#' + @ticket.number + ' - ' + @ticket.title + meta url: => - '#ticket/zoom/' + @ticket.id + '#ticket/zoom/' + @ticket_id activate: => @navupdate '#' @@ -106,9 +108,6 @@ class App.TicketZoom extends App.Controller load: (data, force) => - # reset old indexes - @ticket = undefined - # remember article ids @ticket_article_ids = data.ticket_article_ids @@ -121,14 +120,14 @@ class App.TicketZoom extends App.Controller # load collections App.Event.trigger 'loadAssets', data.assets + # get data + @ticket = App.Ticket.retrieve( @ticket_id ) + # render page @render(force) render: (force) => - # get data - @ticket = App.Ticket.retrieve( @ticket_id ) - # update taskbar with new meta data App.Event.trigger 'task:render' if !@renderDone diff --git a/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee b/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee index 32c82f955..84d95edf5 100644 --- a/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee @@ -371,18 +371,18 @@ class _taskManagerSingleton extends App.Controller # reopen tasks App.Event.trigger 'taskbar:init' - task_count = 1 + task_count = 0 for task in @allTasks task_count += 1 console.log('START', task) - App.Delay.set( - => - task = tasks.shift() - @add(task.key, task.callback, task.params, true) - task_count * 300 - undefined - 'task' - ) + do (task) => + App.Delay.set( + => + @add(task.key, task.callback, task.params, true) + task_count * 300 + undefined + 'task' + ) App.Event.trigger 'taskbar:ready' From 35ffe2c6ddb13994ea7e65b70edfd8e21cc9653b Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 21 Aug 2013 10:55:35 +0200 Subject: [PATCH 04/10] Improved collecting of meta data, fixed race condition. --- .../app/controllers/agent_ticket_create.js.coffee | 7 +------ .../javascripts/app/controllers/task_widget.js.coffee | 9 ++++++++- .../javascripts/app/controllers/ticket_zoom.js.coffee | 8 +++----- .../javascripts/app/lib/app_post/task_manager.js.coffee | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee index a9be66fb5..93498db1a 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee @@ -57,12 +57,7 @@ class App.TicketCreate extends App.Controller meta: => text = App.i18n.translateInline( @article_attributes['title'] ) - if !@_initMetaDone - @_initMetaDone = true - state = App.TaskManager.get(@task_key).state - subject = state['subject'] - else - subject = @el.find('[name=subject]').val() + subject = @el.find('[name=subject]').val() if subject text = "#{text}: #{subject}" meta = diff --git a/app/assets/javascripts/app/controllers/task_widget.js.coffee b/app/assets/javascripts/app/controllers/task_widget.js.coffee index 3936f16bf..2622091ef 100644 --- a/app/assets/javascripts/app/controllers/task_widget.js.coffee +++ b/app/assets/javascripts/app/controllers/task_widget.js.coffee @@ -120,6 +120,8 @@ class Taskbar extends App.Controller tasks = App.TaskManager.all() item_list = [] for task in tasks + + # collect meta data of task for task bar item data = url: '#' id: false @@ -128,8 +130,13 @@ class Taskbar extends App.Controller worker = App.TaskManager.worker( task.key ) if worker meta = worker.meta() + + # apply meta data of controller if meta - data = meta + for key, value of meta + data[key] = value + + # collect new task bar items item = {} item.task = task item.data = data diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee index d6d6633af..e18145b67 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee @@ -36,10 +36,8 @@ class App.TicketZoom extends App.Controller meta: => meta = - url: @url() - head: '???' - title: '???' - id: @ticket_id + url: @url() + id: @ticket_id if @ticket meta.head = @ticket.title meta.title = '#' + @ticket.number + ' - ' + @ticket.title @@ -428,7 +426,7 @@ class Edit extends App.Controller @el.find('.ticket-update').parent().addClass('form-changed') @el.find('.ticket-update').parent().parent().find('.reset-message').show() App.TaskManager.update( @task_key, { 'state': currentData }) - @interval( update, 2800, 'autosave' ) + @interval( update, 3000, 'autosave' ) update: (e) => e.preventDefault() diff --git a/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee b/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee index 84d95edf5..264cbd403 100644 --- a/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee @@ -379,7 +379,7 @@ class _taskManagerSingleton extends App.Controller App.Delay.set( => @add(task.key, task.callback, task.params, true) - task_count * 300 + task_count * 900 undefined 'task' ) From bfc6db9f20f774f53e0b41fd17edfe93cb963c8a Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 21 Aug 2013 11:17:04 +0200 Subject: [PATCH 05/10] Do not overwrite already existing window.onerror if exists. --- .../app/lib/app_init/track.js.coffee | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/app/lib/app_init/track.js.coffee b/app/assets/javascripts/app/lib/app_init/track.js.coffee index e1e1209ba..b045f4750 100644 --- a/app/assets/javascripts/app/lib/app_init/track.js.coffee +++ b/app/assets/javascripts/app/lib/app_init/track.js.coffee @@ -29,10 +29,10 @@ class _trackSingleton @log( 'start', 'notice', {} ) - # start initial submit 10 sec. later to avoid ie10 cookie issues + # start initial submit 30 sec. later to avoid ie10 cookie issues delay = => - App.Interval.set @send, 60000 - App.Delay.set delay, 10000 + App.Interval.set @send, 80000 + App.Delay.set delay, 30000 # log clicks $(document).bind( @@ -139,9 +139,15 @@ class _trackSingleton @data ` -window.onerror = function(errorMsg, url, lineNumber) { - console.error(errorMsg + " - in " + url + ", line " + lineNumber); -}; +(function() { + window.onerrorOld = window.onerror + window.onerror = function(errorMsg, url, lineNumber) { + console.error(errorMsg + " - in " + url + ", line " + lineNumber); + if (window.onerrorOld) { + window.onerrorOld(errorMsg, url, lineNumber); + } + } +}).call(this); (function() { var console = window.console From 11ab38b96435e85bb2c1b69269af22772da9afce Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 21 Aug 2013 11:18:17 +0200 Subject: [PATCH 06/10] Replaced require with load to check if sporadic 404 in develop will go. --- config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index 251d53340..ba2c772e9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,7 +12,7 @@ Zammad::Application.routes.draw do dir = File.expand_path('../', __FILE__) files = Dir.glob( "#{dir}/routes/*.rb" ) for file in files - require file + load file ExtraRoutes.add(self, Rails.configuration.api_path) end end From 9392b5a21ce4048c776dcb12bbf2e045fe030d1a Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 21 Aug 2013 11:18:34 +0200 Subject: [PATCH 07/10] Small code layout improvement. --- config/routes/ticket.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/routes/ticket.rb b/config/routes/ticket.rb index 2924d6564..4e3297efa 100644 --- a/config/routes/ticket.rb +++ b/config/routes/ticket.rb @@ -15,7 +15,7 @@ module ExtraRoutes map.match api_path + '/ticket_merge/:slave_ticket_id/:master_ticket_number', :to => 'tickets#ticket_merge', :via => :get # ticket overviews - map.match api_path + '/ticket_overviews', :to => 'ticket_overviews#show', :via => :get + map.match api_path + '/ticket_overviews', :to => 'ticket_overviews#show', :via => :get # ticket priority map.match api_path + '/ticket_priorities', :to => 'ticket_priorities#index', :via => :get From 977acf0a52b4cf06ec3457d68dff5fe9d8bf6342 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 21 Aug 2013 11:54:07 +0200 Subject: [PATCH 08/10] Added custom log. --- app/controllers/application_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9215386e3..c37b92707 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -14,7 +14,7 @@ class ApplicationController < ActionController::Base :mode_show_rendeder, :model_index_render - before_filter :set_user, :session_update + before_filter :log_request, :set_user, :session_update before_filter :cors_preflight_check after_filter :set_access_control_headers @@ -52,6 +52,10 @@ class ApplicationController < ActionController::Base Observer::Ticket::Notification.transaction end + def log_request + puts Time.now().to_s + ' ' + request.original_fullpath.to_s + end + # Finds the User with the ID stored in the session with the key # :current_user_id This is a common way to handle user login in # a Rails application; logging in sets the session value and From 0eccb81fbc74145c7f3c2546e987c7b8d40ba038 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 21 Aug 2013 20:35:22 +0200 Subject: [PATCH 09/10] Renamed Session module to Sessions to avoid conflicts with active record Session module. --- app/controllers/long_polling_controller.rb | 24 ++++++++--------- .../ticket_overviews_controller.rb | 2 ++ app/models/application_model.rb | 8 +++--- lib/{session.rb => sessions.rb} | 12 ++++----- script/websocket-server.rb | 26 +++++++++---------- 5 files changed, 37 insertions(+), 35 deletions(-) rename lib/{session.rb => sessions.rb} (99%) diff --git a/app/controllers/long_polling_controller.rb b/app/controllers/long_polling_controller.rb index 5903af634..ae4590672 100644 --- a/app/controllers/long_polling_controller.rb +++ b/app/controllers/long_polling_controller.rb @@ -26,7 +26,7 @@ class LongPollingController < ApplicationController # spool messages for new connects if params['data']['spool'] msg = JSON.generate( params['data'] ) - Session.spool_create(msg) + Sessions.spool_create(msg) end # get spool messages and send them to new client connection @@ -40,14 +40,14 @@ class LongPollingController < ApplicationController end if current_user - spool = Session.spool_list( params['data']['timestamp'], current_user.id ) + spool = Sessions.spool_list( params['data']['timestamp'], current_user.id ) spool.each { |item| if item[:type] == 'direct' log 'notice', "send spool to (user_id=#{ current_user.id })", client_id - Session.send( client_id, item[:message] ) + Sessions.send( client_id, item[:message] ) else log 'notice', "send spool", client_id - Session.send( client_id, item[:message] ) + Sessions.send( client_id, item[:message] ) end } end @@ -55,7 +55,7 @@ class LongPollingController < ApplicationController # send spool:sent event to client sleep 0.2 log 'notice', "send spool:sent event", client_id - Session.send( client_id, { :event => 'spool:sent', :data => { :timestamp => Time.now.utc.to_i } } ) + Sessions.send( client_id, { :event => 'spool:sent', :data => { :timestamp => Time.now.utc.to_i } } ) end @@ -67,13 +67,13 @@ class LongPollingController < ApplicationController user = User.user_data_full( user_id ) end log 'notice', "send auth login (user_id #{user_id})", client_id - Session.create( client_id, user, { :type => 'ajax' } ) + Sessions.create( client_id, user, { :type => 'ajax' } ) # broadcast elsif params['data']['action'] == 'broadcast' # list all current clients - client_list = Session.list + client_list = Sessions.list client_list.each {|local_client_id, local_client| if local_client_id != client_id @@ -82,13 +82,13 @@ class LongPollingController < ApplicationController params['data']['recipient']['user_id'].each { |user_id| if local_client[:user][:id] == user_id log 'notice', "send broadcast from (#{client_id.to_s}) to (user_id #{user_id})", local_client_id - Session.send( local_client_id, params['data'] ) + Sessions.send( local_client_id, params['data'] ) end } # broadcast every client else log 'notice', "send broadcast from (#{client_id.to_s})", local_client_id - Session.send( local_client_id, params['data'] ) + Sessions.send( local_client_id, params['data'] ) end else log 'notice', "do not send broadcast to it self", client_id @@ -119,13 +119,13 @@ class LongPollingController < ApplicationController # update last ping sleep 1 - Session.touch( client_id ) + Sessions.touch( client_id ) # set max loop time to 24 sec. because of 30 sec. timeout of mod_proxy count = 12 while true count = count - 1 - queue = Session.queue( client_id ) + queue = Sessions.queue( client_id ) if queue && queue[0] # puts "send " + queue.inspect + client_id.to_s render :json => queue @@ -155,7 +155,7 @@ class LongPollingController < ApplicationController end def client_id_verify return if !params[:client_id] - sessions = Session.sessions + sessions = Sessions.sessions return if !sessions.include?( params[:client_id].to_s ) return true end diff --git a/app/controllers/ticket_overviews_controller.rb b/app/controllers/ticket_overviews_controller.rb index c0f38de75..9433334c4 100644 --- a/app/controllers/ticket_overviews_controller.rb +++ b/app/controllers/ticket_overviews_controller.rb @@ -1,5 +1,7 @@ # Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +require 'ticket/overviews' + class TicketOverviewsController < ApplicationController before_filter :authentication_check diff --git a/app/models/application_model.rb b/app/models/application_model.rb index 5ddeb65e5..b591d47f8 100644 --- a/app/models/application_model.rb +++ b/app/models/application_model.rb @@ -2,7 +2,7 @@ require 'cache' require 'user_info' -require 'session' +require 'sessions' class ApplicationModel < ActiveRecord::Base self.abstract_class = true @@ -340,7 +340,7 @@ class OwnModel < ApplicationModel class_name = self.class.name class_name.gsub!(/::/, '') - Session.broadcast( + Sessions.broadcast( :event => class_name + ':created', :data => { :id => self.id, :updated_at => self.updated_at } ) @@ -368,7 +368,7 @@ class OwnModel < ApplicationModel puts "#{self.class.name.downcase} UPDATED " + self.updated_at.to_s class_name = self.class.name class_name.gsub!(/::/, '') - Session.broadcast( + Sessions.broadcast( :event => class_name + ':updated', :data => { :id => self.id, :updated_at => self.updated_at } ) @@ -395,7 +395,7 @@ class OwnModel < ApplicationModel puts "#{self.class.name.downcase} DESTOY " + self.updated_at.to_s class_name = self.class.name class_name.gsub!(/::/, '') - Session.broadcast( + Sessions.broadcast( :event => class_name + ':destroy', :data => { :id => self.id, :updated_at => self.updated_at } ) diff --git a/lib/session.rb b/lib/sessions.rb similarity index 99% rename from lib/session.rb rename to lib/sessions.rb index 2b2f8b2f2..4c6f98903 100644 --- a/lib/session.rb +++ b/lib/sessions.rb @@ -2,7 +2,7 @@ require 'json' require 'rss' require 'session_helper' -module Session +module Sessions # get application root directory @root = Dir.pwd.to_s @@ -205,7 +205,7 @@ module Session next if @@client_threads[client_id] # get current user - session_data = Session.get( client_id ) + session_data = Sessions.get( client_id ) next if !session_data next if !session_data[:user] next if !session_data[:user][:id] @@ -272,7 +272,7 @@ module Session files.sort.each {|entry| filename = path + '/' + entry if /^send/.match( entry ) - data.push Session.queue_file( path, entry ) + data.push Sessions.queue_file( path, entry ) end } return data @@ -297,7 +297,7 @@ module Session # list all current clients client_list = self.list client_list.each {|local_client_id, local_client| - Session.send( local_client_id, data ) + Sessions.send( local_client_id, data ) } return true end @@ -552,7 +552,7 @@ class ClientState while true # get connection user - session_data = Session.get( @client_id ) + session_data = Sessions.get( @client_id ) return if !session_data return if !session_data[:user] return if !session_data[:user][:id] @@ -849,7 +849,7 @@ class ClientState # send update to browser def send( data ) - Session.send( @client_id, data ) + Sessions.send( @client_id, data ) end def log( level, data ) diff --git a/script/websocket-server.rb b/script/websocket-server.rb index 449c5a1e5..2b487b54c 100755 --- a/script/websocket-server.rb +++ b/script/websocket-server.rb @@ -8,7 +8,7 @@ require 'eventmachine' require 'em-websocket' require 'json' require 'fileutils' -require 'session' +require 'sessions' require 'optparse' require 'daemons' @@ -91,7 +91,7 @@ EventMachine.run { ws.onopen { client_id = ws.object_id.to_s log 'notice', 'Client connected.', client_id - Session.create( client_id, {}, { :type => 'websocket' } ) + Sessions.create( client_id, {}, { :type => 'websocket' } ) if !@clients.include? client_id @clients[client_id] = { @@ -112,7 +112,7 @@ EventMachine.run { @clients.delete client_id end - Session.destory( client_id ) + Sessions.destory( client_id ) } # manage messages @@ -132,7 +132,7 @@ EventMachine.run { # spool messages for new connects if data['spool'] - Session.spool_create(msg) + Sessions.spool_create(msg) end # get spool messages and send them to new client connection @@ -146,7 +146,7 @@ EventMachine.run { end if @clients[client_id] && @clients[client_id][:session] && @clients[client_id][:session]['id'] - spool = Session.spool_list( data['timestamp'], @clients[client_id][:session]['id'] ) + spool = Sessions.spool_list( data['timestamp'], @clients[client_id][:session]['id'] ) spool.each { |item| # create new msg to push to client @@ -171,7 +171,7 @@ EventMachine.run { # get session if data['action'] == 'login' @clients[client_id][:session] = data['session'] - Session.create( client_id, data['session'], { :type => 'websocket' } ) + Sessions.create( client_id, data['session'], { :type => 'websocket' } ) # remember ping, send pong back elsif data['action'] == 'ping' @@ -182,7 +182,7 @@ EventMachine.run { elsif data['action'] == 'broadcast' # list all current clients - client_list = Session.list + client_list = Sessions.list client_list.each {|local_client_id, local_client| if local_client_id != client_id @@ -203,7 +203,7 @@ EventMachine.run { if local_client[:meta][:type] == 'websocket' && @clients[ local_client_id ] @clients[ local_client_id ][:websocket].send( "[#{msg}]" ) else - Session.send( local_client_id, data ) + Sessions.send( local_client_id, data ) end end } @@ -217,7 +217,7 @@ EventMachine.run { if local_client[:meta][:type] == 'websocket' && @clients[ local_client_id ] @clients[ local_client_id ][:websocket].send( "[#{msg}]" ) else - Session.send( local_client_id, data ) + Sessions.send( local_client_id, data ) end end else @@ -247,7 +247,7 @@ EventMachine.run { } # ajax - client_list = Session.list + client_list = Sessions.list clients = 0 client_list.each {|client_id, client| next if client[:meta][:type] == 'websocket' @@ -268,7 +268,7 @@ EventMachine.run { next if client[:disconnect] log 'debug', 'checking for data...', client_id begin - queue = Session.queue( client_id ) + queue = Sessions.queue( client_id ) if queue && queue[0] # log "send " + queue.inspect, client_id log 'notice', "send data to client", client_id @@ -312,12 +312,12 @@ EventMachine.run { } # ajax - clients = Session.list + clients = Sessions.list clients.each { |client_id, client| next if client[:meta][:type] == 'websocket' if ( client[:meta][:last_ping].to_i + ( 60 * idle_time_in_min ) ) < Time.now.to_i log 'notice', "closing idle ajax connection", client_id - Session.destory( client_id ) + Sessions.destory( client_id ) end } end From 04854f8b075fd117a1f9cbf3f9849eff493f856e Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 21 Aug 2013 21:16:42 +0200 Subject: [PATCH 10/10] Moved to new router style. --- config/application.rb | 3 ++ config/routes.rb | 9 +--- config/routes/activity_stream.rb | 10 ++--- config/routes/auth.rb | 29 ++++++------ config/routes/channel.rb | 18 ++++---- config/routes/email_address.rb | 16 +++---- config/routes/getting_started.rb | 12 +++-- config/routes/group.rb | 16 +++---- config/routes/link.rb | 16 +++---- config/routes/message.rb | 14 +++--- config/routes/network.rb | 18 ++++---- config/routes/organization.rb | 18 ++++---- config/routes/overview.rb | 18 ++++---- config/routes/package.rb | 14 +++--- config/routes/postmaster_filter.rb | 18 ++++---- config/routes/recent_viewed.rb | 11 ++--- config/routes/role.rb | 16 +++---- config/routes/rss.rb | 12 +++-- config/routes/search.rb | 10 ++--- config/routes/setting.rb | 18 ++++---- config/routes/signature.rb | 18 ++++---- config/routes/sla.rb | 18 ++++---- config/routes/tag.rb | 16 +++---- config/routes/taskbar.rb | 20 ++++----- config/routes/template.rb | 18 ++++---- config/routes/test.rb | 13 +++--- config/routes/text_module.rb | 18 ++++---- config/routes/ticket.rb | 72 +++++++++++++++--------------- config/routes/translation.rb | 21 +++++---- config/routes/user.rb | 28 ++++++------ 30 files changed, 240 insertions(+), 298 deletions(-) diff --git a/config/application.rb b/config/application.rb index 4620f22aa..660fa2180 100644 --- a/config/application.rb +++ b/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 diff --git a/config/routes.rb b/config/routes.rb index ba2c772e9..ecf3f32e4 100644 --- a/config/routes.rb +++ b/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 \ No newline at end of file diff --git a/config/routes/activity_stream.rb b/config/routes/activity_stream.rb index fc2471628..d43837358 100644 --- a/config/routes/activity_stream.rb +++ b/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 \ No newline at end of file diff --git a/config/routes/auth.rb b/config/routes/auth.rb index 5cd782898..e8098fbb3 100644 --- a/config/routes/auth.rb +++ b/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 \ No newline at end of file diff --git a/config/routes/channel.rb b/config/routes/channel.rb index be37a5949..2939a3773 100644 --- a/config/routes/channel.rb +++ b/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 \ No newline at end of file diff --git a/config/routes/email_address.rb b/config/routes/email_address.rb index 6b61c6a20..986bb2f26 100644 --- a/config/routes/email_address.rb +++ b/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 \ No newline at end of file diff --git a/config/routes/getting_started.rb b/config/routes/getting_started.rb index c6444a37e..398b61da7 100644 --- a/config/routes/getting_started.rb +++ b/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 \ No newline at end of file diff --git a/config/routes/group.rb b/config/routes/group.rb index 0f5e50caa..1ae094968 100644 --- a/config/routes/group.rb +++ b/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 \ No newline at end of file diff --git a/config/routes/link.rb b/config/routes/link.rb index 3a2c09526..4db9d8283 100644 --- a/config/routes/link.rb +++ b/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 \ No newline at end of file diff --git a/config/routes/message.rb b/config/routes/message.rb index 10acb3d3f..4071ff9eb 100644 --- a/config/routes/message.rb +++ b/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 \ No newline at end of file diff --git a/config/routes/network.rb b/config/routes/network.rb index b0e41d99e..a54cca873 100644 --- a/config/routes/network.rb +++ b/config/routes/network.rb @@ -1,13 +1,11 @@ -module ExtraRoutes - def add(map, api_path) +Zammad::Application.routes.draw do + api_path = Rails.configuration.api_path - # networkss - map.match api_path + '/networks', :to => 'networks#index', :via => :get - map.match api_path + '/networks/:id', :to => 'networks#show', :via => :get - map.match api_path + '/networks', :to => 'networks#create', :via => :post - map.match api_path + '/networks/:id', :to => 'networks#update', :via => :put - map.match api_path + '/networks/:id', :to => 'networks#destroy',:via => :delete + # networkss + match api_path + '/networks', :to => 'networks#index', :via => :get + match api_path + '/networks/:id', :to => 'networks#show', :via => :get + match api_path + '/networks', :to => 'networks#create', :via => :post + match api_path + '/networks/:id', :to => 'networks#update', :via => :put + match api_path + '/networks/:id', :to => 'networks#destroy',:via => :delete - end - module_function :add end \ No newline at end of file diff --git a/config/routes/organization.rb b/config/routes/organization.rb index de3471da9..444749c0a 100644 --- a/config/routes/organization.rb +++ b/config/routes/organization.rb @@ -1,12 +1,10 @@ -module ExtraRoutes - def add(map, api_path) +Zammad::Application.routes.draw do + api_path = Rails.configuration.api_path - # organizations - map.match api_path + '/organizations', :to => 'organizations#index', :via => :get - map.match api_path + '/organizations/:id', :to => 'organizations#show', :via => :get - map.match api_path + '/organizations', :to => 'organizations#create', :via => :post - map.match api_path + '/organizations/:id', :to => 'organizations#update', :via => :put + # organizations + match api_path + '/organizations', :to => 'organizations#index', :via => :get + match api_path + '/organizations/:id', :to => 'organizations#show', :via => :get + match api_path + '/organizations', :to => 'organizations#create', :via => :post + match api_path + '/organizations/:id', :to => 'organizations#update', :via => :put - end - module_function :add -end +end \ No newline at end of file diff --git a/config/routes/overview.rb b/config/routes/overview.rb index 0483f2ae7..819a806a8 100644 --- a/config/routes/overview.rb +++ b/config/routes/overview.rb @@ -1,13 +1,11 @@ -module ExtraRoutes - def add(map, api_path) +Zammad::Application.routes.draw do + api_path = Rails.configuration.api_path - # overviews - map.match api_path + '/overviews', :to => 'overviews#index', :via => :get - map.match api_path + '/overviews/:id', :to => 'overviews#show', :via => :get - map.match api_path + '/overviews', :to => 'overviews#create', :via => :post - map.match api_path + '/overviews/:id', :to => 'overviews#update', :via => :put - map.match api_path + '/overviews/:id', :to => 'overviews#destroy', :via => :delete + # overviews + match api_path + '/overviews', :to => 'overviews#index', :via => :get + match api_path + '/overviews/:id', :to => 'overviews#show', :via => :get + match api_path + '/overviews', :to => 'overviews#create', :via => :post + match api_path + '/overviews/:id', :to => 'overviews#update', :via => :put + match api_path + '/overviews/:id', :to => 'overviews#destroy', :via => :delete - end - module_function :add end \ No newline at end of file diff --git a/config/routes/package.rb b/config/routes/package.rb index 3bec7c136..6ea4ff9ab 100644 --- a/config/routes/package.rb +++ b/config/routes/package.rb @@ -1,11 +1,9 @@ -module ExtraRoutes - def add(map, api_path) +Zammad::Application.routes.draw do + api_path = Rails.configuration.api_path - # overviews - map.match api_path + '/packages', :to => 'packages#index', :via => :get - map.match api_path + '/packages', :to => 'packages#install', :via => :post - map.match api_path + '/packages', :to => 'packages#uninstall', :via => :delete + # overviews + match api_path + '/packages', :to => 'packages#index', :via => :get + match api_path + '/packages', :to => 'packages#install', :via => :post + match api_path + '/packages', :to => 'packages#uninstall', :via => :delete - end - module_function :add end \ No newline at end of file diff --git a/config/routes/postmaster_filter.rb b/config/routes/postmaster_filter.rb index 04251d14b..b8b9dd35f 100644 --- a/config/routes/postmaster_filter.rb +++ b/config/routes/postmaster_filter.rb @@ -1,13 +1,11 @@ -module ExtraRoutes - def add(map, api_path) +Zammad::Application.routes.draw do + api_path = Rails.configuration.api_path - # postmaster_filters - map.match api_path + '/postmaster_filters', :to => 'postmaster_filters#index', :via => :get - map.match api_path + '/postmaster_filters/:id', :to => 'postmaster_filters#show', :via => :get - map.match api_path + '/postmaster_filters', :to => 'postmaster_filters#create', :via => :post - map.match api_path + '/postmaster_filters/:id', :to => 'postmaster_filters#update', :via => :put - map.match api_path + '/postmaster_filters/:id', :to => 'postmaster_filters#destroy', :via => :delete + # postmaster_filters + match api_path + '/postmaster_filters', :to => 'postmaster_filters#index', :via => :get + match api_path + '/postmaster_filters/:id', :to => 'postmaster_filters#show', :via => :get + match api_path + '/postmaster_filters', :to => 'postmaster_filters#create', :via => :post + match api_path + '/postmaster_filters/:id', :to => 'postmaster_filters#update', :via => :put + match api_path + '/postmaster_filters/:id', :to => 'postmaster_filters#destroy', :via => :delete - end - module_function :add end \ No newline at end of file diff --git a/config/routes/recent_viewed.rb b/config/routes/recent_viewed.rb index cf1ef4c9b..ed388e9dd 100644 --- a/config/routes/recent_viewed.rb +++ b/config/routes/recent_viewed.rb @@ -1,8 +1,5 @@ -module ExtraRoutes - def add(map, api_path) +Zammad::Application.routes.draw do + api_path = Rails.configuration.api_path - map.match api_path + '/recent_viewed', :to => 'recent_viewed#recent_viewed', :via => :get - - end - module_function :add -end + match api_path + '/recent_viewed', :to => 'recent_viewed#recent_viewed', :via => :get +end \ No newline at end of file diff --git a/config/routes/role.rb b/config/routes/role.rb index 621e02924..81c0596fc 100644 --- a/config/routes/role.rb +++ b/config/routes/role.rb @@ -1,12 +1,10 @@ -module ExtraRoutes - def add(map, api_path) +Zammad::Application.routes.draw do + api_path = Rails.configuration.api_path - # roles - map.match api_path + '/roles', :to => 'roles#index', :via => :get - map.match api_path + '/roles/:id', :to => 'roles#show', :via => :get - map.match api_path + '/roles', :to => 'roles#create', :via => :post - map.match api_path + '/roles/:id', :to => 'roles#update', :via => :put + # roles + match api_path + '/roles', :to => 'roles#index', :via => :get + match api_path + '/roles/:id', :to => 'roles#show', :via => :get + match api_path + '/roles', :to => 'roles#create', :via => :post + match api_path + '/roles/:id', :to => 'roles#update', :via => :put - end - module_function :add end \ No newline at end of file diff --git a/config/routes/rss.rb b/config/routes/rss.rb index ff31463c6..aff1aa2fd 100644 --- a/config/routes/rss.rb +++ b/config/routes/rss.rb @@ -1,9 +1,7 @@ -module ExtraRoutes - def add(map, api_path) +Zammad::Application.routes.draw do + api_path = Rails.configuration.api_path - # rss - map.match api_path + '/rss_fetch', :to => 'rss#fetch', :via => :get + # rss + match api_path + '/rss_fetch', :to => 'rss#fetch', :via => :get - end - module_function :add -end +end \ No newline at end of file diff --git a/config/routes/search.rb b/config/routes/search.rb index f28e8c963..ed877fd92 100644 --- a/config/routes/search.rb +++ b/config/routes/search.rb @@ -1,9 +1,7 @@ -module ExtraRoutes - def add(map, api_path) +Zammad::Application.routes.draw do + api_path = Rails.configuration.api_path - # search - map.match api_path + '/search', :to => 'search#search', :via => [:get, :post] + # search + match api_path + '/search', :to => 'search#search', :via => [:get, :post] - end - module_function :add end \ No newline at end of file diff --git a/config/routes/setting.rb b/config/routes/setting.rb index 0e9d7d5b8..ad739dc72 100644 --- a/config/routes/setting.rb +++ b/config/routes/setting.rb @@ -1,13 +1,11 @@ -module ExtraRoutes - def add(map, api_path) +Zammad::Application.routes.draw do + api_path = Rails.configuration.api_path - # base objects - map.match api_path + '/settings', :to => 'settings#index', :via => :get - map.match api_path + '/settings/:id', :to => 'settings#show', :via => :get - map.match api_path + '/settings', :to => 'settings#create', :via => :post - map.match api_path + '/settings/:id', :to => 'settings#update', :via => :put - map.match api_path + '/settings/:id', :to => 'settings#destroy', :via => :delete + # base objects + match api_path + '/settings', :to => 'settings#index', :via => :get + match api_path + '/settings/:id', :to => 'settings#show', :via => :get + match api_path + '/settings', :to => 'settings#create', :via => :post + match api_path + '/settings/:id', :to => 'settings#update', :via => :put + match api_path + '/settings/:id', :to => 'settings#destroy', :via => :delete - end - module_function :add end \ No newline at end of file diff --git a/config/routes/signature.rb b/config/routes/signature.rb index b4e21d2e7..a771634e3 100644 --- a/config/routes/signature.rb +++ b/config/routes/signature.rb @@ -1,13 +1,11 @@ -module ExtraRoutes - def add(map, api_path) +Zammad::Application.routes.draw do + api_path = Rails.configuration.api_path - # signatures - map.match api_path + '/signatures', :to => 'signatures#index', :via => :get - map.match api_path + '/signatures/:id', :to => 'signatures#show', :via => :get - map.match api_path + '/signatures', :to => 'signatures#create', :via => :post - map.match api_path + '/signatures/:id', :to => 'signatures#update', :via => :put - map.match api_path + '/signatures/:id', :to => 'signatures#destroy', :via => :delete + # signatures + match api_path + '/signatures', :to => 'signatures#index', :via => :get + match api_path + '/signatures/:id', :to => 'signatures#show', :via => :get + match api_path + '/signatures', :to => 'signatures#create', :via => :post + match api_path + '/signatures/:id', :to => 'signatures#update', :via => :put + match api_path + '/signatures/:id', :to => 'signatures#destroy', :via => :delete - end - module_function :add end \ No newline at end of file diff --git a/config/routes/sla.rb b/config/routes/sla.rb index 6b7d44f8b..900695e27 100644 --- a/config/routes/sla.rb +++ b/config/routes/sla.rb @@ -1,13 +1,11 @@ -module ExtraRoutes - def add(map, api_path) +Zammad::Application.routes.draw do + api_path = Rails.configuration.api_path - # slas - map.match api_path + '/slas', :to => 'slas#index', :via => :get - map.match api_path + '/slas/:id', :to => 'slas#show', :via => :get - map.match api_path + '/slas', :to => 'slas#create', :via => :post - map.match api_path + '/slas/:id', :to => 'slas#update', :via => :put - map.match api_path + '/slas/:id', :to => 'slas#destroy', :via => :delete + # slas + match api_path + '/slas', :to => 'slas#index', :via => :get + match api_path + '/slas/:id', :to => 'slas#show', :via => :get + match api_path + '/slas', :to => 'slas#create', :via => :post + match api_path + '/slas/:id', :to => 'slas#update', :via => :put + match api_path + '/slas/:id', :to => 'slas#destroy', :via => :delete - end - module_function :add end \ No newline at end of file diff --git a/config/routes/tag.rb b/config/routes/tag.rb index ebfa10d90..f37c59686 100644 --- a/config/routes/tag.rb +++ b/config/routes/tag.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 + '/tags', :to => 'tags#list', :via => :get - map.match api_path + '/tags/add', :to => 'tags#add', :via => :get - map.match api_path + '/tags/remove', :to => 'tags#remove', :via => :get + # links + match api_path + '/tags', :to => 'tags#list', :via => :get + match api_path + '/tags/add', :to => 'tags#add', :via => :get + match api_path + '/tags/remove', :to => 'tags#remove', :via => :get - end - module_function :add -end +end \ No newline at end of file diff --git a/config/routes/taskbar.rb b/config/routes/taskbar.rb index 0721dd0ea..499bf2291 100644 --- a/config/routes/taskbar.rb +++ b/config/routes/taskbar.rb @@ -1,10 +1,10 @@ -module ExtraRoutes - def add(map, api_path) - map.match api_path + '/taskbar', :to => 'taskbar#index', :via => :get - map.match api_path + '/taskbar/:id', :to => 'taskbar#show', :via => :get - map.match api_path + '/taskbar', :to => 'taskbar#create', :via => :post - map.match api_path + '/taskbar/:id', :to => 'taskbar#update', :via => :put - map.match api_path + '/taskbar/:id', :to => 'taskbar#destroy',:via => :delete - end - module_function :add -end +Zammad::Application.routes.draw do + api_path = Rails.configuration.api_path + + match api_path + '/taskbar', :to => 'taskbar#index', :via => :get + match api_path + '/taskbar/:id', :to => 'taskbar#show', :via => :get + match api_path + '/taskbar', :to => 'taskbar#create', :via => :post + match api_path + '/taskbar/:id', :to => 'taskbar#update', :via => :put + match api_path + '/taskbar/:id', :to => 'taskbar#destroy',:via => :delete + +end \ No newline at end of file diff --git a/config/routes/template.rb b/config/routes/template.rb index 41d41e5c9..c0c5b0755 100644 --- a/config/routes/template.rb +++ b/config/routes/template.rb @@ -1,13 +1,11 @@ -module ExtraRoutes - def add(map, api_path) +Zammad::Application.routes.draw do + api_path = Rails.configuration.api_path - # templates - map.match api_path + '/templates', :to => 'templates#index', :via => :get - map.match api_path + '/templates/:id', :to => 'templates#show', :via => :get - map.match api_path + '/templates', :to => 'templates#create', :via => :post - map.match api_path + '/templates/:id', :to => 'templates#update', :via => :put - map.match api_path + '/templates/:id', :to => 'templates#destroy', :via => :delete + # templates + match api_path + '/templates', :to => 'templates#index', :via => :get + match api_path + '/templates/:id', :to => 'templates#show', :via => :get + match api_path + '/templates', :to => 'templates#create', :via => :post + match api_path + '/templates/:id', :to => 'templates#update', :via => :put + match api_path + '/templates/:id', :to => 'templates#destroy', :via => :delete - end - module_function :add end \ No newline at end of file diff --git a/config/routes/test.rb b/config/routes/test.rb index 75ebce01a..371c93ee2 100644 --- a/config/routes/test.rb +++ b/config/routes/test.rb @@ -1,10 +1,7 @@ -module ExtraRoutes - def add(map, api_path) +Zammad::Application.routes.draw do - map.match '/tests-core', :to => 'tests#core', :via => :get - map.match '/tests-form', :to => 'tests#form', :via => :get - map.match '/tests/wait/:sec', :to => 'tests#wait', :via => :get + match '/tests-core', :to => 'tests#core', :via => :get + match '/tests-form', :to => 'tests#form', :via => :get + match '/tests/wait/:sec', :to => 'tests#wait', :via => :get - end - module_function :add -end +end \ No newline at end of file diff --git a/config/routes/text_module.rb b/config/routes/text_module.rb index f165386ec..f57d864a5 100644 --- a/config/routes/text_module.rb +++ b/config/routes/text_module.rb @@ -1,13 +1,11 @@ -module ExtraRoutes - def add(map, api_path) +Zammad::Application.routes.draw do + api_path = Rails.configuration.api_path - # text_modules - map.match api_path + '/text_modules', :to => 'text_modules#index', :via => :get - map.match api_path + '/text_modules/:id', :to => 'text_modules#show', :via => :get - map.match api_path + '/text_modules', :to => 'text_modules#create', :via => :post - map.match api_path + '/text_modules/:id', :to => 'text_modules#update', :via => :put - map.match api_path + '/text_modules/:id', :to => 'text_modules#destroy', :via => :delete + # text_modules + match api_path + '/text_modules', :to => 'text_modules#index', :via => :get + match api_path + '/text_modules/:id', :to => 'text_modules#show', :via => :get + match api_path + '/text_modules', :to => 'text_modules#create', :via => :post + match api_path + '/text_modules/:id', :to => 'text_modules#update', :via => :put + match api_path + '/text_modules/:id', :to => 'text_modules#destroy', :via => :delete - end - module_function :add end \ No newline at end of file diff --git a/config/routes/ticket.rb b/config/routes/ticket.rb index 4e3297efa..f73b28e22 100644 --- a/config/routes/ticket.rb +++ b/config/routes/ticket.rb @@ -1,43 +1,41 @@ -module ExtraRoutes - def add(map, api_path) +Zammad::Application.routes.draw do + api_path = Rails.configuration.api_path - # tickets - map.match api_path + '/tickets/search', :to => 'tickets#search', :via => [:get, :post] - map.match api_path + '/tickets', :to => 'tickets#index', :via => :get - map.match api_path + '/tickets/:id', :to => 'tickets#show', :via => :get - map.match api_path + '/tickets', :to => 'tickets#create', :via => :post - map.match api_path + '/tickets/:id', :to => 'tickets#update', :via => :put - map.match api_path + '/ticket_create', :to => 'tickets#ticket_create', :via => :get - map.match api_path + '/ticket_full/:id', :to => 'tickets#ticket_full', :via => :get - map.match api_path + '/ticket_history/:id', :to => 'tickets#ticket_history', :via => :get - map.match api_path + '/ticket_customer', :to => 'tickets#ticket_customer', :via => :get - map.match api_path + '/ticket_merge_list/:ticket_id', :to => 'tickets#ticket_merge_list', :via => :get - map.match api_path + '/ticket_merge/:slave_ticket_id/:master_ticket_number', :to => 'tickets#ticket_merge', :via => :get + # tickets + match api_path + '/tickets/search', :to => 'tickets#search', :via => [:get, :post] + match api_path + '/tickets', :to => 'tickets#index', :via => :get + match api_path + '/tickets/:id', :to => 'tickets#show', :via => :get + match api_path + '/tickets', :to => 'tickets#create', :via => :post + match api_path + '/tickets/:id', :to => 'tickets#update', :via => :put + match api_path + '/ticket_create', :to => 'tickets#ticket_create', :via => :get + match api_path + '/ticket_full/:id', :to => 'tickets#ticket_full', :via => :get + match api_path + '/ticket_history/:id', :to => 'tickets#ticket_history', :via => :get + match api_path + '/ticket_customer', :to => 'tickets#ticket_customer', :via => :get + match api_path + '/ticket_merge_list/:ticket_id', :to => 'tickets#ticket_merge_list', :via => :get + match api_path + '/ticket_merge/:slave_ticket_id/:master_ticket_number', :to => 'tickets#ticket_merge', :via => :get - # ticket overviews - map.match api_path + '/ticket_overviews', :to => 'ticket_overviews#show', :via => :get + # ticket overviews + match api_path + '/ticket_overviews', :to => 'ticket_overviews#show', :via => :get - # ticket priority - map.match api_path + '/ticket_priorities', :to => 'ticket_priorities#index', :via => :get - map.match api_path + '/ticket_priorities/:id', :to => 'ticket_priorities#show', :via => :get - map.match api_path + '/ticket_priorities', :to => 'ticket_priorities#create', :via => :post - map.match api_path + '/ticket_priorities/:id', :to => 'ticket_priorities#update', :via => :put + # ticket priority + match api_path + '/ticket_priorities', :to => 'ticket_priorities#index', :via => :get + match api_path + '/ticket_priorities/:id', :to => 'ticket_priorities#show', :via => :get + match api_path + '/ticket_priorities', :to => 'ticket_priorities#create', :via => :post + match api_path + '/ticket_priorities/:id', :to => 'ticket_priorities#update', :via => :put - # ticket state - map.match api_path + '/ticket_states', :to => 'ticket_states#index', :via => :get - map.match api_path + '/ticket_states/:id', :to => 'ticket_states#show', :via => :get - map.match api_path + '/ticket_states', :to => 'ticket_states#create', :via => :post - map.match api_path + '/ticket_states/:id', :to => 'ticket_states#update', :via => :put + # ticket state + match api_path + '/ticket_states', :to => 'ticket_states#index', :via => :get + match api_path + '/ticket_states/:id', :to => 'ticket_states#show', :via => :get + match api_path + '/ticket_states', :to => 'ticket_states#create', :via => :post + match api_path + '/ticket_states/:id', :to => 'ticket_states#update', :via => :put - # ticket articles - map.match api_path + '/ticket_articles', :to => 'ticket_articles#index', :via => :get - map.match api_path + '/ticket_articles/:id', :to => 'ticket_articles#show', :via => :get - map.match api_path + '/ticket_articles', :to => 'ticket_articles#create', :via => :post - map.match api_path + '/ticket_articles/:id', :to => 'ticket_articles#update', :via => :put - map.match api_path + '/ticket_attachment/:ticket_id/:article_id/:id', :to => 'ticket_articles#attachment', :via => :get - map.match api_path + '/ticket_attachment_new', :to => 'ticket_articles#attachment_new', :via => :post - map.match api_path + '/ticket_article_plain/:id', :to => 'ticket_articles#article_plain', :via => :get + # ticket articles + match api_path + '/ticket_articles', :to => 'ticket_articles#index', :via => :get + match api_path + '/ticket_articles/:id', :to => 'ticket_articles#show', :via => :get + match api_path + '/ticket_articles', :to => 'ticket_articles#create', :via => :post + match api_path + '/ticket_articles/:id', :to => 'ticket_articles#update', :via => :put + match api_path + '/ticket_attachment/:ticket_id/:article_id/:id', :to => 'ticket_articles#attachment', :via => :get + match api_path + '/ticket_attachment_new', :to => 'ticket_articles#attachment_new', :via => :post + match api_path + '/ticket_article_plain/:id', :to => 'ticket_articles#article_plain', :via => :get - end - module_function :add -end +end \ No newline at end of file diff --git a/config/routes/translation.rb b/config/routes/translation.rb index 2ff531bfe..b20e6fc8b 100644 --- a/config/routes/translation.rb +++ b/config/routes/translation.rb @@ -1,12 +1,11 @@ -module ExtraRoutes - def add(map, api_path) - map.match api_path + '/translations', :to => 'translations#index', :via => :get - map.match api_path + '/translations/:id', :to => 'translations#show', :via => :get - map.match api_path + '/translations', :to => 'translations#create', :via => :post - map.match api_path + '/translations/:id', :to => 'translations#update', :via => :put - map.match api_path + '/translations/:id', :to => 'translations#destroy', :via => :delete +Zammad::Application.routes.draw do + api_path = Rails.configuration.api_path - map.match api_path + '/translations/lang/:locale', :to => 'translations#load', :via => :get - end - module_function :add -end + match api_path + '/translations', :to => 'translations#index', :via => :get + match api_path + '/translations/:id', :to => 'translations#show', :via => :get + match api_path + '/translations', :to => 'translations#create', :via => :post + match api_path + '/translations/:id', :to => 'translations#update', :via => :put + match api_path + '/translations/:id', :to => 'translations#destroy', :via => :delete + + match api_path + '/translations/lang/:locale', :to => 'translations#load', :via => :get +end \ No newline at end of file diff --git a/config/routes/user.rb b/config/routes/user.rb index c963b2877..7fd3653d4 100644 --- a/config/routes/user.rb +++ b/config/routes/user.rb @@ -1,18 +1,16 @@ -module ExtraRoutes - def add(map, api_path) +Zammad::Application.routes.draw do + api_path = Rails.configuration.api_path - # users - map.match api_path + '/users/search', :to => 'users#search', :via => [:get, :post] - map.match api_path + '/users/password_reset', :to => 'users#password_reset_send', :via => :post - map.match api_path + '/users/password_reset_verify', :to => 'users#password_reset_verify', :via => :post - map.match api_path + '/users/password_change', :to => 'users#password_change', :via => :post - map.match api_path + '/users/preferences', :to => 'users#preferences', :via => :put - map.match api_path + '/users/account', :to => 'users#account_remove', :via => :delete - map.match api_path + '/users', :to => 'users#index', :via => :get - map.match api_path + '/users/:id', :to => 'users#show', :via => :get - map.match api_path + '/users', :to => 'users#create', :via => :post - map.match api_path + '/users/:id', :to => 'users#update', :via => :put + # users + match api_path + '/users/search', :to => 'users#search', :via => [:get, :post] + match api_path + '/users/password_reset', :to => 'users#password_reset_send', :via => :post + match api_path + '/users/password_reset_verify', :to => 'users#password_reset_verify', :via => :post + match api_path + '/users/password_change', :to => 'users#password_change', :via => :post + match api_path + '/users/preferences', :to => 'users#preferences', :via => :put + match api_path + '/users/account', :to => 'users#account_remove', :via => :delete + match api_path + '/users', :to => 'users#index', :via => :get + match api_path + '/users/:id', :to => 'users#show', :via => :get + match api_path + '/users', :to => 'users#create', :via => :post + match api_path + '/users/:id', :to => 'users#update', :via => :put - end - module_function :add end \ No newline at end of file