Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List of Events #118

Merged
merged 22 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3bb5e12
feat: added link to events page
L-Steinmacher Sep 26, 2023
9feaa2e
feat: added events-list.mjs and rendering it on pages/events.mjs
L-Steinmacher Sep 26, 2023
d30bf6d
feat: displaying data and starting html
L-Steinmacher Sep 27, 2023
1318beb
feat:events-sponsors rendered
L-Steinmacher Sep 27, 2023
0e25493
update data being fetched for route
L-Steinmacher Sep 27, 2023
0ab09c2
talks rendering now
L-Steinmacher Sep 27, 2023
1c31dae
small change
L-Steinmacher Sep 27, 2023
1c7472e
feat rendering event talks list and talks on page
L-Steinmacher Sep 27, 2023
fa77933
added anchor tag
L-Steinmacher Sep 27, 2023
f4543a2
cleaned up files
L-Steinmacher Sep 27, 2023
728d4a5
align past events with header
L-Steinmacher Sep 28, 2023
3c08ea3
removed the current/future event from the pastEvents.
L-Steinmacher Sep 28, 2023
40f2a5b
fixed dates on events.json and pastEvents sort
L-Steinmacher Sep 28, 2023
baf3871
fixed past events
L-Steinmacher Sep 29, 2023
b739284
fixed pastEvents, added closing ul and removed target
L-Steinmacher Sep 29, 2023
6a492c0
fixed data fetching for talks, displaying name from speaker
L-Steinmacher Sep 29, 2023
167e775
normalize data and expand data in api events
L-Steinmacher Sep 29, 2023
df608a8
use list-sponsors and list-talks in events/
L-Steinmacher Sep 29, 2023
6144e9d
add turnary on topic for older talks
L-Steinmacher Sep 29, 2023
215d714
removed unused element, reorganized helper functions to respective files
L-Steinmacher Oct 2, 2023
8ca401b
refactored events/ to properly use 404
L-Steinmacher Oct 2, 2023
a45771f
added additional comment for event inflation
L-Steinmacher Oct 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/api/events.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import data from '../data/events.json' assert { type: 'json' }
import { inflateSponsors } from './sponsors.mjs'
import { inflateTalk } from './talks.mjs'
export async function get() {
return {
json: { data }
}
}

export const events = data

export function inflateEvent(event) {
if (event.talks) {
event.talks = event.talks.map(inflateTalk)
event.sponsors = event.sponsors.map(inflateSponsors)
}
return event
}
33 changes: 27 additions & 6 deletions app/api/events/$id.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
import { events } from '../events.mjs'
import events from '../../data/events.json' assert { type: 'json' }
import { inflateEvent } from '../events.mjs'

export async function get(req) {
let { id } = req.params
let event = events.find(s => s.id === id)
let { path } = req
const event = events.find(e => e.id === req.params.id)

if (!event) {
return {
statusCode: 404,
json: {
path,
notFound: true
}
}
} else {
// We have to convert event from an object to an array to inflate it
let inflatedEvent = [event].map(inflateEvent)
let eventSponsors = event.sponsors
let eventTalks = event.talks

// In event/$id we are reusing the element <list-talks> which expects a list of events
return {
json: { event }
}
}
json: {
events: inflatedEvent,
sponsors: eventSponsors,
talks: eventTalks
}
}}
}
24 changes: 1 addition & 23 deletions app/api/index.mjs
Original file line number Diff line number Diff line change
@@ -1,29 +1,7 @@
import { events } from './events.mjs'
import { talks } from './talks.mjs'
import { speakers } from './speakers.mjs'
import { events, inflateEvent } from './events.mjs'
import { organizers } from './organizers.mjs'
import { sponsors } from './sponsors.mjs'

function inflateTalk(talk_id) {
let talk = talks.find(t => t.id === talk_id)
if (talk.speaker_id) {
talk.speaker = speakers.find(s => s.id === talk.speaker_id)
}
return talk
}

