From dbe21b49fafbd11690266736358114791e9921e6 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 22 Apr 2022 18:17:08 +0000 Subject: [PATCH 01/10] chore(deps): add renovate.json --- renovate.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 renovate.json diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..f45d8f1 --- /dev/null +++ b/renovate.json @@ -0,0 +1,5 @@ +{ + "extends": [ + "config:base" + ] +} From 9401bf8f7fca0b6ca6fa7c2355063055a9f9ac3b Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 23 Apr 2022 22:05:57 +0700 Subject: [PATCH 02/10] better CORS solution, note about unstable build --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d218b29..d7a63d4 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ Copy *.env.local.example* to *.env.local* and set: - **NEXTAUTH_URL**: Your frontend, most likely `http://localhost:3000` - **NEXT_PUBLIC_TUBEARCHIVIST_URL**: Your Tube Archivist backend testing server, e.g. `http://localhost:8000` +In general: Use the [unstable builds](https://github.com/tubearchivist/tubearchivist/blob/master/CONTRIBUTING.md#releases) from Tube Archivist or build the image yourself from *testing* branch. + ## Getting Started First, run the development server: @@ -23,7 +25,7 @@ yarn dev ### Errors: - *next command not found*: Install next with `npm install next` - *Error: Invalid src prop [...] hostname [...] is not configured under images in your `next.config.js`*: Add the *NEXT_PUBLIC_TUBEARCHIVIST_URL* to the list of *domains*. -- *CORS errors in console*: In your backend in `tubearchivist/config/settings.py` replace the line containing *CORS_ALLOWED_ORIGIN_REGEXES* with `CORS_ORIGIN_ALLOW_ALL = True` and rebuild the container. NEVER do that on network accessible installation. +- *CORS errors in console*: Set the environment variable `DISABLE_CORS=True` to the Tube Archivist container to circumvent this protection. NEVER do that on network accessible installation. Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. From ca36008df9e6cda54551bbedf6e06022a525670b Mon Sep 17 00:00:00 2001 From: Sean Norwood Date: Sat, 23 Apr 2022 17:43:55 +0000 Subject: [PATCH 03/10] chore: update renovate config --- renovate.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/renovate.json b/renovate.json index f45d8f1..685b3a5 100644 --- a/renovate.json +++ b/renovate.json @@ -1,5 +1,4 @@ { - "extends": [ - "config:base" - ] + "extends": ["config:base"], + "dependencyDashboardApproval": true } From 8c294cec4d33f86fa85f9d355f1783426ee4c385 Mon Sep 17 00:00:00 2001 From: Sean Norwood Date: Sat, 23 Apr 2022 17:52:08 +0000 Subject: [PATCH 04/10] ci: add basic install,build,lint ci --- .github/workflows/ci.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..12ae1dc --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,27 @@ +name: Node.js CI + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.x, 16.x, 18.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: "yarn" + - run: yarn install --frozen-lockfile + - run: yarn build + - run: yarn lint From 2734edcac5235ea93350639752ecafd9730971e2 Mon Sep 17 00:00:00 2001 From: Sean Norwood Date: Sat, 23 Apr 2022 17:58:27 +0000 Subject: [PATCH 05/10] ci: remove node v18 since next-auth doesn't support it --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12ae1dc..58b8433 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: - node-version: [14.x, 16.x, 18.x] + node-version: [14.x, 16.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: From 42362ba14b45f5116017ce43b200adcfe04f18fb Mon Sep 17 00:00:00 2001 From: Sean Norwood Date: Sat, 23 Apr 2022 18:10:12 +0000 Subject: [PATCH 06/10] chore: fix some misc syntax bugs --- src/lib/getPlaylists.ts | 25 +++++++++++++++---------- src/lib/utils.ts | 4 ++-- src/pages/channel.tsx | 20 ++++++++++++++++---- src/pages/playlist.tsx | 6 ++++-- 4 files changed, 37 insertions(+), 18 deletions(-) diff --git a/src/lib/getPlaylists.ts b/src/lib/getPlaylists.ts index edb6f9c..1b76077 100644 --- a/src/lib/getPlaylists.ts +++ b/src/lib/getPlaylists.ts @@ -1,13 +1,15 @@ import { Playlist } from "../types/playlist"; import { Playlists } from "../types/playlists"; -import { TA_BASE_URL } from "./constants"; +import { getTAUrl } from "./constants"; + +const TA_BASE_URL = getTAUrl(); export const getPlaylists = async (token: string): Promise => { if (!token) { throw new Error(`No token provided when fetching a playlists`); } - const response = await fetch(`${TA_BASE_URL}/api/playlist/`, { + const response = await fetch(`${TA_BASE_URL.server}/api/playlist/`, { headers: { Accept: "application/json", "Content-Type": "application/json", @@ -33,14 +35,17 @@ export const getPlaylist = async ( ); } - const response = await fetch(`${TA_BASE_URL}/api/playlist/${playlistId}`, { - headers: { - Accept: "application/json", - "Content-Type": "application/json", - Authorization: `Token ${token}`, - mode: "no-cors", - }, - }); + const response = await fetch( + `${TA_BASE_URL.server}/api/playlist/${playlistId}`, + { + headers: { + Accept: "application/json", + "Content-Type": "application/json", + Authorization: `Token ${token}`, + mode: "no-cors", + }, + } + ); if (!response.ok) { throw new Error( `Error getting playlists information: ${response.statusText}` diff --git a/src/lib/utils.ts b/src/lib/utils.ts index a00c48a..d17bbbb 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -3,8 +3,8 @@ * @param number A number or string number * @returns A number string with an appropriate letter appended */ -export function formatNumbers(number: string): string { - var numberUnformatted = parseFloat(number); +export function formatNumbers(number: string | number): string | number { + var numberUnformatted = parseFloat(number as string); if (numberUnformatted > 999999999) { var numberFormatted = (numberUnformatted / 1000000000).toFixed(1).toString() + "B"; diff --git a/src/pages/channel.tsx b/src/pages/channel.tsx index 14a6151..646b697 100644 --- a/src/pages/channel.tsx +++ b/src/pages/channel.tsx @@ -171,7 +171,9 @@ const Channel: NextPage = () => { {/* {% if channel.source.channel_subs >= 1000000 %} */} -

Subscribers: {formatNumbers(channel?.channel_subs)}

+

+ Subscribers: {formatNumbers(channel?.channel_subs)}{" "} +

{/* {% else %} */} @@ -185,10 +187,20 @@ const Channel: NextPage = () => { className="unsubscribe" type="button" id="{{ channel.source.channel_id }}" - onClick={() => console.log("unsubscribe(this.id) -> toggleSubscribe()")} - title={`${channel?.channel_subscribed ? "Unsubscribe from" : "Subscribe to"} ${channel?.channel_name}`} + onClick={() => + console.log( + "unsubscribe(this.id) -> toggleSubscribe()" + ) + } + title={`${ + channel?.channel_subscribed + ? "Unsubscribe from" + : "Subscribe to" + } ${channel?.channel_name}`} > - {channel?.channel_subscribed ? "Unsubscribe" : "Subscribe"} + {channel?.channel_subscribed + ? "Unsubscribe" + : "Subscribe"} {/* {% else %} */} {/*