summaryrefslogtreecommitdiff
path: root/plugin_loader/loader.py
diff options
context:
space:
mode:
authortza <marios8543@gmail.com>2022-04-05 22:40:24 +0300
committertza <marios8543@gmail.com>2022-04-05 22:40:24 +0300
commit30325397d090cfffee1143f21423aff7bd4e6122 (patch)
tree1b3e238627864b347bc0139069d6a445d0b0e45c /plugin_loader/loader.py
parent8d0fe5c45ac67ea4eef9a7c6a5e4eaaa57ad01d3 (diff)
downloaddecky-loader-30325397d090cfffee1143f21423aff7bd4e6122.tar.gz
decky-loader-30325397d090cfffee1143f21423aff7bd4e6122.zip
added plugin tile view isolation
Tile views will now run each in their own iframe. This makes it more safe as plugins no longer share the same javascript context, and plugin method calls can now be supported from the tile view.
Diffstat (limited to 'plugin_loader/loader.py')
-rw-r--r--plugin_loader/loader.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/plugin_loader/loader.py b/plugin_loader/loader.py
index d74eed51..231fe07b 100644
--- a/plugin_loader/loader.py
+++ b/plugin_loader/loader.py
@@ -43,7 +43,8 @@ class Loader:
web.get("/plugins/iframe", self.plugin_iframe_route),
web.get("/plugins/reload", self.reload_plugins),
web.post("/plugins/method_call", self.handle_plugin_method_call),
- web.get("/plugins/load/{name}", self.load_plugin),
+ web.get("/plugins/load_main/{name}", self.load_plugin_main_view),
+ web.get("/plugins/load_tile/{name}", self.load_plugin_tile_view),
web.get("/steam_resource/{path:.+}", self.get_steam_resource)
])
@@ -94,7 +95,7 @@ class Loader:
except Exception as e:
return web.Response(text=str(e), status=400)
- async def load_plugin(self, request):
+ async def load_plugin_main_view(self, request):
plugin = self.plugins[request.match_info["name"]]
ret = """
<script src="/static/library.js"></script>
@@ -103,6 +104,24 @@ class Loader:
""".format(plugin.name, plugin.main_view_html)
return web.Response(text=ret, content_type="text/html")
+ async def load_plugin_tile_view(self, request):
+ plugin = self.plugins[request.match_info["name"]]
+ ret = """
+ <html style="height: fit-content;">
+ <head>
+ <link rel="stylesheet" href="/steam_resource/css/2.css">
+ <link rel="stylesheet" href="/steam_resource/css/39.css">
+ <link rel="stylesheet" href="/steam_resource/css/library.css">
+ <script src="/static/library.js"></script>
+ <script>const plugin_name = '{name}';</script>
+ </head>
+ <body style="height: fit-content; display: block;">
+ {content}
+ </body>
+ <html>
+ """.format(name=plugin.name, content=plugin.tile_view_html)
+ return web.Response(text=ret, content_type="text/html")
+
@template('plugin_view.html')
async def plugin_iframe_route(self, request):
return {"plugins": self.plugins.values()}