almst complete admin ui and initial store designs

This commit is contained in:
DecDuck
2024-10-11 22:45:02 +11:00
parent 46c8f0c48a
commit 27070b6a4c
21 changed files with 734 additions and 202 deletions

View File

@ -6,12 +6,16 @@
</NuxtLink>
<nav class="inline-flex items-center">
<ol class="inline-flex items-center gap-x-12">
<li
class="transition text-zinc-300 hover:text-zinc-100 uppercase font-display font-semibold text-md"
<NuxtLink
v-for="(nav, navIdx) in navigation"
:href="nav.route"
:class="[
'transition hover:text-zinc-200 uppercase font-display font-semibold text-md',
navIdx === currentPageIndex ? 'text-zinc-100' : 'text-zinc-400',
]"
>
{{ nav.label }}
</li>
</NuxtLink>
</ol>
</nav>
</div>
@ -59,6 +63,8 @@ const navigation: Array<NavigationItem> = [
},
];
const currentPageIndex = useCurrentNavigationIndex(navigation);
const quickActions: Array<QuickActionNav> = [
{
icon: UserGroupIcon,

View File

@ -49,7 +49,7 @@
</div>
<main class="lg:pl-20 min-h-screen bg-zinc-900 flex flex-col">
<div class="flex flex-col grow px-4 py-10 sm:px-6 lg:px-8 lg:py-6">
<div class="flex flex-col grow px-4 py-2 sm:py-10 sm:px-6 lg:px-8 lg:py-6">
<!-- Main area -->
<NuxtPage />
</div>

View File

@ -1,10 +1,10 @@
<template>
<content class="flex flex-col w-full min-h-screen bg-zinc-900">
<UserHeader />
<UserHeader class="z-50" />
<div class="grow flex">
<NuxtPage />
</div>
<UserFooter />
<UserFooter class="z-50" />
</content>
</template>

View File

@ -18,6 +18,7 @@
"bcrypt": "^5.1.1",
"fast-fuzzy": "^1.12.0",
"file-type-mime": "^0.4.3",
"markdown-it": "^14.1.0",
"moment": "^2.30.1",
"nuxt": "^3.13.2",
"prisma": "^5.20.0",
@ -32,7 +33,9 @@
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
"devDependencies": {
"@tailwindcss/forms": "^0.5.9",
"@tailwindcss/typography": "^0.5.15",
"@types/bcrypt": "^5.0.2",
"@types/markdown-it": "^14.1.2",
"@types/turndown": "^5.0.5",
"@types/uuid": "^10.0.0",
"autoprefixer": "^10.4.20",

View File

@ -1,11 +1,154 @@
<template>
<div v-if="game" class="grid grid-cols-2 gap-16">
<div class="grow">
<h1 class="mt-4 text-5xl font-bold font-display text-zinc-100">
{{ game.mName }}
</h1>
<p class="mt-1 text-lg text-zinc-400">{{ game.mShortDescription }}</p>
<div
v-html="descriptionHTML"
class="mt-5 pt-5 border-t border-zinc-700 prose prose-invert prose-blue"
></div>
</div>
<div>
<div class="px-4 py-3 bg-gray-950 rounded">
<div class="border-b border-zinc-800 pb-3">
<div
class="-ml-4 -mt-2 flex flex-wrap items-center justify-between sm:flex-nowrap"
>
<div class="ml-4 mt-2">
<h3
class="text-base font-semibold font-display leading-6 text-zinc-100"
>
Images
</h3>
</div>
<div class="ml-4 mt-2 flex-shrink-0">
<button
type="button"
class="relative inline-flex items-center rounded-md bg-blue-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
>
Upload
</button>
</div>
</div>
</div>
<div class="mt-3 grid grid-cols-2 grid-flow-dense gap-8">
<div
v-for="(image, imageIdx) in game.mImageLibrary"
:key="image"
class="group relative flex items-center"
>
<img :src="useObject(image)" class="w-full h-auto" />
<div
class="transition-all opacity-0 group-hover:opacity-100 absolute flex flex-col gap-y-1 top-1 right-1 bg-zinc-950/50 rounded-xl p-2"
>
<button
v-if="image !== game.mBannerId"
@click="() => updateBannerImage(image)"
type="button"
class="inline-flex items-center gap-x-1.5 rounded-md bg-blue-600 px-1.5 py-0.5 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
>
Set as banner
</button>
<button
v-if="image !== game.mCoverId"
@click="() => updateCoverImage(image)"
type="button"
class="inline-flex items-center gap-x-1.5 rounded-md bg-blue-600 px-1.5 py-0.5 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
>
Set as cover
</button>
<button
@click="() => deleteImage(image)"
type="button"
class="inline-flex items-center gap-x-1.5 rounded-md bg-red-600 px-1.5 py-0.5 text-sm font-semibold text-white shadow-sm hover:bg-red-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-red-600"
>
Delete image
</button>
</div>
<div
v-if="image === game.mBannerId && image === game.mCoverId"
class="absolute bottom-0 left-0 bg-zinc-950/75 text-zinc-100 text-sm font-semibold px-2 py-1 rounded-tr"
>
current banner & cover
</div>
<div
v-else-if="image === game.mCoverId"
class="absolute bottom-0 left-0 bg-zinc-950/75 text-zinc-100 text-sm font-semibold px-2 py-1 rounded-tr"
>
current cover
</div>
<div
v-else-if="image === game.mBannerId"
class="absolute bottom-0 left-0 bg-zinc-950/75 text-zinc-100 text-sm font-semibold px-2 py-1 rounded-tr"
>
current banner
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import type { Game } from "@prisma/client";
import markdownit from "markdown-it";
definePageMeta({
layout: 'admin',
layout: "admin",
});
const route = useRoute();
const gameId = route.params.id.toString();
const headers = useRequestHeaders(["cookie"]);
const game = ref(
await $fetch<Game>(`/api/v1/admin/game?id=${encodeURIComponent(gameId)}`, {
headers,
})
);
const md = markdownit();
const descriptionHTML = md.render(game.value?.mDescription ?? "");
async function updateBannerImage(id: string) {
if (game.value.mBannerId == id) return;
const { mBannerId } = await $fetch("/api/v1/admin/game", {
method: "PATCH",
body: {
id: gameId,
mBannerId: id,
},
});
game.value.mBannerId = mBannerId;
}
async function updateCoverImage(id: string) {
if (game.value.mCoverId == id) return;
const { mCoverId } = await $fetch("/api/v1/admin/game", {
method: "PATCH",
body: {
id: gameId,
mCoverId: id,
},
});
game.value.mCoverId = mCoverId;
}
async function deleteImage(id: string) {
const { mBannerId, mImageLibrary } = await $fetch(
"/api/v1/admin/game/image",
{
method: "DELETE",
body: {
gameId: game.value.id,
imageId: id,
},
}
);
game.value.mImageLibrary = mImageLibrary;
game.value.mBannerId = mBannerId;
}
</script>

View File

@ -28,7 +28,7 @@
</div>
<ul
role="list"
class="grid grid-cols-1 gap-6 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4"
class="grid grid-cols-1 gap-6 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4"
>
<li
v-for="game in libraryNotifications"
@ -41,21 +41,25 @@
:src="useObject(game.mIconId)"
alt=""
/>
<div class="flex-1 flex-col">
<div class="flex flex-col">
<h3 class="text-sm font-medium text-zinc-100 font-display">
{{ game.mName }}
<span
class="ml-2 inline-flex items-center rounded-full bg-blue-600/10 px-2 py-1 text-xs font-medium text-blue-600 ring-1 ring-inset ring-blue-600/20"
>{{ game.metadataSource }}</span
>
</h3>
<dl class="mt-1 flex flex-grow flex-col justify-between">
<dl class="mt-1 flex flex-col justify-between">
<dt class="sr-only">Short Description</dt>
<dd class="text-sm text-zinc-400">{{ game.mShortDescription }}</dd>
<dt class="sr-only">Metadata provider</dt>
<dd class="mt-3">
<span
class="inline-flex items-center rounded-full bg-blue-600/10 px-2 py-1 text-xs font-medium text-blue-600 ring-1 ring-inset ring-blue-600/20"
>{{ game.metadataSource }}</span
>
</dd>
</dl>
<NuxtLink
:href="`/admin/library/${game.id}`"
class="mt-2 w-fit rounded-md bg-blue-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
>
Edit &rarr;
</NuxtLink>
</div>
</div>
<div v-if="game.hasNotifications" class="flex flex-col gap-y-2 p-2">
@ -86,7 +90,10 @@
</div>
</div>
</div>
<div v-if="game.notifications.noVersions" class="rounded-md bg-yellow-600/10 p-4">
<div
v-if="game.notifications.noVersions"
class="rounded-md bg-yellow-600/10 p-4"
>
<div class="flex">
<div class="flex-shrink-0">
<ExclamationTriangleIcon
@ -130,6 +137,6 @@ const libraryNotifications = libraryState.games.map((e) => {
toImport,
},
hasNotifications: noVersions || toImport,
}
})
};
});
</script>

