Class ResourceSvc

  • All Implemented Interfaces:
    ResourceService

    @Singleton
    public class ResourceSvc
    extends java.lang.Object
    implements ResourceService
    ResourceService implementation.
    • Field Detail

      • snippets

        public final java.util.Set<com.djrapitops.plan.delivery.web.ResourceSvc.Snippet> snippets
    • Constructor Detail

      • ResourceSvc

        @Inject
        public ResourceSvc​(PlanFiles files,
                           PlanConfig config,
                           Locale locale,
                           net.playeranalytics.plugin.server.PluginLogger logger,
                           ErrorLogger errorLogger)
    • Method Detail

      • register

        public void register()
      • getResource

        public WebResource getResource​(java.lang.String pluginName,
                                       java.lang.String fileName,
                                       java.util.function.Supplier<WebResource> source)
        Description copied from interface: ResourceService
        Make one of your web resources customizable by user or Plan API.
        Specified by:
        getResource in interface ResourceService
        Parameters:
        pluginName - Name of your plugin (for config purposes)
        fileName - Name of the file (for customization)
        source - Supplier to use to get the original resource, it is assumed that any text based files are encoded in UTF-8.
        Returns:
        Resource of the customized file.
      • checkParams

        public void checkParams​(java.lang.String pluginName,
                                java.lang.String fileName,
                                java.util.function.Supplier<WebResource> source)
      • getTheResource

        public WebResource getTheResource​(java.lang.String pluginName,
                                          java.lang.String fileName,
                                          java.util.function.Supplier<WebResource> source)
      • getOrWriteCustomized

        public WebResource getOrWriteCustomized​(java.lang.String fileName,
                                                java.util.function.Supplier<WebResource> source)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • readCustomized

        public WebResource readCustomized​(Resource customizedResource)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • writeCustomized

        public WebResource writeCustomized​(java.lang.String fileName,
                                           java.util.function.Supplier<WebResource> source)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • addScriptsToResource

        public void addScriptsToResource​(java.lang.String pluginName,
                                         java.lang.String fileName,
                                         ResourceService.Position position,
                                         java.lang.String... jsSrcs)
        Description copied from interface: ResourceService
        Add javascript to load in an existing html resource.

        Adds <script src="jsSrc"></script> or multiple to the resource.

        Specified by:
        addScriptsToResource in interface ResourceService
        Parameters:
        pluginName - Name of your plugin (for config purposes)
        fileName - Name of the .html file being modified
        position - Where to place the script tag on the page.
        jsSrcs - Source URLs.
      • checkParams

        public void checkParams​(java.lang.String pluginName,
                                java.lang.String fileName,
                                ResourceService.Position position,
                                java.lang.String[] jsSrcs)
      • addStylesToResource

        public void addStylesToResource​(java.lang.String pluginName,
                                        java.lang.String fileName,
                                        ResourceService.Position position,
                                        java.lang.String... cssSrcs)
        Description copied from interface: ResourceService
        Add css to load in an existing html resource.

        Adds <link href="cssSrc" rel="stylesheet"></link> or multiple to the resource.

        Specified by:
        addStylesToResource in interface ResourceService
        Parameters:
        pluginName - Name of your plugin (for config purposes)
        fileName - Name of the .html file being modified
        position - Where to place the link tag on the page.
        cssSrcs - Source URLs.