summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorttay24 <tanner.taylor24@gmail.com>2022-04-07 12:25:03 -0500
committerGitHub <noreply@github.com>2022-04-07 20:25:03 +0300
commit0f14f2707bf0c50d6fbbfda3da66394953ae4128 (patch)
treeeb86d5674a3282ce3850a23e99c16bfe8eaa5ccd
parent2188aa03432745aa268186b278e60e892ac887e5 (diff)
downloaddecky-loader-0f14f2707bf0c50d6fbbfda3da66394953ae4128.tar.gz
decky-loader-0f14f2707bf0c50d6fbbfda3da66394953ae4128.zip
Added support for including styles/scripts in the header of html files (#29)
* Added support for including styles/scripts in the header of html files * updated route name
-rw-r--r--plugin_loader/loader.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/plugin_loader/loader.py b/plugin_loader/loader.py
index 8460c792..fb4e3fa8 100644
--- a/plugin_loader/loader.py
+++ b/plugin_loader/loader.py
@@ -69,6 +69,7 @@ class Loader:
web.get("/plugins/reload", self.reload_plugins),
web.post("/plugins/method_call", self.handle_plugin_method_call),
web.get("/plugins/load_main/{name}", self.load_plugin_main_view),
+ web.get("/plugins/plugin_resource/{name}/{path:.+}", self.handle_sub_route),
web.get("/plugins/load_tile/{name}", self.load_plugin_tile_view),
web.get("/steam_resource/{path:.+}", self.get_steam_resource)
])
@@ -138,10 +139,24 @@ class Loader:
ret = """
<script src="/static/library.js"></script>
<script>const plugin_name = '{}' </script>
+ <base href="http://127.0.0.1:1337/plugins/plugin_resource/{}/">
{}
- """.format(plugin.name, template_data)
+ """.format(plugin.name, plugin.name, template_data)
return web.Response(text=ret, content_type="text/html")
+ async def handle_sub_route(self, request):
+ plugin = self.plugins[request.match_info["name"]]
+ route_path = request.match_info["path"]
+ self.logger.info(path)
+
+ ret = ""
+
+ file_path = path.join(self.plugin_path, plugin._plugin_directory, route_path)
+ with open(file_path, 'r') as resource_data:
+ ret = resource_data.read()
+
+ return web.Response(text=ret)
+
async def load_plugin_tile_view(self, request):
plugin = self.plugins[request.match_info["name"]]