knowledge_base.rb 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. Zammad::Application.routes.draw do
  3. #
  4. # API
  5. #
  6. concern :has_publishing do
  7. member do
  8. post :has_publishing_update, action: :has_publishing_update
  9. CanBePublished::StateMachine.aasm.events.each do |event|
  10. post event.name, action: "has_publishing_#{event.name}"
  11. end
  12. end
  13. end
  14. scope Rails.configuration.api_path do
  15. resources :knowledge_bases, only: %i[show update] do
  16. collection do
  17. post :init
  18. get :visible_ids
  19. post :search, controller: 'knowledge_base/search'
  20. get :recent_answers, controller: 'knowledge_base/answers'
  21. resources :manage, controller: 'knowledge_base/manage' do
  22. collection do
  23. get :init
  24. end
  25. member do
  26. get :server_snippets
  27. patch :activate, :deactivate, :update_menu_items
  28. end
  29. end
  30. resource :feed_tokens, controller: 'knowledge_base/feed_tokens', only: %i[show update]
  31. end
  32. member do
  33. resource :permissions, controller: 'knowledge_base/permissions', only: %i[update show]
  34. get ':locale/feed', to: 'knowledge_base/feeds#root', as: :feed
  35. end
  36. resources :categories, controller: 'knowledge_base/categories',
  37. except: %i[new edit] do
  38. member do
  39. patch :reorder_categories, :reorder_answers
  40. resource :permissions, controller: 'knowledge_base/permissions', only: %i[update show]
  41. get ':locale/feed', to: 'knowledge_base/feeds#category', as: :feed
  42. end
  43. collection do
  44. patch :reorder_root_categories
  45. end
  46. end
  47. resources :answers, controller: 'knowledge_base/answers',
  48. only: %i[create update show destroy],
  49. concerns: :has_publishing do
  50. resources :attachments, controller: 'knowledge_base/answer/attachments', only: %i[create destroy] do
  51. collection do
  52. post :clone_to_form
  53. end
  54. end
  55. end
  56. end
  57. end
  58. #
  59. # Public
  60. #
  61. scope :help do
  62. get '', to: 'knowledge_base/public/categories#forward_root', as: :help_no_locale
  63. get ':locale', to: 'knowledge_base/public/categories#index', as: :help_root
  64. get ':locale/:category/feed', to: 'knowledge_base/public/feeds#category', as: :help_category_feed
  65. get ':locale/feed', to: 'knowledge_base/public/feeds#root', as: :help_root_feed
  66. get ':locale/tag/:tag', to: 'knowledge_base/public/tags#show', as: :help_tag
  67. get ':locale/:category', to: 'knowledge_base/public/categories#show', as: :help_category
  68. get ':locale/:category/:answer', to: 'knowledge_base/public/answers#show', as: :help_answer
  69. end
  70. end