Commit graph

8 commits

Author SHA1 Message Date
httpjamesm
4c971f3121
Add theme support using environment variable (#145)
* Add theme support using environment variable

* Propagate theme variable to template in options.go

Propagate the `theme` variable from the environment to the template in `src/routes/options.go`

* Retrieve the `theme` variable from the environment using `os.Getenv("THEME")`
* Set the `theme` variable in the `gin.H` map when rendering the `home.html` template


---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/httpjamesm/AnonymousOverflow/pull/145?shareId=6397c9b4-9450-425c-bbbe-019425965d2b).

* Move all theme environment variable logic to a utils function

Move theme environment variable logic to a utils function and update routes to use it.

* Add `GetThemeFromEnv` function in `src/utils/theme.go` to derive the theme from environment variables and default to "auto" if not set.
* Update `src/routes/home.go` to import and use `GetThemeFromEnv` in the `GetHome` function.
* Update `src/routes/options.go` to import and use `GetThemeFromEnv` in the `ChangeOptions` function.
* Update `src/routes/question.go` to import and use `GetThemeFromEnv` in the `ViewQuestion` function.


---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/httpjamesm/AnonymousOverflow/pull/145?shareId=a0dab6f3-027c-4f6e-85fe-60e7675d0e70).

* fix: imports removed by copilot

* fix: override theme in posthome

* style: reduced repetition in themes with common vars
2024-07-25 10:50:06 -07:00
httpjamesm
e409176642
media query theme (#139)
* feat: use css media query to derive theme

* fix: rename alt for toggle images

* feat: remove no-cache middleware
2024-06-20 00:18:22 -04:00
httpjamesm
991b5b46f4
fix: allow option parsing if only one is present (#60) 2023-09-24 00:59:48 -04:00
httpjamesm
c46820b6d4 fix: add version, rolling ratelimit 2022-12-29 13:54:37 -05:00
httpjamesm
0e9677ec61 feat: success message indicator, better UX for image toggling 2022-12-29 13:52:17 -05:00
httpjamesm
d664899ab6 feat: update example compose, change default redirect 2022-12-28 11:57:08 -05:00
httpjamesm
d92edafb03 feat!: APP_URL env, theme switcher icon with redirect 2022-12-28 11:56:17 -05:00
httpjamesm
10946dcafb feat: change options 2022-12-28 00:08:06 -05:00