@@ -106,6 +106,10 @@ async function handle(type, req, res, next, reqInit = undefined) {
106
106
json = preProcess ( json , type ) ;
107
107
json = addMetadata ( type , json , req , reqInit ) ;
108
108
109
+ if ( type == "world" ) {
110
+ json = addMMC ( json ) ;
111
+ }
112
+
109
113
res . status ( 200 ) . render ( type , json ) ;
110
114
} catch ( error ) {
111
115
console . log ( error ) ;
@@ -204,8 +208,90 @@ function renderCredits(req, res, next) {
204
208
const contributorsFile = fs . readFileSync ( './.all-contributorsrc' ) ;
205
209
contributorsJson = JSON . parse ( contributorsFile ) ;
206
210
207
- console . log ( contributorsJson ) ;
208
211
return res . render ( 'credits' , contributorsJson ) ;
209
212
}
210
213
214
+ var competitionTag = "mmc25" ; //TODO: handle years.
215
+
216
+ var categories = [
217
+ {
218
+ title : "World Social" ,
219
+ requiredTags : [ "world" , "social" ]
220
+ } ,
221
+ {
222
+ title : "World Game" ,
223
+ requiredTags : [ "world" , "game" ]
224
+ } ,
225
+ {
226
+ title : "World Misc" ,
227
+ requiredTags : [ "world" , "misc" ]
228
+ } ,
229
+ // Avatars
230
+ {
231
+ title : "Avatars" ,
232
+ requiredTags : [ "avatar" , "avatars" ]
233
+ } ,
234
+ {
235
+ title : "Avatar Miscellaneous" ,
236
+ requiredTags : [ "avatar" , "misc" ]
237
+ } ,
238
+ // Other
239
+ {
240
+ title : "Other: Tools, Apps & Utilities" ,
241
+ requiredTags : [ "other" , "tau" ]
242
+ } ,
243
+ {
244
+ title : "Other: Miscellaneous" ,
245
+ requiredTags : [ "other" , "misc" ]
246
+ } ,
247
+ // Single tag categories
248
+ {
249
+ title : "Art" ,
250
+ requiredTags : [ "art" ]
251
+ } ,
252
+ {
253
+ title : "Education, Science and Data Visualization" ,
254
+ requiredTags : [ "esd" ]
255
+ } ,
256
+ {
257
+ title : "Meme" ,
258
+ requiredTags : [ "meme" ]
259
+ } ,
260
+ {
261
+ title : "Narrative" ,
262
+ requiredTags : [ "narrative" ]
263
+ }
264
+ ]
265
+
266
+ function matchCategories ( tags ) {
267
+ var cats = [ ] ;
268
+ for ( const category of categories ) {
269
+ var entered = category . requiredTags . every ( tag => tags . includes ( tag ) ) ;
270
+
271
+ if ( ! entered )
272
+ continue ;
273
+
274
+ cats . push ( category ) ;
275
+ }
276
+
277
+ return cats ;
278
+ }
279
+
280
+ function addMMC ( worldRecord ) {
281
+ if ( ! worldRecord . tags . includes ( competitionTag ) )
282
+ return worldRecord ;
283
+
284
+ var categories = matchCategories ( worldRecord . tags ) ;
285
+
286
+ var multipleCategories = categories . length > 1 ; // IN MULTIPLE BAD
287
+
288
+ worldRecord . mmc = {
289
+ entered :true ,
290
+ categories,
291
+ multipleCategories
292
+ }
293
+
294
+ return worldRecord ;
295
+ }
296
+
211
297
export default router ;
0 commit comments