knowledge_base.rb 2.8 KB

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