Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
* Update main.css

* saving settings now clear old cookies of current domain

* Update main.js

* Update classic.css

* Update settings.go

* Update main.css

* Update commentlist.jet.html

* Update generate.go

* Update default_config.yml

* Update structs.go

* Update default_config.yml

* Update find.go

* Update find.go

* Update stats.go

* Update interaction.go
Cette révision appartient à :
kilo 2017-11-08 09:32:06 +01:00 révisé par GitHub
Parent 285bca23cb
révision 213780f0eb
Aucune clé n'a été trouvée pour cette signature dans la base de données
ID de la clé GPG: 4AEE18F83AFDEB23
11 fichiers modifiés avec 41 ajouts et 9 suppressions

Voir le fichier

@ -105,6 +105,9 @@ torrents:
additional_languages: ["es-mx"]
# TorrentFileStorage : Path to default torrent storage location (eg /var/www/wherever/you/want)
torrents:
# GenerationClientPort : Port used by the torrent client created during torrent generation
generation_client_port: 50006
# FileStorage : Location of folder that will contain generated torrent files
filestorage: ./downloads/
# TorrentStorageLink : Url of torrent file download location (eg https://your.site/somewhere/%s)
storage_link: /download/%s

Voir le fichier

@ -145,6 +145,7 @@ type TorrentsConfig struct {
Order string `yaml:"order,omitempty"`
Sort string `yaml:"sort,omitempty"`
Tags Tags `yaml:"tags,flow,omitempty"`
GenerationClientPort int `yaml:"generation_client_port,flow,omitempty"`
}
// UploadConfig : Config struct for uploading torrents

Voir le fichier

