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

"Torrent file not found" page (#1503)

* Add torrent file missing page instead of old 404

* Make download.go redirect to file missing page instead of 404

* Add files via upload

* Update translation changelog

* add translation string for "torrent file not found" page

* Forgot to create variables

* import templates
Cette révision appartient à :
kilo 2017-09-06 08:20:24 +02:00 révisé par GitHub
Parent 70a865e49a
révision a78f4117c3
5 fichiers modifiés avec 21 ajouts et 5 suppressions

Voir le fichier

@ -1,14 +1,13 @@
package torrentController
import (
"errors"
"fmt"
"io"
"net/http"
"os"
"strconv"
"github.com/NyaaPantsu/nyaa/config"
"github.com/NyaaPantsu/nyaa/templates"
"github.com/NyaaPantsu/nyaa/models/torrents"
"github.com/gin-gonic/gin"
)
@ -19,7 +18,8 @@ func DownloadTorrent(c *gin.Context) {
if hash == "" && len(config.Get().Torrents.FileStorage) == 0 {
//File not found, send 404
c.AbortWithError(http.StatusNotFound, errors.New("File not found"))
variables := templates.Commonvariables(c)
templates.Render(c, "errors/torrent_file_missing.jet.html", variables)
return
}
@ -27,7 +27,8 @@ func DownloadTorrent(c *gin.Context) {
Openfile, err := os.Open(fmt.Sprintf("%s%c%s.torrent", config.Get().Torrents.FileStorage, os.PathSeparator, hash))
if err != nil {
//File not found, send 404
c.AbortWithError(http.StatusNotFound, errors.New("File not found"))
variables := templates.Commonvariables(c)
templates.Render(c, "errors/torrent_file_missing.jet.html", variables)
return
}
defer Openfile.Close() //Close after function return
@ -40,7 +41,8 @@ func DownloadTorrent(c *gin.Context) {
if err != nil {
//File not found, send 404
c.AbortWithError(http.StatusNotFound, errors.New("File not found"))
variables := templates.Commonvariables(c)
templates.Render(c, "errors/torrent_file_missing.jet.html", variables)
return
}

BIN
public/img/no_torrent_file.jpg Fichier normal

Fichier binaire non affiché.

Après

Largeur:  |  Hauteur:  |  Taille: 201 KiB

Voir le fichier

@ -0,0 +1,8 @@
{{ extends "layouts/index_site" }}
{{block title()}}{{ T("err_no_torrent_file")}}{{end}}
{{block content_body()}}
<div style="text-align: center;">
<h1>{{ T("err_no_torrent_file")}}</h1>
<img src="/img/no_torrent_file.jpg" alt="No torrent file"/>
</div>
{{end}} {{block mascot()}}<br />{{end}}

Voir le fichier

@ -26,3 +26,5 @@
* + hide_ads_setting_explanation
* + faq_ads
* + faq_ads_explanation
## 2017/09/05
* + err_no_torrent_file

Voir le fichier

@ -199,6 +199,10 @@
"id": "err_no_results",
"translation": "No results found"
},
{
"id": "err_no_torrent_file",
"translation": "Torrent file not found"
},
{
"id": "upload",
"translation": "Upload"