From 47df3d642e224a74f2b50eb395819b8091a96fda Mon Sep 17 00:00:00 2001 From: mrjvs Date: Wed, 13 Dec 2023 00:12:07 +0100 Subject: [PATCH 1/6] delete docs workflow --- .github/workflows/docs.yml | 52 -------------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 .github/workflows/docs.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index f73ab3ff..00000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Publish docs - -on: - push: - branches: - - master - -jobs: - build: - name: Build - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - uses: pnpm/action-setup@v2 - with: - version: 8 - - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version: 18 - - - name: Install packages - working-directory: ./.docs - run: npm install - - - name: Build project - working-directory: ./.docs - run: npm run generate - - - name: Upload production-ready build files - uses: actions/upload-pages-artifact@v1 - with: - path: ./.docs/.output/public - - deploy: - name: Deploy - needs: build - permissions: - pages: write - id-token: write - environment: - name: docs - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v2 From 460ab60a896ead0fcf0488eaa1c7785fea57346e Mon Sep 17 00:00:00 2001 From: mrjvs Date: Wed, 13 Dec 2023 00:23:29 +0100 Subject: [PATCH 2/6] Update contributing guidelines to point to weblate --- .github/CONTRIBUTING.md | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index a4092e52..926899a8 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -85,28 +85,10 @@ Here are some tips to make sure that your pull requests are :pinched_fingers: fi ### Language Contributions Language contributions help movie-web massively, allowing people worldwide to use our app! -Like most apps, our translations are stored in `.json` files. Each language string has a unique key (For example, `notFound.genericTitle`) that references a language string in the appropriate language file. +We use weblate for crowdsourcing our translations. [Click here to go to our translation tool.](https://weblate.movie-web.app/projects/movie-web/website/) -Each language file is called `translation.json` and is stored in the `src/setup/languages//` folder. For example, the English language file is located at `src/setup/languages/en/translation.json`. - -> **Warning** -> -> Before you start a translation, please: -> - Check there isn't an existing GitHub [issue](https://github.com/movie-web/movie-web/issues) or [pull request](https://github.com/movie-web/movie-web/pulls) open for the language. -> - Make sure we aren't in the middle of a new feature update. When releasing major versions, we only accept changes to translations once the new version is complete. Otherwise, the language files would need to be updated. -> -> Please speak to us before starting a language PR. We want to use your time effectively. - -To make a translation: - - Copy the `en` folder inside the `src/setup/languages` folder - - Rename the copied folder to the 2-letter code for the country/language which is being translated. - - [Click this link to see a list of codes](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). Use the codes in the `639-1` column! - - For example, Arabic is `ar` - - Edit the language strings inside the `translation.json` file - - **Do not** edit the keys. Only edit the values. - - e.g. in `"stopEditing": "Stop editing",` - only change the `Stop editing` part, not the `stopEditing` part. - - In the `src/setup/i18n.ts` file: - - Import your new translation file, e.g. `import ar from "./locales/ar/translation.json";` - - Add your translation to the `locales` object (Look at other languages for an example) - -Once you have completed your translation, please open a pull request. We do not accept partial translations, so please ensure every language string is translated to the intended language. +1. First make sure you make an account. (click the link above) +2. Click the language you want to help translate, if it's not listed you can click the plus top left to add a new language. +3. In the top right of the screen, click "translate" +4. Here you will be prompted a key to translate, fill in a translation and proceed to the next item by pressing "save and continue". +5. Thats all there is to it, every translation will eventually come through and be pushed with an update. This usually doesn't take longer than a week. From 4d169474a03188bc18311db2c7c934cb34b6e11e Mon Sep 17 00:00:00 2001 From: mrjvs Date: Wed, 13 Dec 2023 00:26:46 +0100 Subject: [PATCH 3/6] Enable source maps --- vite.config.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vite.config.ts b/vite.config.ts index 0b9ac678..9a0018b0 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -102,6 +102,10 @@ export default defineConfig(({ mode }) => { }) ], + build: { + sourcemap: true, + }, + resolve: { alias: { "@": path.resolve(__dirname, "./src"), From cd4f5985e417c0f6e1dd0a93f2fa6061098803a3 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Wed, 13 Dec 2023 00:32:12 +0100 Subject: [PATCH 4/6] Mention that you have to make a .env file in local dev guide --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 99a336ff..fdc4776d 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,8 @@ pnpm install pnpm run dev ``` +You have to also make an `.env` file to configure your environment. Inspire it from the content of `example.env`. + To build production files, run: ```bash pnpm build @@ -55,7 +57,7 @@ pnpm build A simple guide has been written to assist in hosting your own instance of movie-web. Check it out below -|[Selfhosting guide](https://docs.movie-web.app/self-hosting/self-hosting)| +|[Selfhosting guide](https://docs.movie-web.app)| |---| From c48b82148a80d35d6bb5aa1b2d00acaf9db47770 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Wed, 13 Dec 2023 00:44:35 +0100 Subject: [PATCH 5/6] Fix morning time --- src/pages/parts/home/HeroPart.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/pages/parts/home/HeroPart.tsx b/src/pages/parts/home/HeroPart.tsx index 17a1172c..6b2ef282 100644 --- a/src/pages/parts/home/HeroPart.tsx +++ b/src/pages/parts/home/HeroPart.tsx @@ -16,6 +16,14 @@ export interface HeroPartProps { searchParams: ReturnType; } +function getTimeOfDay(date: Date): "night" | "morning" | "day" { + const hour = date.getHours(); + if (hour < 5) return "night"; + if (hour < 12) return "morning"; + if (hour < 19) return "day"; + return "night"; +} + export function HeroPart({ setIsSticky, searchParams }: HeroPartProps) { const { t: randomT } = useRandomTranslation(); const { t } = useTranslation(); @@ -44,11 +52,7 @@ export function HeroPart({ setIsSticky, searchParams }: HeroPartProps) { } }, [windowWidth]); - let time = "night"; - const hour = new Date().getHours(); - if (hour < 12) time = "morning"; - else if (hour < 19) time = "day"; - + const time = getTimeOfDay(new Date()); const title = randomT(`home.titles.${time}`); const inputRef = useRef(null); From a76b9ed39c278362fe228ba21de9708990f04a70 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Wed, 13 Dec 2023 00:56:15 +0100 Subject: [PATCH 6/6] Add logout button if failing to load profile from original backend url --- src/assets/locales/en.json | 3 ++- src/index.tsx | 25 +++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/assets/locales/en.json b/src/assets/locales/en.json index 71fb1d78..01d6205e 100644 --- a/src/assets/locales/en.json +++ b/src/assets/locales/en.json @@ -260,7 +260,8 @@ "loadingUserError": { "text": "Failed to load your profile", "textWithReset": "Failed to load your profile from your custom server, want to reset back to the default server?", - "reset": "Reset custom server" + "reset": "Reset custom server", + "logout": "Logout" }, "migration": { "failed": "Failed to migrate your data.", diff --git a/src/index.tsx b/src/index.tsx index 780bd63e..8ef5a560 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -15,6 +15,7 @@ import { useAsync } from "react-use"; import { Button } from "@/components/buttons/Button"; import { Icon, Icons } from "@/components/Icon"; import { Loading } from "@/components/layout/Loading"; +import { useAuth } from "@/hooks/auth/useAuth"; import { useAuthRestore } from "@/hooks/auth/useAuthRestore"; import { useBackendUrl } from "@/hooks/auth/useBackendUrl"; import { ErrorBoundary } from "@/pages/errors/ErrorBoundary"; @@ -57,14 +58,22 @@ function LoadingScreen(props: { type: "user" | "lazy" }) { function ErrorScreen(props: { children: ReactNode; showResetButton?: boolean; + showLogoutButton?: boolean; }) { const { t } = useTranslation(); + const { logout } = useAuth(); const setBackendUrl = useAuthStore((s) => s.setBackendUrl); const resetBackend = useCallback(() => { setBackendUrl(null); // eslint-disable-next-line no-restricted-globals location.reload(); }, [setBackendUrl]); + const logoutFromBackend = useCallback(() => { + logout().then(() => { + // eslint-disable-next-line no-restricted-globals + location.reload(); + }); + }, [logout]); return ( ) : null} + {props.showLogoutButton ? ( +
+ +
+ ) : null}
); } @@ -90,12 +106,17 @@ function AuthWrapper() { const userBackendUrl = useBackendUrl(); const { t } = useTranslation(); + const isCustomUrl = backendUrl !== userBackendUrl; + if (status.loading) return ; if (status.error) return ( - + {t( - backendUrl !== userBackendUrl + isCustomUrl ? "screens.loadingUserError.textWithReset" : "screens.loadingUserError.text" )}