[object Object]

← back to Wallco Ai

/designs HTML: filter cards by designHasImage (mirror /api/designs)

187a96b3562e3c3fd157b741afb9ef2601dd2827 · 2026-05-19 15:14:32 -0700 · SteveStudio2

The /designs page route was rendering cards for every matching design
without checking whether the PNG file actually exists on disk. Since
data/generated/ is in the deploy exclude list, any var_NNNN_* variant
generated locally but not rsynced 404s on prod — and the card itself
paints as an empty tile (background-image fires the broken URL).

/api/designs (the API the SPA queries for infinite-scroll pages 2+)
already did DESIGNS.filter(designHasImage); page 1 (server-rendered
HTML) bypassed it. Applying the same filter so the two endpoints stay
in sync — both honor BLANK_IDS + file-on-disk presence.

Verified locally: /designs HTML now returns 60 cards (one full page)
post-filter; was previously serving rows whose background-image
url('/designs/img/var_9367_*.png') 404s on prod.

Files touched

Diff

commit 187a96b3562e3c3fd157b741afb9ef2601dd2827
Author: SteveStudio2 <stevestudio2@SteveStacStudio.lan>
Date:   Tue May 19 15:14:32 2026 -0700

    /designs HTML: filter cards by designHasImage (mirror /api/designs)
    
    The /designs page route was rendering cards for every matching design
    without checking whether the PNG file actually exists on disk. Since
    data/generated/ is in the deploy exclude list, any var_NNNN_* variant
    generated locally but not rsynced 404s on prod — and the card itself
    paints as an empty tile (background-image fires the broken URL).
    
    /api/designs (the API the SPA queries for infinite-scroll pages 2+)
    already did DESIGNS.filter(designHasImage); page 1 (server-rendered
    HTML) bypassed it. Applying the same filter so the two endpoints stay
    in sync — both honor BLANK_IDS + file-on-disk presence.
    
    Verified locally: /designs HTML now returns 60 cards (one full page)
    post-filter; was previously serving rows whose background-image
    url('/designs/img/var_9367_*.png') 404s on prod.
---
 server.js | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/server.js b/server.js
index 059e33b..dde93f7 100644
--- a/server.js
+++ b/server.js
@@ -3221,7 +3221,12 @@ app.get('/designs', (req, res) => {
     if (h < 290) return 'mauve';
     return 'plum';
   }
-  let filtered = [...DESIGNS];
+  // Hard filter — never render a card whose image file isn't on disk OR whose
+  // id is in the blank-guard. /api/designs already does this; mirror it on the
+  // HTML page so missing-file rows don't paint empty cards that 404 their
+  // background-image url(). (data/generated/ is in deploy exclude list, so any
+  // var_NNNN_* PNG generated locally but not rsynced is 404 on prod.)
+  let filtered = DESIGNS.filter(designHasImage);
   if (cat)    filtered = filtered.filter(d => d.category === cat);
   if (motifQ) filtered = filtered.filter(d => (d.motifs || []).includes(motifQ));
   if (hueQ)   filtered = filtered.filter(d => hueBucketOf(d.dominant_hex) === hueQ);

← e9586f4 chore: gitignore generated images + audit logs + classifier  ·  back to Wallco Ai  ·  refiner-compare: 3 more render columns (Gemini 2.5 Flash Ima a109d4f →