From d7e38499bab7330848de7e87ac353318ed7b5b1b Mon Sep 17 00:00:00 2001 From: Gergely Brautigam <182850+Skarlso@users.noreply.github.com> Date: Sun, 31 Dec 2023 20:23:34 +0100 Subject: [PATCH] trying to get the JSs to work (#43) * trying to get the JSs to work * finally got the highlight working and the copy --- wasm/app-worker.js | 8 ++-- wasm/app.go | 36 +++++++++++---- wasm/app.js | 2 +- wasm/index.html | 84 +++++++++++++++++------------------ wasm/main.go | 56 +++++++++++------------ wasm/web/app.wasm | Bin 26588591 -> 26609773 bytes wasm/web/js/clipboard.min.js | 6 +-- 7 files changed, 103 insertions(+), 89 deletions(-) diff --git a/wasm/app-worker.js b/wasm/app-worker.js index bec7a7a..13475ee 100644 --- a/wasm/app-worker.js +++ b/wasm/app-worker.js @@ -1,8 +1,8 @@ -const cacheName = "app-" + "e31aa1c4d4bf560a2b0d649865fab57a2bf48d9c"; -const resourcesToCache = ["/","/app.css","/app.js","/manifest.webmanifest","/wasm_exec.js","/web/app.wasm","/web/css/alert.css","/web/img/logo.png","https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js","https://cdn.jsdelivr.net/npm/halfmoon@2.0.1/css/halfmoon.min.css","https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css","https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js","https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/yaml.min.js","https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css"]; +const cacheName = "app-" + "15bb89e03821d00f824b9b5cbea7b5b036e6fe2a"; +const resourcesToCache = ["/","/app.css","/app.js","/manifest.webmanifest","/wasm_exec.js","/web/app.wasm","/web/css/alert.css","/web/img/logo.png","https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js","https://cdn.jsdelivr.net/npm/halfmoon@2.0.1/css/halfmoon.min.css","https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.11/clipboard.min.js","https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css","https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-twilight.min.css"]; self.addEventListener("install", (event) => { - console.log("installing app worker e31aa1c4d4bf560a2b0d649865fab57a2bf48d9c"); + console.log("installing app worker 15bb89e03821d00f824b9b5cbea7b5b036e6fe2a"); event.waitUntil( caches @@ -28,7 +28,7 @@ self.addEventListener("activate", (event) => { ); }) ); - console.log("app worker e31aa1c4d4bf560a2b0d649865fab57a2bf48d9c is activated"); + console.log("app worker 15bb89e03821d00f824b9b5cbea7b5b036e6fe2a is activated"); }); self.addEventListener("fetch", (event) => { diff --git a/wasm/app.go b/wasm/app.go index ef8a7c5..2a58437 100644 --- a/wasm/app.go +++ b/wasm/app.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "sort" + "strconv" "github.com/maxence-charriere/go-app/v9/pkg/app" "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" @@ -89,17 +90,30 @@ func (h *crdView) Render() app.UI { yamlContent := app.Div().Class("accordion").ID("yaml-accordion-" + version.Version).Body( app.Div().Class("accordion-item").Body( app.H2().Class("accordion-header").Body( - app.Button().Class("accordion-button").Type("button").DataSets( - map[string]any{ - "bs-toggle": "collapse", - "bs-target": "#yaml-accordion-collapse-" + version.Version}). - Aria("expanded", "false"). - Aria("controls", "yaml-accordion-collapse-"+version.Version). - Body(app.Text("Details")), + app.Div().Class("container").Body(app.Div().Class("row").Body( + app.Div().Class("col").Body( + app.Button().Class("accordion-button").Type("button").DataSets( + map[string]any{ + "bs-toggle": "collapse", + "bs-target": "#yaml-accordion-collapse-" + version.Version}). + Aria("expanded", "false"). + Aria("controls", "yaml-accordion-collapse-"+version.Version). + Body(app.Text("Details")), + ), + app.Div().Class("col").Body( + app.Button().Class("clippy-"+strconv.Itoa(i)).DataSet("clipboard-target", "#yaml-sample-"+version.Version).Body( + app.Script().Text(fmt.Sprintf("new ClipboardJS('.clippy-%d');", i)), + app.I().Class("fa fa-clipboard"), + ), + ), + )), ), app.Div().Class("accordion-collapse collapse").ID("yaml-accordion-collapse-"+version.Version).DataSet("bs-parent", "#yaml-accordion-"+version.Version).Body( app.Div().Class("accordion-body").Body( - app.Pre().Body(app.Code().Class("language-yaml").Body(app.Text(version.YAML))), + app.Pre().Body( + app.Code().Class("language-yaml").ID("yaml-sample-"+version.Version).Body( + app.Text(version.YAML), + )), ), ), ), @@ -123,7 +137,11 @@ func (h *crdView) Render() app.UI { return div })) - return wrapper.Body(container) + return wrapper.Body( + app.Script().Src("https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-core.min.js"), + app.Script().Src("https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/autoloader/prism-autoloader.min.js"), + container, + ) } var borderOpacity = map[int]string{ diff --git a/wasm/app.js b/wasm/app.js index 3b6333e..d7452af 100644 --- a/wasm/app.js +++ b/wasm/app.js @@ -5,7 +5,7 @@ var goappNav = function () {}; var goappOnUpdate = function () {}; var goappOnAppInstallChange = function () {}; -const goappEnv = {"GOAPP_INTERNAL_URLS":"null","GOAPP_ROOT_PREFIX":"","GOAPP_STATIC_RESOURCES_URL":"","GOAPP_VERSION":"e31aa1c4d4bf560a2b0d649865fab57a2bf48d9c"}; +const goappEnv = {"GOAPP_INTERNAL_URLS":"null","GOAPP_ROOT_PREFIX":"","GOAPP_STATIC_RESOURCES_URL":"","GOAPP_VERSION":"15bb89e03821d00f824b9b5cbea7b5b036e6fe2a"}; const goappLoadingLabel = "{progress}%"; const goappWasmContentLengthHeader = ""; diff --git a/wasm/index.html b/wasm/index.html index 8093a65..b15154b 100644 --- a/wasm/index.html +++ b/wasm/index.html @@ -3,69 +3,67 @@
- + - + - +