forked from ocftw/civictechfest.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjld.js
301 lines (269 loc) · 8.55 KB
/
jld.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
var jsonfile = require('jsonfile');
var htmlToText = require('html-to-text');
var fs = require('fs');
var md5 = require('md5');
var USEDROOM = {};
const ROOM = {
"Rall": {
"@type": "Place",
"@id": "#Rall",
"name": "所有會議廳 All Conference Room",
"address": "台北市南港區研究院路二段128號3F / 3F No.128, Sec. 2, Academia Rd., Nangang Dist., Taipei City 115, Taiwan",
"url": "http://hssb.committee.sinica.edu.tw/"
},
"R0": {
"@type": "Place",
"@id": "#R0",
"name": "國際會議廳 International Conference Hall",
"address": "台北市南港區研究院路二段128號4F / 4F No.128, Sec. 2, Academia Rd., Nangang Dist., Taipei City 115, Taiwan",
"url": "http://hssb.committee.sinica.edu.tw/room-1.html"
},
"R1": {
"@type": "Place",
"@id": "#R1",
"name": "第1會議室 1st Conference Room",
"address": "台北市南港區研究院路二段128號3F / 3F No.128, Sec. 2, Academia Rd., Nangang Dist., Taipei City 115, Taiwan",
"url": "http://hssb.committee.sinica.edu.tw/room-2.html"
},
"R2": {
"@type": "Place",
"@id": "#R2",
"name": "第2會議室 2nd Conference Room",
"address": "台北市南港區研究院路二段128號3F / 3F No.128, Sec. 2, Academia Rd., Nangang Dist., Taipei City 115, Taiwan",
"url": "http://hssb.committee.sinica.edu.tw/room-3.html"
}
};
const offers = [
{
"@type": "Offer",
"@id": "#offer-earlybird",
"name": "Apply for International Early Bird's ticket",
"category": "primary",
"price": 0.0,
"priceCurrency": "TWD",
"availability": "InStock",
"url": "http://g0v-summit2016.kktix.cc/events/early-bird",
"validFrom": "2016-02-15T20:00:00.000+08:00",
"validThrough": "2016-03-20T23:59:00.000+08:00"
},
{
"@type": "Offer",
"@id": "#offer-regular",
"name": "Attendee (一般票)",
"category": "primary",
"price": 1200.0,
"priceCurrency": "TWD",
"availability": "InStock",
"url": "http://g0v-summit2016.kktix.cc/events/conference",
"validFrom": "2016-04-01T20:00:00.000+08:00",
"validThrough": "2016-04-15T23:59:00.000+08:00"
},
{
"@type": "Offer",
"@id": "#offer-regular-donate",
"name": "Attendee (一般票) + NT$500 donate OCF",
"category": "primary",
"price": 1700.0,
"priceCurrency": "TWD",
"availability": "InStock",
"url": "http://g0v-summit2016.kktix.cc/events/conference",
"validFrom": "2016-04-01T20:00:00.000+08:00",
"validThrough": "2016-04-15T23:59:00.000+08:00"
},
{
"@type": "Offer",
"@id": "#offer-regular-invite",
"name": "Attendee with invite code (一般邀請票)",
"category": "premium",
"price": 1200.0,
"priceCurrency": "TWD",
"availability": "InStock",
"url": "http://g0v-summit2016.kktix.cc/events/conference",
"validFrom": "2016-04-01T20:00:00.000+08:00",
"validThrough": "2016-04-15T23:59:00.000+08:00"
},
{
"@type": "Offer",
"@id": "#offer-vip",
"name": "Attendee with VIP invite code (VIP 票)",
"category": "premium",
"price": 800.0,
"priceCurrency": "TWD",
"availability": "InStock",
"url": "http://g0v-summit2016.kktix.cc/events/conference",
"validFrom": "2016-02-29T20:00:00.000+08:00",
"validThrough": "2016-03-30T23:59:00.000+08:00"
},
{
"@type": "Offer",
"@id": "#offer-vip-donate",
"name": "Attendee with VIP invite code (VIP 票) + NT$500 donate OCF",
"category": "premium",
"price": 1300.0,
"priceCurrency": "TWD",
"availability": "InStock",
"url": "http://g0v-summit2016.kktix.cc/events/conference",
"validFrom": "2016-02-29T20:00:00.000+08:00",
"validThrough": "2016-03-30T23:59:00.000+08:00"
},
{
"@type": "Offer",
"@id": "#offer-reserved",
"name": "Attendee with reserved invite code (保留票)",
"category": "premium",
"price": 0.0,
"priceCurrency": "TWD",
"availability": "InStock",
"url": "http://g0v-summit2016.kktix.cc/events/conference",
"validFrom": "2016-02-15T20:00:00.000+08:00",
"validThrough": "2016-05-13T23:59:00.000+08:00"
}
];
var Base = function () {
var base = {
"@context": "http://schema.org",
"@type": "Event",
"@id": "g0v-summit-2016",
"name": "g0v Summit 2016 Conference",
"url": "http://summit.g0v.tw/2016/",
"startDate": "2016-05-14T09:00:00.000+08:00",
"endDate": "2016-05-15T17:40:00.000+08:00",
"location": {
"@type": "EventVenue",
"name": "中研院人文社會科學館 / Social Sciences Building, Academia Sinica, Taipei, Taiwan",
"address": "台北市南港區研究院路二段128號 / No.128, Sec. 2, Academia Rd., Nangang Dist., Taipei City 115, Taiwan",
"url": "http://hssb.committee.sinica.edu.tw/"
}
};
base.description = "Civic Tech is a new kind of civic engagement that uses technology and has become a key building block for democracies in the digital age. “Civic Tech Fest” is Asia’s first ever civic technology festival and conference, featuring a series of forums, workshops, roundtables, conferences and hackathons related to open data and open government. Civic Tech Fest will also host “TICTeC@Taipei: Impacts of Civic Technology Conference,” organized by mySociety. We will invite a number of experts, academics, hackers and members of governments to discuss and collaborate, and most importantly, have fun together";
return base;
};
var talk = function (name, description, performers, start, end, location) {
var obj = {
"@type": "Event",
location: location,
"startDate": start,
"endDate": end,
"offers": offers_ref
};
if (name) {
obj.name = name;
}
if (description) {
obj.description = description;
}
if (performers) {
if (performers.length > 1) {
obj.performers = performers;
} else {
obj.performer = performers;
}
}
return obj;
};
var person = function (name) {
return {
"@type": "Person",
"name": name
};
};
var datetime = function (day, hhmm) {
if (day === 1) {
return `2016-05-14T${hhmm}:00.000+08:00`;
} else {
return `2016-05-15T${hhmm}:00.000+08:00`;
}
};
var location_by_room = function (room) {
if (!room) {
room = 'Rall';
}
if (USEDROOM[room]) {
return {
"@id": ROOM[room]['@id']
};
} else {
USEDROOM[room] = true;
return ROOM[room];
}
};
var html2text = function (html) {
return htmlToText.fromString(html, {wordwrap: null}).replace(/\n/g, ' ');
};
var offers_ref = offers.map(function (offer) {
return {
"@id": offer["@id"]
};
});
var basic = JSON.stringify(function () {
var base = Base();
base.offers = offers;
return base;
}());
var schedule = JSON.stringify(function () {
var base = Base();
base.subEvents = [];
var schedule_data = jsonfile.readFileSync('./app/javascripts/components/Schedule/schedules.json');
var day1 = schedule_data["en-US"]["day1"];
var day2 = schedule_data["en-US"]["day2"];
var slot, event;
var day, start, end, temp;
var performers;
var days = [[], day1, day2];
for (day in days) {
for (slot of days[day]) {
if (!slot.events) {
slot.events = [slot.event];
}
temp = slot.time.split('-');
start = temp[0];
end = temp[1];
for (event of slot.events) {
performers = null;
if (event.title && event.title !== 'TBA') {
if (event.speaker) {
performers = event.speaker.split(/[,&]/).map(function (name) {
return person(name.trim());
});
}
base.subEvents.push(talk(event.title, html2text(event.abstract), performers, datetime(day, start), datetime(day, end), location_by_room(event.venue)));
}
}
}
}
return base;
}());
var hash_file = function (file) {
return md5(fs.readFileSync(file));
};
var sponsors = JSON.stringify(function () {
var base = [Base()];
var sponsors_data = jsonfile.readFileSync('./app/jsons/sponsors.json')['en-US'];
for (let cat of sponsors_data) {
for (let sponsor of cat.sponsors) {
var agent = {
"@type": "Organization",
"name": sponsor.name
};
if (sponsor.url) {
agent.url = sponsor.url;
}
if (sponsor.desc) {
agent.description = sponsor.desc;
}
if (sponsor.logo) {
agent.logo = `http://summit.g0v.tw/2016/${hash_file(`./app/images/sponsors/${sponsor.logo}`)}.png`;
}
base.push({
"@context": "http://schema.org",
"@type": "JoinAction",
"agent": agent,
"object": {
"@id": "g0v-summit-2016",
}
});
}
}
return base;
}());
export {basic, schedule, sponsors}