knowledge_base.rb 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # Copyright (C) 2012-2025 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. get 'preview/:object/:id/:locale', to: 'knowledge_bases#preview'
  22. resources :manage, controller: 'knowledge_base/manage' do
  23. collection do
  24. get :init
  25. end
  26. member do
  27. get :server_snippets
  28. patch :activate
  29. patch :deactivate
  30. patch :update_menu_items
  31. end
  32. end
  33. resource :feed_tokens, controller: 'knowledge_base/feed_tokens', only: %i[show update]
  34. end
  35. member do
  36. resource :permissions, controller: 'knowledge_base/permissions', only: %i[update show]
  37. get ':locale/feed', to: 'knowledge_base/feeds#root', as: :feed
  38. end
  39. resources :categories, controller: 'knowledge_base/categories',
  40. except: %i[new edit] do
  41. member do
  42. patch :reorder_categories
  43. patch :reorder_answers
  44. resource :permissions, controller: 'knowledge_base/permissions', only: %i[update show]
  45. get ':locale/feed', to: 'knowledge_base/feeds#category', as: :feed
  46. end
  47. collection do
  48. patch :reorder_root_categories
  49. end
  50. end
  51. resources :answers, controller: 'knowledge_base/answers',
  52. only: %i[create update show destroy],
  53. concerns: :has_publishing do
  54. resources :attachments, controller: 'knowledge_base/answer/attachments', only: %i[create destroy] do
  55. collection do
  56. post :clone_to_form
  57. end
  58. end
  59. end
  60. end
  61. end
  62. #
  63. # Public
  64. #
  65. scope :help do
  66. get '', to: 'knowledge_base/public/categories#forward_root', as: :help_no_locale
  67. get ':locale', to: 'knowledge_base/public/categories#index', as: :help_root
  68. get ':locale/:category/feed', to: 'knowledge_base/public/feeds#category', as: :help_category_feed
  69. get ':locale/feed', to: 'knowledge_base/public/feeds#root', as: :help_root_feed
  70. get ':locale/tag/:tag', to: 'knowledge_base/public/tags#show', as: :help_tag
  71. get ':locale/:category', to: 'knowledge_base/public/categories#show', as: :help_category
  72. get ':locale/:category/:answer', to: 'knowledge_base/public/answers#show', as: :help_answer
  73. end
  74. end