+ We’ve sent a confirmation email to your inbox. +
++ If you don't receive that email or have any other issues please + email info@methodconf.com +
+Be kind to each other.
', + blocks: [], + }, + }), + ), + }, + ), + contentBase( + 'speaker-ada', + 'speaker', + 'Ada Lovelace', + '/2024/speakers/ada/', + { + jobTitle: 'Computer scientist', + profileImage: [image('/media/ada.jpg')], + bio: { markup: 'Ada wrote about computing.
', blocks: [] }, + websiteUrl: 'https://example.test/ada', + }, + ), + contentBase('sessions-root', 'sessions', 'Sessions', '/2024/sessions/'), + contentBase( + 'session-1', + 'session', + 'Opening keynote', + '/2024/sessions/opening/', + { + start: '2024-09-01T09:00:00Z', + end: '2024-09-01T10:00:00Z', + speakers: [ + contentBase( + 'speaker-ada', + 'speaker', + 'Ada Lovelace', + '/2024/speakers/ada/', + { + jobTitle: 'Computer scientist', + profileImage: [image('/media/ada.jpg')], + }, + ), + ], + description: { markup: 'Opening remarks.
', blocks: [] }, + }, + ), + contentBase('sponsors-root', 'sponsors', 'Sponsors', '/2024/sponsors/', { + tiers: { + items: [ + { + content: block('sponsor-tier', 'sponsorTier', { + title: 'Community', + sponsors: { + items: [ + { + content: block('sponsor-acme', 'sponsor', { + title: 'Acme', + url: 'https://example.test', + logo: [image('/media/acme.svg')], + }), + }, + ], + }, + }), + }, + ], + }, + }), + contentBase( + 'unsupported', + 'sessions', + 'Sessions leaf', + '/2024/not-a-page/', + ), +]; + +const defaultConferences = () => [ + conference('2023', '2023-09-01T09:00:00Z'), + conference( + '2024', + '2024-09-01T09:00:00Z', + 'https://sessionize.example/method-2024/', + 'https://tickets.example/embed?id=5b12c452dc', + ), +]; + +const state = { + conferences: defaultConferences(), mediaRequests: [], newsletterRequests: [], cmsRequests: 0, @@ -76,9 +203,36 @@ async function startUpstream() { if (url.pathname === '/umbraco/delivery/api/v2/content') { state.cmsRequests += 1; + const filters = url.searchParams.getAll('filter'); + const fetch = url.searchParams.get('fetch') ?? ''; + let items = state.conferences; + + if (fetch.startsWith('descendants:2024')) { + items = contentItems; + } + + if (fetch.startsWith('descendants:sessions-root')) { + items = contentItems.filter((item) => + ['session', 'track'].includes(item.contentType), + ); + } + + for (const filter of filters) { + if (filter.startsWith('contentType:')) { + const contentType = filter.replace('contentType:', ''); + items = items.filter( + (item) => item.contentType === contentType, + ); + } + + if (filter === 'speaker:speaker-ada') { + items = items.filter((item) => item.id === 'session-1'); + } + } + writeJson(response, 200, { - total: state.conferences.length, - items: state.conferences, + total: items.length, + items, }); return; } @@ -101,7 +255,15 @@ async function startUpstream() { return; } - const item = state.conferences.find((item) => item.name === slug); + const byPath = new Map([ + ...state.conferences.map((item) => [item.name, item]), + ...contentItems.map((item) => [ + item.route.path.replace(/^\//, '').replace(/\/$/, ''), + item, + ]), + ['2024/home', contentItems[0]], + ]); + const item = byPath.get(slug.replace(/\/$/, '')); if (!item) { writeJson(response, 404, { message: 'not found' }); @@ -112,6 +274,13 @@ async function startUpstream() { return; } + if (url.pathname === '/api/v1/conference/2024/schedule') { + writeJson(response, 200, { + scheduleGrid: [['session-1']], + }); + return; + } + if (url.pathname === '/api/public/subscription') { let body = ''; request.setEncoding('utf8'); @@ -479,18 +648,56 @@ async function runRouteChecks(origin) { (await request(origin, '/2024/sessions/not-a-page/')).status, 404, ); - assert.equal((await request(origin, '/sitemap.xml')).status, 404); + assert.equal((await request(origin, '/2024/not-a-page/')).status, 404); + await expectRedirect(origin, '/sitemap.xml', 308, './sitemap.xml/'); + assert.equal((await request(origin, '/sitemap.xml/')).status, 404); + + const home = await expectHead(origin, '/2024/', 200); + assert.match(home.html, /Invest In Yourself and Hone Your Craft/); + assert.match(home.html, /Stay in-the-know about event updates/); + assert.match(home.html, /Schedule/); + assert.match(home.html, /Location Info/); + assert.match(home.html, /Sponsors/); + assert.match(home.head, /