"Alternating Colors" option in settings (#1440)
* Non-bold torrent name when using alternating background colors * Add alternating colors for g.css * Add alternating colors for classic.css * Add alternating colors for tomorreuw * Update classic.css * Add alternating colors to settings page * Add alt-colors class to tbody if enabled * Add GetAltColorsFromRequest() function to get AltColors cookie value * Create AltColors variable for usage in listing * Make settings handle altColors input * Add AltColors in user struct * Returned the wrong variable here * Turn function return value into bool * Condition checks variable like a bool * ditto * better color for g.css * even better color * better * Last change for g.css * Improvement for tomorrow * Update classic.css * add alt-colors class to upload preview * Add alt-colors to user profile * more vivid color for g * Fix typo * Remove browser outline for refine when clicked on * remove browser outline * Fix rules that didn't apply and category icon being way too small on user profile thanks to usage of percentage * Remove show-xs class for search inputs * Turn refine button back into position: absolute to pin at very bottom of refine * Alternating colors for g's trusted, remake & aplus * Update tomorrow.css * attempt at fixing travis * test (will have to rollback that change) * rollback * will have to rollback * will have to rollback * will have to rollback * will have to rollback * add AltColors variable to template test * rollback * rollback * rollback * rollback
Cette révision appartient à :
Parent
508c6fd578
révision
5a184bfb50
14 fichiers modifiés avec 71 ajouts et 18 suppressions
|
@ -33,6 +33,7 @@ func ChangePublicSettingsHandler(c *gin.Context) {
|
|||
lang := c.PostForm("language")
|
||||
mascot := c.PostForm("mascot")
|
||||
mascotURL := c.PostForm("mascot_url")
|
||||
altColors := c.PostForm("altColors")
|
||||
|
||||
messages := msg.GetMessages(c)
|
||||
|
||||
|
@ -59,6 +60,7 @@ func ChangePublicSettingsHandler(c *gin.Context) {
|
|||
user.Theme = theme
|
||||
user.Mascot = mascot
|
||||
user.MascotURL = mascotURL
|
||||
user.AltColors = altColors
|
||||
user.UpdateRaw()
|
||||
}
|
||||
// Set cookie with http and not gin for expires (maxage not supported in <IE8)
|
||||
|
@ -66,6 +68,7 @@ func ChangePublicSettingsHandler(c *gin.Context) {
|
|||
http.SetCookie(c.Writer, &http.Cookie{Name: "theme", Value: theme, Domain: getDomainName(), Path: "/", Expires: timeHelper.FewDaysLater(365)})
|
||||
http.SetCookie(c.Writer, &http.Cookie{Name: "mascot", Value: mascot, Domain: getDomainName(), Path: "/", Expires: timeHelper.FewDaysLater(365)})
|
||||
http.SetCookie(c.Writer, &http.Cookie{Name: "mascot_url", Value: mascotURL, Domain: getDomainName(), Path: "/", Expires: timeHelper.FewDaysLater(365)})
|
||||
http.SetCookie(c.Writer, &http.Cookie{Name: "altColors", Value: altColors, Domain: getDomainName(), Path: "/", Expires: timeHelper.FewDaysLater(365)})
|
||||
|
||||
c.Redirect(http.StatusSeeOther, "/")
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ type User struct {
|
|||
APITokenExpiry time.Time `gorm:"column:api_token_expiry"`
|
||||
Language string `gorm:"column:language"`
|
||||
Theme string `gorm:"column:theme"`
|
||||
AltColors string `gorm:"column:alt_colors"`
|
||||
Mascot string `gorm:"column:mascot"`
|
||||
MascotURL string `gorm:"column:mascot_url"`
|
||||
UserSettings string `gorm:"column:settings"`
|
||||
|
|
|
@ -113,7 +113,9 @@ td.tr-le, .error-text {
|
|||
color: #1fa4d0;
|
||||
}
|
||||
|
||||
|
||||
.alt-colors tr:nth-child(odd) {
|
||||
background: hsla(231, 8%, 73%, 0.2);
|
||||
}
|
||||
/* Original Nyaa colors, do NOT change! */
|
||||
|
||||
.aplus, .btn-blue {
|
||||
|
|
|
@ -115,6 +115,17 @@ td.tr-le, .error-text {
|
|||
color: #E8E8E8;
|
||||
}
|
||||
|
||||
.alt-colors tr:nth-child(odd) {
|
||||
background: hsla(288, 39%, 83%, 0.2);
|
||||
}
|
||||
.alt-colors tr:nth-child(even).aplus {
|
||||
background: hsla(200, 90%, 56%, 0.2) !important;
|
||||
}
|
||||
.alt-colors tr:nth-child(even).trusted {
|
||||
background: hsla(100, 100%, 63%, 0.2) !important;
|
||||
}
|
||||
.alt-colors tr:nth-child(even).remake {
|
||||
background: hsla(30, 100%, 62%, 0.2) !important;
|
||||
.aplus, .btn-blue {
|
||||
background: hsla(200, 100%, 50%, 0.2) !important;
|
||||
}
|
||||
|
|
|
@ -186,12 +186,14 @@ select.form-input {
|
|||
width: 22px;
|
||||
height: 25px;
|
||||
border: none;
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.form-input.refine {
|
||||
border-radius: 0 3px 3px 0;
|
||||
border-left: none;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.form-input.language {
|
||||
|
@ -515,6 +517,9 @@ th {
|
|||
word-break: break-word;
|
||||
font-weight: bold;
|
||||
}
|
||||
.alt-colors .tr-name {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.tr-links {
|
||||
width: 48px;
|
||||
|
@ -699,6 +704,9 @@ html, body {
|
|||
.tr-cat {
|
||||
width: 8.7%;
|
||||
}
|
||||
.user-td.tr-cat {
|
||||
width: 11.7%;
|
||||
}
|
||||
.torrent-preview-table .tr-cat {
|
||||
width: 9.1%;
|
||||
}
|
||||
|
@ -791,10 +799,10 @@ html, body {
|
|||
display: block!important;
|
||||
}
|
||||
.profile-panel, .profile-content {
|
||||
border-radius: 4px;
|
||||
border-right: 1px solid;
|
||||
border-radius: 4pximportant;
|
||||
border-right: 1px solid!important;
|
||||
width: 100% !important;
|
||||
margin-bottom: 20px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.header .h-user {
|
||||
width: 46px;
|
||||
|
@ -809,9 +817,6 @@ html, body {
|
|||
.header .h-user .user-menu {
|
||||
right: 104px;
|
||||
}
|
||||
.box {
|
||||
padding: 7px;
|
||||
}
|
||||
.torrent-preview-table .tr-cat {
|
||||
width: 74px;
|
||||
}
|
||||
|
@ -1661,7 +1666,9 @@ details[open] summary:after {
|
|||
.refine-btn {
|
||||
width: 426px;
|
||||
max-width: 100%;
|
||||
float:right;
|
||||
position:absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.torrent-preview-table>table {
|
||||
|
|
|
@ -88,6 +88,12 @@ td.tr-le, .error-text {
|
|||
background-color: #cc6666;
|
||||
}
|
||||
|
||||
.alt-colors tr:nth-child(even) {
|
||||
background: hsla(255, 4%, 29%, 0.2);
|
||||
}
|
||||
.alt-colors tr:nth-child(odd) {
|
||||
background: hsla(255, 31%, 6%, 0.2);
|
||||
}
|
||||
.aplus, .btn-blue {
|
||||
background: hsla(180, 50%, 50%, 0.2) !important;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
<input class="form-input refine-date spacing" size="7" name="toDate" type="text" value="{{Search.ToDate}}" placeholder="YYYY/MM/DD"/>
|
||||
Exclude: <input type="text" name="nuserID" placeholder="UserID" value="" class="form-input refine-userid" style="width: 62px;">
|
||||
</span>
|
||||
<span class="form-refine show-xs" style="margin-bottom: 2px;">
|
||||
<span class="form-refine" style="margin-bottom: 2px;">
|
||||
<span class="spacing">{{T("sort_by")}}</span>
|
||||
<select name="sort" class="form-input">
|
||||
<option value="1"{{if Search.Sort == 1}}selected{{end}}>{{T("name")}}</option>
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="torrentListResults">
|
||||
<tbody id="torrentListResults" {{if AltColors}}class="alt-colors"{{end}}>
|
||||
{{ range Models}}
|
||||
<tr id="torrent_{{ .ID }}" class="torrent-info {{if .Status == 2}}remake{{else if .Status == 3}}trusted{{else if .Status == 4}}aplus{{end}}" >
|
||||
{{ if User.HasAdmin() }}
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="torrentListResults">
|
||||
<tbody id="torrentListResults" {{if AltColors}}class="alt-colors"{{end}}>
|
||||
<tr class="torrent-info hidden">
|
||||
<td class="tr-cat home-td"></td>
|
||||
<td class="tr-name home-td" colspan="2"><a></a></td>
|
||||
|
|
|
@ -31,6 +31,13 @@
|
|||
<input type="text" name="mascot_url" class="form-input" value="{{ MascotURL }}"/>
|
||||
<br/>
|
||||
|
||||
<h3>Alternating Colors</h3>
|
||||
<select id="altColors-selector" name="altColors" class="form-input">
|
||||
<option value="false">Disabled</option>
|
||||
<option value="true" {{if AltColors}}selected{{end}}>Enabled</option>
|
||||
</select>
|
||||
<br/>
|
||||
|
||||
<p>{{ T("cookies")}}</p>
|
||||
<button type="submit" class="form-input btn">{{ T("save_changes")}}</button>
|
||||
</div>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
{{ block profile_navigation()}}{{ yield profile_menu(route="profile") }}{{end}}
|
||||
{{block profile_content()}}
|
||||
{{ if len(UserProfile.Torrents) > 0 }}
|
||||
<table>
|
||||
<table {{if AltColors}}class="alt-colors"{{end}}>
|
||||
<tr class="torrent-info">
|
||||
<th class="tr-cat user-td">{{ T("category")}}</th>
|
||||
<th class="tr-name user-td">{{ T("name")}}</th>
|
||||
|
|
|
@ -53,6 +53,7 @@ func Commonvariables(c *gin.Context) jet.VarMap {
|
|||
variables.Set("Search", NewSearchForm(c))
|
||||
variables.Set("T", publicSettings.GetTfuncFromRequest(c))
|
||||
variables.Set("Theme", publicSettings.GetThemeFromRequest(c))
|
||||
variables.Set("AltColors", publicSettings.GetAltColorsFromRequest(c))
|
||||
variables.Set("Mascot", publicSettings.GetMascotFromRequest(c))
|
||||
variables.Set("MascotURL", publicSettings.GetMascotURLFromRequest(c))
|
||||
variables.Set("User", user)
|
||||
|
|
|
@ -51,7 +51,9 @@ func walkDirTest(dir string, t *testing.T) {
|
|||
em := "cop@cat.fe"
|
||||
|
||||
fakeTag := &models.Tag{1, 1, "12345", "anidbid", 1, 0, true}
|
||||
fakeUser := &models.User{1, "test", "test", "test", 1, time.Now(), time.Now(), "test", time.Now(), "en", "test", "test", "test", "test", 0, []models.User{}, []models.User{}, "test", []models.Torrent{}, []models.Notification{}, 1, models.UserSettings{}, []models.Tag{*fakeTag}}
|
||||
//fakeUser := &models.User{1, "test", "test", "test", 1, time.Now(), time.Now(), "test", time.Now(), "en", "test", "test", "test", "test", 0, []models.User{}, []models.User{}, "test", []models.Torrent{}, []models.Notification{}, 1, models.UserSettings{}, []models.Tag{*fakeTag}}
|
||||
//The first fakeUser is the real line, had to modify it without knowing what the fuck i did to fix travis
|
||||
fakeUser := &models.User{1, "test", "test", "test", 1, time.Now(), time.Now(), "test", time.Now(), "en", "test", "test", "test", "test", "test", 0.0, []models.User{}, []models.User{}, "test", []models.Torrent{}, []models.Notification{}, 1, models.UserSettings{}, []models.Tag{*fakeTag}}
|
||||
fakeComment := &models.Comment{1, 1, 1, "test", time.Now(), time.Now(), nil, &models.Torrent{}, fakeUser}
|
||||
fakeScrapeData := &models.Scrape{1, 0, 0, 10, time.Now()}
|
||||
fakeFile := &models.File{1, 1, "l12:somefile.mp4e", 3}
|
||||
|
@ -278,6 +280,7 @@ func mockupCommonvariables(t *testing.T) jet.VarMap {
|
|||
}
|
||||
variables.Set("T", T)
|
||||
variables.Set("Theme", "test")
|
||||
variables.Set("AltColors", "test")
|
||||
variables.Set("Mascot", "test")
|
||||
variables.Set("MascotURL", "test")
|
||||
variables.Set("User", &models.User{})
|
||||
|
|
|
@ -181,6 +181,18 @@ func GetThemeFromRequest(c *gin.Context) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func GetAltColorsFromRequest(c *gin.Context) bool {
|
||||
user, _ := getCurrentUser(c)
|
||||
if user.ID > 0 {
|
||||
return user.AltColors == "true"
|
||||
}
|
||||
cookie, err := c.Cookie("altColors")
|
||||
if err == nil {
|
||||
return cookie == "true"
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// GetMascotFromRequest : Gets the user selected theme from the request
|
||||
func GetMascotFromRequest(c *gin.Context) string {
|
||||
user, _ := getCurrentUser(c)
|
||||
|
|
Référencer dans un nouveau ticket