diff --git a/src/admin-client/src/app.css b/src/admin-client/src/app.css index 7bb1a9f..e37a57d 100644 --- a/src/admin-client/src/app.css +++ b/src/admin-client/src/app.css @@ -52,6 +52,10 @@ section { .spacer { display: inline-block; width: 24px; } #pnlImportErrors { white-space: pre-wrap; color: var(--clrError); } +#cnvIcon { + width: 256px; height: 256px; background-color: black; +} + @font-face { font-display: swap; font-family: 'Open Sans'; diff --git a/src/admin-client/src/app.js b/src/admin-client/src/app.js index c94eb88..68d6848 100644 --- a/src/admin-client/src/app.js +++ b/src/admin-client/src/app.js @@ -1,4 +1,5 @@ import {feedUrls} from "./urls-debug.js"; +import {initGenIcon} from "./gen-icon.js"; const elmTxtServerUrl = document.getElementById("txtServerUrl"); const elmTxtApiKey = document.getElementById("txtApiKey"); @@ -31,6 +32,7 @@ const feedImportStats = { initParams(); initFeedImport(); +initGenIcon(); function initParams() { let stgs = null; diff --git a/src/admin-client/src/gen-icon.js b/src/admin-client/src/gen-icon.js new file mode 100644 index 0000000..c5dd35d --- /dev/null +++ b/src/admin-client/src/gen-icon.js @@ -0,0 +1,18 @@ +let elmCanvas, elmLink; + +export function initGenIcon() { + + // Get elements + elmCanvas = document.getElementById("cnvIcon"); + elmLink = document.getElementById("lnkSaveIcon"); + + // Draw parrot emoji + const ctx = elmCanvas.getContext("2d"); + ctx.font = "192px Arial"; + ctx.fillText("🦜", 36, 196); + + // Get PNG image and add to link as data URL + const dataURL = elmCanvas.toDataURL("image/png"); + elmLink.href = dataURL; + elmLink.download = "favicon-256.png"; +} diff --git a/src/admin-client/src/index.html b/src/admin-client/src/index.html index af08c57..bd33586 100644 --- a/src/admin-client/src/index.html +++ b/src/admin-client/src/index.html @@ -45,5 +45,12 @@

Import feeds

+
+

Generate favicon

+ +
+ Save icon +
+ \ No newline at end of file diff --git a/src/server/server/server.go b/src/server/server/server.go index 85bea7b..07f0e08 100644 --- a/src/server/server/server.go +++ b/src/server/server/server.go @@ -14,6 +14,7 @@ import ( ) const assetsDir = "/assets" +const faviconName = "/favicon.ico" const chunkSize = 65536 const strCacheControlHdr = "Cache-Control" @@ -105,12 +106,16 @@ func handleStatic(logger shared.ILogger, w.Header().Set(strCacheControlHdr, "max-age=31536000, immutable") - if !strings.HasPrefix(r.URL.Path, assetsDir) { + // We serve everything from /assets folder, EXCEPT favicon.ico, which gets special treatment + if r.URL.Path != faviconName && !strings.HasPrefix(r.URL.Path, assetsDir) { return404() return } fn := filepath.Join(wwwPathPrefx, r.URL.Path) + if r.URL.Path == faviconName { + fn = filepath.Join(wwwPathPrefx, assetsDir, r.URL.Path) + } file, err := os.Open(fn) if err != nil { return404() diff --git a/src/server/www/assets/favicon-16x16.png b/src/server/www/assets/favicon-16x16.png new file mode 100644 index 0000000..bc499b3 Binary files /dev/null and b/src/server/www/assets/favicon-16x16.png differ diff --git a/src/server/www/assets/favicon-32x32.png b/src/server/www/assets/favicon-32x32.png new file mode 100644 index 0000000..51ee71b Binary files /dev/null and b/src/server/www/assets/favicon-32x32.png differ diff --git a/src/server/www/assets/favicon.ico b/src/server/www/assets/favicon.ico new file mode 100644 index 0000000..d0e4f38 Binary files /dev/null and b/src/server/www/assets/favicon.ico differ diff --git a/src/server/www/index.tmpl b/src/server/www/index.tmpl index 1c34269..0fcbb14 100644 --- a/src/server/www/index.tmpl +++ b/src/server/www/index.tmpl @@ -6,8 +6,8 @@ RSS Parrot - +{{/* */}} +{{/* */}}