Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
* Fix S/L/D columns wasting huge amounts of space

Partially reverts 0c9cdfa8bf.

* Move last scrape below seed-bar

Also fixes the very misleading indentation

* Show category name on view page too

* Fix fucked up login page (fixes #640)

* Fix empty page on login w/o pass (fixes #634)

* Fix incorrectly colored error text in day mode

* Better readable footer in night mode

* Prepare having old uploader names on sukebei and various fixes for sukebei

* Different HTML title for sukebei
Cette révision appartient à :
sfan5 2017-05-20 12:45:27 +02:00 révisé par ewhal
Parent d862a01a9e
révision a3fa6df938
14 fichiers modifiés avec 77 ajouts et 67 suppressions

Voir le fichier

@ -12,14 +12,25 @@ import (
const (
// LastOldTorrentID is the highest torrent ID
// that was copied from the original Nyaa
LastOldTorrentID = 923000
TorrentsTableName = "torrents"
CommentsTableName = "comments"
// for sukebei
//TableName = "sukebei_torrents"
//CommentsTableName = "sukebei_comments"
LastOldTorrentID = 923000
TorrentsTableName = "torrents"
CommentsTableName = "comments"
UploadsOldTableName = "user_uploads_old"
// for sukebei:
//LastOldTorrentID = 2303945
//TorrentsTableName = "sukebei_torrents"
//CommentsTableName = "sukebei_comments"
//UploadsOldTableName = "sukebei_user_uploads_old"
// FIXME: files table needs to be seperate too
)
func IsSukebei() bool {
return TorrentsTableName == "sukebei_torrents"
}
type Config struct {
Host string `json:"host"`
Port int `json:"port"`

Voir le fichier

@ -187,9 +187,12 @@ func (t *Torrent) ToJSON() TorrentJSON {
}
torrentlink := ""
if t.ID <= config.LastOldTorrentID && len(config.TorrentCacheLink) > 0 {
torrentlink = fmt.Sprintf(config.TorrentCacheLink, t.Hash)
if config.IsSukebei() {
torrentlink = "" // torrent cache doesn't have sukebei torrents
} else {
torrentlink = fmt.Sprintf(config.TorrentCacheLink, t.Hash)
}
} else if t.ID > config.LastOldTorrentID && len(config.TorrentStorageLink) > 0 {
// TODO: Fix as part of configuration changes (fix what?)
torrentlink = fmt.Sprintf(config.TorrentStorageLink, t.Hash)
}
res := TorrentJSON{
@ -223,7 +226,7 @@ func (t *Torrent) ToJSON() TorrentJSON {
/* Complete the functions when necessary... */
// Map Torrents to TorrentsToJSON without reallocations
func TorrentsToJSON(t []Torrent) []TorrentJSON { // TODO: Convert to singular version
func TorrentsToJSON(t []Torrent) []TorrentJSON {
json := make([]TorrentJSON, len(t))
for i := range t {
json[i] = t[i].ToJSON()

Voir le fichier

@ -2,6 +2,8 @@ package model
import (
"time"
"github.com/NyaaPantsu/nyaa/config"
)
const (
@ -86,8 +88,8 @@ type UserUploadsOld struct {
}
func (c UserUploadsOld) TableName() string {
// TODO: rename this in db
return "user_uploads_old"
// is this needed here?
return config.UploadsOldTableName
}
func (u *User) ToJSON() UserJSON {

Voir le fichier

@ -60,8 +60,8 @@
background-image: url(/img/megumin.png);
}
body {
background-color:#282A2E;
body, footer {
background-color: #282A2E;
color: #eff5f5;
}

Voir le fichier

@ -440,8 +440,7 @@ select#bottom_language_selector {
}
.text-error {
background: white;
color: #cf9fff;
color: #fb3333;
}
/* Wordbreak fix*/

Voir le fichier

@ -72,7 +72,6 @@ func (f *ReassignForm) ExtractInfo(r *http.Request) error {
}
func (f *ReassignForm) ExecuteAction() (int, error) {
var toBeChanged []uint
var err error
if f.By == "olduser" {
@ -93,7 +92,6 @@ func (f *ReassignForm) ExecuteAction() (int, error) {
num += 1
}
}
// TODO: clean shit from user_uploads_old if needed
return num, nil
}

Voir le fichier

@ -131,13 +131,7 @@ var FuncMap = template.FuncMap{
}
return template.HTML(ret)
},
"Sukebei": func() bool {
if config.TorrentsTableName == "sukebei_torrents" {
return true
} else {
return false
}
},
"Sukebei": config.IsSukebei,
"T": i18n.IdentityTfunc,
"Ts": i18n.IdentityTfunc,
"getDefaultLanguage": languages.GetDefaultLanguage,

Voir le fichier

@ -282,13 +282,14 @@ func UserLoginPostHandler(w http.ResponseWriter, r *http.Request) {
if errorTmpl != nil {
http.Error(w, errorTmpl.Error(), http.StatusInternalServerError)
}
return
} else {
url, _ := Router.Get("home").URL()
http.Redirect(w, r, url.String(), http.StatusSeeOther)
}
}
if len(err) > 0 {
languages.SetTranslationFromRequest(viewRegisterTemplate, r)
languages.SetTranslationFromRequest(viewLoginTemplate, r)
htv := UserLoginFormVariables{b, err, NewSearchForm(), NewNavigation(), GetUser(r), r.URL, mux.CurrentRoute(r)}
errorTmpl := viewLoginTemplate.ExecuteTemplate(w, "index.html", htv)
if errorTmpl != nil {

Voir le fichier

@ -58,7 +58,7 @@ func GetTorrentById(id string) (torrent model.Torrent, err error) {
if err != nil {
return
}
if id_int <= config.LastOldTorrentID {
if id_int <= config.LastOldTorrentID && !config.IsSukebei() {
// only preload old comments if they could actually exist
tmp = tmp.Preload("OldComments")
}
@ -73,7 +73,7 @@ func GetTorrentById(id string) (torrent model.Torrent, err error) {
torrent.OldUploader = ""
if torrent.ID <= config.LastOldTorrentID && torrent.UploaderID == 0 {
var tmp model.UserUploadsOld
if !db.ORM.Where("torrent_id = ?", torrent.ID).Find(&tmp).RecordNotFound() {
if !db.ORM.Table(config.UploadsOldTableName).Where("torrent_id = ?", torrent.ID).Find(&tmp).RecordNotFound() {
torrent.OldUploader = tmp.Username
}
}
@ -91,7 +91,7 @@ func GetTorrentById(id string) (torrent model.Torrent, err error) {
// won't fetch user or comments
func GetRawTorrentById(id uint) (torrent model.Torrent, err error) {
err = nil
if db.ORM.Table(config.TorrentsTableName).Table(config.TorrentsTableName).Where("torrent_id = ?", id).Find(&torrent).RecordNotFound() {
if db.ORM.Table(config.TorrentsTableName).Where("torrent_id = ?", id).Find(&torrent).RecordNotFound() {
err = errors.New("Article is not found.")
}
return
@ -127,7 +127,6 @@ func getTorrentsOrderBy(parameters *serviceBase.WhereParams, orderBy string, lim
return
}
}
// TODO: Vulnerable to injections. Use query builder. (is it?)
// build custom db query for performance reasons
dbQuery := "SELECT * FROM " + config.TorrentsTableName

Voir le fichier

@ -268,7 +268,7 @@ func RetrieveUserByUsername(username string) (*model.PublicUser, string, int, er
func RetrieveOldUploadsByUsername(username string) ([]uint, error) {
var ret []uint
var tmp []*model.UserUploadsOld
err := db.ORM.Where("username = ?", username).Find(&tmp).Error
err := db.ORM.Table(config.UploadsOldTableName).Where("username = ?", username).Find(&tmp).Error
if err != nil {
return ret, err
}

Voir le fichier

@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Nyaa Pantsu - {{block "title" .}}{{ T "error_404" }}{{end}}</title>
<title>{{if Sukebei}}Sukebei{{else}}Nyaa{{end}} Pantsu - {{block "title" .}}{{ T "error_404" }}{{end}}</title>
<link rel="icon" type="image/png" href="/img/favicon.png?v=3" />
<!-- RSS Feed with Context -->

Voir le fichier

@ -25,13 +25,15 @@ Your browser does not support the audio element.
<table class="table custom-table-hover">
<tr>
<th class="col-xs-1 hidden-xs">{{T "category"}}</th>
<th class="col-xs-5">
<th class="col-xs-12">
<a href="{{ genSearchWithOrdering .URL "1" }}">{{T "name"}}{{ genSortArrows .URL "1" }}</a>
</th>
<th class="col-xs-1 hidden-xs">
<a href="{{ genSearchWithOrdering .URL "5" }}">{{T "S"}}{{ genSortArrows .URL "5" }}</a> /
<a href="{{ genSearchWithOrdering .URL "6" }}">{{T "L"}}{{ genSortArrows .URL "6" }}</a> /
<a href="{{ genSearchWithOrdering .URL "7" }}">{{T "D"}}{{ genSortArrows .URL "7" }}</a>
</th>
<!-- <th class="col-xs-1 hidden-xs"><span class="glyphicon glyphicon-comment"></span></th> -->
<th class="col-xs-1 hidden-xs"><a href="{{ genSearchWithOrdering .URL "5" }}">{{T "S"}}{{ genSortArrows .URL "5" }}</a></th>
<th class="col-xs-1 hidden-xs"><a href="{{ genSearchWithOrdering .URL "6" }}">{{T "L"}}{{ genSortArrows .URL "6" }}</a></th>
<th class="col-xs-1 hidden-xs"><a href="{{ genSearchWithOrdering .URL "7" }}">{{T "D"}}{{ genSortArrows .URL "7" }}</a></th>
<th class="col-xs-1 hidden-xs"><a href="{{ genSearchWithOrdering .URL "2" }}">{{T "date"}}{{ genSortArrows .URL "2" }}</th></a>
<th class="col-xs-1 hidden-xs"><a href="{{ genSearchWithOrdering .URL "4" }}">{{T "size"}}{{ genSortArrows .URL "4" }}</a></th>
<th class="col-xs-1 hidden-xs">{{T "links"}}</th>
@ -62,11 +64,13 @@ Your browser does not support the audio element.
</td>
-->
{{if .LastScrape.IsZero}}
<td class="hidden-xs" colspan="3" align="center">{{T "unknown"}}</td>
<td class="hidden-xs" align="center">{{T "unknown"}}</td>
{{else}}
<td class="hidden-xs"><b class="text-success">{{.Seeders}}</b></td>
<td class="hidden-xs"><b class="text-danger">{{.Leechers}}</b></td>
<td class="hidden-xs">{{.Completed}}</td>
<td class="hidden-xs">
<b class="text-success">{{.Seeders}}</b> /
<b class="text-danger">{{.Leechers}}</b> /
{{.Completed}}
</td>
{{end}}
<td class="hidden-xs nowrap date-short">{{.Date}}</td>
<td class="hidden-xs nowrap">{{.Filesize}}</td>

Voir le fichier

@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Nyaa Pantsu - {{block "title" .}}{{ T "error_404" }}{{end}}</title>
<title>{{if Sukebei}}Sukebei{{else}}Nyaa{{end}} Pantsu - {{block "title" .}}{{ T "error_404" }}{{end}}</title>
<link rel="icon" type="image/png" href="/img/favicon.png?v=3" />
<!-- RSS Feed with Context -->

Voir le fichier

@ -16,9 +16,11 @@
<div class="col-md-12">
<div style="float: left;">
{{ if Sukebei }}
<img style="float:left; margin-right: 1em;" src="{{$.URL.Parse (printf "/img/torrents/sukebei/%s%s.png" .Category .SubCategory) }}" title="{{ T (Category_Sukebei .Category .SubCategory) }}">
<img style="float:left; margin-right: 1em;" src="{{$.URL.Parse (printf "/img/torrents/sukebei/%s%s.png" .Category .SubCategory) }}" title="{{ T (Category_Sukebei .Category .SubCategory) }}">
<span style="vertical-align:middle;font-size:large;">{{ T (Category_Sukebei .Category .SubCategory) }}</span>
{{ else }}
<img style="float:left; margin-right: 1em;" src="{{$.URL.Parse (printf "/img/torrents/%s.png" .SubCategory) }}" title="{{ T (Category_Nyaa .Category .SubCategory) }}">
<img style="float:left; margin-right: 1em;" src="{{$.URL.Parse (printf "/img/torrents/%s.png" .SubCategory) }}" title="{{ T (Category_Nyaa .Category .SubCategory) }}">
<span style="vertical-align:middle;font-size:large;">{{ T (Category_Nyaa .Category .SubCategory) }}</span>
{{ end }}
<br />
<h4 style="display:inline-block">
@ -72,31 +74,23 @@
{{end}}
<div class="row">
<div class="col-md-12 col-xs-6">
<div class="row">
<div class="col-md-4">{{T "seeders"}}</div>
<div class="col-md-4">{{T "leechers"}}</div>
<div class="col-md-4">{{T "completed"}}</div>
</div>
</div>
<div class="col-md-12 col-xs-6">
<div class="row">
{{if .LastScrape.IsZero}}
<div class="col-md-12" align="center">{{T "unknown"}}</div>
{{else}}
<div class="col-md-4">{{.Seeders}}</div>
<div class="col-md-4">{{.Leechers}}</div>
<div class="col-md-4"><span class="completed" style="">{{.Completed}}</span></div>
{{end}}
</div>
</div>
<div class="col-md-12 col-xs-12">
<div class="row">
{{if not .LastScrape.IsZero}}
<div class="col-md-4 col-xs-8">{{T "last_scraped"}}</div>
<div class="col-md-8 col-xs-4 date-short">{{ formatDateRFC .LastScrape }}</div>
{{end}}
</div>
</div>
<div class="row">
<div class="col-md-4">{{T "seeders"}}</div>
<div class="col-md-4">{{T "leechers"}}</div>
<div class="col-md-4">{{T "completed"}}</div>
</div>
</div>
<div class="col-md-12 col-xs-6">
<div class="row">
{{if .LastScrape.IsZero}}
<div class="col-md-12" align="center">{{T "unknown"}}</div>
{{else}}
<div class="col-md-4">{{.Seeders}}</div>
<div class="col-md-4">{{.Leechers}}</div>
<div class="col-md-4"><span class="completed" style="">{{.Completed}}</span></div>
{{end}}
</div>
</div>
</div>
<div class="row">
<div class="col-md-8">
@ -105,6 +99,11 @@
<div class="leechs" style="width: {{ calcWidthLeech .Seeders .Leechers }}%;"></div>
</div>
</div>
<div class="col-md-12 col-xs-12">
{{if not .LastScrape.IsZero}}
{{T "last_scraped"}}<span class="date-short">{{ formatDateRFC .LastScrape }}</span>
{{end}}
</div>
</div>
<hr>
</div>