Skip to content

Commit

Permalink
Added cover in app page
Browse files Browse the repository at this point in the history
  • Loading branch information
notangelmario committed Jan 23, 2023
1 parent af48312 commit 17a6593
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 61 deletions.
2 changes: 1 addition & 1 deletion components/Container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Container = (props: Props & JSX.IntrinsicElements["h1"]) => {
return (
<div
{...props}
class={`md:container
class={`md:container lg:!max-w-screen-lg
${!props.disableGutters && "px-4"}
${props.class || ""}
`}
Expand Down
2 changes: 1 addition & 1 deletion components/SlideContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function SlideContainer(props: JSX.IntrinsicElements["div"]) {
<div
{...props}
class={`
flex flex-row overflow-x-scroll md:container
flex flex-row overflow-x-scroll md:container lg:!max-w-screen-lg
${props.class || ""}
`}
style={{
Expand Down
2 changes: 1 addition & 1 deletion lib/app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "dotenv";

export const APP = {
version: "3.0.0",
version: "3.1.0",
codename: "Cristina",
discordInvite: "https://discord.com/invite/DXke9aSZh6",
githubRepo: "https://github.com/notangelmario/paquet",
Expand Down
120 changes: 64 additions & 56 deletions routes/app/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,62 +48,71 @@ export default function App({ data }: PageProps<DataProps>) {
<Stack>
<Card
inset
class="bg-light dark:bg-dark flex flex-row flex-wrap gap-4"
disableGutters
class="bg-light dark:bg-dark"
>
<img
class="rounded w-20 h-20 shadow-outset-light dark:shadow-outset-dark bg-light-light dark:bg-dark-light"
src={data.app.icon}
/>
<div class="flex-1">
<h2 class="text-3xl">
{data.app.name}
</h2>
<p class="opacity-50">
{data.app.author}
</p>
</div>
<div class="min-w-full space-y-2 sm:min-w-[30%]">
<a
href={data.app.url}
target="_blank"
rel="noopener noreferrer"
>
<Button
icon="external-link"
fullWidth
style={{
backgroundColor:
data.app.accent_color,
boxShadow:
`0 0 8px ${data.app.accent_color}`,
color: "#ffffff",
}}
iconProps={{
name: "external-link",
color: "#ffffff",
}}
{data.app.cover &&
<img
src={data.app.cover}
class="w-full h-32 object-cover rounded-t"
/>
}
<div class="flex flex-row flex-wrap gap-4 p-4 shadow-inset-light dark:shadow-inset-dark">
<img
class="rounded w-20 h-20 shadow-outset-light dark:shadow-outset-dark bg-light-light dark:bg-dark-light"
src={data.app.icon}
/>
<div class="flex-1">
<h2 class="text-3xl">
{data.app.name}
</h2>
<p class="opacity-50">
{data.app.author}
</p>
</div>
<div class="min-w-full space-y-2 sm:min-w-[30%]">
<a
href={data.app.url}
target="_blank"
rel="noopener noreferrer"
>
Open
</Button>
</a>
{data.userLoggedIn
? (
<LoveAppButton
app={data.app}
ssrLoved={data.ssrLoved}
/>
)
: (
<a href="/login" class="block">
<Button
outlined
fullWidth
icon="heart"
>
Login to give hearts
</Button>
</a>
)}
<Button
icon="external-link"
fullWidth
style={{
backgroundColor:
data.app.accent_color,
boxShadow:
`0 0 8px ${data.app.accent_color}`,
color: "#ffffff",
}}
iconProps={{
name: "external-link",
color: "#ffffff",
}}
>
Open
</Button>
</a>
{data.userLoggedIn
? (
<LoveAppButton
app={data.app}
ssrLoved={data.ssrLoved}
/>
)
: (
<a href="/login" class="block">
<Button
outlined
fullWidth
icon="heart"
>
Login to give hearts
</Button>
</a>
)}
</div>
</div>
</Card>
<div>
Expand Down Expand Up @@ -192,7 +201,7 @@ export default function App({ data }: PageProps<DataProps>) {
export const handler: Handler = async (_, ctx) => {
const { data: app } = await supabase.from("apps")
.select(
"id, name, author, description, url, icon, accent_color, screenshots, features, categories, github_url, gitlab_url",
"id, name, author, description, url, icon, cover, accent_color, screenshots, features, categories, github_url, gitlab_url",
)
.eq("id", ctx.params.id)
.single();
Expand Down Expand Up @@ -222,7 +231,6 @@ export const handler: Handler = async (_, ctx) => {

const { data: otherApps } = await supabase.from("random_apps")
.select("id, name, author, icon")
.containedBy("categories", app.categories)
.neq("id", app.id)
.limit(5);

Expand Down
16 changes: 14 additions & 2 deletions scripts/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,18 @@ await Promise.all(apps.map(async (app) => {
await clearAppFromStorage(app.id, "covers");

if (cover_url) {
if (cover_url.startsWith("http")) {
cover_url = slashSlashes(cover_url);
} else if (cover_url.startsWith("//")) {
cover_url = "https://" + cover_url.slice(2);
} else if (cover_url.startsWith("/")) {
cover_url = slashSlashes(new URL(app.url).origin) +
"/" + slashSlashes(cover_url);
} else {
cover_url = slashSlashes(manifestParent.join("/")) +
"/" + slashSlashes(cover_url);
}

const cover_blob = await fetch(
new URL(cover_url, app.url).href,
{
Expand Down Expand Up @@ -342,8 +354,8 @@ await Promise.all(apps.map(async (app) => {
manifest_hash: hash,
icon: `${IMAGES_URL}/${app.id}/icon`,
icon_original: icon_url,
cover: `${IMAGES_URL}/${app.id}/cover`,
cover_original: cover_url,
cover: cover_url ? `${IMAGES_URL}/${app.id}/cover` : undefined,
cover_original: cover_url || undefined,
})
.eq("id", app.id);
}
Expand Down

0 comments on commit 17a6593

Please sign in to comment.