Albirew/nyaa-pantsu
Albirew
/
nyaa-pantsu
Archivé
1
0
Bifurcation 0

"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 à :
kilo 2017-08-30 07:21:45 +02:00 révisé par ewhal
Parent 508c6fd578
révision 5a184bfb50
14 fichiers modifiés avec 71 ajouts et 18 suppressions

Voir le fichier

@ -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, "/")
}

Voir le fichier

@ -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"`

Voir le fichier

@ -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 {

Voir le fichier

@ -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;
}
@ -197,4 +208,4 @@ td.tr-le, .error-text {
.modtools {
background-color: #F7F8F9;
border-color: #cbbdd7;
}
}

Voir le fichier

@ -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 {

Voir le fichier

@ -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;
}

Voir le fichier

@ -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>

Voir le fichier

@ -3,7 +3,7 @@
{{block title()}}{{ T("home")}}{{end}}
{{block contclass()}}{{if User.HasAdmin() }}content-admin{{end}}{{end}}
{{block content_body()}}
<!-- Contain the table within a grid, as for better sizing -->
<!-- Contain the table within a grid, as for better sizing -->
<div class="results box">
<table>
<thead class="torrent-info">
@ -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() }}

Voir le fichier

@ -13,7 +13,7 @@
<h3>{{ T("name")}}</h3>
<input type="text" name="name" id="name" class="form-input up-input form-torrent-name" placeholder="{{ T("file_name")}}" value="{{Form.Name}}" autofocus>
{{ yield errors(name="name")}}
<div class="torrent-preview-table" style="display: none;"><center><h3 style="margin-bottom: 3px;">{{ T("torrent_preview")}}</h3></center>
<table>
<thead class="torrent-info table-torrent-thead">
@ -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>

Voir le fichier

@ -3,7 +3,7 @@
{{block title()}}{{ T("change_settings")}}{{end}}
{{block content_body()}}
<div style="text-align: left;" class="box">
<form role="form" method="POST">
<form role="form" method="POST">
{{ yield csrf_field() }}
<div class="form-group">
<h3>{{ T("language")}}</h3>
@ -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>

Voir le fichier

@ -3,14 +3,14 @@
{{ 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>
<th class="tr-links user-td">{{ T("links")}}</th>
<th class="tr-size user-td hide-xs">{{ T("size")}}</th>
<th class="tr-date user-td hide-smol">{{ T("date")}}</th>
</tr>
</tr>
{{ range i, t := UserProfile.Torrents }}
{{ torrent := t.ToJSON() }}
<tr class="torrent-info

Voir le fichier

@ -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)

Voir le fichier

@ -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{})

Voir le fichier

@ -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)