Removed video, combined all images
This commit is contained in:
parent
941ae62099
commit
b7dca38786
|
@ -1,23 +0,0 @@
|
|||
import { Collections } from "../../constants";
|
||||
import { buildImageCollectionConfig } from "../../utils/imageCollectionConfig";
|
||||
|
||||
const fields = {
|
||||
filename: "filename",
|
||||
mimeType: "mimeType",
|
||||
filesize: "filesize",
|
||||
posts: "posts",
|
||||
updatedAt: "updatedAt",
|
||||
} as const satisfies Record<string, string>;
|
||||
|
||||
export const BackgroundImages = buildImageCollectionConfig({
|
||||
slug: Collections.BackgroundImages,
|
||||
labels: {
|
||||
singular: "Background Image",
|
||||
plural: "Background Images",
|
||||
},
|
||||
admin: { defaultColumns: [fields.filename, fields.posts, fields.updatedAt] },
|
||||
upload: {
|
||||
imageSizes: [],
|
||||
},
|
||||
fields: [],
|
||||
});
|
|
@ -206,7 +206,7 @@ export const Collectibles = buildVersionedCollectionConfig({
|
|||
fields: [
|
||||
imageField({
|
||||
name: fields.backgroundImage,
|
||||
relationTo: Collections.BackgroundImages,
|
||||
relationTo: Collections.Images,
|
||||
admin: {
|
||||
description:
|
||||
"The image used as background from the webpage.\
|
||||
|
|
|
@ -101,7 +101,7 @@ export const Pages = buildVersionedCollectionConfig({
|
|||
}),
|
||||
imageField({
|
||||
name: fields.backgroundImage,
|
||||
relationTo: Collections.BackgroundImages,
|
||||
relationTo: Collections.Images,
|
||||
admin: {
|
||||
description:
|
||||
"The image used as background from the webpage.\
|
||||
|
|
|
@ -89,7 +89,7 @@ export const Recorders = buildCollectionConfig({
|
|||
},
|
||||
imageField({
|
||||
name: fields.avatar,
|
||||
relationTo: Collections.RecordersThumbnails,
|
||||
relationTo: Collections.Images,
|
||||
}),
|
||||
]),
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@ export const importFromStrapi = createStrapiImportEndpoint<StrapiRecorder>({
|
|||
collection: Collections.Recorders,
|
||||
import: async ({ username, anonymize, anonymous_code, languages, avatar, bio: bios }, user) => {
|
||||
const avatarId = await uploadStrapiImage({
|
||||
collection: Collections.RecordersThumbnails,
|
||||
collection: Collections.Images,
|
||||
image: avatar,
|
||||
});
|
||||
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
import { Collections } from "../../constants";
|
||||
import { backPropagationField } from "../../fields/backPropagationField/backPropagationField";
|
||||
import { buildImageCollectionConfig } from "../../utils/imageCollectionConfig";
|
||||
|
||||
const fields = {
|
||||
filename: "filename",
|
||||
mimeType: "mimeType",
|
||||
filesize: "filesize",
|
||||
recorder: "recorder",
|
||||
updatedAt: "updatedAt",
|
||||
} as const satisfies Record<string, string>;
|
||||
|
||||
export const RecordersThumbnails = buildImageCollectionConfig({
|
||||
slug: Collections.RecordersThumbnails,
|
||||
labels: {
|
||||
singular: "Recorders Thumbnail",
|
||||
plural: "Recorders Thumbnails",
|
||||
},
|
||||
admin: { defaultColumns: [fields.filename, fields.recorder, fields.updatedAt] },
|
||||
upload: {
|
||||
imageSizes: [
|
||||
{
|
||||
name: "square",
|
||||
height: 150,
|
||||
width: 150,
|
||||
fit: "cover",
|
||||
formatOptions: {
|
||||
format: "webp",
|
||||
options: { effort: 6, quality: 80, alphaQuality: 80 },
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
fields: [
|
||||
backPropagationField({
|
||||
name: fields.recorder,
|
||||
hasMany: false,
|
||||
relationTo: Collections.Recorders,
|
||||
where: ({ id }) => ({ avatar: { equals: id } }),
|
||||
}),
|
||||
],
|
||||
});
|
|
@ -1,93 +0,0 @@
|
|||
import { CollectionConfig } from "payload/types";
|
||||
import { mustBeAdmin } from "../../accesses/collections/mustBeAdmin";
|
||||
import { CollectionGroups, Collections, VideoSources } from "../../constants";
|
||||
import { rowField } from "../../fields/rowField/rowField";
|
||||
import { buildCollectionConfig } from "../../utils/collectionConfig";
|
||||
import { importFromStrapi } from "./endpoints/importFromStrapi";
|
||||
|
||||
const fields = {
|
||||
uid: "uid",
|
||||
gone: "gone",
|
||||
source: "source",
|
||||
liveChat: "liveChat",
|
||||
title: "title",
|
||||
description: "description",
|
||||
publishedDate: "publishedDate",
|
||||
views: "views",
|
||||
likes: "likes",
|
||||
channel: "channel",
|
||||
} as const satisfies Record<string, string>;
|
||||
|
||||
export const Videos: CollectionConfig = buildCollectionConfig({
|
||||
slug: Collections.Videos,
|
||||
labels: {
|
||||
singular: "Video",
|
||||
plural: "Videos",
|
||||
},
|
||||
defaultSort: fields.uid,
|
||||
admin: {
|
||||
useAsTitle: fields.title,
|
||||
defaultColumns: [
|
||||
fields.uid,
|
||||
fields.title,
|
||||
fields.source,
|
||||
fields.gone,
|
||||
fields.liveChat,
|
||||
fields.publishedDate,
|
||||
fields.views,
|
||||
fields.likes,
|
||||
fields.channel,
|
||||
],
|
||||
group: CollectionGroups.Media,
|
||||
disableDuplicate: true,
|
||||
},
|
||||
access: {
|
||||
create: mustBeAdmin,
|
||||
delete: mustBeAdmin,
|
||||
},
|
||||
endpoints: [importFromStrapi],
|
||||
timestamps: false,
|
||||
fields: [
|
||||
rowField([
|
||||
{ name: fields.uid, type: "text", required: true, unique: true },
|
||||
{
|
||||
name: fields.gone,
|
||||
type: "checkbox",
|
||||
defaultValue: false,
|
||||
required: true,
|
||||
admin: {
|
||||
description:
|
||||
"Is the video no longer available (deleted, privatized, unlisted, blocked...)",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: fields.source,
|
||||
type: "select",
|
||||
required: true,
|
||||
options: Object.entries(VideoSources).map(([_, value]) => ({
|
||||
label: value,
|
||||
value: value,
|
||||
})),
|
||||
},
|
||||
]),
|
||||
{ name: fields.title, type: "text", required: true },
|
||||
{ name: fields.description, type: "textarea" },
|
||||
rowField([
|
||||
{ name: fields.likes, type: "number" },
|
||||
{ name: fields.views, type: "number" },
|
||||
]),
|
||||
{
|
||||
name: fields.publishedDate,
|
||||
type: "date",
|
||||
admin: {
|
||||
date: { pickerAppearance: "dayOnly", displayFormat: "yyyy-MM-dd" },
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: fields.channel,
|
||||
type: "relationship",
|
||||
relationTo: Collections.VideosChannels,
|
||||
},
|
||||
],
|
||||
});
|
|
@ -1,88 +0,0 @@
|
|||
import payload from "payload";
|
||||
import { Collections, VideoSources } from "../../../constants";
|
||||
import { createStrapiImportEndpoint } from "../../../endpoints/createStrapiImportEndpoint";
|
||||
import { isDefined, isUndefined } from "../../../utils/asserts";
|
||||
|
||||
type StapiVideo = {
|
||||
uid: string;
|
||||
title: string;
|
||||
description: string;
|
||||
published_date: {
|
||||
year?: number;
|
||||
month?: number;
|
||||
day?: number;
|
||||
};
|
||||
views: number;
|
||||
likes: number;
|
||||
source?: VideoSources;
|
||||
gone: boolean;
|
||||
channel: { data?: { attributes: { uid: string; title: string; subscribers: number } } };
|
||||
};
|
||||
|
||||
export const importFromStrapi = createStrapiImportEndpoint<StapiVideo>({
|
||||
strapi: {
|
||||
collection: "videos",
|
||||
params: { populate: "published_date,channel" },
|
||||
},
|
||||
payload: {
|
||||
collection: Collections.Videos,
|
||||
import: async (
|
||||
{
|
||||
uid,
|
||||
title,
|
||||
description,
|
||||
views,
|
||||
likes,
|
||||
gone,
|
||||
source,
|
||||
published_date: { year, month, day },
|
||||
channel,
|
||||
},
|
||||
user
|
||||
) => {
|
||||
if (isUndefined(source)) throw new Error("A source is required to create a Video");
|
||||
if (source === VideoSources.YouTube && isUndefined(channel.data))
|
||||
throw new Error("A channel is required to create a YouTube Video");
|
||||
|
||||
let videoChannelId;
|
||||
if (isDefined(channel.data)) {
|
||||
try {
|
||||
await payload.create({
|
||||
collection: Collections.VideosChannels,
|
||||
data: {
|
||||
uid: channel.data.attributes.uid,
|
||||
title: channel.data.attributes.title,
|
||||
subscribers: channel.data.attributes.subscribers,
|
||||
},
|
||||
user,
|
||||
});
|
||||
} catch (e) {}
|
||||
|
||||
const result = await payload.find({
|
||||
collection: Collections.VideosChannels,
|
||||
where: { uid: { equals: channel.data.attributes.uid } },
|
||||
});
|
||||
|
||||
if (result.docs[0]) {
|
||||
videoChannelId = result.docs[0].id;
|
||||
}
|
||||
}
|
||||
|
||||
await payload.create({
|
||||
collection: Collections.Videos,
|
||||
data: {
|
||||
uid,
|
||||
title,
|
||||
description,
|
||||
views,
|
||||
likes,
|
||||
gone,
|
||||
source,
|
||||
publishedDate: `${year}-${month}-${day}`,
|
||||
channel: videoChannelId,
|
||||
},
|
||||
user,
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
|
@ -1,39 +0,0 @@
|
|||
import { CollectionConfig } from "payload/types";
|
||||
import { mustBeAdmin } from "../../accesses/collections/mustBeAdmin";
|
||||
import { CollectionGroups, Collections } from "../../constants";
|
||||
import { rowField } from "../../fields/rowField/rowField";
|
||||
import { buildCollectionConfig } from "../../utils/collectionConfig";
|
||||
|
||||
const fields = {
|
||||
uid: "uid",
|
||||
title: "title",
|
||||
subscribers: "subscribers",
|
||||
videos: "videos",
|
||||
} as const satisfies Record<string, string>;
|
||||
|
||||
export const VideosChannels: CollectionConfig = buildCollectionConfig({
|
||||
slug: Collections.VideosChannels,
|
||||
labels: {
|
||||
singular: "Videos Channel",
|
||||
plural: "Videos Channels",
|
||||
},
|
||||
defaultSort: fields.title,
|
||||
admin: {
|
||||
useAsTitle: fields.title,
|
||||
defaultColumns: [fields.uid, fields.title, fields.subscribers, fields.videos],
|
||||
group: CollectionGroups.Media,
|
||||
disableDuplicate: true,
|
||||
},
|
||||
access: {
|
||||
create: mustBeAdmin,
|
||||
delete: mustBeAdmin,
|
||||
},
|
||||
timestamps: false,
|
||||
fields: [
|
||||
{ name: fields.uid, type: "text", required: true, unique: true },
|
||||
rowField([
|
||||
{ name: fields.title, type: "text", required: true },
|
||||
{ name: fields.subscribers, type: "number" },
|
||||
]),
|
||||
],
|
||||
});
|
|
@ -11,9 +11,6 @@ export enum Collections {
|
|||
Pages = "pages",
|
||||
PagesThumbnails = "pages-thumbnails",
|
||||
Recorders = "recorders",
|
||||
RecordersThumbnails = "recorders-thumbnails",
|
||||
VideosChannels = "videos-channels",
|
||||
Videos = "videos",
|
||||
Folders = "folders",
|
||||
Tags = "tags",
|
||||
TagsGroups = "tags-groups",
|
||||
|
@ -21,7 +18,6 @@ export enum Collections {
|
|||
Wordings = "wordings",
|
||||
Collectibles = "collectibles",
|
||||
GenericContents = "generic-contents",
|
||||
BackgroundImages = "background-images",
|
||||
HomeFolders = "home-folders",
|
||||
}
|
||||
|
||||
|
@ -79,12 +75,6 @@ export enum CollectionStatus {
|
|||
Published = "published",
|
||||
}
|
||||
|
||||
export enum VideoSources {
|
||||
YouTube = "YouTube",
|
||||
NicoNico = "NicoNico",
|
||||
Tumblr = "Tumblr",
|
||||
}
|
||||
|
||||
export enum PageType {
|
||||
Content = "Content",
|
||||
Post = "Post",
|
||||
|
|
|
@ -2,7 +2,6 @@ import { webpackBundler } from "@payloadcms/bundler-webpack";
|
|||
import { mongooseAdapter } from "@payloadcms/db-mongodb";
|
||||
import path from "path";
|
||||
import { buildConfig } from "payload/config";
|
||||
import { BackgroundImages } from "./collections/BackgroundImages/BackgroundImages";
|
||||
import { ChronologyEvents } from "./collections/ChronologyEvents/ChronologyEvents";
|
||||
import { Collectibles } from "./collections/Collectibles/Collectibles";
|
||||
import { Currencies } from "./collections/Currencies/Currencies";
|
||||
|
@ -14,11 +13,8 @@ import { Languages } from "./collections/Languages/Languages";
|
|||
import { Notes } from "./collections/Notes/Notes";
|
||||
import { Pages } from "./collections/Pages/Pages";
|
||||
import { Recorders } from "./collections/Recorders/Recorders";
|
||||
import { RecordersThumbnails } from "./collections/RecordersThumbnails/RecordersThumbnails";
|
||||
import { Tags } from "./collections/Tags/Tags";
|
||||
import { TagsGroups } from "./collections/TagsGroups/TagsGroups";
|
||||
import { Videos } from "./collections/Videos/Videos";
|
||||
import { VideosChannels } from "./collections/VideosChannels/VideosChannels";
|
||||
import { Wordings } from "./collections/Wordings/Wordings";
|
||||
import { Icon } from "./components/Icon";
|
||||
import { Logo } from "./components/Logo";
|
||||
|
@ -47,10 +43,6 @@ export default buildConfig({
|
|||
Notes,
|
||||
|
||||
Images,
|
||||
BackgroundImages,
|
||||
RecordersThumbnails,
|
||||
Videos,
|
||||
VideosChannels,
|
||||
|
||||
Tags,
|
||||
TagsGroups,
|
||||
|
|
|
@ -49,10 +49,6 @@ export interface Config {
|
|||
"chronology-events": ChronologyEvent;
|
||||
notes: Note;
|
||||
images: Image;
|
||||
"background-images": BackgroundImage;
|
||||
"recorders-thumbnails": RecordersThumbnail;
|
||||
videos: Video;
|
||||
"videos-channels": VideosChannel;
|
||||
tags: Tag;
|
||||
"tags-groups": TagsGroup;
|
||||
recorders: Recorder;
|
||||
|
@ -76,7 +72,7 @@ export interface Page {
|
|||
slug: string;
|
||||
type: "Content" | "Post" | "Generic";
|
||||
thumbnail?: string | Image | null;
|
||||
backgroundImage?: string | BackgroundImage | null;
|
||||
backgroundImage?: string | Image | null;
|
||||
tags?: (string | Tag)[] | null;
|
||||
authors?: (string | Recorder)[] | null;
|
||||
translations: {
|
||||
|
@ -160,31 +156,6 @@ export interface Image {
|
|||
};
|
||||
};
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "background-images".
|
||||
*/
|
||||
export interface BackgroundImage {
|
||||
id: string;
|
||||
updatedAt: string;
|
||||
createdAt: string;
|
||||
url?: string | null;
|
||||
filename?: string | null;
|
||||
mimeType?: string | null;
|
||||
filesize?: number | null;
|
||||
width?: number | null;
|
||||
height?: number | null;
|
||||
sizes?: {
|
||||
thumb?: {
|
||||
url?: string | null;
|
||||
width?: number | null;
|
||||
height?: number | null;
|
||||
mimeType?: string | null;
|
||||
filesize?: number | null;
|
||||
filename?: string | null;
|
||||
};
|
||||
};
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "tags".
|
||||
|
@ -233,7 +204,7 @@ export interface TagsGroup {
|
|||
export interface Recorder {
|
||||
id: string;
|
||||
username: string;
|
||||
avatar?: string | RecordersThumbnail | null;
|
||||
avatar?: string | Image | null;
|
||||
languages?: (string | Language)[] | null;
|
||||
biographies?: RecorderBiographies;
|
||||
role?: ("Admin" | "Recorder" | "Api")[] | null;
|
||||
|
@ -247,40 +218,6 @@ export interface Recorder {
|
|||
lockUntil?: string | null;
|
||||
password?: string | null;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "recorders-thumbnails".
|
||||
*/
|
||||
export interface RecordersThumbnail {
|
||||
id: string;
|
||||
recorder?: (string | null) | Recorder;
|
||||
updatedAt: string;
|
||||
createdAt: string;
|
||||
url?: string | null;
|
||||
filename?: string | null;
|
||||
mimeType?: string | null;
|
||||
filesize?: number | null;
|
||||
width?: number | null;
|
||||
height?: number | null;
|
||||
sizes?: {
|
||||
thumb?: {
|
||||
url?: string | null;
|
||||
width?: number | null;
|
||||
height?: number | null;
|
||||
mimeType?: string | null;
|
||||
filesize?: number | null;
|
||||
filename?: string | null;
|
||||
};
|
||||
square?: {
|
||||
url?: string | null;
|
||||
width?: number | null;
|
||||
height?: number | null;
|
||||
mimeType?: string | null;
|
||||
filesize?: number | null;
|
||||
filename?: string | null;
|
||||
};
|
||||
};
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "folders".
|
||||
|
@ -371,7 +308,7 @@ export interface Collectible {
|
|||
} | null;
|
||||
id?: string | null;
|
||||
}[];
|
||||
backgroundImage?: string | BackgroundImage | null;
|
||||
backgroundImage?: string | Image | null;
|
||||
gallery?:
|
||||
| {
|
||||
image: string | Image;
|
||||
|
@ -685,32 +622,6 @@ export interface Note {
|
|||
updatedAt: string;
|
||||
createdAt: string;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "videos".
|
||||
*/
|
||||
export interface Video {
|
||||
id: string;
|
||||
uid: string;
|
||||
gone: boolean;
|
||||
source: "YouTube" | "NicoNico" | "Tumblr";
|
||||
title: string;
|
||||
description?: string | null;
|
||||
likes?: number | null;
|
||||
views?: number | null;
|
||||
publishedDate: string;
|
||||
channel?: (string | null) | VideosChannel;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "videos-channels".
|
||||
*/
|
||||
export interface VideosChannel {
|
||||
id: string;
|
||||
uid: string;
|
||||
title: string;
|
||||
subscribers?: number | null;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "wordings".
|
||||
|
|
Loading…
Reference in New Issue