Package com.djrapitops.plan.delivery.web
Class ResourceSvc
- java.lang.Object
-
- com.djrapitops.plan.delivery.web.ResourceSvc
-
- All Implemented Interfaces:
ResourceService
@Singleton public class ResourceSvc extends java.lang.Object implements ResourceService
ResourceService implementation.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.djrapitops.plan.delivery.web.ResourceService
ResourceService.Holder, ResourceService.Position
-
-
Field Summary
Fields Modifier and Type Field Description java.util.Set<com.djrapitops.plan.delivery.web.ResourceSvc.Snippet>
snippets
-
Constructor Summary
Constructors Constructor Description ResourceSvc(PlanFiles files, PlanConfig config, Locale locale, net.playeranalytics.plugin.server.PluginLogger logger, ErrorLogger errorLogger)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addScriptsToResource(java.lang.String pluginName, java.lang.String fileName, ResourceService.Position position, java.lang.String... jsSources)
Add javascript to load in an existing html resource.void
addStylesToResource(java.lang.String pluginName, java.lang.String fileName, ResourceService.Position position, java.lang.String... cssSources)
Add css to load in an existing html resource.void
checkParams(java.lang.String pluginName, java.lang.String fileName, ResourceService.Position position, java.lang.String[] jsSources)
void
checkParams(java.lang.String pluginName, java.lang.String fileName, java.util.function.Supplier<WebResource> source)
WebResource
getOrWriteCustomized(java.lang.String fileName, java.util.function.Supplier<WebResource> source)
WebResource
getResource(java.lang.String pluginName, java.lang.String fileName, java.util.function.Supplier<WebResource> source)
Make one of your web resources customizable by user or Plan API.WebResource
getTheResource(java.lang.String pluginName, java.lang.String fileName, java.util.function.Supplier<WebResource> source)
WebResource
readCustomized(Resource customizedResource)
void
register()
WebResource
writeCustomized(java.lang.String fileName, java.util.function.Supplier<WebResource> source)
-
-
-
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 interfaceResourceService
- 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... jsSources)
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 interfaceResourceService
- Parameters:
pluginName
- Name of your plugin (for config purposes)fileName
- Name of the .html file being modifiedposition
- Where to place the script tag on the page.jsSources
- Source URLs.
-
checkParams
public void checkParams(java.lang.String pluginName, java.lang.String fileName, ResourceService.Position position, java.lang.String[] jsSources)
-
addStylesToResource
public void addStylesToResource(java.lang.String pluginName, java.lang.String fileName, ResourceService.Position position, java.lang.String... cssSources)
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 interfaceResourceService
- Parameters:
pluginName
- Name of your plugin (for config purposes)fileName
- Name of the .html file being modifiedposition
- Where to place the link tag on the page.cssSources
- Source URLs.
-
-