function inflateSponsors(sponsor_id) {
return sponsors.find(s => s.id === sponsor_id)
}

function inflateEvent(event) {
if (event.talks) {
event.talks = event.talks.map(inflateTalk)
event.sponsors = event.sponsors.map(inflateSponsors)
}
return event
}

function filterFutureEvents() {
const TWELVE_HOURS = 1000 * 60 * 60 * 12
return events.filter(
Expand Down
5 changes: 5 additions & 0 deletions app/api/sponsors.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ export async function get() {
}

export const sponsors = data

export
function inflateSponsors(sponsor_id) {
return sponsors.find(s => s.id === sponsor_id)
}
22 changes: 21 additions & 1 deletion app/api/talks.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
import data from '../data/talks.json' assert { type: 'json' }
import speakers from '../data/speakers.json' assert { type: 'json' }

export async function get() {

return {
json: data
json: data.map(t => {
let speaker = speakers.find(s => s.id === t.speaker_id)
return {
id: t.id,
event_id: t.event_id,
title: t.title,
abstract: t.abstract,
speaker,
}
})
}
}

export const talks = data

export function inflateTalk(talk_id) {
let talk = talks.find(t => t.id === talk_id)
if (talk.speaker_id) {
talk.speaker = speakers.find(s => s.id === talk.speaker_id)
}
return talk
}
22 changes: 11 additions & 11 deletions app/data/events.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"id": "may-2022",
"title": "SeattleJS May 2022",
"date": "2022-10-12",
"date": "2022-05-11",
"sponsors": [
"collective-seattle"
],
Expand All @@ -13,7 +13,7 @@
{
"id": "june-2022",
"title": "SeattleJS June 2022",
"date": "2022-10-12",
"date": "2022-06-08",
"sponsors": [
"collective-seattle"
],
Expand All @@ -24,29 +24,29 @@
{
"id": "july-2022",
"title": "SeattleJS July 2022",
"date": "2022-10-12",
"date": "2022-07-13",
"sponsors": [
"collective-seattle"
]
],
"talks": []
},
{
"id": "august-2022",
"title": "SeattleJS August 2022",
"date": "2022-10-12",
"date": "2022-08-10",
"sponsors": [
"collective-seattle"
]
],
"talks": []
},
{
"id": "september-2022",
"title": "SeattleJS September 2022",
"date": "2022-10-12",
"date": "2022-09-14",
"sponsors": [
"collective-seattle"
],
"talks": [
"rachel-lee-nabors"
]
"talks": []
},
{
"id": "october-2022",
Expand Down Expand Up @@ -85,7 +85,7 @@
"title": "SeattleJS January 2023",
"date": "2023-01-11",
"sponsors": [
"aws-skills-center"
"aws-skills-center-seattle"
],
"talks": [
"calvin-kipperman-january-2023",
Expand Down
43 changes: 43 additions & 0 deletions app/elements/events-list.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
export default function EventsList({ html, state }) {
const { store } = state
const allEvents = store.data.sort((a,b) => new Date(b.date) - new Date(a.date))

let now = new Date().toISOString().split('T')[0]
let pastEvents = allEvents.filter(e => e.date < now)

if (pastEvents.length > 0) {
return html`
<style>
@media only screen and (min-width: 768px) {
:host {
display: flex;
flex-wrap: wrap;
align-items: flex-start;
}
}
ul {
margin: 0;
padding: 0;
}
li {
list-style-type: none;
}
</style>
<ul>
andrewiggins marked this conversation as resolved.
Show resolved Hide resolved
${pastEvents.map(
e => `
<li >
<a href="/events/${e.id}">
${e.title}
</a>
</li>`
)
.join('')}
</ul>
`
}else {
return `
<p>Wait for it...</p>
`
}
}
2 changes: 1 addition & 1 deletion app/elements/list-sponsors.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function ListSponsors({ html, state = {} }) {
${sponsors
.map(
s => html` <div>
<a target="_sponsor" href="${s.url}"
<a target="_blank" href="${s.url}"
><img src="/_public/images/sponsors/${s.image}"
/></a>
</div>`
Expand Down
6 changes: 6 additions & 0 deletions app/elements/view-event.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { marked } from 'marked'

export default function ViewEvent({ html, state = {} }) {
const { attrs, store } = state

let { events } = store
let { id } = attrs
let event = events.find(e => e.id === id)
Expand All @@ -27,5 +28,10 @@ export default function ViewEvent({ html, state = {} }) {
></a>
</div>
<list-talks event_id="${event.id}"></list-talks>
<div class="">
<a target="_self" href="/events">
See all past events <i class="fa-solid fa-arrow-right"></i>
</a>
</div>
`
}
14 changes: 4 additions & 10 deletions app/pages/events.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
export default function ({ html, state = {} }) {
let { store = {} } = state
let { events } = store
//console.log(events)
export default function events({ html }) {

return html`
<my-layout>
<div id="page">
<div class="page-title"><h1>Our Events</h1></div>
<div class="page-body">
<ul>
${events.map(e => /*html*/ `<li>${e.title}</li>`).join('')}
</ul>
</div>
<div class=""><h1>Our Past Events</h1></div>
<events-list></events-list>
</div>
</my-layout>
`
Expand Down
20 changes: 17 additions & 3 deletions app/pages/events/$id.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import { marked } from "marked"

export default function ({ html, state = {} }) {
let { store = {} } = state
let { event } = store
let event = store.events[0]
let hasTalks = event.talks && event.talks.length > 0
let { id, title, sponsors, description } = event

return html`
<page-layout title=${event.title}>
<pre>${JSON.stringify(event, null, 2)}</pre>
<page-layout title=${title}>
<h3>${title}</h3>
${description && `<p>${marked(description)}</p>` }
<h4>Thanks to our Sponsors ❤️</h4>
${sponsors ? html`<list-sponsors></list-sponsors>` : null}
${hasTalks ? html`<list-talks event_id="${id}"></list-talks>`: html`<p>No talks were given durring this event.</p>`}
<div class="">
<a target="_self" href="/events">
See all past events <i class="fa-solid fa-arrow-right"></i>
</a>
</div>
</page-layout>
`
}
22 changes: 18 additions & 4 deletions app/pages/talks.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
export default function ({ html, state = {} }) {
let { store = {} } = state
let { talks } = store
let { store } = state
let talks = [...Object.values(store)]

return html`
<style>
ul {
padding: 0;
}
li {
list-style-type: none;
padding-bottom: 0.5em;
}
</style>
<my-layout>
<div id="page">
<div class="page-title"><h1>Talk List</h1></div>
<div class="page-title"><h1>Past Talks</h1></div>
<div class="page-body">
<ul>
${talks.map(t => /*html*/ `<li>${t.title}</li>`).join('')}
${talks
.map(
t => /*html*/ `<li>${t.title} - Speaker: ${t.speaker.name}</li>`
)
.join('')}
</ul>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions app/pages/talks/$id.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function ({ html, state = {} }) {
</div>
`
}
else {
else {
// set the "photo" property with an absolute path (so that the <person-detail> element will work)
let speakerClone = { ...speaker }
speakerClone.photo = '/_public/images/speakers/' + speaker.photo
Expand All @@ -40,9 +40,9 @@ export default function ({ html, state = {} }) {
padding:8px;
}
</style>
<page-layout title=${talk.title}>
<page-layout title=${talk.title}>
<h2>${ title }</h2>
<div class="topics">${ topics.map(t => `<div class=topic>${ t }</div>`).join('') }</div>
${topics ? html`<div class="topics">${ topics.map(t => `<div class=topic>${ t }</div>`).join('') }</div>` : null }
<div class="abstract">${ marked.parse(abstract) }</div>
<person-detail ${ speakerProps }></person-detail>
</page-layout>
Expand Down