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

Merge branch 'dev' into filelist-fetching

Cette révision appartient à :
kilo 2017-11-08 09:32:31 +01:00 révisé par GitHub
révision 2087c271f3
Signature inconnue de Forgejo
ID de la clé GPG: 4AEE18F83AFDEB23
11 fichiers modifiés avec 115 ajouts et 15 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

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

@ -21,7 +21,7 @@
},
{
"id": "rules_sukebei",
"translation": "えっちのは sukebei.pantsu.cat へ"
"translation": "えっちのは sukebei.pantsu.cat へ"
},
{
"id": "rule_tracker_url",
@ -139,6 +139,10 @@
"id": "torrents",
"translation": "Torrent"
},
{
"id": "followers",
"translation": "フォロワー数"
},
{
"id": "follow",
"translation": "フォロー"
@ -535,6 +539,10 @@
"id": "description_markdown_notice",
"translation": "説明文には MarkDown 記法を使うことができます。"
},
{
"id": "comment_markdown_notice",
"translation": "コメントには MarkDown 記法を使うことができます。"
},
{
"id": "show_all",
"translation": "すべて表示"
@ -623,6 +631,10 @@
"id": "userstatus_moderator",
"translation": "モデレーター"
},
{
"id": "userstatus_uploader",
"translation": "アップロード者"
},
{
"id": " api_token",
"translation": "API トークン"
@ -771,6 +783,10 @@
"id": "report_type",
"translation": "通報理由"
},
{
"id": "report_message",
"translation": "通報メッセージ"
},
{
"id": "illegal_content",
"translation": "違法なコンテンツ"
@ -787,6 +803,14 @@
"id": "duplicate_deprecated",
"translation": "重複 / 非推奨"
},
{
"id": "nsfw_content",
"translation": "えっちぃコンテンツ"
},
{
"id": "other",
"translation": "その他"
},
{
"id": "captcha",
"translation": "画像認証"
@ -823,6 +847,18 @@
"id": "no_database_dumps_available",
"translation": "現在利用可能なデータベースダンプはありません。"
},
{
"id": "clear_notifications",
"translation": "既読の通知をクリア"
},
{
"id": "clear_all_notifications",
"translation": "すべての通知をクリア"
},
{
"id": "mark_notifications_as_read",
"translation": "既読の通知としてマークする"
},
{
"id": "clear_notifications",
"translation": "通知をクリア"
@ -831,6 +867,10 @@
"id": "notifications_cleared",
"translation": "通知がクリアされました。"
},
{
"id": "notifications_read",
"translation": "すべての通知が既読としてマークされました。"
},
{
"id": "my_notifications",
"translation": "通知"
@ -951,6 +991,10 @@
"id": "delete_report",
"translation": "レポートを削除"
},
{
"id": "delete_all_reports",
"translation": "すべてのレポートを削除"
},
{
"id": "comment_deleted",
"translation": "コメントが削除されました。"
@ -981,7 +1025,7 @@
},
{
"id": "something_went_wrong",
"translation": "不具合が発生しました。"
"translation": "問題が発生しました。"
},
{
"id": "nb_torrents_updated",
@ -2057,7 +2101,7 @@
},
{
"id": "tagtype_tags",
"translation": "通常タグ"
"translation": "説明タグ"
},
{
"id": "tagvalue_select",
@ -2089,7 +2133,7 @@
},
{
"id": "delay",
"translation": "遅延"
"translation": "遅延 (時間単位)"
},
{
"id": "update_annoucement_panel",
@ -2109,7 +2153,7 @@
},
{
"id": "complement",
"translation": "補充"
"translation": "追加"
},
{
"id": "from",
@ -2139,6 +2183,10 @@
"id": "generating_torrent",
"translation": "Torrent ファイルを生成中..."
},
{
"id": "generating_torrent_failed",
"translation": "Torrent ファイルを生成できませんでした"
},
{
"id": "enabled",
"translation": "有効"
@ -2157,7 +2205,7 @@
},
{
"id": "search_from_user",
"translation": "このユーザーのアップロードを検索..."
"translation": "このユーザーから検索..."
},
{
"id": "usersearch_user_not_found",
@ -2173,7 +2221,11 @@
},
{
"id": "search_from_specific_user",
"translation": "%s のアップロードを検索"
"translation": "%s さんから検索"
},
{
"id": "browsing_user_torrents",
"translation": "<a href=\"/user/%d/%s\">%s</a> さんの Torrent を参照中"
},
{
"id": "hours_minutes_ago",
@ -2182,5 +2234,21 @@
{
"id": "days_hours_ago",
"translation": "{0} 日 {1} 時間前"
},
{
"id": "status",
"translation": "状態"
},
{
"id": "event",
"translation": "イベント"
},
{
"id": "read",
"translation": "既読"
},
{
"id": "unread",
"translation": "未読"
}
]

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