Skip to content

Commit ccd892b

Browse files
committed
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.
1 parent 0f6e567 commit ccd892b

File tree

89 files changed

+316
-219
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+316
-219
lines changed

src/content.js

Lines changed: 108 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,137 @@
11
const talks = require("./talks");
2-
const speakers = resolveSocialLinks(require("./speakers"));
3-
const organizers = resolveSocialLinks(require("./organizers"));
2+
const people = resolveSocialLinks(require("./people"));
3+
const enums = require("./enums");
4+
5+
const speakers = people.filter(({ type }) => type.some(equals(enums.SPEAKER)));
6+
const organizers = people.filter(({ type }) =>
7+
type.some(equals(enums.ORGANIZER))
8+
);
9+
410
const sponsors = resolveSocialLinks(require("./sponsors"));
511
const workshops = require("./workshops");
6-
const enums = require("./enums");
712

813
const keynotes = talks.filter(({ type }) => type === enums.KEYNOTE);
914
const lightningTalks = talks.filter(
10-
({ type }) => type === enums.LIGHTNING_TALK
15+
({ type }) => type === enums.LIGHTNING_TALK
1116
);
1217
const presentations = talks.filter(({ type }) => type === enums.PRESENTATION);
13-
const partners = sponsors.filter(({ type }) => type === enums.PARTNER);
14-
const goldSponsors = sponsors.filter(({ type }) => type === enums.GOLD_SPONSOR);
15-
const silverSponsors = sponsors.filter(
16-
({ type }) => type === enums.SILVER_SPONSOR
18+
const partners = sponsors.filter(({ type }) =>
19+
type.some(equals(enums.PARTNER))
20+
);
21+
const goldSponsors = sponsors.filter(({ type }) =>
22+
type.some(equals(enums.GOLD_SPONSOR))
1723
);
18-
const bronzeSponsors = sponsors.filter(
19-
({ type }) => type === enums.BRONZE_SPONSOR
24+
const silverSponsors = sponsors.filter(({ type }) =>
25+
type.some(equals(enums.SILVER_SPONSOR))
26+
);
27+
const bronzeSponsors = sponsors.filter(({ type }) =>
28+
type.some(equals(enums.BRONZE_SPONSOR))
2029
);
2130

2231
module.exports = {
23-
breakfasts: require("./breakfasts"),
24-
coffeeBreaks: require("./coffee-breaks"),
25-
locations: resolveSocialLinks(require('./locations')),
26-
keynotes,
27-
lightningTalks,
28-
lunches: require("./lunches"),
29-
organizers,
30-
panels: require("./panels"),
31-
pages: require("./pages"),
32-
sponsors,
33-
partners,
34-
goldSponsors,
35-
silverSponsors,
36-
bronzeSponsors,
37-
presentations,
38-
schedules: require("./schedules"),
39-
speakers: associate(speakers, [
40-
{
41-
field: "keynotes",
42-
sourceData: keynotes,
43-
condition: speakersContainSpeakerByName,
44-
},
45-
{
46-
field: "lightningTalks",
47-
sourceData: lightningTalks,
48-
condition: speakersContainSpeakerByName,
49-
},
50-
{
51-
field: "presentations",
52-
sourceData: presentations,
53-
condition: speakersContainSpeakerByName,
54-
},
55-
{
56-
field: "talks",
57-
sourceData: talks,
58-
condition: speakersContainSpeakerByName,
59-
},
60-
{
61-
field: "workshops",
62-
sourceData: workshops,
63-
condition: speakersContainSpeakerByName,
64-
},
65-
]),
66-
talks,
67-
tickets: require("./tickets"),
68-
workshops,
32+
breakfasts: require("./breakfasts"),
33+
coffeeBreaks: require("./coffee-breaks"),
34+
locations: resolveSocialLinks(require("./locations")),
35+
keynotes,
36+
lightningTalks,
37+
lunches: require("./lunches"),
38+
organizers,
39+
panels: require("./panels"),
40+
pages: require("./pages"),
41+
sponsors,
42+
partners,
43+
goldSponsors,
44+
silverSponsors,
45+
bronzeSponsors,
46+
presentations,
47+
schedules: require("./schedules"),
48+
speakers: associate(speakers, [
49+
{
50+
field: "keynotes",
51+
sourceData: keynotes,
52+
condition: speakersContainSpeakerByName,
53+
},
54+
{
55+
field: "lightningTalks",
56+
sourceData: lightningTalks,
57+
condition: speakersContainSpeakerByName,
58+
},
59+
{
60+
field: "presentations",
61+
sourceData: presentations,
62+
condition: speakersContainSpeakerByName,
63+
},
64+
{
65+
field: "talks",
66+
sourceData: talks,
67+
condition: speakersContainSpeakerByName,
68+
},
69+
{
70+
field: "workshops",
71+
sourceData: workshops,
72+
condition: speakersContainSpeakerByName,
73+
},
74+
]),
75+
talks,
76+
tickets: require("./tickets"),
77+
workshops,
6978
};
7079

7180
function associate(data, rules) {
72-
return data.map(target => {
73-
const associations = {};
74-
75-
rules.forEach(({ field, sourceData, condition }) => {
76-
sourceData.forEach(source => {
77-
if (condition({ source, target })) {
78-
if (!associations[field]) {
79-
associations[field] = [];
80-
}
81+
return data.map(target => {
82+
const associations = {};
8183

82-
associations[field].push(source);
83-
}
84-
});
85-
});
84+
rules.forEach(({ field, sourceData, condition }) => {
85+
sourceData.forEach(source => {
86+
if (condition({ source, target })) {
87+
if (!associations[field]) {
88+
associations[field] = [];
89+
}
8690

87-
return Object.assign({}, target, associations);
91+
associations[field].push(source);
92+
}
93+
});
8894
});
95+
96+
return Object.assign({}, target, associations);
97+
});
98+
}
99+
100+
function equals(expected) {
101+
return value => value === expected;
89102
}
90103

91104
function speakersContainSpeakerByName({
92-
source: { speakers },
93-
target: { name },
105+
source: { speakers },
106+
target: { name },
94107
}) {
95-
return speakers.map(({ name }) => name).indexOf(name) >= 0;
108+
return speakers.map(({ name }) => name).indexOf(name) >= 0;
96109
}
97110

98111
function resolveSocialLinks(data) {
99-
function resolve(social, o) {
100-
const rules = {
101-
homepage: social.homepage,
102-
facebook: `https://facebook.com/${social.facebook}`,
103-
github: `https://github.com/${social.github}`,
104-
linkedin: `https://linkedin.com/${social.linkedin}`,
105-
medium: `https://medium.com/${social.medium}`,
106-
instagram: `https://instagram.com/${social.instagram}`,
107-
twitter: `https://twitter.com/${social.twitter}`,
108-
youtube: `https://www.youtube.com/${social.youtube}`,
109-
vk: `https://vk.com/${social.vk}`,
110-
};
111-
const ret = {};
112+
function resolve(social, o) {
113+
const rules = {
114+
homepage: social.homepage,
115+
facebook: `https://facebook.com/${social.facebook}`,
116+
github: `https://github.com/${social.github}`,
117+
linkedin: `https://linkedin.com/${social.linkedin}`,
118+
medium: `https://medium.com/${social.medium}`,
119+
instagram: `https://instagram.com/${social.instagram}`,
120+
twitter: `https://twitter.com/${social.twitter}`,
121+
youtube: `https://www.youtube.com/${social.youtube}`,
122+
vk: `https://vk.com/${social.vk}`,
123+
};
124+
const ret = {};
112125

113-
Object.keys(social).forEach(media => {
114-
ret[media] = rules[media];
115-
});
126+
Object.keys(social).forEach(media => {
127+
ret[media] = rules[media];
128+
});
116129

117-
return ret;
118-
}
130+
return ret;
131+
}
119132

120-
return data.map(o => ({
121-
...o,
122-
social: resolve(o.social, o),
123-
}));
133+
return data.map(o => ({
134+
...o,
135+
social: resolve(o.social, o),
136+
}));
124137
}

src/enums.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ module.exports = {
33
GOLD_SPONSOR: "goldSponsor",
44
KEYNOTE: "keynote",
55
LIGHTNING_TALK: "lightningTalk",
6+
ORGANIZER: "organizer",
67
PARTNER: "partner",
78
PRESENTATION: "presentation",
89
SILVER_SPONSOR: "silverSponsor",
10+
SPEAKER: "speaker",
911
};

src/organizers/index.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/organizers/juho-vepsalainen.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/speakers/_template.js renamed to src/people/_template.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const enums = require("../enums");
12
const keywords = require("../keywords");
23

34
module.exports = {
@@ -22,4 +23,5 @@ module.exports = {
2223
city: "", // TODO: City name
2324
},
2425
keywords: [keywords.REACT], // TODO: check keywords for more
26+
type: [enums.SPEAKER],
2527
};

src/organizers/aarni-koskela.js renamed to src/people/aarni-koskela.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const enums = require("../enums");
2+
13
module.exports = {
24
name: "Aarni Koskela",
35
about: "Aarni works on the site and the app. Specializes in terrible puns.",
@@ -15,4 +17,5 @@ module.exports = {
1517
},
1618
},
1719
keywords: [],
20+
type: [enums.ORGANIZER],
1821
};

src/organizers/aleksi-pousar.js renamed to src/people/aleksi-pousar.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const enums = require("../enums");
2+
13
module.exports = {
24
name: "Aleksi Pousar",
35
about:
@@ -16,4 +18,5 @@ module.exports = {
1618
},
1719
},
1820
keywords: [],
21+
type: [enums.ORGANIZER],
1922
};

src/speakers/andrey-okonetchnikov.js renamed to src/people/andrey-okonetchnikov.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const enums = require("../enums");
12
const keywords = require("../keywords");
23

34
module.exports = {
@@ -23,4 +24,5 @@ module.exports = {
2324
keywords.STYLE_GUIDES,
2425
keywords.TOOLING,
2526
],
27+
type: [enums.SPEAKER],
2628
};

src/speakers/artem-sapegin.js renamed to src/people/artem-sapegin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const enums = require("../enums");
12
const keywords = require("../keywords");
23

34
module.exports = {
@@ -25,4 +26,5 @@ module.exports = {
2526
keywords.STYLE_GUIDES,
2627
keywords.TOOLING,
2728
],
29+
type: [enums.SPEAKER],
2830
};

src/speakers/christian-alfoni.js renamed to src/people/christian-alfoni.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const enums = require("../enums");
12
const keywords = require("../keywords");
23

34
module.exports = {
@@ -18,4 +19,5 @@ module.exports = {
1819
city: "Trondheim",
1920
},
2021
keywords: [keywords.CEREBRAL, keywords.REACT, keywords.STATE_MANAGEMENT],
22+
type: [enums.SPEAKER],
2123
};

0 commit comments

Comments
 (0)