Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

fix wrong translation string being used on user edit page for mods & improve stats.go (#1665)

* fix wrong translation string being used on user edit page for mods

* fix css rule that did not apply

* fix error in stats.go

* stats.go scrapes default trackers if torrent has no tracker

* remove useless thing

* change behavior of right arrow in page list (now goes to latest page)

* fix { too much

* Update view.jet.html

* Update view.jet.html

* pin user search input & link at the bottom of user page

* HTML to go along
Cette révision appartient à :
kilo 2017-10-15 13:18:57 +02:00 révisé par GitHub
Parent 61d1aa4195
révision 1ec2a77974
7 fichiers modifiés avec 48 ajouts et 10 suppressions

Voir le fichier

@ -8,6 +8,7 @@ import (
"github.com/NyaaPantsu/nyaa/models/torrents"
"github.com/NyaaPantsu/nyaa/models"
"github.com/NyaaPantsu/nyaa/config"
"github.com/Stephen304/goscrape"
"github.com/gin-gonic/gin"
)
@ -27,14 +28,19 @@ func GetStatsHandler(c *gin.Context) {
var Trackers []string
for _, line := range strings.Split(torrent.Trackers[3:], "&tr=") {
//Starts at character 3 because the three first characters are always "tr=" so we need to dismiss them
tracker, error := url.QueryUnescape(line)
if error == nil && tracker[:6] == "udp://" {
if error == nil && strings.Contains(tracker, "udp://") {
Trackers = append(Trackers, tracker)
}
//Cannot scrape from http trackers so don't put them in the array
}
for _, line := range config.Get().Torrents.Trackers.Default {
if !contains(Trackers, line) {
Trackers = append(Trackers, line)
}
}
stats := goscrape.Single(Trackers, []string{
torrent.Hash,
})[0]
@ -73,3 +79,12 @@ func GetStatsHandler(c *gin.Context) {
return
}
func contains(s []string, e string) bool {
for _, a := range s {
if a == e {
return true
}
}
return false
}

Voir le fichier

@ -2216,6 +2216,19 @@ form.delete-form button.form-input.btn-red {
height: 28px;
}
.user-torrent-table {
margin-bottom: 80px
}
.user-torrent-search {
width: 100%;
position: absolute;
right: 0;
left: 0;
bottom: 9px;
}
/* Language specific CSS */
html[lang="ja-jp"] .form-refine span.spacing {

Voir le fichier

@ -123,9 +123,9 @@ th.tr-name a {
.icon-magnet:before {
font-size: 14px;
}.upload-tag-table
}
.icon-floppy::before {
.icon-floppy:before {
content: '';
}
.icon-floppy {

Voir le fichier

@ -151,10 +151,18 @@
{{ if User.ID > 0}}
<a id="reportPopup" href="#" class="form-input">{{ T("report_btn") }}</a>
{{ if User.HasAdmin()}}
<a href="/mod/torrent/delete?id={{ Torrent.ID }}" class="form-input btn-red" onclick="if (!confirm('{{ T("are_you_sure") }}')) return false;">{{ T("delete") }}</a>
<form method="POST" action="/mod/torrent/delete" class="delete-form">
{{ yield csrf_field()}}
<input type="hidden" name="id" value="{{ Torrent.ID }}">
<button type="submit" class="form-input btn-red" onclick="if (!confirm('{{ T(" are_you_sure ") }}{{ T("delete") }}')) return false;"><i class="icon-trash"></i>{{ T("delete") }}</button>
</form>
<a href="/mod/torrent?id={{ Torrent.ID }}" class="form-input btn-orange">{{ T("edit") }}</a>
{{ else if User.CurrentUserIdentical(Torrent.UploaderID) }}
<a href="/torrent/delete?id={{ Torrent.ID }}" class="form-input btn-red" onclick="if (!confirm('{{ T("are_you_sure") }}')) return false;">{{ T("delete") }}</a>
<form method="POST" action="/torrent/delete" class="delete-form">
{{ yield csrf_field()}}
<input type="hidden" name="id" value="{{ Torrent.ID }}">
<button type="submit" class="form-input btn-red" onclick="if (!confirm('{{ T(" are_you_sure ") }}{{ T("delete") }}')) return false;"><i class="icon-trash"></i>{{ T("delete") }}</button>
</form>
<a href="/torrent?id={{ Torrent.ID }}" class="form-input btn-orange">{{ T("edit") }}</a>
{{end}}
{{end}}

Voir le fichier

@ -233,7 +233,7 @@
<table class="user-edit-table">
<tbody>
<tr>
<td><label for="username">{{ T("moderation") }}:</label></td>
<td><label for="username">{{ T("username") }}:</label></td>
<td><input class="form-input up-input" name="username" id="username" type="text" value="{{UserProfile.Username}}"></td>
</tr>
<tr>

Voir le fichier

@ -3,7 +3,7 @@
{{ block profile_navigation()}}{{ yield profile_menu(route="profile") }}{{end}}
{{block profile_content()}}
{{ if len(UserProfile.Torrents) > 0 }}
<table {{if AltColors}}class="alt-colors"{{end}}>
<table class="user-torrent-table{{if AltColors}} 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>
@ -47,6 +47,7 @@
</tr>
{{end}}
</table>
<div class="user-torrent-search">
<div class="pagination">
<a href="/search?userID={{ UserProfile.ID }}" aria-label="Next">
<span style="display:block;border-right:1px solid;">
@ -60,6 +61,7 @@
<button type="submit" class="form-input icon-search"></button>
</form>
</div>
</div>
{{else}}
<h2 style="text-align: center;">{{ T("no_torrents_uploaded") }}</h2>
{{end}}

Voir le fichier

@ -177,7 +177,7 @@ func genNav(nav Navigation, currentURL *url.URL, pagesSelectable int) template.H
display = " style=\"display:none;\""
if nav.CurrentPage < int(maxPages) {
display = ""
href = " href=\"" + "/" + nav.Route + "/" + strconv.Itoa(nav.CurrentPage+1) + "?" + currentURL.RawQuery + "\""
href = " href=\"" + "/" + nav.Route + "/" + strconv.Itoa(int(maxPages)) + "?" + currentURL.RawQuery + "\""
}
ret = ret + "<a id=\"page-next\"" + display + href +" aria-label=\"Next\"><span aria-hidden=\"true\">&raquo;</span></a>"