View File

@ -0,0 +1,91 @@
<template>
<div
class="mx-auto w-full relative flex flex-col justify-center pt-24 z-10 overflow-hidden"
>
<!-- banner image -->
<div class="absolute flex top-0 h-fit inset-x-0 h-12 -z-[20]">
<img :src="useObject(game.mBannerId)" class="w-full h-auto" />
<div
class="absolute inset-0 bg-gradient-to-b from-transparent to-80% to-zinc-900"
/>
</div>
<!-- main page -->
<div class="max-w-7xl w-full mx-auto bg-zinc-900 px-16 py-12 rounded-md">
<h1
class="text-5xl font-bold font-display text-zinc-100 pb-4 border-b border-zinc-800"
>
{{ game.mName }}
</h1>
<div class="mt-8 grid grid-cols-4 gap-x-10">
<div class="col-span-3">
<p class="text-lg text-zinc-400">
{{ game.mShortDescription }}
</p>
<div
class="mt-6 flex flex-row overflow-x-auto max-w-full p-4 bg-zinc-800 rounded gap-x-2"
>
<img
v-for="image in game.mImageLibrary"
class="h-64 w-auto rounded"
:src="useObject(image)"
/>
</div>
<div
v-html="descriptionHTML"
class="mt-12 prose prose-invert prose-blue max-w-none"
/>
</div>
<div class="flex flex-col gap-y-6 items-center">
<img class="w-full h-auto rounded" :src="useObject(game.mCoverId)" />
<button
type="button"
class="inline-flex items-center gap-x-2 rounded-md bg-blue-600 px-3.5 py-2.5 text-xl font-semibold font-display text-white shadow-sm hover:bg-blue-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
>
Add to Library
<PlusIcon class="-mr-0.5 h-7 w-7" aria-hidden="true" />
</button>
<div class="inline-flex items-center gap-x-3">
<span class="text-zinc-100 font-semibold">Available on:</span>
<component
v-for="platform in platforms"
:is="icons[platform]"
class="text-blue-600 w-6 h-6"
/>
<span
v-if="platforms.length == 0"
class="font-semibold text-blue-600"
>coming soon</span
>
</div>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { PlusIcon } from "@heroicons/vue/20/solid";
import { Platform, type Game, type GameVersion } from "@prisma/client";
import MarkdownIt from "markdown-it";
import LinuxLogo from "~/components/LinuxLogo.vue";
import WindowsLogo from "~/components/WindowsLogo.vue";
const route = useRoute();
const gameId = route.params.id.toString();
const game = await $fetch<Game & { versions: GameVersion[] }>(
`/api/v1/games/${gameId}`
);
const md = MarkdownIt();
const descriptionHTML = md.render(game.mDescription);
const platforms = game.versions
.map((e) => e.platform)
.flat()
.filter((e, i, u) => u.indexOf(e) === i);
const icons = {
[Platform.Linux]: LinuxLogo,
[Platform.Windows]: WindowsLogo,
};
</script>

