From a7417a221a6aa80966345a8141e29a749bc7fbbf Mon Sep 17 00:00:00 2001 From: LIAUD Corentin Date: Sun, 24 Mar 2024 16:10:49 +0100 Subject: [PATCH] Final work to add torrents categories --- .gitignore | 2 + server/torr/apihelper.go | 4 +- server/torr/dbwrapper.go | 1 + server/web/api/torrents.go | 2 +- server/web/pages/template/html.go | 20 ++++----- .../pages/template/pages/asset-manifest.json | 14 +++---- server/web/pages/template/pages/index.html | 2 +- server/web/pages/template/route.go | 34 +++++++-------- web/src/components/Add/AddDialog.jsx | 4 +- web/src/components/Add/RightSideComponent.jsx | 41 ++++++++++--------- web/src/components/TorrentCard/index.jsx | 9 +++- 11 files changed, 73 insertions(+), 60 deletions(-) diff --git a/.gitignore b/.gitignore index a806eca..07196f0 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,5 @@ server/config.db server/web/pages/template/route.go server/server.pem server/server.key +settings.json +viewed.json \ No newline at end of file diff --git a/server/torr/apihelper.go b/server/torr/apihelper.go index 60a9e33..178bed9 100644 --- a/server/torr/apihelper.go +++ b/server/torr/apihelper.go @@ -114,7 +114,7 @@ func GetTorrent(hashHex string) *Torrent { return tor } -func SetTorrent(hashHex, title, poster, data string) *Torrent { +func SetTorrent(hashHex, title, poster, category string, data string) *Torrent { hash := metainfo.NewHashFromHex(hashHex) torr := bts.GetTorrent(hash) torrDb := GetTorrentDB(hash) @@ -133,12 +133,14 @@ func SetTorrent(hashHex, title, poster, data string) *Torrent { } torr.Title = title torr.Poster = poster + torr.Category = category torr.Data = data } if torrDb != nil { torrDb.Title = title torrDb.Poster = poster + torrDb.Category = category torrDb.Data = data AddTorrentDB(torrDb) } diff --git a/server/torr/dbwrapper.go b/server/torr/dbwrapper.go index 2c01db4..663a580 100644 --- a/server/torr/dbwrapper.go +++ b/server/torr/dbwrapper.go @@ -75,6 +75,7 @@ func ListTorrentsDB() map[metainfo.Hash]*Torrent { torr.Poster = db.Poster torr.Timestamp = db.Timestamp torr.Size = db.Size + torr.Category = db.Category torr.Data = db.Data torr.Stat = state.TorrentInDB ret[torr.TorrentSpec.InfoHash] = torr diff --git a/server/web/api/torrents.go b/server/web/api/torrents.go index 40811e7..c5b18b8 100644 --- a/server/web/api/torrents.go +++ b/server/web/api/torrents.go @@ -153,7 +153,7 @@ func setTorrent(req torrReqJS, c *gin.Context) { c.AbortWithError(http.StatusBadRequest, errors.New("hash is empty")) return } - torr.SetTorrent(req.Hash, req.Title, req.Poster, req.Data) + torr.SetTorrent(req.Hash, req.Title, req.Poster, req.Category, req.Data) c.Status(200) } diff --git a/server/web/pages/template/html.go b/server/web/pages/template/html.go index 13672a6..e4da0f1 100644 --- a/server/web/pages/template/html.go +++ b/server/web/pages/template/html.go @@ -118,20 +118,20 @@ var Mstile150x150png []byte //go:embed pages/site.webmanifest var Sitewebmanifest []byte -//go:embed pages/static/js/2.916c2545.chunk.js -var Staticjs2916c2545chunkjs []byte +//go:embed pages/static/js/2.00261e25.chunk.js +var Staticjs200261e25chunkjs []byte -//go:embed pages/static/js/2.916c2545.chunk.js.LICENSE.txt -var Staticjs2916c2545chunkjsLICENSEtxt []byte +//go:embed pages/static/js/2.00261e25.chunk.js.LICENSE.txt +var Staticjs200261e25chunkjsLICENSEtxt []byte -//go:embed pages/static/js/2.916c2545.chunk.js.map -var Staticjs2916c2545chunkjsmap []byte +//go:embed pages/static/js/2.00261e25.chunk.js.map +var Staticjs200261e25chunkjsmap []byte -//go:embed pages/static/js/main.55f380e1.chunk.js -var Staticjsmain55f380e1chunkjs []byte +//go:embed pages/static/js/main.4f4f0915.chunk.js +var Staticjsmain4f4f0915chunkjs []byte -//go:embed pages/static/js/main.55f380e1.chunk.js.map -var Staticjsmain55f380e1chunkjsmap []byte +//go:embed pages/static/js/main.4f4f0915.chunk.js.map +var Staticjsmain4f4f0915chunkjsmap []byte //go:embed pages/static/js/runtime-main.f542387e.js var Staticjsruntimemainf542387ejs []byte diff --git a/server/web/pages/template/pages/asset-manifest.json b/server/web/pages/template/pages/asset-manifest.json index c6b5e05..55f3c9e 100644 --- a/server/web/pages/template/pages/asset-manifest.json +++ b/server/web/pages/template/pages/asset-manifest.json @@ -1,17 +1,17 @@ { "files": { - "main.js": "/static/js/main.55f380e1.chunk.js", - "main.js.map": "/static/js/main.55f380e1.chunk.js.map", + "main.js": "/static/js/main.4f4f0915.chunk.js", + "main.js.map": "/static/js/main.4f4f0915.chunk.js.map", "runtime-main.js": "/static/js/runtime-main.f542387e.js", "runtime-main.js.map": "/static/js/runtime-main.f542387e.js.map", - "static/js/2.916c2545.chunk.js": "/static/js/2.916c2545.chunk.js", - "static/js/2.916c2545.chunk.js.map": "/static/js/2.916c2545.chunk.js.map", + "static/js/2.00261e25.chunk.js": "/static/js/2.00261e25.chunk.js", + "static/js/2.00261e25.chunk.js.map": "/static/js/2.00261e25.chunk.js.map", "index.html": "/index.html", - "static/js/2.916c2545.chunk.js.LICENSE.txt": "/static/js/2.916c2545.chunk.js.LICENSE.txt" + "static/js/2.00261e25.chunk.js.LICENSE.txt": "/static/js/2.00261e25.chunk.js.LICENSE.txt" }, "entrypoints": [ "static/js/runtime-main.f542387e.js", - "static/js/2.916c2545.chunk.js", - "static/js/main.55f380e1.chunk.js" + "static/js/2.00261e25.chunk.js", + "static/js/main.4f4f0915.chunk.js" ] } \ No newline at end of file diff --git a/server/web/pages/template/pages/index.html b/server/web/pages/template/pages/index.html index b489fb1..a3db807 100644 --- a/server/web/pages/template/pages/index.html +++ b/server/web/pages/template/pages/index.html @@ -1 +1 @@ -TorrServer MatriX
\ No newline at end of file +TorrServer MatriX
\ No newline at end of file diff --git a/server/web/pages/template/route.go b/server/web/pages/template/route.go index 3800b6f..22be5f4 100644 --- a/server/web/pages/template/route.go +++ b/server/web/pages/template/route.go @@ -207,7 +207,7 @@ func RouteWebPages(route gin.IRouter) { etag := fmt.Sprintf("%x", md5.Sum(Browserconfigxml)) c.Header("Cache-Control", "public, max-age=31536000") c.Header("ETag", etag) - c.Data(200, "application/xml; charset=utf-8", Browserconfigxml) + c.Data(200, "text/xml; charset=utf-8", Browserconfigxml) }) route.GET("/dlnaicon-120.png", func(c *gin.Context) { @@ -280,46 +280,46 @@ func RouteWebPages(route gin.IRouter) { c.Data(200, "application/manifest+json", Sitewebmanifest) }) - route.GET("/static/js/2.916c2545.chunk.js", func(c *gin.Context) { - etag := fmt.Sprintf("%x", md5.Sum(Staticjs2916c2545chunkjs)) + route.GET("/static/js/2.00261e25.chunk.js", func(c *gin.Context) { + etag := fmt.Sprintf("%x", md5.Sum(Staticjs200261e25chunkjs)) c.Header("Cache-Control", "public, max-age=31536000") c.Header("ETag", etag) - c.Data(200, "application/javascript; charset=utf-8", Staticjs2916c2545chunkjs) + c.Data(200, "text/javascript; charset=utf-8", Staticjs200261e25chunkjs) }) - route.GET("/static/js/2.916c2545.chunk.js.LICENSE.txt", func(c *gin.Context) { - etag := fmt.Sprintf("%x", md5.Sum(Staticjs2916c2545chunkjsLICENSEtxt)) + route.GET("/static/js/2.00261e25.chunk.js.LICENSE.txt", func(c *gin.Context) { + etag := fmt.Sprintf("%x", md5.Sum(Staticjs200261e25chunkjsLICENSEtxt)) c.Header("Cache-Control", "public, max-age=31536000") c.Header("ETag", etag) - c.Data(200, "text/plain; charset=utf-8", Staticjs2916c2545chunkjsLICENSEtxt) + c.Data(200, "text/plain; charset=utf-8", Staticjs200261e25chunkjsLICENSEtxt) }) - route.GET("/static/js/2.916c2545.chunk.js.map", func(c *gin.Context) { - etag := fmt.Sprintf("%x", md5.Sum(Staticjs2916c2545chunkjsmap)) + route.GET("/static/js/2.00261e25.chunk.js.map", func(c *gin.Context) { + etag := fmt.Sprintf("%x", md5.Sum(Staticjs200261e25chunkjsmap)) c.Header("Cache-Control", "public, max-age=31536000") c.Header("ETag", etag) - c.Data(200, "application/json", Staticjs2916c2545chunkjsmap) + c.Data(200, "application/json", Staticjs200261e25chunkjsmap) }) - route.GET("/static/js/main.55f380e1.chunk.js", func(c *gin.Context) { - etag := fmt.Sprintf("%x", md5.Sum(Staticjsmain55f380e1chunkjs)) + route.GET("/static/js/main.4f4f0915.chunk.js", func(c *gin.Context) { + etag := fmt.Sprintf("%x", md5.Sum(Staticjsmain4f4f0915chunkjs)) c.Header("Cache-Control", "public, max-age=31536000") c.Header("ETag", etag) - c.Data(200, "application/javascript; charset=utf-8", Staticjsmain55f380e1chunkjs) + c.Data(200, "text/javascript; charset=utf-8", Staticjsmain4f4f0915chunkjs) }) - route.GET("/static/js/main.55f380e1.chunk.js.map", func(c *gin.Context) { - etag := fmt.Sprintf("%x", md5.Sum(Staticjsmain55f380e1chunkjsmap)) + route.GET("/static/js/main.4f4f0915.chunk.js.map", func(c *gin.Context) { + etag := fmt.Sprintf("%x", md5.Sum(Staticjsmain4f4f0915chunkjsmap)) c.Header("Cache-Control", "public, max-age=31536000") c.Header("ETag", etag) - c.Data(200, "application/json", Staticjsmain55f380e1chunkjsmap) + c.Data(200, "application/json", Staticjsmain4f4f0915chunkjsmap) }) route.GET("/static/js/runtime-main.f542387e.js", func(c *gin.Context) { etag := fmt.Sprintf("%x", md5.Sum(Staticjsruntimemainf542387ejs)) c.Header("Cache-Control", "public, max-age=31536000") c.Header("ETag", etag) - c.Data(200, "application/javascript; charset=utf-8", Staticjsruntimemainf542387ejs) + c.Data(200, "text/javascript; charset=utf-8", Staticjsruntimemainf542387ejs) }) route.GET("/static/js/runtime-main.f542387e.js.map", func(c *gin.Context) { diff --git a/web/src/components/Add/AddDialog.jsx b/web/src/components/Add/AddDialog.jsx index a589bef..ffa3123 100644 --- a/web/src/components/Add/AddDialog.jsx +++ b/web/src/components/Add/AddDialog.jsx @@ -26,12 +26,13 @@ export default function AddDialog({ title: originalTitle, name: originalName, poster: originalPoster, + category: originalCategory, }) { const { t } = useTranslation() const isEditMode = !!originalHash const [torrentSource, setTorrentSource] = useState(originalHash || '') const [title, setTitle] = useState(originalTitle || '') - const [category, setCategory] = useState('Unknown') + const [category, setCategory] = useState(originalCategory || '') const [originalTorrentTitle, setOriginalTorrentTitle] = useState('') const [parsedTitle, setParsedTitle] = useState('') const [posterUrl, setPosterUrl] = useState(originalPoster || '') @@ -248,7 +249,6 @@ export default function AddDialog({ setTorrentSource={setTorrentSource} /> )} - @@ -113,26 +115,6 @@ export default function RightSideComponent({ ), }} /> - - - Torrent category - - ) : ( + + Torrent category + + + {isPosterUrlCorrect ? poster : } diff --git a/web/src/components/TorrentCard/index.jsx b/web/src/components/TorrentCard/index.jsx index f955d60..c812bee 100644 --- a/web/src/components/TorrentCard/index.jsx +++ b/web/src/components/TorrentCard/index.jsx @@ -185,7 +185,14 @@ const Torrent = ({ torrent }) => { {isEditDialogOpen && ( - + )} )