Skip to content

Commit

Permalink
tiny refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Skarlso committed May 25, 2024
1 parent 2f6037a commit f016a9d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 33 deletions.
6 changes: 3 additions & 3 deletions wasm/app-worker.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const cacheName = "app-" + "65fbac8be5b22d2841d916b839e784627375616c";
const cacheName = "app-" + "f8ac4218bb548048986824403cd7e3fdb9206c6d";
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/[email protected]/dist/js/bootstrap.bundle.min.js","https://cdn.jsdelivr.net/npm/[email protected]/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 65fbac8be5b22d2841d916b839e784627375616c");
console.log("installing app worker f8ac4218bb548048986824403cd7e3fdb9206c6d");

event.waitUntil(
caches
Expand All @@ -28,7 +28,7 @@ self.addEventListener("activate", (event) => {
);
})
);
console.log("app worker 65fbac8be5b22d2841d916b839e784627375616c is activated");
console.log("app worker f8ac4218bb548048986824403cd7e3fdb9206c6d is activated");
});

self.addEventListener("fetch", (event) => {
Expand Down
42 changes: 22 additions & 20 deletions wasm/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,32 +60,34 @@ func (h *crdView) buildError(err error) app.UI {
}

func (h *crdView) OnNav(ctx app.Context) {
if strings.Contains(ctx.Page().URL().String(), "share") {
u := ctx.Page().URL().Query().Get("url")
if u == "" {
h.preRenderErr = errors.New(
"url parameter has to be define in the following format: " +
"/share?url=https://example.com/crd.yaml")

return
}
if !strings.Contains(ctx.Page().URL().String(), "share") {
return
}

if _, err := url.Parse(u); err != nil {
h.preRenderErr = fmt.Errorf("invald url provided in query: %w", err)
u := ctx.Page().URL().Query().Get("url")
if u == "" {
h.preRenderErr = errors.New(
"url parameter has to be define in the following format: " +
"/share?url=https://example.com/crd.yaml")

return
}
return
}

f := fetcher.NewFetcher(http.DefaultClient)
content, err := f.Fetch(u)
if err != nil {
h.preRenderErr = err
if _, err := url.Parse(u); err != nil {
h.preRenderErr = fmt.Errorf("invald url provided in query: %w", err)

return
}
return
}

h.content = content
f := fetcher.NewFetcher(http.DefaultClient)
content, err := f.Fetch(u)
if err != nil {
h.preRenderErr = err

return
}

h.content = content
}

// The Render method is where the component appearance is defined. Here, a
Expand Down
2 changes: 1 addition & 1 deletion wasm/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var goappOnAppInstallChange = function () {
goappAppInstallChangedBeforeWasmLoaded = true;
};

const goappEnv = {"GOAPP_INTERNAL_URLS":"null","GOAPP_ROOT_PREFIX":"/","GOAPP_STATIC_RESOURCES_URL":"/web","GOAPP_VERSION":"65fbac8be5b22d2841d916b839e784627375616c"};
const goappEnv = {"GOAPP_INTERNAL_URLS":"null","GOAPP_ROOT_PREFIX":"/","GOAPP_STATIC_RESOURCES_URL":"/web","GOAPP_VERSION":"f8ac4218bb548048986824403cd7e3fdb9206c6d"};
const goappLoadingLabel = "{progress}%";
const goappWasmContentLength = "";
const goappWasmContentLengthHeader = "";
Expand Down
18 changes: 9 additions & 9 deletions wasm/index.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
<!DOCTYPE html>
<html data-bs-core="modern" data-bs-theme="dark" lang="en">
<html data-bs-theme="dark" lang="en" data-bs-core="modern">
<head>
<meta charset="UTF-8">
<meta name="author" content="Gergely Brautigam">
<meta name="description" content>
<meta name="theme-color" content="#2d2c2c">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0, viewport-fit=cover">
<meta property="og:url" content="https://">
<meta property="og:title" content="Preview CRDs">
<meta content="Preview CRDs" property="og:title">
<meta property="og:description" content>
<meta property="og:type" content="website">
<meta property="og:image" content="https://">
<title>Preview CRDs</title>
<link as="style" href="/app.css" type="text/css" rel="preload">
<link type="text/css" rel="preload" as="style" href="/app.css">
<link href="/web/css/alert.css" type="text/css" rel="preload" as="style">
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-twilight.min.css" type="text/css" rel="preload" as="style">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/css/halfmoon.min.css" type="text/css" rel="preload" as="style">
<link as="style" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" type="text/css" rel="preload">
<link rel="preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-twilight.min.css" type="text/css">
<link rel="preload" as="style" href="https://cdn.jsdelivr.net/npm/[email protected]/css/halfmoon.min.css" type="text/css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" type="text/css" rel="preload" as="style">
<link rel="icon" href="https://raw.githubusercontent.com/maxence-charriere/go-app/master/docs/web/icon.svg">
<link rel="apple-touch-icon" href="/web/img/logo.png">
<link rel="manifest" href="/manifest.webmanifest">
<link href="/app.css" type="text/css" rel="stylesheet">
<link rel="stylesheet" href="/web/css/alert.css" type="text/css">
<link href="/web/css/alert.css" type="text/css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-twilight.min.css" type="text/css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/css/halfmoon.min.css" type="text/css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/halfmoon.min.css" type="text/css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" type="text/css">
<script defer src="/wasm_exec.js"></script>
<script defer src="/app.js"></script>
Expand Down Expand Up @@ -61,7 +61,7 @@
<body>
<main></main>
<aside id="app-wasm-loader" class="goapp-app-info">
<img src="/web/img/logo.png" id="app-wasm-loader-icon" class="goapp-logo goapp-spin" alt="wasm loader icon">
<img id="app-wasm-loader-icon" class="goapp-logo goapp-spin" alt="wasm loader icon" src="/web/img/logo.png">
<p id="app-wasm-loader-label" class="goapp-label">0%</p>
</aside>
</body>
Expand Down
Binary file modified wasm/web/app.wasm
Binary file not shown.

0 comments on commit f016a9d

Please sign in to comment.