diff --git a/README.md b/README.md index f3d40a6..72b81ce 100644 --- a/README.md +++ b/README.md @@ -6,24 +6,26 @@ The site is based on the HTML5 UP Lens template and currently ships as a plain s ## Repo Layout -- `index.html`: main gallery page +- `templates/index.html`: source template for the main gallery page +- `index.html`: generated static gallery page - `assets/`: site CSS, JavaScript, fonts, and audio - `images/fulls/`: full-size gallery images - `images/thumbs/`: gallery thumbnails - `data/meals.json`: source of truth for gallery entries -- `scripts/render-gallery.js`: regenerates the gallery markup in `index.html` from `data/meals.json` +- `scripts/build.js`: renders static pages from templates and data +- `package.json`: minimal Node build entrypoint ## Content Workflow -Gallery entries now live in `data/meals.json`. +Gallery entries live in `data/meals.json`, and `index.html` is generated from `templates/index.html`. -After editing that file, regenerate the static markup with: +After editing content or templates, rebuild the site with: ```sh -node scripts/render-gallery.js +npm run build ``` -The script updates only the generated gallery block inside `index.html`. +The build currently renders the main page without changing the existing Lens gallery structure, so the current client-side viewer code continues to work. ## Image Conventions diff --git a/index.html b/index.html index 633e235..2557b15 100755 --- a/index.html +++ b/index.html @@ -1,222 +1,220 @@ - - - - - vicky n pham fanpage - - - - - - - - - - - - - - - -
- - - - - -
- -
- -

sf on $10

-

this was so not real i can't believe technically u paid for our first meal back. calmluh 3 years after. first hang !!!! pork buns were yummy 7/10

-
-
- -

honey butter chicken

-

the first thing you cooked for me ! so yum 10/10

-
-
- -

aloha fresh

-

we fucking love this place 10/10 i love poke i should have never quit pokehouse

-
-
- -

mad yolks

-

for our santa cruz hang! u in my city now. so so good but lwk so so tax 9/10

-
-
- -

sizzling lunch

-

better than pepper lunch. server was being a little bitchy but i would be too if i was the only one working the front. 8/10

-
-
- -

braised pork belly

-

omfg this is my favorite thing uve made 100/10

-
-
- -

sushi w/ claire!

-

and then we played bananagrams. sushi 8/10 thanks for paying mommy

-
-
- -

myungrang hot dog

-

main street tino nothing special 7/10

-
-
- -

liangs village

-

my peoples food. 9/10

-
-
- -

cabonara

-

insane safeway hang 9/10

-
-
- -

heytea

-

this fuckass blue drink

-
-
- -

sparcos

-

one of many.. 100/10

-
-
- -

noahs bagels

-

this is the plaza where i used to go to all the time before school 9/10

-
-
- -

homeroom

-

mac and cheese was gas. 10/10. you know its my fav comfort food. free the girl crying in the corner tho

-
-
- -

sparcos x2

-

spartan tacos

-
-
- -

sparcos x3

-

okay damn no way we got this b2b

-
-
- -

aloha fresh

-

this is lowkey the spot poke always hits so fucking good

-
-
- -

house of bagels

-

hobags ughgmmfmfm im such a fucking ho for hobags 100/10

-
-
- -

toro sushi

-

carmel by the sea! we love sushi but tax 8/10

-
-
- -

sul and beans

-

sweet treat -> claire dropping the most insane piece of information ever -> hti the yap

-
-
- -

highland hand pulled noodles

-

so good and soooo filling 10/10. also my peoples food.

-
-
- -

bloom

-

even when its rich white people breakfast im getting salmon nox 10/10

-
-
- -

happy donuts

-

1k cal meal 0 protein 10/10

-
-
- -

marugame

-

i dont want to talk about this. 9/10

-
-
- -

siam station!

-

i can't believe u didnt eat ur leftovers. 10/10

-
-
- -

muukata 6395

-

for my birthday!! i love eating meat and i love you so perfect combination 1000/10

-
-
- -

bambu

-

why was the store so nice. i wonder about the 4 sisters

-
-
- -

porridge at julias

-

