Przeglądaj źródła

feat: add HIDE_HISTORY option to control visibility of history page

g.petrakis 3 miesięcy temu
rodzic
commit
9d1c93155c
5 zmienionych plików z 42 dodań i 28 usunięć
  1. 1 0
      README.md
  2. 17 17
      bun.lock
  3. 1 0
      compose.yaml
  4. 15 11
      src/components/header.tsx
  5. 8 0
      src/index.tsx

+ 1 - 0
README.md

@@ -80,6 +80,7 @@ All are optional, JWT_SECRET is recommended to be set.
 | AUTO_DELETE_EVERY_N_HOURS | 24 | Checks every n hours for files older then n hours and deletes them, set to 0 to disable |
 | WEBROOT                   |  | The address to the root path setting this to "/convert" will serve the website on "example.com/convert/" |
 | FFMPEG_ARGS               |  | Arguments to pass to ffmpeg, e.g. `-preset veryfast` |
+| HIDE_HISTORY             | false | Hide the history page |
 
 > [!WARNING]
 > If you can't login, make sure you are accessing the service over https or set HTTP_ALLOWED=true

+ 17 - 17
bun.lock

@@ -8,35 +8,35 @@
         "@elysiajs/jwt": "^1.2.0",
         "@elysiajs/static": "^1.2.0",
         "@kitajs/html": "^4.2.7",
-        "elysia": "^1.2.12",
+        "elysia": "^1.2.25",
         "sanitize-filename": "^1.6.3",
       },
       "devDependencies": {
-        "@eslint/js": "^9.19.0",
+        "@eslint/js": "^9.23.0",
         "@ianvs/prettier-plugin-sort-imports": "^4.4.1",
         "@kitajs/ts-html-plugin": "^4.1.1",
-        "@tailwindcss/cli": "^4.0.4",
-        "@tailwindcss/postcss": "^4.0.4",
+        "@tailwindcss/cli": "^4.0.17",
+        "@tailwindcss/postcss": "^4.0.17",
         "@total-typescript/ts-reset": "^0.6.1",
-        "@types/bun": "^1.2.2",
+        "@types/bun": "^1.2.8",
         "@types/eslint-plugin-tailwindcss": "^3.17.0",
-        "@types/node": "^22.13.1",
-        "autoprefixer": "^10.4.20",
+        "@types/node": "^22.13.16",
+        "autoprefixer": "^10.4.21",
         "cssnano": "^7.0.6",
-        "eslint": "^9.19.0",
-        "eslint-plugin-readable-tailwind": "^2.0.0-beta.4",
+        "eslint": "^9.23.0",
+        "eslint-plugin-readable-tailwind": "^2.0.0",
         "eslint-plugin-simple-import-sort": "^12.1.1",
         "eslint-plugin-tailwindcss": "4.0.0-alpha.0",
         "globals": "^16.0.0",
-        "knip": "^5.43.6",
+        "knip": "^5.46.4",
         "npm-run-all2": "^7.0.2",
-        "postcss": "^8.5.1",
-        "postcss-cli": "^11.0.0",
-        "prettier": "^3.4.2",
-        "tailwind-scrollbar": "^4.0.0",
-        "tailwindcss": "^4.0.4",
-        "typescript": "^5.7.3",
-        "typescript-eslint": "^8.23.0",
+        "postcss": "^8.5.3",
+        "postcss-cli": "^11.0.1",
+        "prettier": "^3.5.3",
+        "tailwind-scrollbar": "^4.0.2",
+        "tailwindcss": "^4.0.17",
+        "typescript": "^5.8.2",
+        "typescript-eslint": "^8.29.0",
       },
     },
   },

+ 1 - 0
compose.yaml

@@ -13,5 +13,6 @@ services:
       - AUTO_DELETE_EVERY_N_HOURS=1 # checks every n hours for files older then n hours and deletes them, set to 0 to disable
       # - FFMPEG_ARGS=-hwaccel vulkan # additional arguments to pass to ffmpeg
       # - WEBROOT=/convertx # the root path of the web interface, leave empty to disable
+      # - HIDE_HISTORY=true # hides the history tab in the web interface, defaults to false
     ports:
       - 3000:3000

+ 15 - 11
src/components/header.tsx

@@ -4,28 +4,32 @@ export const Header = ({
   loggedIn,
   accountRegistration,
   allowUnauthenticated,
+  hideHistory,
   webroot = "",
 }: {
   loggedIn?: boolean;
   accountRegistration?: boolean;
   allowUnauthenticated?: boolean;
+  hideHistory?: boolean;
   webroot?: string;
 }) => {
   let rightNav: JSX.Element;
   if (loggedIn) {
     rightNav = (
       <ul class="flex gap-4">
-        <li>
-          <a
-            class={`
-              text-accent-600 transition-all
-              hover:text-accent-500 hover:underline
-            `}
-            href={`${webroot}/history`}
-          >
-            History
-          </a>
-        </li>
+        {!hideHistory && (
+          <li>
+            <a
+              class={`
+                text-accent-600 transition-all
+                hover:text-accent-500 hover:underline
+              `}
+              href={`${webroot}/history`}
+            >
+              History
+            </a>
+          </li>
+        )}
         {!allowUnauthenticated ? (
           <li>
             <a

+ 8 - 0
src/index.tsx

@@ -36,6 +36,8 @@ const ALLOW_UNAUTHENTICATED =
 const AUTO_DELETE_EVERY_N_HOURS = process.env.AUTO_DELETE_EVERY_N_HOURS
   ? Number(process.env.AUTO_DELETE_EVERY_N_HOURS)
   : 24;
+const HIDE_HISTORY =
+  process.env.HIDE_HISTORY?.toLowerCase() === "true" || false;
 
 const WEBROOT = process.env.WEBROOT ?? "";
 
@@ -351,6 +353,7 @@ const app = new Elysia({
             webroot={WEBROOT}
             accountRegistration={ACCOUNT_REGISTRATION}
             allowUnauthenticated={ALLOW_UNAUTHENTICATED}
+            hideHistory={HIDE_HISTORY}
           />
           <main
             class={`
@@ -953,6 +956,10 @@ const app = new Elysia({
     },
   )
   .get("/history", async ({ jwt, redirect, cookie: { auth } }) => {
+    if (HIDE_HISTORY) {
+      return redirect(`${WEBROOT}/`, 302);
+    }
+    
     if (!auth?.value) {
       return redirect(`${WEBROOT}/login`, 302);
     }
@@ -986,6 +993,7 @@ const app = new Elysia({
           <Header
             webroot={WEBROOT}
             allowUnauthenticated={ALLOW_UNAUTHENTICATED}
+            hideHistory={HIDE_HISTORY}
             loggedIn
           />
           <main