From 97ba2e573f193dc1717df848048bae44185b1850 Mon Sep 17 00:00:00 2001 From: nikk gitanes Date: Thu, 9 Mar 2023 01:02:08 +0300 Subject: [PATCH 1/4] add torrents sort icon --- web/src/components/App/index.jsx | 13 +++++++++++-- web/src/components/TorrentList/index.jsx | 12 ++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/web/src/components/App/index.jsx b/web/src/components/App/index.jsx index 83dbd7d..52ef5ac 100644 --- a/web/src/components/App/index.jsx +++ b/web/src/components/App/index.jsx @@ -7,6 +7,8 @@ import { Brightness4 as Brightness4Icon, Brightness5 as Brightness5Icon, BrightnessAuto as BrightnessAutoIcon, + Sort as SortIcon, + SortByAlpha as SortByAlphaIcon, } from '@material-ui/icons' import { echoHost } from 'utils/Hosts' import Div100vh from 'react-div-100vh' @@ -47,6 +49,9 @@ export default function App() { onError: () => setIsOffline(true), onSuccess: () => setIsOffline(false), }) + const [sortABC, setSortABC] = useState(false) + const handleClickSortABC = () => setSortABC(true) + const handleClickSortDate = () => setSortABC(false) useEffect(() => { axios.get(echoHost()).then(({ data }) => setTorrServerVersion(data)) @@ -76,8 +81,12 @@ export default function App() {
+ (sortABC === true ? handleClickSortDate() : handleClickSortABC())}> + {sortABC === true ? : } + + { if (currentThemeMode === THEME_MODES.LIGHT) updateThemeMode(THEME_MODES.DARK) @@ -115,7 +124,7 @@ export default function App() { setIsDonationDialogOpen={setIsDonationDialogOpen} /> - + @@ -20,7 +20,15 @@ export default function TorrentList({ isOffline, isLoading, torrents }) { ) } - return ( + return sortABC ? ( + + {torrents + .sort((a, b) => a.title > b.title) + .map(torrent => ( + + ))} + + ) : ( {torrents.map(torrent => ( From 78de9c543bef42e185034455906f4d266eb3b827 Mon Sep 17 00:00:00 2001 From: YouROK <8YouROK8@mail.ru> Date: Thu, 9 Mar 2023 22:43:32 +0300 Subject: [PATCH 2/4] add search without auth --- server/cmd/main.go | 3 ++- server/server.go | 4 ++-- server/settings/settings.go | 4 +++- server/web/auth/auth.go | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/server/cmd/main.go b/server/cmd/main.go index 712fe6e..d97966f 100644 --- a/server/cmd/main.go +++ b/server/cmd/main.go @@ -35,6 +35,7 @@ type args struct { TorrentAddr string `help:"Torrent client address, default :32000"` PubIPv4 string `arg:"-4" help:"set public IPv4 addr"` PubIPv6 string `arg:"-6" help:"set public IPv6 addr"` + SearchWA bool `arg:"-swa" help:"search without auth"` } func (args) Version() string { @@ -91,7 +92,7 @@ func main() { go watchTDir(params.TorrentsDir) } - server.Start(params.Port, params.RDB) + server.Start(params.Port, params.RDB, params.SearchWA) log.TLogln(server.WaitServer()) log.Close() time.Sleep(time.Second * 3) diff --git a/server/server.go b/server/server.go index b9ebab8..8aebb3d 100644 --- a/server/server.go +++ b/server/server.go @@ -11,8 +11,8 @@ import ( "server/web" ) -func Start(port string, roSets bool) { - settings.InitSets(roSets) +func Start(port string, roSets, searchWA bool) { + settings.InitSets(roSets, searchWA) if port == "" { port = "8090" } diff --git a/server/settings/settings.go b/server/settings/settings.go index a59be07..09f129e 100644 --- a/server/settings/settings.go +++ b/server/settings/settings.go @@ -13,13 +13,15 @@ var ( Port string ReadOnly bool HttpAuth bool + SearchWA bool PubIPv4 string PubIPv6 string TorAddr string ) -func InitSets(readOnly bool) { +func InitSets(readOnly, searchWA bool) { ReadOnly = readOnly + SearchWA = searchWA tdb = NewTDB() if tdb == nil { log.TLogln("Error open db:", filepath.Join(Path, "config.db")) diff --git a/server/web/auth/auth.go b/server/web/auth/auth.go index 61408bb..2b07c90 100644 --- a/server/web/auth/auth.go +++ b/server/web/auth/auth.go @@ -66,7 +66,8 @@ func BasicAuth(accounts gin.Accounts) gin.HandlerFunc { if strings.HasPrefix(c.FullPath(), "/stream") || c.FullPath() == "/site.webmanifest" || // https://github.com/YouROK/TorrServer/issues/172 - (strings.HasPrefix(c.FullPath(), "/play") && c.FullPath() != "/playlistall/all.m3u") { + (strings.HasPrefix(c.FullPath(), "/play") && c.FullPath() != "/playlistall/all.m3u") || + (settings.SearchWA && strings.HasPrefix(c.FullPath(), "/search")) { c.Set("not_auth", true) return } From 37d3878cb0d4f2fb1a6e8d56d4b8d7c327b81262 Mon Sep 17 00:00:00 2001 From: YouROK <8YouROK8@mail.ru> Date: Thu, 9 Mar 2023 23:00:22 +0300 Subject: [PATCH 3/4] fix arg --- server/cmd/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/cmd/main.go b/server/cmd/main.go index d97966f..10fab82 100644 --- a/server/cmd/main.go +++ b/server/cmd/main.go @@ -35,7 +35,7 @@ type args struct { TorrentAddr string `help:"Torrent client address, default :32000"` PubIPv4 string `arg:"-4" help:"set public IPv4 addr"` PubIPv6 string `arg:"-6" help:"set public IPv6 addr"` - SearchWA bool `arg:"-swa" help:"search without auth"` + SearchWA bool `arg:"-s" help:"search without auth"` } func (args) Version() string { From 654ce23f0f4f6bacc2930495d3615549d6212a68 Mon Sep 17 00:00:00 2001 From: YouROK <8YouROK8@mail.ru> Date: Fri, 10 Mar 2023 09:47:53 +0300 Subject: [PATCH 4/4] add unescape --- server/web/api/rutor.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/web/api/rutor.go b/server/web/api/rutor.go index 3127628..7ac938f 100644 --- a/server/web/api/rutor.go +++ b/server/web/api/rutor.go @@ -2,12 +2,14 @@ package api import ( "github.com/gin-gonic/gin" + "net/url" "server/rutor" "server/rutor/models" ) func rutorSearch(c *gin.Context) { query := c.Query("query") + query, _ = url.QueryUnescape(query) list := rutor.Search(query) if list == nil { list = []*models.TorrentDetails{}