her boyfriend is so not real hes so stupid and funny. porridge was gas too i love eating free at julias 10/10

-
-
- -

sparcos x4

-

spartan tacos. i was moody lol.

-
-
- -

wonton udon

-

i helped wrap the wontons w/ u !!! super fun and super yummy 10/10

-
-
- -

steak dinna for vday

-

marry me? yes. 100/10 best valentines day ever

-
-
- -

poke house

-

poke house 3 years later 9/10 but +1 point bc its basically free

-
-
- -

hey tea

-

mochi yinje black milk tea ts was actually so buss 10/10 only boba i've ever wanted to get again myself

-
- -
- - - - -
- - - - - - - - - + + + + + vicky n pham fanpage + + + + + + + + + + + + + + + +
+ + + + + +
+
+ +

sf on $10

+

this was so not real i can't believe technically u paid for our first meal back. calmluh 3 years after. first hang !!!! pork buns were yummy 7/10

+
+
+ +

honey butter chicken

+

the first thing you cooked for me ! so yum 10/10

+
+
+ +

aloha fresh

+

we fucking love this place 10/10 i love poke i should have never quit pokehouse

+
+
+ +

mad yolks

+

for our santa cruz hang! u in my city now. so so good but lwk so so tax 9/10

+
+
+ +

sizzling lunch

+

better than pepper lunch. server was being a little bitchy but i would be too if i was the only one working the front. 8/10

+
+
+ +

braised pork belly

+

omfg this is my favorite thing uve made 100/10

+
+
+ +

sushi w/ claire!

+

and then we played bananagrams. sushi 8/10 thanks for paying mommy

+
+
+ +

myungrang hot dog

+

main street tino nothing special 7/10

+
+
+ +

liangs village

+

my peoples food. 9/10

+
+
+ +

cabonara

+

insane safeway hang 9/10

+
+
+ +

heytea

+

this fuckass blue drink

+
+
+ +

sparcos

+

one of many.. 100/10

+
+
+ +

noahs bagels

+

this is the plaza where i used to go to all the time before school 9/10

+
+
+ +

homeroom

+

mac and cheese was gas. 10/10. you know its my fav comfort food. free the girl crying in the corner tho

+
+
+ +

sparcos x2

+

spartan tacos

+
+
+ +

sparcos x3

+

okay damn no way we got this b2b

+
+
+ +

aloha fresh

+

this is lowkey the spot poke always hits so fucking good

+
+
+ +

house of bagels

+

hobags ughgmmfmfm im such a fucking ho for hobags 100/10

+
+
+ +

toro sushi

+

carmel by the sea! we love sushi but tax 8/10

+
+
+ +

sul and beans

+

sweet treat -> claire dropping the most insane piece of information ever -> hti the yap

+
+
+ +

highland hand pulled noodles

+

so good and soooo filling 10/10. also my peoples food.

+
+
+ +

bloom

+

even when its rich white people breakfast im getting salmon nox 10/10

+
+
+ +

happy donuts

+

1k cal meal 0 protein 10/10

+
+
+ +

marugame

+

i dont want to talk about this. 9/10

+
+
+ +

siam station!

+

i can't believe u didnt eat ur leftovers. 10/10

+
+
+ +

muukata 6395

+

for my birthday!! i love eating meat and i love you so perfect combination 1000/10

+
+
+ +

bambu

+

why was the store so nice. i wonder about the 4 sisters

+
+
+ +

porridge at julias

+

her boyfriend is so not real hes so stupid and funny. porridge was gas too i love eating free at julias 10/10

+
+
+ +

sparcos x4

+

spartan tacos. i was moody lol.

+
+
+ +

wonton udon

+

i helped wrap the wontons w/ u !!! super fun and super yummy 10/10

+
+
+ +

steak dinna for vday

+

marry me? yes. 100/10 best valentines day ever

+
+
+ +

poke house

+

poke house 3 years later 9/10 but +1 point bc its basically free

+
+
+ +

hey tea

+

mochi yinje black milk tea ts was actually so buss 10/10 only boba i've ever wanted to get again myself

