Class ApproximateMarkdownServlet

  • All Implemented Interfaces:
    Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

    public class ApproximateMarkdownServlet
    extends org.apache.sling.api.servlets.SlingSafeMethodsServlet
    Renders an approximate markdown representation of the text content of a page / resource. The Sling way would be to create markdown.jsp for each component, but that would be quite an effort with all existing Pages components, and since the markdown representation is only for retrieving text for suggesting keywords and summarizing, keywording etc. we just go with a simple approach for now, which just might be good enough. There can be plugins for the markdown conversion: see ApproximateMarkdownServicePlugin. Can also be used to get the result as richtext by giving a .html suffix instead of .md.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected com.composum.ai.backend.base.service.chat.GPTChatCompletionService chatService  
      protected static org.slf4j.Logger LOG  
      static String PARAM_URL
      If this is given with an URL instead of a suffix, we retrieve the HTML from the given source.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void doGet​(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response)  
      protected void getUrl​(String urlString, boolean richtext, org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response)  
      • Methods inherited from class org.apache.sling.api.servlets.SlingSafeMethodsServlet

        doGeneric, doHead, doOptions, doTrace, getAllowedRequestMethods, getServletInfo, handleMethodNotImplemented, mayService, service, service
      • Methods inherited from class javax.servlet.GenericServlet

        destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, init, log, log
    • Field Detail

      • LOG

        protected static final org.slf4j.Logger LOG
      • PARAM_URL

        public static final String PARAM_URL
        If this is given with an URL instead of a suffix, we retrieve the HTML from the given source.
        See Also:
        Constant Field Values
      • chatService

        protected com.composum.ai.backend.base.service.chat.GPTChatCompletionService chatService
    • Constructor Detail

      • ApproximateMarkdownServlet

        public ApproximateMarkdownServlet()
    • Method Detail

      • doGet

        protected void doGet​(@Nonnull
                             org.apache.sling.api.SlingHttpServletRequest request,
                             @Nonnull
                             org.apache.sling.api.SlingHttpServletResponse response)
                      throws javax.servlet.ServletException,
                             IOException
        Overrides:
        doGet in class org.apache.sling.api.servlets.SlingSafeMethodsServlet
        Throws:
        javax.servlet.ServletException
        IOException
      • getUrl

        protected void getUrl​(String urlString,
                              boolean richtext,
                              @Nonnull
                              org.apache.sling.api.SlingHttpServletRequest request,
                              @Nonnull
                              org.apache.sling.api.SlingHttpServletResponse response)
                       throws IOException
        Throws:
        IOException