"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 à :
Parent
70a865e49a
révision
a78f4117c3
|
@ -1,14 +1,13 @@
|
||||||
package torrentController
|
package torrentController
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/NyaaPantsu/nyaa/config"
|
"github.com/NyaaPantsu/nyaa/config"
|
||||||
|
"github.com/NyaaPantsu/nyaa/templates"
|
||||||
"github.com/NyaaPantsu/nyaa/models/torrents"
|
"github.com/NyaaPantsu/nyaa/models/torrents"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
@ -19,7 +18,8 @@ func DownloadTorrent(c *gin.Context) {
|
||||||
|
|
||||||
if hash == "" && len(config.Get().Torrents.FileStorage) == 0 {
|
if hash == "" && len(config.Get().Torrents.FileStorage) == 0 {
|
||||||
//File not found, send 404
|
//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
|
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))
|
Openfile, err := os.Open(fmt.Sprintf("%s%c%s.torrent", config.Get().Torrents.FileStorage, os.PathSeparator, hash))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//File not found, send 404
|
//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
|
return
|
||||||
}
|
}
|
||||||
defer Openfile.Close() //Close after function return
|
defer Openfile.Close() //Close after function return
|
||||||
|
@ -40,7 +41,8 @@ func DownloadTorrent(c *gin.Context) {
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//File not found, send 404
|
//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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Fichier binaire non affiché.
Après Largeur: | Hauteur: | Taille: 201 KiB |
|
@ -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}}
|
|
@ -26,3 +26,5 @@
|
||||||
* + hide_ads_setting_explanation
|
* + hide_ads_setting_explanation
|
||||||
* + faq_ads
|
* + faq_ads
|
||||||
* + faq_ads_explanation
|
* + faq_ads_explanation
|
||||||
|
## 2017/09/05
|
||||||
|
* + err_no_torrent_file
|
||||||
|
|
|
@ -199,6 +199,10 @@
|
||||||
"id": "err_no_results",
|
"id": "err_no_results",
|
||||||
"translation": "No results found"
|
"translation": "No results found"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "err_no_torrent_file",
|
||||||
|
"translation": "Torrent file not found"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "upload",
|
"id": "upload",
|
||||||
"translation": "Upload"
|
"translation": "Upload"
|
||||||
|
|
Référencer dans un nouveau ticket