From 4d2defa630d16effbd17d637e3a3045b44aed42c Mon Sep 17 00:00:00 2001 From: tdurieux Date: Thu, 12 Aug 2021 16:01:48 +0200 Subject: [PATCH] improve download button --- public/css/style.css | 16 +++++++++++++--- public/partials/explorer.htm | 33 +++++++++++++++++++-------------- src/routes/repository-public.ts | 22 ++++++++++++++++++---- 3 files changed, 50 insertions(+), 21 deletions(-) diff --git a/public/css/style.css b/public/css/style.css index 54f92c8..9db9a1d 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -78,8 +78,8 @@ input, button { outline: none; } -*:hover, -*:active { +input:hover, +input:active { box-shadow: none !important; } @@ -326,7 +326,7 @@ a:hover { cursor: default; } -.paths { +.status-bar { background-color: var(--main-bg-color); padding: 8px 6px; margin: 0; @@ -334,6 +334,15 @@ a:hover { border-radius: 0; } +.paths { + padding: 0; + margin: 0; + background-color: initial; + border: none; + border-radius: 0; + align-items: center; +} + .paths a { color: var(--color); } @@ -507,3 +516,4 @@ loc .lang { rgb(23 26 49) 100% ); } + diff --git a/public/partials/explorer.htm b/public/partials/explorer.htm index 866bfc7..d62f635 100644 --- a/public/partials/explorer.htm +++ b/public/partials/explorer.htm @@ -4,24 +4,29 @@
- +
+ Download file + Download Repository +
+
diff --git a/src/routes/repository-public.ts b/src/routes/repository-public.ts index 1384a44..d08ed4d 100644 --- a/src/routes/repository-public.ts +++ b/src/routes/repository-public.ts @@ -50,12 +50,26 @@ router.get( router.get( "/:repoId/options", async (req: express.Request, res: express.Response) => { - const repo = await getRepo(req, res); - if (!repo) return; - try { + const repo = await getRepo(req, res, { nocheck: true }); + + let redirectURL = null; + if ( + repo.status == "expired" && + repo.options.expirationMode == "redirect" && + repo.source.url + ) { + redirectURL = repo.source.url; + } else { + repo.check(); + } + await repo.updateIfNeeded(); - res.json(repo.options); + + res.json({ + url: redirectURL, + download: !!config.ENABLE_DOWNLOAD, + }); } catch (error) { handleError(error, res); }