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 à :
Parent
61d1aa4195
révision
1ec2a77974
7 fichiers modifiés avec 48 ajouts et 10 suppressions
|
@ -8,6 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/NyaaPantsu/nyaa/models/torrents"
|
"github.com/NyaaPantsu/nyaa/models/torrents"
|
||||||
"github.com/NyaaPantsu/nyaa/models"
|
"github.com/NyaaPantsu/nyaa/models"
|
||||||
|
"github.com/NyaaPantsu/nyaa/config"
|
||||||
"github.com/Stephen304/goscrape"
|
"github.com/Stephen304/goscrape"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
@ -27,13 +28,18 @@ func GetStatsHandler(c *gin.Context) {
|
||||||
|
|
||||||
var Trackers []string
|
var Trackers []string
|
||||||
for _, line := range strings.Split(torrent.Trackers[3:], "&tr=") {
|
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)
|
tracker, error := url.QueryUnescape(line)
|
||||||
if error == nil && tracker[:6] == "udp://" {
|
if error == nil && strings.Contains(tracker, "udp://") {
|
||||||
Trackers = append(Trackers, tracker)
|
Trackers = append(Trackers, tracker)
|
||||||
}
|
}
|
||||||
//Cannot scrape from http trackers so don't put them in the array
|
//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{
|
stats := goscrape.Single(Trackers, []string{
|
||||||
torrent.Hash,
|
torrent.Hash,
|
||||||
|
@ -73,3 +79,12 @@ func GetStatsHandler(c *gin.Context) {
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func contains(s []string, e string) bool {
|
||||||
|
for _, a := range s {
|
||||||
|
if a == e {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
|
@ -2216,6 +2216,19 @@ form.delete-form button.form-input.btn-red {
|
||||||
height: 28px;
|
height: 28px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.user-torrent-table {
|
||||||
|
margin-bottom: 80px
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-torrent-search {
|
||||||
|
width: 100%;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
left: 0;
|
||||||
|
bottom: 9px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Language specific CSS */
|
/* Language specific CSS */
|
||||||
|
|
||||||
html[lang="ja-jp"] .form-refine span.spacing {
|
html[lang="ja-jp"] .form-refine span.spacing {
|
||||||
|
|
|
@ -123,9 +123,9 @@ th.tr-name a {
|
||||||
|
|
||||||
.icon-magnet:before {
|
.icon-magnet:before {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}.upload-tag-table
|
}
|
||||||
|
|
||||||
.icon-floppy::before {
|
.icon-floppy:before {
|
||||||
content: '';
|
content: '';
|
||||||
}
|
}
|
||||||
.icon-floppy {
|
.icon-floppy {
|
||||||
|
|
|
@ -151,10 +151,18 @@
|
||||||
{{ if User.ID > 0}}
|
{{ if User.ID > 0}}
|
||||||
<a id="reportPopup" href="#" class="form-input">{{ T("report_btn") }}</a>
|
<a id="reportPopup" href="#" class="form-input">{{ T("report_btn") }}</a>
|
||||||
{{ if User.HasAdmin()}}
|
{{ 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>
|
<a href="/mod/torrent?id={{ Torrent.ID }}" class="form-input btn-orange">{{ T("edit") }}</a>
|
||||||
{{ else if User.CurrentUserIdentical(Torrent.UploaderID) }}
|
{{ 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>
|
<a href="/torrent?id={{ Torrent.ID }}" class="form-input btn-orange">{{ T("edit") }}</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -233,7 +233,7 @@
|
||||||
<table class="user-edit-table">
|
<table class="user-edit-table">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<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>
|
<td><input class="form-input up-input" name="username" id="username" type="text" value="{{UserProfile.Username}}"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
{{ block profile_navigation()}}{{ yield profile_menu(route="profile") }}{{end}}
|
{{ block profile_navigation()}}{{ yield profile_menu(route="profile") }}{{end}}
|
||||||
{{block profile_content()}}
|
{{block profile_content()}}
|
||||||
{{ if len(UserProfile.Torrents) > 0 }}
|
{{ 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">
|
<tr class="torrent-info">
|
||||||
<th class="tr-cat user-td">{{ T("category")}}</th>
|
<th class="tr-cat user-td">{{ T("category")}}</th>
|
||||||
<th class="tr-name user-td">{{ T("name")}}</th>
|
<th class="tr-name user-td">{{ T("name")}}</th>
|
||||||
|
@ -47,6 +47,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
</table>
|
</table>
|
||||||
|
<div class="user-torrent-search">
|
||||||
<div class="pagination">
|
<div class="pagination">
|
||||||
<a href="/search?userID={{ UserProfile.ID }}" aria-label="Next">
|
<a href="/search?userID={{ UserProfile.ID }}" aria-label="Next">
|
||||||
<span style="display:block;border-right:1px solid;">
|
<span style="display:block;border-right:1px solid;">
|
||||||
|
@ -60,6 +61,7 @@
|
||||||
<button type="submit" class="form-input icon-search"></button>
|
<button type="submit" class="form-input icon-search"></button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
<h2 style="text-align: center;">{{ T("no_torrents_uploaded") }}</h2>
|
<h2 style="text-align: center;">{{ T("no_torrents_uploaded") }}</h2>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -177,7 +177,7 @@ func genNav(nav Navigation, currentURL *url.URL, pagesSelectable int) template.H
|
||||||
display = " style=\"display:none;\""
|
display = " style=\"display:none;\""
|
||||||
if nav.CurrentPage < int(maxPages) {
|
if nav.CurrentPage < int(maxPages) {
|
||||||
display = ""
|
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\">»</span></a>"
|
ret = ret + "<a id=\"page-next\"" + display + href +" aria-label=\"Next\"><span aria-hidden=\"true\">»</span></a>"
|
||||||
|
|
||||||
|
|
Référencer dans un nouveau ticket