mirror of
https://github.com/OpenCut-app/OpenCut.git
synced 2026-07-13 21:52:53 +02:00
Merge branch 'main' into dev
This commit is contained in:
+4
-2
@@ -6,6 +6,8 @@ WORKDIR /app
|
|||||||
|
|
||||||
ARG FREESOUND_CLIENT_ID
|
ARG FREESOUND_CLIENT_ID
|
||||||
ARG FREESOUND_API_KEY
|
ARG FREESOUND_API_KEY
|
||||||
|
ARG NEXT_PUBLIC_MARBLE_API_URL=https://api.marblecms.com
|
||||||
|
ARG MARBLE_WORKSPACE_KEY=build-placeholder
|
||||||
|
|
||||||
COPY package.json package.json
|
COPY package.json package.json
|
||||||
COPY bun.lock bun.lock
|
COPY bun.lock bun.lock
|
||||||
@@ -30,8 +32,8 @@ ENV BETTER_AUTH_SECRET="build-time-secret"
|
|||||||
ENV UPSTASH_REDIS_REST_URL="http://localhost:8079"
|
ENV UPSTASH_REDIS_REST_URL="http://localhost:8079"
|
||||||
ENV UPSTASH_REDIS_REST_TOKEN="example_token"
|
ENV UPSTASH_REDIS_REST_TOKEN="example_token"
|
||||||
ENV NEXT_PUBLIC_SITE_URL="http://localhost:3000"
|
ENV NEXT_PUBLIC_SITE_URL="http://localhost:3000"
|
||||||
ENV NEXT_PUBLIC_MARBLE_API_URL="https://api.marblecms.com"
|
ENV NEXT_PUBLIC_MARBLE_API_URL=$NEXT_PUBLIC_MARBLE_API_URL
|
||||||
ENV MARBLE_WORKSPACE_KEY="build-placeholder"
|
ENV MARBLE_WORKSPACE_KEY=$MARBLE_WORKSPACE_KEY
|
||||||
ENV CLOUDFLARE_ACCOUNT_ID="build-placeholder"
|
ENV CLOUDFLARE_ACCOUNT_ID="build-placeholder"
|
||||||
ENV R2_ACCESS_KEY_ID="build-placeholder"
|
ENV R2_ACCESS_KEY_ID="build-placeholder"
|
||||||
ENV R2_SECRET_ACCESS_KEY="build-placeholder"
|
ENV R2_SECRET_ACCESS_KEY="build-placeholder"
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export const metadata: Metadata = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default async function BlogPage() {
|
export default async function BlogPage() {
|
||||||
const data = await getPosts();
|
const data = await getPosts().catch(() => null);
|
||||||
if (!data || !data.posts) return <div>No posts yet</div>;
|
if (!data || !data.posts) return <div>No posts yet</div>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import type {
|
import type {
|
||||||
MarbleAuthorList,
|
MarbleAuthorList,
|
||||||
MarbleCategoryList,
|
MarbleCategoryList,
|
||||||
|
Pagination,
|
||||||
MarblePost,
|
MarblePost,
|
||||||
MarblePostList,
|
MarblePostList,
|
||||||
MarbleTagList,
|
MarbleTagList,
|
||||||
@@ -16,43 +17,98 @@ const url =
|
|||||||
process.env.NEXT_PUBLIC_MARBLE_API_URL ?? "https://api.marblecms.com";
|
process.env.NEXT_PUBLIC_MARBLE_API_URL ?? "https://api.marblecms.com";
|
||||||
const key = process.env.MARBLE_WORKSPACE_KEY ?? "cmd4iw9mm0006l804kwqv0k46";
|
const key = process.env.MARBLE_WORKSPACE_KEY ?? "cmd4iw9mm0006l804kwqv0k46";
|
||||||
|
|
||||||
|
const EMPTY_PAGINATION: Pagination = {
|
||||||
|
limit: 0,
|
||||||
|
currpage: 1,
|
||||||
|
nextPage: null,
|
||||||
|
prevPage: null,
|
||||||
|
totalItems: 0,
|
||||||
|
totalPages: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
const EMPTY_POSTS: MarblePostList = {
|
||||||
|
posts: [],
|
||||||
|
pagination: EMPTY_PAGINATION,
|
||||||
|
};
|
||||||
|
|
||||||
|
const EMPTY_TAGS: MarbleTagList = {
|
||||||
|
tags: [],
|
||||||
|
pagination: EMPTY_PAGINATION,
|
||||||
|
};
|
||||||
|
|
||||||
|
const EMPTY_CATEGORIES: MarbleCategoryList = {
|
||||||
|
categories: [],
|
||||||
|
pagination: EMPTY_PAGINATION,
|
||||||
|
};
|
||||||
|
|
||||||
|
const EMPTY_AUTHORS: MarbleAuthorList = {
|
||||||
|
authors: [],
|
||||||
|
pagination: EMPTY_PAGINATION,
|
||||||
|
};
|
||||||
|
|
||||||
|
function isMarbleConfigured() {
|
||||||
|
return !["", "placeholder", "build-placeholder", "your_workspace_key_here"].includes(key);
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchFromMarble<T>({
|
async function fetchFromMarble<T>({
|
||||||
endpoint,
|
endpoint,
|
||||||
|
fallback,
|
||||||
}: {
|
}: {
|
||||||
endpoint: string;
|
endpoint: string;
|
||||||
|
fallback: T;
|
||||||
}): Promise<T> {
|
}): Promise<T> {
|
||||||
|
if (!isMarbleConfigured()) {
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${url}/${key}/${endpoint}`);
|
const response = await fetch(`${url}/${key}/${endpoint}`);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(
|
console.warn(
|
||||||
`Failed to fetch ${endpoint}: ${response.status} ${response.statusText}`,
|
`Failed to fetch ${endpoint}: ${response.status} ${response.statusText}`,
|
||||||
);
|
);
|
||||||
|
return fallback;
|
||||||
}
|
}
|
||||||
return (await response.json()) as T;
|
return (await response.json()) as T;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error fetching ${endpoint}:`, error);
|
console.error(`Error fetching ${endpoint}:`, error);
|
||||||
throw error;
|
return fallback;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getPosts() {
|
export async function getPosts() {
|
||||||
return fetchFromMarble<MarblePostList>({ endpoint: "posts" });
|
return fetchFromMarble<MarblePostList>({
|
||||||
|
endpoint: "posts",
|
||||||
|
fallback: EMPTY_POSTS,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getTags() {
|
export async function getTags() {
|
||||||
return fetchFromMarble<MarbleTagList>({ endpoint: "tags" });
|
return fetchFromMarble<MarbleTagList>({
|
||||||
|
endpoint: "tags",
|
||||||
|
fallback: EMPTY_TAGS,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getSinglePost({ slug }: { slug: string }) {
|
export async function getSinglePost({ slug }: { slug: string }) {
|
||||||
return fetchFromMarble<MarblePost>({ endpoint: `posts/${slug}` });
|
return fetchFromMarble<MarblePost | null>({
|
||||||
|
endpoint: `posts/${slug}`,
|
||||||
|
fallback: null,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getCategories() {
|
export async function getCategories() {
|
||||||
return fetchFromMarble<MarbleCategoryList>({ endpoint: "categories" });
|
return fetchFromMarble<MarbleCategoryList>({
|
||||||
|
endpoint: "categories",
|
||||||
|
fallback: EMPTY_CATEGORIES,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAuthors() {
|
export async function getAuthors() {
|
||||||
return fetchFromMarble<MarbleAuthorList>({ endpoint: "authors" });
|
return fetchFromMarble<MarbleAuthorList>({
|
||||||
|
endpoint: "authors",
|
||||||
|
fallback: EMPTY_AUTHORS,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function processHtmlContent({
|
export async function processHtmlContent({
|
||||||
|
|||||||
@@ -100,8 +100,21 @@ export class SceneExporter extends EventEmitter<SceneExporterEvents> {
|
|||||||
|
|
||||||
let audioSource: AudioBufferSource | null = null;
|
let audioSource: AudioBufferSource | null = null;
|
||||||
if (this.shouldIncludeAudio && this.audioBuffer) {
|
if (this.shouldIncludeAudio && this.audioBuffer) {
|
||||||
|
let audioCodec: "aac" | "opus" =
|
||||||
|
this.format === "webm" ? "opus" : "aac";
|
||||||
|
|
||||||
|
if (audioCodec === "aac" && typeof AudioEncoder !== "undefined") {
|
||||||
|
const { supported } = await AudioEncoder.isConfigSupported({
|
||||||
|
codec: "mp4a.40.2",
|
||||||
|
sampleRate: this.audioBuffer.sampleRate,
|
||||||
|
numberOfChannels: this.audioBuffer.numberOfChannels,
|
||||||
|
bitrate: 192000,
|
||||||
|
});
|
||||||
|
if (!supported) audioCodec = "opus";
|
||||||
|
}
|
||||||
|
|
||||||
audioSource = new AudioBufferSource({
|
audioSource = new AudioBufferSource({
|
||||||
codec: this.format === "webm" ? "opus" : "aac",
|
codec: audioCodec,
|
||||||
bitrate: qualityMap[this.quality],
|
bitrate: qualityMap[this.quality],
|
||||||
});
|
});
|
||||||
output.addAudioTrack(audioSource);
|
output.addAudioTrack(audioSource);
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ services:
|
|||||||
args:
|
args:
|
||||||
- FREESOUND_CLIENT_ID=${FREESOUND_CLIENT_ID}
|
- FREESOUND_CLIENT_ID=${FREESOUND_CLIENT_ID}
|
||||||
- FREESOUND_API_KEY=${FREESOUND_API_KEY}
|
- FREESOUND_API_KEY=${FREESOUND_API_KEY}
|
||||||
|
- NEXT_PUBLIC_MARBLE_API_URL=${NEXT_PUBLIC_MARBLE_API_URL:-https://api.marblecms.com}
|
||||||
|
- MARBLE_WORKSPACE_KEY=${MARBLE_WORKSPACE_KEY:-build-placeholder}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "3100:3000"
|
- "3100:3000"
|
||||||
|
|||||||
Reference in New Issue
Block a user