Package com.djrapitops.plan.delivery.web
Interface ResourceService
- All Known Implementing Classes:
ResourceSvc
public interface ResourceService
Service for making plugin resources customizable by user or Plan API.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
static enum
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
addJavascriptToResource
(String pluginName, String fileName, ResourceService.Position position, String scriptName, String javascriptAsString) Add javascript to load in a html resource.void
addScriptsToResource
(String pluginName, String fileName, ResourceService.Position position, String... jsSources) Add javascript to load in a html resource.void
addStylesToResource
(String pluginName, String fileName, ResourceService.Position position, String... cssSources) Add css to load in an existing html resource.default void
addStyleToResource
(String pluginName, String fileName, ResourceService.Position position, String cssFileName, String cssAsString) Add javascript to load in a html resource.static ResourceService
getResource
(String pluginName, String fileName, Supplier<WebResource> source) Make one of your web resources customizable by user or Plan API.
-
Method Details
-
getInstance
-
getResource
Make one of your web resources customizable by user or Plan API.- 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.
- Throws:
IllegalArgumentException
- If pluginName is empty or nullIllegalArgumentException
- If fileName is empty or nullIllegalArgumentException
- If source is null
-
addScriptsToResource
void addScriptsToResource(String pluginName, String fileName, ResourceService.Position position, String... jsSources) Add javascript to load in a html resource.Adds
<script src="jsSrc"></script>
or multiple to the resource.- 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.- Throws:
IllegalArgumentException
- If pluginName is empty or nullIllegalArgumentException
- If fileName is null, empty or does not end with .htmlIllegalArgumentException
- If position nullIllegalArgumentException
- If jsSources is empty or null
-
addJavascriptToResource
default void addJavascriptToResource(String pluginName, String fileName, ResourceService.Position position, String scriptName, String javascriptAsString) Add javascript to load in a html resource.Requires PAGE_EXTENSION_RESOURCES_REGISTER_DIRECT_CUSTOMIZATION Capability.
- 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.scriptName
- Name of your javascript file (used on the page)javascriptAsString
- Javascript file contents in UTF-8- Throws:
IllegalArgumentException
- If fileName is null, empty or does not end with .htmlIllegalArgumentException
- If anything is empty or null
-
addStylesToResource
void addStylesToResource(String pluginName, String fileName, ResourceService.Position position, String... cssSources) Add css to load in an existing html resource.Adds
<link href="cssSrc" rel="stylesheet"></link>
or multiple to the resource.- 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.- Throws:
IllegalArgumentException
- If pluginName is empty or nullIllegalArgumentException
- If fileName is null, empty or does not end with .htmlIllegalArgumentException
- If position nullIllegalArgumentException
- If cssSources is empty or null
-
addStyleToResource
default void addStyleToResource(String pluginName, String fileName, ResourceService.Position position, String cssFileName, String cssAsString) Add javascript to load in a html resource.Requires PAGE_EXTENSION_RESOURCES_REGISTER_DIRECT_CUSTOMIZATION Capability.
- 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.cssFileName
- Name of your css file (used on the page)cssAsString
- CSS file contents in UTF-8- Throws:
IllegalArgumentException
- If fileName is null, empty or does not end with .htmlIllegalArgumentException
- If anything is empty or null
-