+
+
+ + + + +
+ + + + + + + + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..54c1158 --- /dev/null +++ b/package.json @@ -0,0 +1,7 @@ +{ + "name": "gallery", + "private": true, + "scripts": { + "build": "node scripts/build.js" + } +} diff --git a/scripts/build.js b/scripts/build.js new file mode 100644 index 0000000..2b28d23 --- /dev/null +++ b/scripts/build.js @@ -0,0 +1,90 @@ +const fs = require("fs"); +const path = require("path"); + +const repoRoot = path.resolve(__dirname, ".."); +const mealsPath = path.join(repoRoot, "data", "meals.json"); +const indexTemplatePath = path.join(repoRoot, "templates", "index.html"); +const indexOutputPath = path.join(repoRoot, "index.html"); + +function detectEol(text) { + return text.includes("\r\n") ? "\r\n" : "\n"; +} + +function escapeHtml(value) { + return value + .replace(/&/g, "&") + .replace(/", + `\t\t\t\t\t`, + `\t\t\t\t\t

${escapeHtml(meal.title)}

`, + `\t\t\t\t\t

${escapeHtml(meal.description)}

`, + "\t\t\t\t", + ].join(eol); +} + +function renderGallery(meals, eol) { + return meals.map((meal) => renderGalleryItem(meal, eol)).join(eol); +} + +function replaceBlock(template, token, replacement) { + const pattern = new RegExp(`^[\\t ]*\\{\\{${token}\\}\\}$`, "m"); + + if (!pattern.test(template)) { + throw new Error(`Template is missing required block token "{{${token}}}"`); + } + + return template.replace(pattern, () => replacement); +} + +function buildIndex() { + const template = fs.readFileSync(indexTemplatePath, "utf8"); + const eol = detectEol(template); + const meals = JSON.parse(fs.readFileSync(mealsPath, "utf8")); + + validateMeals(meals); + + return replaceBlock(template, "gallery_items", renderGallery(meals, eol)); +} + +function writeFile(filePath, contents) { + fs.writeFileSync(filePath, contents); +} + +function main() { + writeFile(indexOutputPath, buildIndex()); +} + +main(); diff --git a/scripts/render-gallery.js b/scripts/render-gallery.js deleted file mode 100644 index 578f69c..0000000 --- a/scripts/render-gallery.js +++ /dev/null @@ -1,61 +0,0 @@ -const fs = require("fs"); -const path = require("path"); - -const repoRoot = path.resolve(__dirname, ".."); -const dataPath = path.join(repoRoot, "data", "meals.json"); -const indexPath = path.join(repoRoot, "index.html"); - -const startMarker = ""; -const endMarker = ""; - -function escapeHtml(value) { - return value - .replace(/&/g, "&") - .replace(/", - `\t\t\t\t\t`, - `\t\t\t\t\t

${escapeHtml(entry.title)}

`, - `\t\t\t\t\t

${escapeHtml(entry.description)}

`, - "\t\t\t\t", - ].join(eol); -} - -function renderGallery(entries, eol) { - return entries.map((entry) => renderArticle(entry, eol)).join(eol); -} - -function main() { - const entries = JSON.parse(fs.readFileSync(dataPath, "utf8")); - const indexHtml = fs.readFileSync(indexPath, "utf8"); - const eol = indexHtml.includes("\r\n") ? "\r\n" : "\n"; - const galleryMarkup = renderGallery(entries, eol); - const replacement = [ - `\t\t\t\t${startMarker}`, - galleryMarkup, - `\t\t\t\t${endMarker}`, - ].join(eol); - - const markerPattern = new RegExp( - `^[\\t ]*${startMarker}[\\s\\S]*?^[\\t ]*${endMarker}`, - "m" - ); - - if (!markerPattern.test(indexHtml)) { - throw new Error("Could not find gallery markers in index.html"); - } - - fs.writeFileSync(indexPath, indexHtml.replace(markerPattern, replacement)); -} - -main(); diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..c481725 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,56 @@ + + + + + vicky n pham fanpage + + + + + + + + + + + + + + + +
+ + + + + +
+ {{gallery_items}} +
+ + + + +
+ + + + + + + + +