Fix unintended behavior for theme toggler when logged in, fix missing styling for a button & background of markdown for classic theme (#1747)
* missing background color, fix missing background color on markdown editor on torrent view page fix missing classic styling on "Upload to Nyaa/Sukebei" button * Fix theme toggler that didn't behave as intended Fix theme toggler that didn't behave as intended when the user was logged in and his theme cookie had a different value than his user theme setting * Classic theme default on nyaa.pt
Cette révision appartient à :
Parent
a2ea5b3bea
révision
418dc81e19
3 fichiers modifiés avec 36 ajouts et 11 suppressions
|
@ -7,26 +7,29 @@ import (
|
|||
"github.com/NyaaPantsu/nyaa/controllers/router"
|
||||
"github.com/NyaaPantsu/nyaa/utils/timeHelper"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/NyaaPantsu/nyaa/utils/publicSettings"
|
||||
|
||||
)
|
||||
|
||||
// toggleThemeHandler : Controller to switch between theme1 & theme2
|
||||
func toggleThemeHandler(c *gin.Context) {
|
||||
|
||||
theme, err := c.Cookie("theme")
|
||||
if err != nil {
|
||||
theme = config.DefaultTheme(false)
|
||||
}
|
||||
DefaultTheme := config.DefaultTheme(false)
|
||||
DefaultDarkTheme := config.DefaultTheme(true)
|
||||
|
||||
theme := publicSettings.GetThemeFromRequest(c)
|
||||
theme2, err := c.Cookie("theme2")
|
||||
|
||||
if err != nil {
|
||||
theme2 = config.DefaultTheme(true)
|
||||
theme2 = publicSettings.GetDarkThemeFromRequest(c)
|
||||
}
|
||||
if theme != config.DefaultTheme(true) && theme2 != config.DefaultTheme(true) {
|
||||
|
||||
if theme != DefaultDarkTheme && theme2 != DefaultDarkTheme {
|
||||
//None of the themes are dark ones, force the second one as the dark one
|
||||
theme2 = config.DefaultTheme(true)
|
||||
theme2 = DefaultDarkTheme
|
||||
} else if theme == theme2 {
|
||||
//Both theme are dark ones, force the second one as the default (light) theme
|
||||
theme2 = config.DefaultTheme(false)
|
||||
theme2 = DefaultTheme
|
||||
}
|
||||
//Get theme1 & theme2 value
|
||||
|
||||
|
|
|
@ -454,7 +454,7 @@ span.comment-user:hover {
|
|||
float: right;
|
||||
margin-top: 7px;
|
||||
}
|
||||
.torrent-buttons a, .torrent-buttons button {
|
||||
.torrent-buttons a, .torrent-buttons button, .torrent-buttons input[type="submit"] {
|
||||
height: 26px!important;
|
||||
background: linear-gradient(to bottom, #33ca98 0%, #336867 72%);
|
||||
color: white!important;
|
||||
|
@ -465,9 +465,9 @@ span.comment-user:hover {
|
|||
border: none;
|
||||
padding: 2px 7px;
|
||||
margin-right: 6px;
|
||||
float: left;
|
||||
float: left!important;
|
||||
}
|
||||
.sukebei .torrent-buttons a, .sukebei .torrent-buttons button {
|
||||
.sukebei .torrent-buttons a, .sukebei .torrent-buttons button, .sukebei .torrent-buttons input[type="submit"] {
|
||||
background: linear-gradient(to bottom, #CA3346 5%, #482120 80%);
|
||||
}
|
||||
.torrent-buttons a.hidden {
|
||||
|
@ -476,6 +476,7 @@ span.comment-user:hover {
|
|||
}
|
||||
.torrent-buttons a:hover {
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
.torrent-buttons div {
|
||||
margin-right: 0!important;
|
||||
|
@ -733,6 +734,7 @@ span.tag {
|
|||
.comment-form .editor-toolbar a {
|
||||
width: 24px;
|
||||
height: 20px;
|
||||
background: #fbfbfb;
|
||||
}
|
||||
.editor-toolbar a:before {
|
||||
line-height: 25px;
|
||||
|
|
|
@ -195,6 +195,26 @@ function startupCode() {
|
|||
//If user has no default theme, set these by default
|
||||
|
||||
|
||||
if(getCookieValue("theme") == "") {
|
||||
//User has no theme selected, we check if the domain name (without sub domain) includes the word "nyaa" and if it does, we set the theme as classic theme
|
||||
|
||||
var hostName = window.location.host
|
||||
|
||||
var lastDotIndex = hostName.lastIndexOf(".")
|
||||
var secondLast = -1
|
||||
|
||||
for(var index = 0; index < lastDotIndex; index++) {
|
||||
if(hostName[index] == '.')
|
||||
secondLast = index
|
||||
}
|
||||
hostName = hostName.substr(secondLast == -1 ? 0 : secondLast)
|
||||
|
||||
if(hostName.includes("nyaa")) {
|
||||
document.cookie = "theme=classic;path=/;expires=" + farFutureString + ";domain=" + domain
|
||||
document.getElementById("theme").href = "/css/themes/classic.css";
|
||||
}
|
||||
}
|
||||
|
||||
if(document.cookie.includes("theme2=")) {
|
||||
UserTheme[1] = getCookieValue("theme2")
|
||||
//If user already has ran the ToggleTheme() function in the past, we get the value of the second theme (the one the script switches to)
|
||||
|
|
Référencer dans un nouveau ticket