-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(schema): Attach type information to people
Now organizers and speakers are behind the same directory. No need to separate as that's more complex. Enum is enough.
- Loading branch information
Showing
89 changed files
with
316 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,124 +1,137 @@ | ||
const talks = require("./talks"); | ||
const speakers = resolveSocialLinks(require("./speakers")); | ||
const organizers = resolveSocialLinks(require("./organizers")); | ||
const people = resolveSocialLinks(require("./people")); | ||
const enums = require("./enums"); | ||
|
||
const speakers = people.filter(({ type }) => type.some(equals(enums.SPEAKER))); | ||
const organizers = people.filter(({ type }) => | ||
type.some(equals(enums.ORGANIZER)) | ||
); | ||
|
||
const sponsors = resolveSocialLinks(require("./sponsors")); | ||
const workshops = require("./workshops"); | ||
const enums = require("./enums"); | ||
|
||
const keynotes = talks.filter(({ type }) => type === enums.KEYNOTE); | ||
const lightningTalks = talks.filter( | ||
({ type }) => type === enums.LIGHTNING_TALK | ||
({ type }) => type === enums.LIGHTNING_TALK | ||
); | ||
const presentations = talks.filter(({ type }) => type === enums.PRESENTATION); | ||
const partners = sponsors.filter(({ type }) => type === enums.PARTNER); | ||
const goldSponsors = sponsors.filter(({ type }) => type === enums.GOLD_SPONSOR); | ||
const silverSponsors = sponsors.filter( | ||
({ type }) => type === enums.SILVER_SPONSOR | ||
const partners = sponsors.filter(({ type }) => | ||
type.some(equals(enums.PARTNER)) | ||
); | ||
const goldSponsors = sponsors.filter(({ type }) => | ||
type.some(equals(enums.GOLD_SPONSOR)) | ||
); | ||
const bronzeSponsors = sponsors.filter( | ||
({ type }) => type === enums.BRONZE_SPONSOR | ||
const silverSponsors = sponsors.filter(({ type }) => | ||
type.some(equals(enums.SILVER_SPONSOR)) | ||
); | ||
const bronzeSponsors = sponsors.filter(({ type }) => | ||
type.some(equals(enums.BRONZE_SPONSOR)) | ||
); | ||
|
||
module.exports = { | ||
breakfasts: require("./breakfasts"), | ||
coffeeBreaks: require("./coffee-breaks"), | ||
locations: resolveSocialLinks(require('./locations')), | ||
keynotes, | ||
lightningTalks, | ||
lunches: require("./lunches"), | ||
organizers, | ||
panels: require("./panels"), | ||
pages: require("./pages"), | ||
sponsors, | ||
partners, | ||
goldSponsors, | ||
silverSponsors, | ||
bronzeSponsors, | ||
presentations, | ||
schedules: require("./schedules"), | ||
speakers: associate(speakers, [ | ||
{ | ||
field: "keynotes", | ||
sourceData: keynotes, | ||
condition: speakersContainSpeakerByName, | ||
}, | ||
{ | ||
field: "lightningTalks", | ||
sourceData: lightningTalks, | ||
condition: speakersContainSpeakerByName, | ||
}, | ||
{ | ||
field: "presentations", | ||
sourceData: presentations, | ||
condition: speakersContainSpeakerByName, | ||
}, | ||
{ | ||
field: "talks", | ||
sourceData: talks, | ||
condition: speakersContainSpeakerByName, | ||
}, | ||
{ | ||
field: "workshops", | ||
sourceData: workshops, | ||
condition: speakersContainSpeakerByName, | ||
}, | ||
]), | ||
talks, | ||
tickets: require("./tickets"), | ||
workshops, | ||
breakfasts: require("./breakfasts"), | ||
coffeeBreaks: require("./coffee-breaks"), | ||
locations: resolveSocialLinks(require("./locations")), | ||
keynotes, | ||
lightningTalks, | ||
lunches: require("./lunches"), | ||
organizers, | ||
panels: require("./panels"), | ||
pages: require("./pages"), | ||
sponsors, | ||
partners, | ||
goldSponsors, | ||
silverSponsors, | ||
bronzeSponsors, | ||
presentations, | ||
schedules: require("./schedules"), | ||
speakers: associate(speakers, [ | ||
{ | ||
field: "keynotes", | ||
sourceData: keynotes, | ||
condition: speakersContainSpeakerByName, | ||
}, | ||
{ | ||
field: "lightningTalks", | ||
sourceData: lightningTalks, | ||
condition: speakersContainSpeakerByName, | ||
}, | ||
{ | ||
field: "presentations", | ||
sourceData: presentations, | ||
condition: speakersContainSpeakerByName, | ||
}, | ||
{ | ||
field: "talks", | ||
sourceData: talks, | ||
condition: speakersContainSpeakerByName, | ||
}, | ||
{ | ||
field: "workshops", | ||
sourceData: workshops, | ||
condition: speakersContainSpeakerByName, | ||
}, | ||
]), | ||
talks, | ||
tickets: require("./tickets"), | ||
workshops, | ||
}; | ||
|
||
function associate(data, rules) { | ||
return data.map(target => { | ||
const associations = {}; | ||
|
||
rules.forEach(({ field, sourceData, condition }) => { | ||
sourceData.forEach(source => { | ||
if (condition({ source, target })) { | ||
if (!associations[field]) { | ||
associations[field] = []; | ||
} | ||
return data.map(target => { | ||
const associations = {}; | ||
|
||
associations[field].push(source); | ||
} | ||
}); | ||
}); | ||
rules.forEach(({ field, sourceData, condition }) => { | ||
sourceData.forEach(source => { | ||
if (condition({ source, target })) { | ||
if (!associations[field]) { | ||
associations[field] = []; | ||
} | ||
|
||
return Object.assign({}, target, associations); | ||
associations[field].push(source); | ||
} | ||
}); | ||
}); | ||
|
||
return Object.assign({}, target, associations); | ||
}); | ||
} | ||
|
||
function equals(expected) { | ||
return value => value === expected; | ||
} | ||
|
||
function speakersContainSpeakerByName({ | ||
source: { speakers }, | ||
target: { name }, | ||
source: { speakers }, | ||
target: { name }, | ||
}) { | ||
return speakers.map(({ name }) => name).indexOf(name) >= 0; | ||
return speakers.map(({ name }) => name).indexOf(name) >= 0; | ||
} | ||
|
||
function resolveSocialLinks(data) { | ||
function resolve(social, o) { | ||
const rules = { | ||
homepage: social.homepage, | ||
facebook: `https://facebook.com/${social.facebook}`, | ||
github: `https://github.com/${social.github}`, | ||
linkedin: `https://linkedin.com/${social.linkedin}`, | ||
medium: `https://medium.com/${social.medium}`, | ||
instagram: `https://instagram.com/${social.instagram}`, | ||
twitter: `https://twitter.com/${social.twitter}`, | ||
youtube: `https://www.youtube.com/${social.youtube}`, | ||
vk: `https://vk.com/${social.vk}`, | ||
}; | ||
const ret = {}; | ||
function resolve(social, o) { | ||
const rules = { | ||
homepage: social.homepage, | ||
facebook: `https://facebook.com/${social.facebook}`, | ||
github: `https://github.com/${social.github}`, | ||
linkedin: `https://linkedin.com/${social.linkedin}`, | ||
medium: `https://medium.com/${social.medium}`, | ||
instagram: `https://instagram.com/${social.instagram}`, | ||
twitter: `https://twitter.com/${social.twitter}`, | ||
youtube: `https://www.youtube.com/${social.youtube}`, | ||
vk: `https://vk.com/${social.vk}`, | ||
}; | ||
const ret = {}; | ||
|
||
Object.keys(social).forEach(media => { | ||
ret[media] = rules[media]; | ||
}); | ||
Object.keys(social).forEach(media => { | ||
ret[media] = rules[media]; | ||
}); | ||
|
||
return ret; | ||
} | ||
return ret; | ||
} | ||
|
||
return data.map(o => ({ | ||
...o, | ||
social: resolve(o.social, o), | ||
})); | ||
return data.map(o => ({ | ||
...o, | ||
social: resolve(o.social, o), | ||
})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const enums = require("../enums"); | ||
const keywords = require("../keywords"); | ||
|
||
module.exports = { | ||
name: "Eemeli Aro", | ||
about: | ||
"Eemeli has been falling down the rabbit hole of JavaScript localization for about six years now, and keeps wondering at what the next level might be. For work he makes complicated systems seem simple, for fun he writes open-source libraries, and in his spare time he organises science fiction conventions.", | ||
image: "speakers/eemeli.jpg", | ||
social: { | ||
homepage: "", | ||
twitter: "eemeli_aro", | ||
github: "eemeli", | ||
}, | ||
location: { | ||
country: { | ||
name: "Finland", | ||
code: "FI", | ||
}, | ||
city: "Helsinki", | ||
}, | ||
keywords: [keywords.TOOLING, keywords.REACT], | ||
type: [enums.SPEAKER], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.