Compare commits

..

6 Commits

Author SHA1 Message Date
httpjamesm ef2f8afc4b style: reduced repetition in themes with common vars 2024-07-25 10:45:49 -07:00
httpjamesm ac69c3a59d fix: override theme in posthome 2024-07-25 10:14:06 -07:00
httpjamesm 6b9afed2dd fix: imports removed by copilot 2024-07-25 10:09:32 -07:00
httpjamesm 578e4b173e 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).
2024-07-25 10:03:55 -07:00
httpjamesm 31390edfc4 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).
2024-07-25 10:00:09 -07:00
httpjamesm bd969567a4 Add theme support using environment variable 2024-07-25 09:57:47 -07:00
4 changed files with 2 additions and 14 deletions
+1 -1
View File
@@ -43,7 +43,7 @@ StackOverflow has a cluttered UI that might distract you from the content you're
The open-source [Libredirect](https://github.com/libredirect/libredirect) extension for Firefox and Chromium-based desktop browsers has support for redirections to AnonymousOverflow. To enable this, simply open the extension settings, click on Stack Overflow, then toggle "Enable". That's it, now Stack Overflow links will go to AnonymousOverflow.
The open-source [Proxy_Redirect](https://openuserjs.org/scripts/sjehuda/Proxy_Redirect) user.js script for web browsers with userscript support. You can install it with a web extension like [Greasemonkey](https://greasespot.net/), [Tampermonkey](https://tampermonkey.net/) or [Violentmonkey](https://violentmonkey.github.io/). Once installed, Stack Overflow links will go to AnonymousOverflow.
The open-source [FREEdirector](https://openuserjs.org/scripts/sjehuda/FREEdirector) user.js script for web browsers with userscript support. You can install it with a web extension like [Greasemonkey](https://greasespot.net/), [Tampermonkey](https://tampermonkey.net/) or [Violentmonkey](https://violentmonkey.github.io/). Once installed, Stack Overflow links will go to AnonymousOverflow.
## How it works
+1 -1
View File
@@ -123,7 +123,7 @@
{
"url": "https://soflow.nerdvpn.de",
"regions": ["Ukraine"],
"operators": ["https://nerdvpn.de"]
"operators": ["https://github.com/Sommerwiesel"]
},
{
"url": "https://overflow.einfachzocken.eu/",
-2
View File
@@ -86,8 +86,6 @@ func main() {
r.GET("/proxy", routes.GetImage)
r.GET("/version", routes.GetVersion)
soPingCheck := checks.NewPingCheck("https://stackoverflow.com", "GET", 5000, nil, nil)
sePingCheck := checks.NewPingCheck("https://stackexchange.com", "GET", 5000, nil, nil)
healthcheck.New(r, config.DefaultConfig(), []checks.Check{soPingCheck, sePingCheck})
-10
View File
@@ -1,10 +0,0 @@
package routes
import (
"anonymousoverflow/config"
"github.com/gin-gonic/gin"
)
func GetVersion(c *gin.Context) {
c.String(200, config.Version)
}