server_snippet.rb 669 B

123456789101112131415161718192021222324252627282930
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class KnowledgeBase
  3. class ServerSnippet
  4. def initialize(knowledge_base)
  5. @kb = knowledge_base
  6. end
  7. def render
  8. raise Exceptions::UnprocessableEntity, __('Custom address is not set') if @kb.custom_address_uri.nil?
  9. template_rewrite = host.present? ? template_full : template_path
  10. "#{template_rewrite}\n#{template_original_url}"
  11. end
  12. def host
  13. @kb.custom_address_uri&.host
  14. end
  15. def path
  16. @kb.custom_address_uri&.path || ''
  17. end
  18. def template_path; end
  19. def template_full; end
  20. def template_original_url; end
  21. end
  22. end