From 7134a21f6a8f82ccc9dbc269b8e419eebf2078a2 Mon Sep 17 00:00:00 2001 From: sawka Date: Sun, 2 Apr 2023 00:19:20 -0700 Subject: [PATCH] updates for serving off AWS / cloudfront --- scripthaus.md | 6 +++--- src/webshare-model.ts | 9 ++++++++- webpack.share.dev.js | 3 +++ webshare/static/index-dev.html | 21 +++++++++++++++++++++ webshare/static/index.html | 6 +++--- 5 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 webshare/static/index-dev.html diff --git a/scripthaus.md b/scripthaus.md index 10d5fdf1..2f9f2992 100644 --- a/scripthaus.md +++ b/scripthaus.md @@ -131,7 +131,7 @@ rm *.dmg ```bash # @scripthaus command sync-webshare-dev # @scripthaus cd :playbook -aws --profile prompt-s3 s3 cp webshare/static/index.html s3://prompt-devshare-static/ --cache-control 'public, max-age=600, s-maxage=300, stale-if-error=60' -aws --profile prompt-s3 s3 sync webshare/static s3://prompt-devshare-static/static --cache-control 'public, max-age=600, s-maxage=300, stale-if-error=60' -aws --profile prompt-s3 s3 sync webshare/dist-dev s3://prompt-devshare-static/ --cache-control 'public, max-age=600, s-maxage=300, stale-if-error=60' +# no-cache for dev +aws --profile prompt-s3 s3 sync webshare/static s3://prompt-devshare-static/static --cache-control 'no-cache' +aws --profile prompt-s3 s3 sync webshare/dist-dev s3://prompt-devshare-static/dist-dev --cache-control 'no-cache' ``` diff --git a/src/webshare-model.ts b/src/webshare-model.ts index 247e40f1..3d95a49b 100644 --- a/src/webshare-model.ts +++ b/src/webshare-model.ts @@ -50,9 +50,16 @@ class WebShareModelClass { remoteScreenVts : number = 0; constructor() { + let pathName = window.location.pathname; + let screenMatch = pathName.match(/\/share\/([a-f0-9-]+)/); + if (screenMatch != null) { + this.screenId = screenMatch[1]; + } let urlParams = new URLSearchParams(window.location.search); this.viewKey = urlParams.get("viewkey"); - this.screenId = urlParams.get("screenid"); + if (this.screenId == null) { + this.screenId = urlParams.get("screenid"); + } setTimeout(() => this.loadFullScreenData(false), 10); this.wsControl = new WebShareWSControl(getBaseWSUrl(), this.screenId, this.viewKey, this.wsMessageCallback.bind(this)); document.addEventListener("keydown", this.docKeyDownHandler.bind(this)); diff --git a/webpack.share.dev.js b/webpack.share.dev.js index d95b5761..1a3771e4 100644 --- a/webpack.share.dev.js +++ b/webpack.share.dev.js @@ -20,6 +20,9 @@ var merged = merge.merge(common, { headers: { 'Cache-Control': 'no-store', }, + devMiddleware: { + publicPath: '/dist-dev/' + }, allowedHosts: "all", hot: false, liveReload: false, diff --git a/webshare/static/index-dev.html b/webshare/static/index-dev.html new file mode 100644 index 00000000..6e1c8ff9 --- /dev/null +++ b/webshare/static/index-dev.html @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + +
+
+ + + + diff --git a/webshare/static/index.html b/webshare/static/index.html index 248ab71c..864fc9ac 100644 --- a/webshare/static/index.html +++ b/webshare/static/index.html @@ -2,15 +2,15 @@ - - + + - +