Skip to content

Commit 0b88230

Browse files
committed
update
1 parent ae672e3 commit 0b88230

4 files changed

Lines changed: 118 additions & 98 deletions

File tree

index.js

Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,22 @@ const NOTION_STORE_DATABASE_ID = "7c36ef34cebb48e097706442634abaaf";
1616
const redis = require('redis');
1717
const client = redis.createClient(); // Connects to default 127.0.0.1:6379 on your Droplet
1818

19-
client.on('error', (err) => console.log('Redis Client Error', err));
20-
client.connect(); // v4 of redis requires explicit connect
19+
client.on('error', (err) => {
20+
// console.log('Redis Client Error:', err.message);
21+
// This prevents the app from crashing; it just logs the error
22+
});
23+
let redisIsReady = false;
24+
async function connectRedis() {
25+
try {
26+
await client.connect();
27+
redisIsReady = true;
28+
console.log("Connected to Redis");
29+
} catch (err) {
30+
console.log("Redis not found. Running in 'No-Cache' mode.");
31+
redisIsReady = false;
32+
}
33+
}
34+
connectRedis();
2135
const CACHE_TTL = 3500; // 60 minutes in seconds
2236
console.log("starting up")
2337
app.use(express.static("public"))
@@ -254,7 +268,7 @@ app.get("/poetic-promenade", async (req,res) => {
254268
// console.log(response)
255269

256270
const response = await prepareEventData(eventData, "poetic-promenade")
257-
271+
console.log(response)
258272
res.render("programs/prom", response)
259273

260274
//
@@ -1036,6 +1050,7 @@ app.get("/sessions/:session/:class", async(req,res) => {
10361050
const cacheKey = `cache:session:${session}:class:${className}`;
10371051

10381052
try {
1053+
if(redisIsReady){
10391054
// 1. Try to get data from Redis
10401055
const cachedData = await client.get(cacheKey);
10411056

@@ -1055,6 +1070,14 @@ app.get("/sessions/:session/:class", async(req,res) => {
10551070
res.status(404).send("Class not found");
10561071
}
10571072
}
1073+
} else {
1074+
const freshData = await revalidateClassData(session, className, cacheKey);
1075+
if (freshData) {
1076+
res.render("programs/class-concurrent", freshData);
1077+
} else {
1078+
res.status(404).send("Class not found");
1079+
}
1080+
}
10581081
} catch (error) {
10591082
console.error("Route Error:", error);
10601083
res.status(500).send("Internal Server Error");
@@ -1161,6 +1184,7 @@ app.get("/blog/:slug", async (req, res) => {
11611184
const cacheKey = `cache:blog:${slug}`;
11621185

11631186
try {
1187+
if(redisIsReady){
11641188
const cachedData = await client.get(cacheKey);
11651189

11661190
if (cachedData) {
@@ -1187,6 +1211,19 @@ app.get("/blog/:slug", async (req, res) => {
11871211
res.status(404).send("Post not found");
11881212
}
11891213
}
1214+
} else {
1215+
console.log("skipping redis")
1216+
const freshData = await revalidateBlogData(slug, cacheKey);
1217+
if (freshData) {
1218+
res.render("blog/post", {
1219+
title: freshData.Name,
1220+
postHTML: freshData.postHTML,
1221+
...freshData
1222+
});
1223+
} else {
1224+
res.status(404).send("Post not found");
1225+
}
1226+
}
11901227
} catch (error) {
11911228
console.error("Blog Route Error:", error);
11921229
res.status(500).send("Internal Server Error");
@@ -1443,6 +1480,7 @@ async function prepareEventData(eventData, eventSlug){
14431480
const webContent = contentBlockId ? await getBlocks(contentBlockId) : [];
14441481
let response = parseEventData(eventData)
14451482
response.pageContent = parsePageContentIntoKeyedObject(webContent);
1483+
response.Images = response["Event Photos"]
14461484

14471485
return response
14481486
}
@@ -2441,6 +2479,10 @@ function formatRichText(textArray) {
24412479
}
24422480

24432481
async function getCachedData(key, fetcher) {
2482+
if (!redisIsReady) {
2483+
console.log(`[Local] Skipping cache for: ${key}`);
2484+
return await fetcher();
2485+
}
24442486
const cached = await client.get(key);
24452487

24462488
if (cached) {
@@ -2471,11 +2513,14 @@ async function revalidateClassData(sessionSlug, classSlug, cacheKey) {
24712513

24722514
// Your original processing logic
24732515
const response = await prepareClassData(data, classSlug);
2474-
2516+
if(redisIsReady){
24752517
// Store in Redis (Expire after 1 hour to account for image URL expiration)
2476-
await client.set(cacheKey, JSON.stringify(response), {
2477-
EX: 3500
2478-
});
2518+
await client.set(cacheKey, JSON.stringify(response), {
2519+
EX: 3500
2520+
});
2521+
} else {
2522+
console.log("skipping redis")
2523+
}
24792524

24802525
return response;
24812526
}
@@ -2494,11 +2539,15 @@ async function revalidateBlogData(slug, cacheKey) {
24942539
const postHTML = parsePageContentHTML(pageContent);
24952540

24962541
const finalData = { ...parsedData, postHTML };
2542+
if(redisIsReady){
2543+
// Update Redis with a TTL (e.g., 1 hour)
2544+
await client.set(cacheKey, JSON.stringify(finalData), {
2545+
EX: 3500
2546+
});
2547+
} else {
2548+
console.log("skipping redis")
2549+
}
24972550

2498-
// Update Redis with a TTL (e.g., 1 hour)
2499-
await client.set(cacheKey, JSON.stringify(finalData), {
2500-
EX: 3500
2501-
});
25022551

25032552
return finalData;
25042553
}

public/lcd.css

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@
3939
white #FFFFFF */
4040
/* --summer-25-background: #FFF; */
4141

42+
--prom-26-background: black;
43+
--prom-26-text: white;
44+
--prom-26-text-on-bg: #cad1f7;
45+
--prom-26-link: #7c9efb;
46+
--prom-26-special-text: #fdad78;
47+
4248
--summer-26-background: black;
4349
--summer-26-text: white;
4450
--summer-26-text-on-bg: #cad1f7;
@@ -436,7 +442,7 @@ select#allSections {
436442
/* /////////// start prom styles ///////////////////////////////*/
437443

438444
.shell.prom-26{
439-
background-color: var(--sw-lightblue);
445+
background-color: black !important;
440446
color: white;
441447
}
442448

@@ -481,6 +487,25 @@ select#allSections {
481487
.prom-26 .workshop #class-block {
482488
background: var(--sw-lightblue)!important;
483489
}
490+
.prom-26 section#section-outro,
491+
#class .intro.prom-26,
492+
.shell.prom-26 .class-details,
493+
.prom-26 #class section,
494+
.prom-26 #class .entity,
495+
.prom-26 .accordion dd.active,
496+
.prom-26 section ul,
497+
.prom-26 .website-grid
498+
{
499+
/* background-color: var(--summer-26-background); */
500+
background: var(--prom-26-background);
501+
color: var(--summer-26-text) !important;
502+
border-radius: var(--border-rad);
503+
/* text-shadow: 2px 2px 0px var(--summer-24-background); */
504+
505+
506+
/* -webkit-text-stroke-width: 1px; */
507+
/* -webkit-text-stroke-color: var(--summer-24-link); */
508+
}
484509
/* /////////// start summer-26 ///////////////////////////////*/
485510
.shell.april-26-shell {
486511
background-color: var(--summer-26-background);

public/templates/about/about.hbs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,12 +415,14 @@
415415
General inquires: <BR> <a href="mailto:info@sfpc.study">info@sfpc.study</a>
416416
<BR><BR>
417417
Admissions inquiries: <BR> <a href="mailto:admissions@sfpc.study">admissions@sfpc.study</a>
418+
<BR><BR>
419+
Payment inquiries: <BR> <a href="mailto:admissions@sfpc.study">payments@sfpc.study</a>
418420
</div>
419421
</div> <BR>
420422
<div class="details">
421423
<div class="labels">instagram </div>
422424
<div class="labels-info">
423-
<a href="https://instagram.com/sfpc_nyc">@sfpc_nyc</a>
425+
<a href="https://instagram.com/sfpc.study">@sfpc.study</a>
424426
</div>
425427
</div>
426428

public/templates/programs/prom.hbs

Lines changed: 29 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<meta charset="UTF-8">
77
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
8-
<meta name="title" content="School for Poetic Computation">
8+
<meta name="title" content="Poetic Promenade - SFPC">
99
<meta name="description" content="The School for Poetic Computation is an experimental school in New York City supporting interdisciplinary study in art, code, hardware and critical theory. It's a place for learning and unlearning.">
1010
<meta property="og:type" content="website">
1111
<meta property="og:url" content="https://sfpc.study/">
@@ -49,7 +49,7 @@
4949

5050
<div class="crt-overlay crt-overlay-fullsize"></div>
5151

52-
<div id="shell" class="shell shell-fullsize about sfpc">
52+
<div id="shell" class="shell shell-fullsize about sfpc summer-26">
5353

5454
<div class="loader-content">
5555
<p tabindex="0" class="large">
@@ -68,11 +68,6 @@
6868

6969

7070

71-
<h4 class="breadcrumb hide-content">
72-
<a href="/events">events</a>
73-
<!-- <span class="caret"></span> -->
74-
</h4>
75-
7671

7772

7873

@@ -136,47 +131,6 @@
136131
</div>
137132
{{/if}}
138133

139-
<!--
140-
{{#if Website-Organizers}}
141-
<div class="details">
142-
<div class="labels">Organizers</div>
143-
<div class="labels-info" id="teachers-list">{{#each Website-Organizers}}{{this}}{{#unless @last}},{{/unless}} {{/each}} {{#each this.[Additional organizers]}} {{this}} {{/each}}</div>
144-
</div>
145-
{{/if}}
146-
147-
{{#if Website-Contributors}}
148-
<div class="details">
149-
<div class="labels">Contributors</div>
150-
<div class="labels-info">
151-
<span tabindex="0" class="expand"><a class="link">{{Website-Contributors.length}} contributors...</a>
152-
<span class="expanded hide-expanded">
153-
{{#each Website-Contributors}}{{this}}{{#unless @last}},{{/unless}} {{/each}}
154-
</span></span>
155-
</div>
156-
</div>
157-
{{/if}}
158-
159-
{{#if Partnership?}}
160-
<div class="details">
161-
<div class="labels">Partners</div>
162-
<div class="labels-info" id="teachers-list">{{Partnership?}} {{Partners}}</div>
163-
</div>
164-
{{/if}} -->
165-
166-
167-
<!-- {{#if Website-Session}}
168-
<div class="details">
169-
<div class="labels">Program</div>
170-
<div class="labels-info" id="program-info">
171-
172-
{{#if Website-Class}}
173-
{{#each Website-Class}}{{this}}{{#unless @last}}, {{/unless}} {{/each}} {{/if}}
174-
175-
176-
177-
</div>
178-
</div>
179-
{{/if}} -->
180134

181135

182136
<div class="details">
@@ -197,19 +151,9 @@
197151
<p class="large apply">
198152

199153
{{#if External-Website}}
200-
<a href="{{"External-Website"}}" target="_blank" id="application-link">
201-
202-
203-
{{External-CTA}}
204-
205-
</a>
206-
207-
{{else}}
208-
209-
{{#if RSVP}}
210-
<a href="{{RSVP}}" target="_blank" id="application-link">RSVP</a>
211-
{{/if}}
212-
154+
<p class="large">
155+
<a class="special-button" href="{{"External-Website"}}" target="_blank" id="application-link">{{External-CTA}}</a>
156+
</p>
213157

214158
{{/if}}
215159
</p>
@@ -251,30 +195,6 @@
251195
</div>
252196
</section>
253197
{{/if}}
254-
255-
{{#each pageContent}}
256-
257-
258-
<div class="break"></div>
259-
260-
261-
<section id="section-{{dashcase @key}}" class="program-content">
262-
<div class="grid-2">
263-
<h1>{{@key}}</h1>
264-
</div>
265-
266-
<div class="grid-2">
267-
{{{this}}}
268-
</div>
269-
</section>
270-
271-
272-
{{/each}}
273-
274-
275-
276-
277-
278198
{{#if Images}}
279199

280200
<div class="break-noline"></div>
@@ -303,6 +223,30 @@
303223

304224
</div>
305225
{{/if}}
226+
{{#each pageContent}}
227+
228+
229+
<div class="break"></div>
230+
231+
232+
<section id="section-{{dashcase @key}}" class="program-content">
233+
<div class="grid-2">
234+
<h1>{{@key}}</h1>
235+
</div>
236+
237+
<div class="grid-2">
238+
{{{this}}}
239+
</div>
240+
</section>
241+
242+
243+
{{/each}}
244+
245+
246+
247+
248+
249+
306250

307251

308252
<div class="break"></div>

0 commit comments

Comments
 (0)