Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Add failsafe to prevent theme1 & theme2 being dentical at time (#1385)

* Add failsafe for theme toggle

* remove unneeded /
Cette révision appartient à :
kilo 2017-08-22 02:49:43 +02:00 révisé par ewhal
Parent cd4154cf7f
révision 1a0f8e6604
2 fichiers modifiés avec 11 ajouts et 2 suppressions

Voir le fichier

@ -12,7 +12,6 @@ import (
// toggleThemeHandler : Controller to switch between theme1 & theme2
func toggleThemeHandler(c *gin.Context) {
//Get theme1 & theme2 value, set g.css & tomorrow.css by default
theme, err := c.Cookie("theme")
if err != nil {
theme = "g"
@ -21,6 +20,16 @@ func toggleThemeHandler(c *gin.Context) {
if err != nil {
theme2 = "tomorrow"
}
if theme == theme2 {
if theme == "tomorrow" {
theme2 = "g"
}
if theme != "tomorrow" {
theme2 = "tomorrow"
}
}
//Get theme1 & theme2 value, set g.css & tomorrow.css by default
//Also check if both theme are identical which can happen at time
//Switch theme & theme2 value
http.SetCookie(c.Writer, &http.Cookie{Name: "theme", Value: theme2, Domain: getDomainName(), Path: "/", Expires: timeHelper.FewDaysLater(365)})

Voir le fichier

@ -84,7 +84,7 @@
<footer id="footer">
<div class="container footer center">
<div class="footer-opt">
<p><a href="/settings">{{ T("change_settings") }}</a><a id="dark-toggle" href="/dark/{{ URL.String()}}"> - Toggle Dark Mode</a></p>
<p><a href="/settings">{{ T("change_settings") }}</a><a id="dark-toggle" href="/dark{{ URL.String()}}"> - Toggle Dark Mode</a></p>
</div>
<span><i>Powered by <a href="#">Nyaa Pantsu</a> v{{ Config.Version }} - commit <a id="commit" href="https://github.com/NyaaPantsu/nyaa/commit/{{ Config.Build }}">{{ Config.Build }}</a></i></span>
</div>