Interface TemplateManager

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      static void addResourceRequest​(Context ctx, java.lang.String type, java.lang.String resource)
      Adds a resource request to the current request context.
      java.lang.String findJSP​(javax.servlet.jsp.PageContext pageContext, java.lang.String name)
      A utility method for finding a JSP page.
      java.lang.String findJSP​(javax.servlet.jsp.PageContext pageContext, java.lang.String template, java.lang.String name)
      Attempts to locate a resource under the given template.
      java.lang.String findResource​(Context ctx, java.lang.String template, java.lang.String name)
      Attempts to locate a resource under the given template.
      static java.lang.String getJSLocalizedStrings​(Context context)
      Extract all i18n strings in the javascript domain.
      static java.lang.String getMarker​(Context context, java.lang.String type)
      Returns the include resources marker for a given type.
      static java.lang.String[] getResourceRequests​(Context ctx, java.lang.String type)
      Returns resource requests for a particular type.
      static java.lang.String[] getResourceTypes​(Context ctx)
      Returns all those types that have been requested so far.
      default java.util.Map<java.lang.String,​java.lang.String> listLanguages​(javax.servlet.jsp.PageContext pageContext)
      List all installed i18n language properties by classpath searching for files like : templates/default_*.properties templates/default.properties
      java.util.Set<java.lang.String> listSkins​(javax.servlet.jsp.PageContext pageContext, java.lang.String template)
      Lists the skins available under this template.
      java.util.Map<java.lang.String,​java.lang.String> listTimeFormats​(javax.servlet.jsp.PageContext pageContext)
      List all available timeformats, read from the jspwiki.properties
      default java.util.Map<java.lang.String,​java.lang.String> listTimeZones​(javax.servlet.jsp.PageContext pageContext)
      List all timezones, with special marker for server timezone
      boolean templateExists​(java.lang.String templateName)
      Check the existence of a template.
    • Method Detail

      • templateExists

        boolean templateExists​(java.lang.String templateName)
        Check the existence of a template.
      • findJSP

        java.lang.String findJSP​(javax.servlet.jsp.PageContext pageContext,
                                 java.lang.String name)
        A utility method for finding a JSP page. It searches only under either current context or by the absolute name.
        Parameters:
        pageContext - the JSP PageContext
        name - The name of the JSP page to look for (e.g "Wiki.jsp")
        Returns:
        The context path to the resource
      • findJSP

        java.lang.String findJSP​(javax.servlet.jsp.PageContext pageContext,
                                 java.lang.String template,
                                 java.lang.String name)
        Attempts to locate a resource under the given template. If that template does not exist, or the page does not exist under that template, will attempt to locate a similarly named file under the default template.

        Even though the name suggests only JSP files can be located, but in fact this method can find also other resources than JSP files.

        Parameters:
        pageContext - The JSP PageContext
        template - From which template we should seek initially?
        name - Which resource are we looking for (e.g. "ViewTemplate.jsp")
        Returns:
        path to the JSP page; null, if it was not found.
      • findResource

        java.lang.String findResource​(Context ctx,
                                      java.lang.String template,
                                      java.lang.String name)
        Attempts to locate a resource under the given template. This matches the functionality findJSP(), but uses the WikiContext as the argument. If there is no servlet context (i.e. this is embedded), will just simply return a best-guess.

        This method is typically used to locate any resource, including JSP pages, images, scripts, etc.

        Parameters:
        ctx - the wiki context
        template - the name of the template to use
        name - the name of the resource to fine
        Returns:
        the path to the resource
        Since:
        2.6
      • listSkins

        java.util.Set<java.lang.String> listSkins​(javax.servlet.jsp.PageContext pageContext,
                                                  java.lang.String template)
        Lists the skins available under this template. Returns an empty Set, if there are no extra skins available. Note that this method does not check whether there is anything actually in the directories, it just lists them. This may change in the future.
        Parameters:
        pageContext - the JSP PageContext
        template - The template to search
        Returns:
        Set of Strings with the skin names.
        Since:
        2.3.26
      • listLanguages

        default java.util.Map<java.lang.String,​java.lang.String> listLanguages​(javax.servlet.jsp.PageContext pageContext)
        List all installed i18n language properties by classpath searching for files like : templates/default_*.properties templates/default.properties
        Parameters:
        pageContext - page context
        Returns:
        map of installed Languages
        Since:
        2.7.x
      • listTimeFormats

        java.util.Map<java.lang.String,​java.lang.String> listTimeFormats​(javax.servlet.jsp.PageContext pageContext)
        List all available timeformats, read from the jspwiki.properties
        Parameters:
        pageContext - page context
        Returns:
        map of TimeFormats
        Since:
        2.7.x
      • listTimeZones

        default java.util.Map<java.lang.String,​java.lang.String> listTimeZones​(javax.servlet.jsp.PageContext pageContext)
        List all timezones, with special marker for server timezone
        Parameters:
        pageContext - page context
        Returns:
        map of TimeZones
        Since:
        2.7.x
      • getMarker

        static java.lang.String getMarker​(Context context,
                                          java.lang.String type)
        Returns the include resources marker for a given type. This is in an HTML or Javascript comment format.
        Parameters:
        context - the wiki context
        type - the marker
        Returns:
        the generated marker comment
      • getJSLocalizedStrings

        static java.lang.String getJSLocalizedStrings​(Context context)
        Extract all i18n strings in the javascript domain. (javascript.*) Returns a javascript snippet which defines the LocalizedStings array.
        Parameters:
        context - the Context
        Returns:
        Javascript snippet which defines the LocalizedStrings array
        Since:
        2.5.108
      • addResourceRequest

        static void addResourceRequest​(Context ctx,
                                       java.lang.String type,
                                       java.lang.String resource)
        Adds a resource request to the current request context. The content will be added at the resource-type marker (see IncludeResourcesTag) in WikiJSPFilter.

        The resources can be of different types. For RESOURCE_SCRIPT and RESOURCE_STYLESHEET this is a URI path to the resource (a script file or an external stylesheet) that needs to be included. For RESOURCE_INLINECSS the resource should be something that can be added between <style></style> in the header file (commonheader.jsp). For RESOURCE_JSFUNCTION it is the name of the Javascript function that should be run at page load.

        The IncludeResourceTag inserts code in the template files, which is then filled by the WikiFilter after the request has been rendered but not yet sent to the recipient.

        Note that ALL resource requests get rendered, so this method does not check if the request already exists in the resources. Therefore, if you have a plugin which makes a new resource request every time, you'll end up with multiple resource requests rendered. It's thus a good idea to make this request only once during the page life cycle.

        Parameters:
        ctx - The current wiki context
        type - What kind of resource should be added?
        resource - The resource to add.
      • getResourceRequests

        static java.lang.String[] getResourceRequests​(Context ctx,
                                                      java.lang.String type)
        Returns resource requests for a particular type. If there are no resources, returns an empty array.
        Parameters:
        ctx - WikiContext
        type - The resource request type
        Returns:
        a String array for the resource requests
      • getResourceTypes

        static java.lang.String[] getResourceTypes​(Context ctx)
        Returns all those types that have been requested so far.
        Parameters:
        ctx - the wiki context
        Returns:
        the array of types requested