From 33c1b0dd178a4f52402fc5bc66709b3cf23ec051 Mon Sep 17 00:00:00 2001 From: Tigor Hutasuhut Date: Mon, 29 Apr 2024 13:31:09 +0700 Subject: [PATCH] navigation: added theme select support --- Makefile | 5 ++ api/context.go | 32 ------------ api/reddit/check_subreddit.go | 8 --- views/components/doctype.templ | 2 +- views/components/head.templ | 2 +- views/components/navigation.templ | 64 +++++++++++++++-------- views/homeview/recently_added_image.templ | 6 +-- 7 files changed, 52 insertions(+), 67 deletions(-) delete mode 100644 api/context.go diff --git a/Makefile b/Makefile index 272cf19..73b77dc 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,11 @@ build-dependencies: echo "Dayjs Relative Time not found, installing it" curl -o public/dayjs-relativeTime-1.11.10.min.js https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.10/plugin/relativeTime.min.js fi + @if [ ! -f "public/theme-change-2.0.2.min.js" ]; then + mkdir -p public + echo "Theme change not found, installing it" + curl -o public/theme-change-2.0.2.min.js https://cdn.jsdelivr.net/npm/theme-change@2.0.2/index.js + fi build: build-dependencies prepare go build -o redmage diff --git a/api/context.go b/api/context.go deleted file mode 100644 index ff5d7dc..0000000 --- a/api/context.go +++ /dev/null @@ -1,32 +0,0 @@ -package api - -import ( - "context" - "time" -) - -type noTimeoutContext struct { - inner context.Context -} - -func (no noTimeoutContext) Deadline() (deadline time.Time, ok bool) { - return time.Time{}, false -} - -func (no noTimeoutContext) Done() <-chan struct{} { - return nil -} - -func (no noTimeoutContext) Err() error { - return nil -} - -func (no noTimeoutContext) Value(key any) any { - return no.inner.Value(key) -} - -func noCancelContext(ctx context.Context) context.Context { - return noTimeoutContext{ - inner: ctx, - } -} diff --git a/api/reddit/check_subreddit.go b/api/reddit/check_subreddit.go index cbbd941..2553e3f 100644 --- a/api/reddit/check_subreddit.go +++ b/api/reddit/check_subreddit.go @@ -65,14 +65,6 @@ func (reddit *Reddit) CheckSubreddit(ctx context.Context, params CheckSubredditP "response.location", resp.Request.URL.String(), ).Code(http.StatusTooManyRequests) } - if resp.StatusCode >= 400 { - msg := fmt.Sprintf("unexpected %d status code from reddit", resp.StatusCode) - return actual, errs.Fail(msg, - "params", params, - "url", url, - "response.location", resp.Request.URL.String(), - ).Code(http.StatusFailedDependency) - } if resp.Request.URL.Path == "/subreddits/search.json" { return actual, errs.Fail("subreddit not found", diff --git a/views/components/doctype.templ b/views/components/doctype.templ index ac0a3a9..51d3de2 100644 --- a/views/components/doctype.templ +++ b/views/components/doctype.templ @@ -2,7 +2,7 @@ package components templ Doctype() { - + { children... } } diff --git a/views/components/head.templ b/views/components/head.templ index ed3f924..5a0b6fb 100644 --- a/views/components/head.templ +++ b/views/components/head.templ @@ -13,6 +13,7 @@ templ Head(vc *views.Context, extras ...templ.Component) { + if vc.Config.Bool("http.hotreload") { } @@ -25,4 +26,3 @@ templ Head(vc *views.Context, extras ...templ.Component) { templ HeadTitle(name string) { { name } } - diff --git a/views/components/navigation.templ b/views/components/navigation.templ index 332fb8e..e6feace 100644 --- a/views/components/navigation.templ +++ b/views/components/navigation.templ @@ -9,7 +9,7 @@ templ Navigation(c *views.Context) {