@ -3,6 +3,7 @@ package settingsController
import (
"net/http"
"net/url"
"time"
"github.com/NyaaPantsu/nyaa/config"
"github.com/NyaaPantsu/nyaa/controllers/router"
@ -65,6 +66,17 @@ func ChangePublicSettingsHandler(c *gin.Context) {
user.OldNav = oldNav
user.UpdateRaw()
}
if getDomainName() != "" {
//Clear every cookie from current domain so that users that old cookies from current domain do not interfere with new ones, should new one be shared within multiple subdomains
http.SetCookie(c.Writer, &http.Cookie{Name: "lang", Value: "", Domain: "", Path: "/", Expires: time.Now().AddDate(-1, -1, -1)})
http.SetCookie(c.Writer, &http.Cookie{Name: "theme", Value: "", Domain: "", Path: "/", Expires: time.Now().AddDate(-1, -1, -1)})
http.SetCookie(c.Writer, &http.Cookie{Name: "mascot", Value: "", Domain: "", Path: "/", Expires: time.Now().AddDate(-1, -1, -1)})
http.SetCookie(c.Writer, &http.Cookie{Name: "mascot_url", Value: "", Domain: "", Path: "/", Expires: time.Now().AddDate(-1, -1, -1)})
http.SetCookie(c.Writer, &http.Cookie{Name: "oldNav", Value: "", Domain: "", Path: "/", Expires: time.Now().AddDate(-1, -1, -1)})
}
// Set cookie with http and not gin for expires (maxage not supported in <IE8)
http.SetCookie(c.Writer, &http.Cookie{Name: "lang", Value: lang, Domain: getDomainName(), Path: "/", Expires: timeHelper.FewDaysLater(365)})
http.SetCookie(c.Writer, &http.Cookie{Name: "theme", Value: theme, Domain: getDomainName(), Path: "/", Expires: timeHelper.FewDaysLater(365)})

Voir le fichier

@ -42,7 +42,7 @@ func GetStatsHandler(c *gin.Context) {
}
var Trackers []string
if len(Trackers) > 3 {
if len(torrent.Trackers) > 3 {
for _, line := range strings.Split(torrent.Trackers[3:], "&tr=") {
tracker, error := url.QueryUnescape(line)
if error == nil && strings.Contains(tracker, "udp://") {

Voir le fichier

@ -55,9 +55,11 @@ func findOrderBy(parameters Query, orderBy string, limit int, offset int, countA
return
}
}
var blankReport models.TorrentReport
// build custom db query for performance reasons
dbQuery := "SELECT * FROM torrent_reports"
dbQuery := "SELECT * FROM " + blankReport.TableName()
if conditions != "" {
dbQuery = dbQuery + " WHERE " + conditions
}

Voir le fichier

@ -4,6 +4,7 @@ import (
"errors"
"net/http"
"github.com/jinzhu/gorm"
"github.com/NyaaPantsu/nyaa/models"
"github.com/NyaaPantsu/nyaa/utils/log"
)
@ -94,7 +95,7 @@ func FindOldUploadsByUsername(username string) ([]uint, error) {
// FindByID retrieves a user by ID.
func FindByID(id uint) (*models.User, int, error) {
var user = &models.User{}
if models.ORM.Preload("Notifications").Last(user, id).RecordNotFound() {
if models.ORM.Preload("Notifications", func(db *gorm.DB) *gorm.DB { return db.Order("id DESC") }).Last(user, id).RecordNotFound() {
return user, http.StatusNotFound, errors.New("user_not_found")
}
var liked, likings []models.User
@ -116,7 +117,7 @@ func FindRawByID(id uint) (*models.User, int, error) {
func SessionByID(id uint) (*models.User, int, error) {
var user = &models.User{}
if models.ORM.Preload("Notifications").Where("user_id = ?", id).First(user).RecordNotFound() { // We only load unread notifications
if models.ORM.Preload("Notifications", func(db *gorm.DB) *gorm.DB { return db.Order("id DESC") }).Where("user_id = ?", id).First(user).RecordNotFound() { // We only load unread notifications
return user, http.StatusBadRequest, errors.New("user_not_found")
}
return user, http.StatusOK, nil
@ -125,7 +126,7 @@ func SessionByID(id uint) (*models.User, int, error) {
// FindForAdmin retrieves a user for an administrator, preloads torrents.
func FindForAdmin(id uint) (*models.User, int, error) {
var user = &models.User{}
if models.ORM.Preload("Notifications").Preload("Torrents").Last(user, id).RecordNotFound() {
if models.ORM.Preload("Notifications", func(db *gorm.DB) *gorm.DB { return db.Order("id DESC") }).Preload("Torrents").Last(user, id).RecordNotFound() {
return user, http.StatusNotFound, errors.New("user_not_found")
}
var liked, likings []models.User

Voir le fichier

@ -1231,7 +1231,7 @@ html, body {
margin-left: 4px;
}
.comment-content {
.comment-content img {
max-width: 100%;
max-height: 500px;
}
@ -2429,7 +2429,7 @@ td.notification-status.notification-unread {
}
.torrent-report-table td, .torrent-report-table th {
width: 165px;
width: 195px;
}
.td-report-message {
width: auto!important;

Voir le fichier

@ -730,6 +730,9 @@ span.tag {
width: 128px!important;
height: 20px;
}
#subscribe-link {
text-transform: lowercase;
}
.sukebei .torrent-info-data #subscribe-link {
color: #660000;
}

Voir le fichier

@ -117,6 +117,7 @@ function resetCookies() {
//only execute if cookie are supposed to be shared between nyaa & sukebei, aka on host name without subdomain
var cookieValue = getCookieValue(cookieName)
document.cookie = cookieName + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;"
document.cookie = cookieName + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;domain=" + window.location.host
document.cookie = cookieName + "=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;"
if(cookieName != "session")
document.cookie = cookieName + "=" + cookieValue + ";path=/;expires=" + farFutureString + ";domain=" + domain
@ -128,6 +129,7 @@ function resetCookies() {
}
document.cookie = cookieName + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;"
document.cookie = cookieName + "=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;"
document.cookie = cookieName + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;domain=" + window.location.host
}
//Set new version in cookie

Voir le fichier

@ -11,7 +11,7 @@
<td>{{T("user_id")}}</td><td><input type="text" name="userid" class="form-input" placeholder="{{T("user_id")}}" value="{{if Search.UserID > 0}}{{Search.UserID}}{{end}}"><td/>
</tr>
<tr>
<td>{{T("username")}}</td><td><input type="text" name="username" class="form-input" placeholder="{{T("username")}}" value="{{Search.UserName}}"><td/>
<td>{{T("username")}}</td><td><input type="text" name="user" class="form-input" placeholder="{{T("username")}}" value="{{Search.UserName}}"><td/>
</tr>
</tbody>
</table>

Voir le fichier

@ -1,12 +1,14 @@
package upload
import (
"strconv"
"errors"
"fmt"
"os"
"github.com/NyaaPantsu/nyaa/config"
"github.com/NyaaPantsu/nyaa/utils/log"
"github.com/anacrolix/dht"
"github.com/anacrolix/torrent"
"github.com/anacrolix/torrent/bencode"
)
@ -15,7 +17,13 @@ var queue []string
var client *torrent.Client
func initClient() error {
cl, err := torrent.NewClient(nil)
clientConfig := torrent.Config{
DHTConfig: dht.ServerConfig{
StartingNodes: dht.GlobalBootstrapAddrs,
},
ListenAddr: ":" + strconv.Itoa(config.Get().Torrents.GenerationClientPort),
}
cl, err := torrent.NewClient(&clientConfig)
if err != nil {
log.Errorf("error creating client: %s", err)
return err