3
pages/store/index.vue Normal file
View File

@ -0,0 +1,3 @@
<template>
</template>

View File

@ -0,0 +1,14 @@
/*
Warnings:
- You are about to drop the column `mArt` on the `Game` table. All the data in the column will be lost.
- You are about to drop the column `mBannerId` on the `Game` table. All the data in the column will be lost.
- You are about to drop the column `mScreenshots` on the `Game` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "Game" DROP COLUMN "mArt",
DROP COLUMN "mBannerId",
DROP COLUMN "mScreenshots",
ADD COLUMN "mBannerIndex" INTEGER NOT NULL DEFAULT 0,
ADD COLUMN "mImageLibrary" TEXT[];

View File

@ -0,0 +1,10 @@
/*
Warnings:
- You are about to drop the column `mBannerIndex` on the `Game` table. All the data in the column will be lost.
- Added the required column `mBannerId` to the `Game` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Game" DROP COLUMN "mBannerIndex",
ADD COLUMN "mBannerId" TEXT NOT NULL;

View File

@ -0,0 +1,8 @@
/*
Warnings:
- Added the required column `mCoverId` to the `Game` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Game" ADD COLUMN "mCoverId" TEXT NOT NULL;

View File

@ -88,8 +88,8 @@ model Game {
mIconId String // linked to objects in s3
mBannerId String // linked to objects in s3
mArt String[] // linked to objects in s3
mScreenshots String[] // linked to objects in s3
mCoverId String
mImageLibrary String[] // linked to objects in s3
versionOrder String[]
versions GameVersion[]

View File

@ -0,0 +1,56 @@
import prisma from "~/server/internal/db/database";
export default defineEventHandler(async (h3) => {
const user = await h3.context.session.getAdminUser(h3);
if (!user) throw createError({ statusCode: 403 });
const body = await readBody(h3);
const gameId = body.gameId;
const imageId = body.imageId;
if (!gameId || !imageId)
throw createError({
statusCode: 400,
statusMessage: "Missing gameId or imageId in body",
});
const game = await prisma.game.findUnique({
where: {
id: gameId,
},
select: {
mBannerId: true,
mImageLibrary: true,
mCoverId: true,
},
});
if (!game)
throw createError({ statusCode: 400, statusMessage: "Invalid game ID" });
game.mImageLibrary = game.mImageLibrary.filter((e) => e != imageId);
if (game.mBannerId === imageId) {
game.mBannerId = game.mImageLibrary[0];
}
if (game.mCoverId === imageId) {
game.mCoverId = game.mImageLibrary[0];
}
const result = await prisma.game.update({
where: {
id: gameId,
},
data: {
mBannerId: game.mBannerId,
mImageLibrary: game.mImageLibrary,
mCoverId: game.mCoverId,
},
select: {
mBannerId: true,
mImageLibrary: true,
mCoverId: true,
},
});
return result;
});

View File

@ -0,0 +1,25 @@
import prisma from "~/server/internal/db/database";
export default defineEventHandler(async (h3) => {
const user = await h3.context.session.getAdminUser(h3);
if (!user) throw createError({ statusCode: 403 });
const query = getQuery(h3);
const gameId = query.id?.toString();
if (!gameId)
throw createError({
statusCode: 400,
statusMessage: "Missing id in query",
});
const game = await prisma.game.findUnique({
where: {
id: gameId,
},
});
if (!game)
throw createError({ statusCode: 404, statusMessage: "Game ID not found" });
return game;
});

View File

@ -0,0 +1,24 @@
import prisma from "~/server/internal/db/database";
export default defineEventHandler(async (h3) => {
const user = await h3.context.session.getAdminUser(h3);
if (!user) throw createError({ statusCode: 403 });
const body = await readBody(h3);
const id = body.id;
if (!id)
throw createError({ statusCode: 400, statusMessage: "Missing id in body" });
const restOfTheBody = { ...body };
delete restOfTheBody["id"];
const newObj = await prisma.game.update({
where: {
id: id,
},
data: restOfTheBody,
// I would put a select here, but it would be based on the body, and muck up the types
});
return newObj;
});

View File

@ -0,0 +1,25 @@
import prisma from "~/server/internal/db/database";
export default defineEventHandler(async (h3) => {
const userId = await h3.context.session.getUserId(h3);
if (!userId) throw createError({ statusCode: 403 });
const gameId = getRouterParam(h3, "id");
if (!gameId)
throw createError({
statusCode: 400,
statusMessage: "Missing gameId in route params (somehow...?)",
});
const game = await prisma.game.findUnique({
where: { id: gameId },
include: {
versions: true,
},
});
if (!game)
throw createError({ statusCode: 404, statusMessage: "Game not found" });
return game;
});

View File

@ -1,64 +1,72 @@
import { Developer, MetadataSource, Publisher } from "@prisma/client";
import { MetadataProvider } from ".";
import { GameMetadataSearchResult, _FetchGameMetadataParams, GameMetadata, _FetchPublisherMetadataParams, PublisherMetadata, _FetchDeveloperMetadataParams, DeveloperMetadata } from "./types";
import {
GameMetadataSearchResult,
_FetchGameMetadataParams,
GameMetadata,
_FetchPublisherMetadataParams,
PublisherMetadata,
_FetchDeveloperMetadataParams,
DeveloperMetadata,
} from "./types";
import axios, { AxiosRequestConfig } from "axios";
import moment from "moment";
import TurndownService from "turndown";
interface GiantBombResponseType<T> {
error: "OK" | string;
limit: number,
offset: number,
number_of_page_results: number,
number_of_total_results: number,
status_code: number,
results: T,
version: string
limit: number;
offset: number;
number_of_page_results: number;
number_of_total_results: number;
status_code: number;
results: T;
version: string;
}
interface GameSearchResult {
guid: string,
name: string,
deck: string,
original_release_date?: string
expected_release_year?: number
guid: string;
name: string;
deck: string;
original_release_date?: string;
expected_release_year?: number;
image?: {
icon_url: string
}
icon_url: string;
};
}
interface GameResult {
guid: string,
name: string,
deck: string,
description?: string,
guid: string;
name: string;
deck: string;
description?: string;
developers: Array<{ id: number, name: string }>,
publishers: Array<{ id: number, name: string }>
developers: Array<{ id: number; name: string }>;
publishers: Array<{ id: number; name: string }>;
number_of_user_reviews: number, // Doesn't provide an actual rating, so kinda useless
number_of_user_reviews: number; // Doesn't provide an actual rating, so kinda useless
image: {
icon_url: string,
screen_large_url: string,
},
icon_url: string;
screen_large_url: string;
};
images: Array<{
tags: string; // If it's "All Images", art, otherwise screenshot
original: string
}>
original: string;
}>;
}
interface CompanySearchResult {
guid: string,
deck: string | null,
description: string | null,
name: string,
website: string | null,
guid: string;
deck: string | null;
description: string | null;
name: string;
website: string | null;
image: {
icon_url: string,
screen_large_url: string,
}
icon_url: string;
screen_large_url: string;
};
}
export class GiantBombProvider implements MetadataProvider {
@ -70,26 +78,41 @@ export class GiantBombProvider implements MetadataProvider {
if (!apikey) throw new Error("No GIANT_BOMB_API_KEY in environment");
this.apikey = apikey;
this.turndown = new TurndownService();
this.turndown.addRule("remove-links", {
filter: ["a"],
replacement: function (content) {
return content;
},
});
}
private async request<T>(resource: string, url: string, query: { [key: string]: string | Array<string> }, options?: AxiosRequestConfig) {
const queryOptions = { ...query, api_key: this.apikey, format: 'json' };
const queryString = Object.entries(queryOptions).map(([key, value]) => {
private async request<T>(
resource: string,
url: string,
query: { [key: string]: string | Array<string> },
options?: AxiosRequestConfig
) {
const queryOptions = { ...query, api_key: this.apikey, format: "json" };
const queryString = Object.entries(queryOptions)
.map(([key, value]) => {
if (Array.isArray(value)) {
return `${key}=${value.map(encodeURIComponent).join(',')}`
return `${key}=${value.map(encodeURIComponent).join(",")}`;
}
return `${key}=${encodeURIComponent(value)}`;
}).join("&");
})
.join("&");
const finalURL = `https://www.giantbomb.com/api/${resource}/${url}?${queryString}`;
const overlay: AxiosRequestConfig = {
url: finalURL,
baseURL: "",
}
const response = await axios.request<GiantBombResponseType<T>>(Object.assign({}, options, overlay));
};
const response = await axios.request<GiantBombResponseType<T>>(
Object.assign({}, options, overlay)
);
return response;
}
@ -97,39 +120,48 @@ export class GiantBombProvider implements MetadataProvider {
return "giantbomb";
}
name() {
return "GiantBomb"
return "GiantBomb";
}
source() {
return MetadataSource.GiantBomb;
}
async search(query: string): Promise<GameMetadataSearchResult[]> {
const results = await this.request<Array<GameSearchResult>>("search", "", { query: query, resources: ["game"] });
const results = await this.request<Array<GameSearchResult>>("search", "", {
query: query,
resources: ["game"],
});
const mapped = results.data.results.map((result) => {
const date = (result.original_release_date ? moment(result.original_release_date).year() : result.expected_release_year) ?? 0;
const date =
(result.original_release_date
? moment(result.original_release_date).year()
: result.expected_release_year) ?? 0;
const metadata: GameMetadataSearchResult = {
id: result.guid,
name: result.name,
icon: result.image?.icon_url ?? "",
description: result.deck,
year: date
}
year: date,
};
return metadata;
})
});
return mapped;
}
async fetchGame({ id, publisher, developer, createObject }: _FetchGameMetadataParams): Promise<GameMetadata> {
async fetchGame({
id,
publisher,
developer,
createObject,
}: _FetchGameMetadataParams): Promise<GameMetadata> {
const result = await this.request<GameResult>("game", id, {});
const gameData = result.data.results;
const longDescription = gameData.description ?
this.turndown.turndown(gameData.description) :
gameData.deck;
const longDescription = gameData.description
? this.turndown.turndown(gameData.description)
: gameData.deck;
const publishers: Publisher[] = [];
for (const pub of gameData.publishers) {
@ -144,19 +176,9 @@ export class GiantBombProvider implements MetadataProvider {
const icon = createObject(gameData.image.icon_url);
const banner = createObject(gameData.image.screen_large_url);
const artUrls: string[] = [];
const screenshotUrls: string[] = [];
// If it's "All Images", art, otherwise screenshot
for (const image of gameData.images) {
if (image.tags == 'All Images') {
artUrls.push(image.original)
} else {
screenshotUrls.push(image.original)
}
}
const imageURLs: string[] = gameData.images.map((e) => e.original);
const art = artUrls.map(createObject);
const screenshots = screenshotUrls.map(createObject);
const images = [banner, ...imageURLs.map(createObject)];
const metadata: GameMetadata = {
id: gameData.guid,
@ -171,23 +193,32 @@ export class GiantBombProvider implements MetadataProvider {
developers,
icon,
banner,
art,
screenshots
}
bannerId: banner,
coverId: images[1],
images,
};
return metadata;
}
async fetchPublisher({ query, createObject }: _FetchPublisherMetadataParams): Promise<PublisherMetadata> {
const results = await this.request<Array<CompanySearchResult>>("search", "", { query, resources: "company" });
async fetchPublisher({
query,
createObject,
}: _FetchPublisherMetadataParams): Promise<PublisherMetadata> {
const results = await this.request<Array<CompanySearchResult>>(
"search",
"",
{ query, resources: "company" }
);
// Find the right entry
const company = results.data.results.find((e) => e.name == query) ?? results.data.results.at(0);
const company =
results.data.results.find((e) => e.name == query) ??
results.data.results.at(0);
if (!company) throw new Error(`No results for "${query}"`);
const longDescription = company.description ?
this.turndown.turndown(company.description) :
company.deck;
const longDescription = company.description
? this.turndown.turndown(company.description)
: company.deck;
const metadata: PublisherMetadata = {
id: company.guid,
@ -198,12 +229,13 @@ export class GiantBombProvider implements MetadataProvider {
logo: createObject(company.image.icon_url),
banner: createObject(company.image.screen_large_url),
}
};
return metadata;
}
async fetchDeveloper(params: _FetchDeveloperMetadataParams): Promise<DeveloperMetadata> {
return await this.fetchPublisher(params)
async fetchDeveloper(
params: _FetchDeveloperMetadataParams
): Promise<DeveloperMetadata> {
return await this.fetchPublisher(params);
}
}

View File

@ -129,9 +129,9 @@ export class MetadataHandler {
mReviewRating: metadata.reviewRating,
mIconId: metadata.icon,
mBannerId: metadata.banner,
mArt: metadata.art,
mScreenshots: metadata.screenshots,
mBannerId: metadata.bannerId,
mCoverId: metadata.coverId,
mImageLibrary: metadata.images,
versionOrder: [],
libraryBasePath,

View File

@ -32,9 +32,9 @@ export interface GameMetadata {
// Created with another utility function
icon: ObjectReference,
banner: ObjectReference,
art: ObjectReference[],
screenshots: ObjectReference[],
bannerId: ObjectReference,
coverId: ObjectReference;
images: ObjectReference[],
}
export interface PublisherMetadata {

View File

@ -21,5 +21,5 @@ export default {
},
},
},
plugins: [require("@tailwindcss/forms")],
plugins: [require("@tailwindcss/forms"), require("@tailwindcss/typography")],
};

View File

@ -296,12 +296,12 @@
dependencies:
mime "^3.0.0"
"@drop/droplet-linux-x64-gnu@^0.4.4":
"@drop/droplet-linux-x64-gnu@0.4.4", "@drop/droplet-linux-x64-gnu@^0.4.4":
version "0.4.4"
resolved "https://lab.deepcore.dev/api/v4/projects/57/packages/npm/@drop/droplet-linux-x64-gnu/-/@drop/droplet-linux-x64-gnu-0.4.4.tgz#6678a0923bb13d37e20cae467f45c72bc5d9fe6e"
integrity sha1-ZnigkjuxPTfiDK5Gf0XHK8XZ/m4=
"@drop/droplet-win32-x64-msvc@^0.4.4":
"@drop/droplet-win32-x64-msvc@0.4.4", "@drop/droplet-win32-x64-msvc@^0.4.4":
version "0.4.4"
resolved "https://lab.deepcore.dev/api/v4/projects/57/packages/npm/@drop/droplet-win32-x64-msvc/-/@drop/droplet-win32-x64-msvc-0.4.4.tgz#10802bb36c6ec7d69aa17ea22081e5d5f0dac3c3"
integrity sha1-EIArs2xux9aaoX6iIIHl1fDaw8M=
@ -1304,6 +1304,16 @@
dependencies:
mini-svg-data-uri "^1.2.3"
"@tailwindcss/typography@^0.5.15":
version "0.5.15"
resolved "https://registry.yarnpkg.com/@tailwindcss/typography/-/typography-0.5.15.tgz#007ab9870c86082a1c76e5b3feda9392c7c8d648"
integrity sha512-AqhlCXl+8grUz8uqExv5OTtgpjuVIwFTSXTrh8y9/pw6q2ek7fJ+Y8ZEVw7EB2DCcuCOtEjf9w3+J3rzts01uA==
dependencies:
lodash.castarray "^4.4.0"
lodash.isplainobject "^4.0.6"
lodash.merge "^4.6.2"
postcss-selector-parser "6.0.10"
"@tanstack/virtual-core@3.10.8":
version "3.10.8"
resolved "https://registry.yarnpkg.com/@tanstack/virtual-core/-/virtual-core-3.10.8.tgz#975446a667755222f62884c19e5c3c66d959b8b4"
@ -1345,6 +1355,24 @@
dependencies:
"@types/node" "*"
"@types/linkify-it@^5":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@types/linkify-it/-/linkify-it-5.0.0.tgz#21413001973106cda1c3a9b91eedd4ccd5469d76"
integrity sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q==
"@types/markdown-it@^14.1.2":
version "14.1.2"
resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-14.1.2.tgz#57f2532a0800067d9b934f3521429a2e8bfb4c61"
integrity sha512-promo4eFwuiW+TfGxhi+0x3czqTYJkG8qB17ZUJiVF10Xm7NLVRSLUsfRTU/6h1e24VvRnXCx+hG7li58lkzog==
dependencies:
"@types/linkify-it" "^5"
"@types/mdurl" "^2"
"@types/mdurl@^2":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@types/mdurl/-/mdurl-2.0.0.tgz#d43878b5b20222682163ae6f897b20447233bdfd"
integrity sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg==
"@types/node@*":
version "22.7.4"
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.4.tgz#e35d6f48dca3255ce44256ddc05dee1c23353fcc"
@ -2514,7 +2542,7 @@ enhanced-resolve@^5.14.1:
graceful-fs "^4.2.4"
tapable "^2.2.0"
entities@^4.2.0, entities@^4.5.0:
entities@^4.2.0, entities@^4.4.0, entities@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/entities/-/entities-4.5.0.tgz#5d268ea5e7113ec74c4d033b79ea5a35a488fb48"
integrity sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==
@ -3412,6 +3440,13 @@ lines-and-columns@^1.1.6:
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632"
integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==
linkify-it@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-5.0.0.tgz#9ef238bfa6dc70bd8e7f9572b52d369af569b421"
integrity sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==
dependencies:
uc.micro "^2.0.0"
listhen@^1.7.2:
version "1.8.0"
resolved "https://registry.yarnpkg.com/listhen/-/listhen-1.8.0.tgz#e1a30904e6deb40d951b9c5ff044478c3b79c7cb"
@ -3444,6 +3479,11 @@ local-pkg@^0.5.0:
mlly "^1.4.2"
pkg-types "^1.0.3"
lodash.castarray@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.castarray/-/lodash.castarray-4.4.0.tgz#c02513515e309daddd4c24c60cfddcf5976d9115"
integrity sha512-aVx8ztPv7/2ULbArGJ2Y42bG1mEQ5mGjpdvrbJcJFU3TbYybe+QlLS4pst9zV52ymy2in1KpFPiZnAOATxD4+Q==
lodash.defaults@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c"
@ -3454,11 +3494,21 @@ lodash.isarguments@^3.1.0:
resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a"
integrity sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg==
lodash.isplainobject@^4.0.6:
version "4.0.6"
resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb"
integrity sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==
lodash.memoize@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
integrity sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==
lodash.merge@^4.6.2:
version "4.6.2"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
lodash.uniq@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
@ -3511,6 +3561,18 @@ make-dir@^3.1.0:
dependencies:
semver "^6.0.0"
markdown-it@^14.1.0:
version "14.1.0"
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-14.1.0.tgz#3c3c5992883c633db4714ccb4d7b5935d98b7d45"
integrity sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==
dependencies:
argparse "^2.0.1"
entities "^4.4.0"
linkify-it "^5.0.0"
mdurl "^2.0.0"
punycode.js "^2.3.1"
uc.micro "^2.1.0"
mdn-data@2.0.28:
version "2.0.28"
resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.28.tgz#5ec48e7bef120654539069e1ae4ddc81ca490eba"
@ -3521,6 +3583,11 @@ mdn-data@2.0.30:
resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.30.tgz#ce4df6f80af6cfbe218ecd5c552ba13c4dfa08cc"
integrity sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==
mdurl@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-2.0.0.tgz#80676ec0433025dd3e17ee983d0fe8de5a2237e0"
integrity sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==
merge-stream@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
@ -4355,6 +4422,14 @@ postcss-reduce-transforms@^7.0.0:
dependencies:
postcss-value-parser "^4.2.0"
postcss-selector-parser@6.0.10:
version "6.0.10"
resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.0.10.tgz#79b61e2c0d1bfc2602d549e11d0876256f8df88d"
integrity sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==
dependencies:
cssesc "^3.0.0"
util-deprecate "^1.0.2"
postcss-selector-parser@^6.0.11, postcss-selector-parser@^6.1.1, postcss-selector-parser@^6.1.2:
version "6.1.2"
resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.1.2.tgz#27ecb41fb0e3b6ba7a1ec84fff347f734c7929de"
@ -4434,6 +4509,11 @@ proxy-from-env@^1.1.0:
resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2"
integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==
punycode.js@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/punycode.js/-/punycode.js-2.3.1.tgz#6b53e56ad75588234e79f4affa90972c7dd8cdb7"
integrity sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==
queue-microtask@^1.2.2:
version "1.2.3"
resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243"
@ -5192,6 +5272,11 @@ type-fest@^3.8.0:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-3.13.1.tgz#bb744c1f0678bea7543a2d1ec24e83e68e8c8706"
integrity sha512-tLq3bSNx+xSpwvAJnzrK0Ep5CLNWjvFTOp71URMaAEWBfRb9nnJiBoUe0tF8bI4ZFO3omgBR6NvnbzVUT3Ly4g==
uc.micro@^2.0.0, uc.micro@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-2.1.0.tgz#f8d3f7d0ec4c3dea35a7e3c8efa4cb8b45c9e7ee"
integrity sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==
ufo@^1.1.2, ufo@^1.5.3, ufo@^1.5.4:
version "1.5.4"
resolved "https://registry.yarnpkg.com/ufo/-/ufo-1.5.4.tgz#16d6949674ca0c9e0fbbae1fa20a71d7b1ded754"