Skip to content

Commit 93dd30e

Browse files
committed
feat: add functionality to copy movie assets during setup and update movie data structure to use local paths for posters and videos
1 parent 9127b57 commit 93dd30e

26 files changed

+149
-126
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ data.db
1010
**/tsconfig.tsbuildinfo
1111
**/dist
1212

13+
# Movie assets copied during setup
14+
exercises/**/public/posters/
15+
exercises/**/public/videos/
16+
1317
# in a real app you'd want to not commit the .env
1418
# file as well, but since this is for a workshop
1519
# we're going to keep them around.

epicshop/setup-custom.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@ await warm()
1212
const allApps = await getApps()
1313
const problemApps = allApps.filter(isProblemApp)
1414

15+
// Copy posters and videos to each app's public directory
16+
console.log('🎬 Copying posters and videos to all apps...')
17+
const rootPublicPath = path.join(process.cwd(), 'public')
18+
const postersSource = path.join(rootPublicPath, 'posters')
19+
const videosSource = path.join(rootPublicPath, 'videos')
20+
21+
for (const app of allApps) {
22+
const appPublicPath = path.join(app.fullPath, 'public')
23+
if (await fsExtra.exists(appPublicPath)) {
24+
const postersTarget = path.join(appPublicPath, 'posters')
25+
const videosTarget = path.join(appPublicPath, 'videos')
26+
27+
await fsExtra.copy(postersSource, postersTarget, { overwrite: true })
28+
await fsExtra.copy(videosSource, videosTarget, { overwrite: true })
29+
}
30+
}
31+
32+
console.log('✅ Posters and videos copied to all apps')
33+
1534
if (!process.env.SKIP_PLAYGROUND) {
1635
const firstProblemApp = problemApps[0]
1736
if (firstProblemApp) {
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { useState } from 'react'
2-
import LiteYouTubeEmbed from 'react-lite-youtube-embed'
3-
import 'react-lite-youtube-embed/dist/LiteYouTubeEmbed.css'
1+
import { Activity, useState } from 'react'
42
import { type Movie } from '#app/movies-data.ts'
53

64
export function MovieTrailer({ movie }: { movie: Movie }) {
@@ -14,16 +12,18 @@ export function MovieTrailer({ movie }: { movie: Movie }) {
1412
>
1513
{showTrailer ? 'Hide Trailer' : 'Watch Trailer'}
1614
</button>
17-
{showTrailer && (
15+
<Activity mode={showTrailer ? 'visible' : 'hidden'}>
1816
<div className="overflow-hidden rounded-lg">
19-
<LiteYouTubeEmbed
20-
id={movie.youtubeId}
17+
<video
18+
src={movie.videoUrl}
2119
title={movie.title}
22-
params="autoplay=1&mute=0&rel=0&modestbranding=1"
23-
alwaysLoadIframe={true}
20+
autoPlay
21+
muted
22+
loop
23+
controls
2424
/>
2525
</div>
26-
)}
26+
</Activity>
2727
</div>
2828
)
2929
}

exercises/01.start/01.problem.vite-plugin/app/movies-data.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ let movies = [
1818
title: 'The Lord of the Rings: The Fellowship of the Ring',
1919
year: 2001,
2020
isFavorite: false,
21-
poster: 'https://image.tmdb.org/t/p/w500/6oom5QYQ2yQTMJIbnvbkBL9cHo6.jpg',
22-
youtubeId: 'V75dMMIW2B4',
21+
poster: '/posters/lotr-fellowship-poster.jpg',
22+
videoUrl: '/videos/lotr-fellowship-trailer.mp4',
2323
description:
2424
'A meek Hobbit from the Shire and eight companions set out on a journey to destroy the powerful One Ring and save Middle-earth from the Dark Lord Sauron.',
2525
rating: 8.8,
@@ -29,8 +29,8 @@ let movies = [
2929
title: 'The Lord of the Rings: The Two Towers',
3030
year: 2002,
3131
isFavorite: true,
32-
poster: 'https://image.tmdb.org/t/p/w500/5VTN0pR8gcqV3EPUHHfMGnJYN9L.jpg',
33-
youtubeId: 'LbfMDwc4azU',
32+
poster: '/posters/lotr-two-towers-poster.jpg',
33+
videoUrl: '/videos/lotr-two-towers-trailer.mp4',
3434
description:
3535
"While Frodo and Sam edge closer to Mordor with the help of the shifty Gollum, the divided fellowship makes a stand against Sauron's new ally, Saruman, and his hordes of Isengard.",
3636
rating: 8.7,
@@ -40,8 +40,8 @@ let movies = [
4040
title: 'The Lord of the Rings: The Return of the King',
4141
year: 2003,
4242
isFavorite: false,
43-
poster: 'https://image.tmdb.org/t/p/w500/rCzpDGLbOoPwLjy3OAm5NUPOTrC.jpg',
44-
youtubeId: 'r5X-hFf6Bwo',
43+
poster: '/posters/lotr-return-king-poster.jpg',
44+
videoUrl: '/videos/lotr-return-king-trailer.mp4',
4545
description:
4646
"Gandalf and Aragorn lead the World of Men against Sauron's army to draw his gaze from Frodo and Sam as they approach Mount Doom on their quest to destroy the One Ring.",
4747
rating: 8.9,
@@ -51,8 +51,8 @@ let movies = [
5151
title: 'K-Pop Demon Hunters',
5252
year: 2025,
5353
isFavorite: true,
54-
poster: 'https://image.tmdb.org/t/p/w500/22AouvwlhlXbe3nrFcjzL24bvWH.jpg',
55-
youtubeId: 'dQw4w9WgXcQ',
54+
poster: '/posters/kpop-demon-hunters-poster.jpg',
55+
videoUrl: '/videos/kpop-demon-hunters-trailer.mp4',
5656
description:
5757
'An animated musical comedy about a group of K-pop idols who moonlight as demon hunters, saving the world one catchy song at a time.',
5858
rating: 9.2,
@@ -62,8 +62,8 @@ let movies = [
6262
title: 'Spider-Man: Into the Spider-Verse',
6363
year: 2018,
6464
isFavorite: false,
65-
poster: 'https://image.tmdb.org/t/p/w500/iiZZdoQBEYBv6id8su7ImL0oCbD.jpg',
66-
youtubeId: 'g4Hbz2jLxvQ',
65+
poster: '/posters/spiderverse-into-poster.jpg',
66+
videoUrl: '/videos/spiderverse-into-trailer.mp4',
6767
description:
6868
'Teen Miles Morales becomes Spider-Man of his reality, crossing his path with five counterparts from other dimensions to stop a threat for all realities.',
6969
rating: 8.4,
@@ -73,8 +73,8 @@ let movies = [
7373
title: 'Spider-Man: Across the Spider-Verse',
7474
year: 2023,
7575
isFavorite: true,
76-
poster: 'https://image.tmdb.org/t/p/w500/8Vt6mWEReuy4Of61Lnj5Xj704m8.jpg',
77-
youtubeId: 'cqGjhVJWtEg',
76+
poster: '/posters/spiderverse-across-poster.jpg',
77+
videoUrl: '/videos/spiderverse-across-trailer.mp4',
7878
description:
7979
"After reuniting with Gwen Stacy, Brooklyn's full-time, friendly neighborhood Spider-Man is catapulted across the Multiverse, where he encounters a team of Spider-People charged with protecting its very existence.",
8080
rating: 8.6,
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { useState } from 'react'
2-
import LiteYouTubeEmbed from 'react-lite-youtube-embed'
3-
import 'react-lite-youtube-embed/dist/LiteYouTubeEmbed.css'
1+
import { Activity, useState } from 'react'
42
import { type Movie } from '#app/movies-data.ts'
53

64
export function MovieTrailer({ movie }: { movie: Movie }) {
@@ -14,16 +12,18 @@ export function MovieTrailer({ movie }: { movie: Movie }) {
1412
>
1513
{showTrailer ? 'Hide Trailer' : 'Watch Trailer'}
1614
</button>
17-
{showTrailer && (
15+
<Activity mode={showTrailer ? 'visible' : 'hidden'}>
1816
<div className="overflow-hidden rounded-lg">
19-
<LiteYouTubeEmbed
20-
id={movie.youtubeId}
17+
<video
18+
src={movie.videoUrl}
2119
title={movie.title}
22-
params="autoplay=1&mute=0&rel=0&modestbranding=1"
23-
alwaysLoadIframe={true}
20+
autoPlay
21+
muted
22+
loop
23+
controls
2424
/>
2525
</div>
26-
)}
26+
</Activity>
2727
</div>
2828
)
2929
}

exercises/01.start/01.solution.vite-plugin/app/movies-data.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ let movies = [
1818
title: 'The Lord of the Rings: The Fellowship of the Ring',
1919
year: 2001,
2020
isFavorite: false,
21-
poster: 'https://image.tmdb.org/t/p/w500/6oom5QYQ2yQTMJIbnvbkBL9cHo6.jpg',
22-
youtubeId: 'V75dMMIW2B4',
21+
poster: '/posters/lotr-fellowship-poster.jpg',
22+
videoUrl: '/videos/lotr-fellowship-trailer.mp4',
2323
description:
2424
'A meek Hobbit from the Shire and eight companions set out on a journey to destroy the powerful One Ring and save Middle-earth from the Dark Lord Sauron.',
2525
rating: 8.8,
@@ -29,8 +29,8 @@ let movies = [
2929
title: 'The Lord of the Rings: The Two Towers',
3030
year: 2002,
3131
isFavorite: true,
32-
poster: 'https://image.tmdb.org/t/p/w500/5VTN0pR8gcqV3EPUHHfMGnJYN9L.jpg',
33-
youtubeId: 'LbfMDwc4azU',
32+
poster: '/posters/lotr-two-towers-poster.jpg',
33+
videoUrl: '/videos/lotr-two-towers-trailer.mp4',
3434
description:
3535
"While Frodo and Sam edge closer to Mordor with the help of the shifty Gollum, the divided fellowship makes a stand against Sauron's new ally, Saruman, and his hordes of Isengard.",
3636
rating: 8.7,
@@ -40,8 +40,8 @@ let movies = [
4040
title: 'The Lord of the Rings: The Return of the King',
4141
year: 2003,
4242
isFavorite: false,
43-
poster: 'https://image.tmdb.org/t/p/w500/rCzpDGLbOoPwLjy3OAm5NUPOTrC.jpg',
44-
youtubeId: 'r5X-hFf6Bwo',
43+
poster: '/posters/lotr-return-king-poster.jpg',
44+
videoUrl: '/videos/lotr-return-king-trailer.mp4',
4545
description:
4646
"Gandalf and Aragorn lead the World of Men against Sauron's army to draw his gaze from Frodo and Sam as they approach Mount Doom on their quest to destroy the One Ring.",
4747
rating: 8.9,
@@ -51,8 +51,8 @@ let movies = [
5151
title: 'K-Pop Demon Hunters',
5252
year: 2025,
5353
isFavorite: true,
54-
poster: 'https://image.tmdb.org/t/p/w500/22AouvwlhlXbe3nrFcjzL24bvWH.jpg',
55-
youtubeId: 'dQw4w9WgXcQ',
54+
poster: '/posters/kpop-demon-hunters-poster.jpg',
55+
videoUrl: '/videos/kpop-demon-hunters-trailer.mp4',
5656
description:
5757
'An animated musical comedy about a group of K-pop idols who moonlight as demon hunters, saving the world one catchy song at a time.',
5858
rating: 9.2,
@@ -62,8 +62,8 @@ let movies = [
6262
title: 'Spider-Man: Into the Spider-Verse',
6363
year: 2018,
6464
isFavorite: false,
65-
poster: 'https://image.tmdb.org/t/p/w500/iiZZdoQBEYBv6id8su7ImL0oCbD.jpg',
66-
youtubeId: 'g4Hbz2jLxvQ',
65+
poster: '/posters/spiderverse-into-poster.jpg',
66+
videoUrl: '/videos/spiderverse-into-trailer.mp4',
6767
description:
6868
'Teen Miles Morales becomes Spider-Man of his reality, crossing his path with five counterparts from other dimensions to stop a threat for all realities.',
6969
rating: 8.4,
@@ -73,8 +73,8 @@ let movies = [
7373
title: 'Spider-Man: Across the Spider-Verse',
7474
year: 2023,
7575
isFavorite: true,
76-
poster: 'https://image.tmdb.org/t/p/w500/8Vt6mWEReuy4Of61Lnj5Xj704m8.jpg',
77-
youtubeId: 'cqGjhVJWtEg',
76+
poster: '/posters/spiderverse-across-poster.jpg',
77+
videoUrl: '/videos/spiderverse-across-trailer.mp4',
7878
description:
7979
"After reuniting with Gwen Stacy, Brooklyn's full-time, friendly neighborhood Spider-Man is catapulted across the Multiverse, where he encounters a team of Spider-People charged with protecting its very existence.",
8080
rating: 8.6,
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { useState } from 'react'
2-
import LiteYouTubeEmbed from 'react-lite-youtube-embed'
3-
import 'react-lite-youtube-embed/dist/LiteYouTubeEmbed.css'
1+
import { Activity, useState } from 'react'
42
import { type Movie } from '#app/movies-data.ts'
53

64
export function MovieTrailer({ movie }: { movie: Movie }) {
@@ -14,16 +12,18 @@ export function MovieTrailer({ movie }: { movie: Movie }) {
1412
>
1513
{showTrailer ? 'Hide Trailer' : 'Watch Trailer'}
1614
</button>
17-
{showTrailer && (
15+
<Activity mode={showTrailer ? 'visible' : 'hidden'}>
1816
<div className="overflow-hidden rounded-lg">
19-
<LiteYouTubeEmbed
20-
id={movie.youtubeId}
17+
<video
18+
src={movie.videoUrl}
2119
title={movie.title}
22-
params="autoplay=1&mute=0&rel=0&modestbranding=1"
23-
alwaysLoadIframe={true}
20+
autoPlay
21+
muted
22+
loop
23+
controls
2424
/>
2525
</div>
26-
)}
26+
</Activity>
2727
</div>
2828
)
2929
}

exercises/01.start/02.solution.loader-rsc/app/movies-data.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ let movies = [
1818
title: 'The Lord of the Rings: The Fellowship of the Ring',
1919
year: 2001,
2020
isFavorite: false,
21-
poster: 'https://image.tmdb.org/t/p/w500/6oom5QYQ2yQTMJIbnvbkBL9cHo6.jpg',
22-
youtubeId: 'V75dMMIW2B4',
21+
poster: '/posters/lotr-fellowship-poster.jpg',
22+
videoUrl: '/videos/lotr-fellowship-trailer.mp4',
2323
description:
2424
'A meek Hobbit from the Shire and eight companions set out on a journey to destroy the powerful One Ring and save Middle-earth from the Dark Lord Sauron.',
2525
rating: 8.8,
@@ -29,8 +29,8 @@ let movies = [
2929
title: 'The Lord of the Rings: The Two Towers',
3030
year: 2002,
3131
isFavorite: true,
32-
poster: 'https://image.tmdb.org/t/p/w500/5VTN0pR8gcqV3EPUHHfMGnJYN9L.jpg',
33-
youtubeId: 'LbfMDwc4azU',
32+
poster: '/posters/lotr-two-towers-poster.jpg',
33+
videoUrl: '/videos/lotr-two-towers-trailer.mp4',
3434
description:
3535
"While Frodo and Sam edge closer to Mordor with the help of the shifty Gollum, the divided fellowship makes a stand against Sauron's new ally, Saruman, and his hordes of Isengard.",
3636
rating: 8.7,
@@ -40,8 +40,8 @@ let movies = [
4040
title: 'The Lord of the Rings: The Return of the King',
4141
year: 2003,
4242
isFavorite: false,
43-
poster: 'https://image.tmdb.org/t/p/w500/rCzpDGLbOoPwLjy3OAm5NUPOTrC.jpg',
44-
youtubeId: 'r5X-hFf6Bwo',
43+
poster: '/posters/lotr-return-king-poster.jpg',
44+
videoUrl: '/videos/lotr-return-king-trailer.mp4',
4545
description:
4646
"Gandalf and Aragorn lead the World of Men against Sauron's army to draw his gaze from Frodo and Sam as they approach Mount Doom on their quest to destroy the One Ring.",
4747
rating: 8.9,
@@ -51,8 +51,8 @@ let movies = [
5151
title: 'K-Pop Demon Hunters',
5252
year: 2025,
5353
isFavorite: true,
54-
poster: 'https://image.tmdb.org/t/p/w500/22AouvwlhlXbe3nrFcjzL24bvWH.jpg',
55-
youtubeId: 'dQw4w9WgXcQ',
54+
poster: '/posters/kpop-demon-hunters-poster.jpg',
55+
videoUrl: '/videos/kpop-demon-hunters-trailer.mp4',
5656
description:
5757
'An animated musical comedy about a group of K-pop idols who moonlight as demon hunters, saving the world one catchy song at a time.',
5858
rating: 9.2,
@@ -62,8 +62,8 @@ let movies = [
6262
title: 'Spider-Man: Into the Spider-Verse',
6363
year: 2018,
6464
isFavorite: false,
65-
poster: 'https://image.tmdb.org/t/p/w500/iiZZdoQBEYBv6id8su7ImL0oCbD.jpg',
66-
youtubeId: 'g4Hbz2jLxvQ',
65+
poster: '/posters/spiderverse-into-poster.jpg',
66+
videoUrl: '/videos/spiderverse-into-trailer.mp4',
6767
description:
6868
'Teen Miles Morales becomes Spider-Man of his reality, crossing his path with five counterparts from other dimensions to stop a threat for all realities.',
6969
rating: 8.4,
@@ -73,8 +73,8 @@ let movies = [
7373
title: 'Spider-Man: Across the Spider-Verse',
7474
year: 2023,
7575
isFavorite: true,
76-
poster: 'https://image.tmdb.org/t/p/w500/8Vt6mWEReuy4Of61Lnj5Xj704m8.jpg',
77-
youtubeId: 'cqGjhVJWtEg',
76+
poster: '/posters/spiderverse-across-poster.jpg',
77+
videoUrl: '/videos/spiderverse-across-trailer.mp4',
7878
description:
7979
"After reuniting with Gwen Stacy, Brooklyn's full-time, friendly neighborhood Spider-Man is catapulted across the Multiverse, where he encounters a team of Spider-People charged with protecting its very existence.",
8080
rating: 8.6,
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { useState } from 'react'
2-
import LiteYouTubeEmbed from 'react-lite-youtube-embed'
3-
import 'react-lite-youtube-embed/dist/LiteYouTubeEmbed.css'
1+
import { Activity, useState } from 'react'
42
import { type Movie } from '#app/movies-data.ts'
53

64
export function MovieTrailer({ movie }: { movie: Movie }) {
@@ -14,16 +12,18 @@ export function MovieTrailer({ movie }: { movie: Movie }) {
1412
>
1513
{showTrailer ? 'Hide Trailer' : 'Watch Trailer'}
1614
</button>
17-
{showTrailer && (
15+
<Activity mode={showTrailer ? 'visible' : 'hidden'}>
1816
<div className="overflow-hidden rounded-lg">
19-
<LiteYouTubeEmbed
20-
id={movie.youtubeId}
17+
<video
18+
src={movie.videoUrl}
2119
title={movie.title}
22-
params="autoplay=1&mute=0&rel=0&modestbranding=1"
23-
alwaysLoadIframe={true}
20+
autoPlay
21+
muted
22+
loop
23+
controls
2424
/>
2525
</div>
26-
)}
26+
</Activity>
2727
</div>
2828
)
2929
}

0 commit comments

Comments
 (0)