Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Fix invalid comment date when JS is enabled, wrong url in an admin torrent list link, malformed pubDate for RSS feed (#1654)

* Fix invalid comment date when JS is enabled

* fix travis

* fix wrong url in admin torrent list

* Fix wrong pubDate for /feed

* Different function name

* same changes as rss for magnet rss

* travis test

* fix delete button on torrent view

* Update edit.jet.html

* Update index.jet.html

* Update userlist.jet.html

* Update torrentlist.jet.html
Cette révision appartient à :
kilo 2017-10-12 17:53:04 +02:00 révisé par sfan5
Parent 941aceb9b0
révision bde8ff4f49
8 fichiers modifiés avec 27 ajouts et 15 suppressions

Voir le fichier

@ -4,7 +4,6 @@ import (
"net/http"
"strconv"
"strings"
"time"
"github.com/NyaaPantsu/nyaa/config"
"github.com/NyaaPantsu/nyaa/utils/feeds"
@ -26,7 +25,7 @@ func RSSMagnetHandler(c *gin.Context) {
feed := &nyaafeeds.RssFeed{
Title: title,
Link: config.WebAddress() + "/",
PubDate: createdAsTime.String(),
PubDate: formatRSSDate(createdAsTime),
}
feed.Items = make([]*nyaafeeds.RssItem, len(torrents))
@ -36,7 +35,7 @@ func RSSMagnetHandler(c *gin.Context) {
Title: torrentJSON.Name,
Link: &nyaafeeds.RssMagnetLink{Text: string(torrentJSON.Magnet)},
Description: string(torrentJSON.Description),
PubDate: torrent.Date.Format(time.RFC1123Z),
PubDate: formatRSSDate(torrent.Date),
GUID: config.WebAddress() + "/view/" + strconv.FormatUint(uint64(torrentJSON.ID), 10),
Enclosure: &nyaafeeds.RssEnclosure{
URL: config.WebAddress() + "/download/" + strings.TrimSpace(torrentJSON.Hash),

Voir le fichier

@ -5,6 +5,7 @@ import (
"strconv"
"strings"
"time"
"fmt"
"github.com/NyaaPantsu/nyaa/config"
"github.com/NyaaPantsu/nyaa/utils/feeds"
@ -26,7 +27,7 @@ func RSSHandler(c *gin.Context) {
feed := &nyaafeeds.RssFeed{
Title: title,
Link: config.WebAddress() + "/",
PubDate: createdAsTime.String(),
PubDate: formatRSSDate(createdAsTime),
}
feed.Items = make([]*nyaafeeds.RssItem, len(torrents))
@ -36,7 +37,7 @@ func RSSHandler(c *gin.Context) {
Title: torrentJSON.Name,
Link: config.WebAddress() + "/download/" + torrentJSON.Hash,
Description: string(torrentJSON.Description),
PubDate: torrent.Date.Format(time.RFC1123Z),
PubDate: formatRSSDate(torrent.Date),
GUID: config.WebAddress() + "/view/" + strconv.FormatUint(uint64(torrentJSON.ID), 10),
Enclosure: &nyaafeeds.RssEnclosure{
URL: config.WebAddress() + "/download/" + strings.TrimSpace(torrentJSON.Hash),
@ -57,3 +58,9 @@ func RSSHandler(c *gin.Context) {
c.AbortWithError(http.StatusInternalServerError, writeErr)
}
}
//Return date in an RFC 2822 format, the official one for RSS2
func formatRSSDate(Date time.Time) string {
Date = Date.UTC()
return fmt.Sprintf("%.3s, %.2d %.3s %d %.2d:%.2d:%.2d +0000", Date.Weekday(), Date.Day(), Date.Month(), Date.Year(), Date.Hour(), Date.Minute(), Date.Second())
}

Voir le fichier

@ -2148,7 +2148,7 @@ table.multiple-upload {
width: 150px;
font-weight: bold;
font-size: 14px!important;
padding: 5px 0;
padding: 5px 0;
}
.user-search {

Voir le fichier

@ -24,7 +24,7 @@
<td class="tr-size home-td">
<form method="POST" action="/mod/torrent/delete">
<input type="hidden" name="id" value="{{ .ID }}">
<button type="submit" class="form-input btn-red"onclick="if (!confirm('{{ T(" are_you_sure ") }}')) return false;"><i class="icon-trash"></i> {{ T("delete") }}</button>
<button type="submit" class="form-input btn-red" onclick="if (!confirm('{{ T(" are_you_sure ") }}')) return false;"><i class="icon-trash"></i> {{ T("delete") }}</button>
</form>
</td>
</tr>

Voir le fichier

@ -50,7 +50,7 @@
</td>
<td class="tr-size home-td">
{{ if .Uploader }}
<a href="/torrents{{ if .IsDeleted }}/deleted{{end}}?userID={{.UploaderID}}">
<a href="/user/{{.UploaderID}}/{{.Uploader.Username}}">
{{ .Uploader.Username }}
</a> {{ else }}れんちょん{{end}}
</td>
@ -67,12 +67,12 @@
<form method="POST" action="/mod/torrent/delete">
<input type="hidden" name="id" value="{{ .ID }}">
<input type="hidden" name="definitely" value="true">
<button type="submit" class="form-input btn-red"onclick="if (!confirm('{{ T(" are_you_sure ") }} {{ T("delete_definitely_torrent_warning ")}}')) return false;"><i class="icon-trash"></i> {{ T("delete_definitely") }}</button>
<button type="submit" class="form-input btn-red" onclick="if (!confirm('{{ T(" are_you_sure ") }} {{ T("delete_definitely_torrent_warning ")}}')) return false;"><i class="icon-trash"></i> {{ T("delete_definitely") }}</button>
</form>
{{ else }}
<form method="POST" action="/mod/torrent/delete">
<input type="hidden" name="id" value="{{ .ID }}">
<button type="submit" class="form-input btn-red"onclick="if (!confirm('{{ T(" are_you_sure ") }}')) return false;"><i class="icon-trash"></i> {{ T("delete") }}</button>
<button type="submit" class="form-input btn-red" onclick="if (!confirm('{{ T(" are_you_sure ") }}')) return false;"><i class="icon-trash"></i> {{ T("delete") }}</button>
</form>
{{ end }}
</td>

Voir le fichier

@ -19,7 +19,7 @@
<td class="tr-actions home-td">
{{if .ID > 0}}
<form method="POST" action="/user/{{.ID}}/{{.Username }}/delete">
<button type="submit" class="form-input btn-red"onclick="if (!confirm('{{ T(" are_you_sure ") }}')) return false;"><i class="icon-trash"></i> {{ T("delete") }}</button>
<button type="submit" class="form-input btn-red" onclick="if (!confirm('{{ T(" are_you_sure ") }}')) return false;"><i class="icon-trash"></i> {{ T("delete") }}</button>
</form>
{{end}}
</td>

Voir le fichier

@ -139,10 +139,16 @@
{{ 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">
<input type="hidden" name="id" value="{{ Torrent.ID }}">
<button type="submit" class="form-input btn-red" onclick="if (!confirm('{{ T(" are_you_sure ") }}')) 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">
<input type="hidden" name="id" value="{{ Torrent.ID }}">
<button type="submit" class="form-input btn-red" onclick="if (!confirm('{{ T(" are_you_sure ") }}')) 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}}
@ -184,7 +190,7 @@
<div class="torrent-info-box comment-box">
<span class="comment-index">
<a href="#comment_{{idx}}">{{idx}}</a>
<small style="padding-left: 4px;" class="date-short">{{formatDateRFC(element.Date)}}</small>
<small style="padding-left: 4px;" class="date-full" title="{{element.Date}}">{{formatDate(element.Date, false)}}</small>
</span>
<p><img src="https://www.gravatar.com/avatar/{{ element.UserAvatar }}"/><a {{if element.UserID > 0}}href="/user/{{element.UserID}}/{{element.Username}}"{{end}} class="comment-user">{{if element.Username == ""}}れんちょん{{else}}{{element.Username}}{{end}}</a></p>
<p class="comment-content">{{element.Content|raw}}</p>

Voir le fichier

@ -262,7 +262,7 @@
{{ if User.CurrentOrAdmin(UserProfile.ID) }}
<hr/>
<form method="POST" action="/user/{{UserProfile.ID}}/{{UserProfile.Username}}/delete" >
<button type="submit" class="form-input btn-red"onclick="if (!confirm('{{ T(" delete_account_confirm ") }}')) return false;" style="float:right">{{ T("delete_account") }}</button>
<button type="submit" class="form-input btn-red" onclick="if (!confirm('{{ T(" delete_account_confirm ") }}')) return false;" style="float:right">{{ T("delete_account") }}</button>
</form>
{{end}}
{{end}}