server_snippet.rb 588 B

12345678910111213141516171819202122232425262728
  1. class KnowledgeBase
  2. class ServerSnippet
  3. def initialize(knowledge_base)
  4. @kb = knowledge_base
  5. end
  6. def render
  7. raise Exceptions::UnprocessableEntity, 'Custom address is not set' if @kb.custom_address_uri.nil?
  8. template_rewrite = host.present? ? template_full : template_path
  9. template_rewrite + "\n" + template_original_url
  10. end
  11. def host
  12. @kb.custom_address_uri&.host
  13. end
  14. def path
  15. @kb.custom_address_uri&.path || ''
  16. end
  17. def template_path; end
  18. def template_full; end
  19. def template_original_url; end
  20. end
  21. end