diff --git a/competition.js b/competition.js index f7ce540..59ef3a6 100644 --- a/competition.js +++ b/competition.js @@ -29,8 +29,11 @@ function listFiles() { for (const f of files) { if (f.endsWith('.cs')) { out.push((dir + '/' + f).substring(2)) - } else if (fs.lstatSync(process.env.SCRIPT_BASE + '/' + dir + '/' + f)) { - dirs.push(dir + '/' + f) + } else { + stats = fs.lstatSync(process.env.SCRIPT_BASE + '/' + dir + '/' + f); + if (stats.isDirectory()) { + dirs.push(dir + '/' + f) + } } } } diff --git a/group.js b/group.js index 9c3eb1a..81a1890 100644 --- a/group.js +++ b/group.js @@ -12,7 +12,13 @@ class Group { name() { if (this.activityCode.isActivity()) { - return this.room.name.split(' ')[0] + ' ' + this.activityCode.groupNumber + // This is not ideal; when displaying room names we'd like to + // keep only the meaningful part (eg: "Red" when it's "Red Stage", which + // is usually the first part of the name in English, but may be some other + // parts in other languages. This is a compromise where we strip out + // 'Stage' or 'Room' suffix, which should be enough in "regular" major + // competitions setup while not messing up room names in non English setups. + return this.room.name.replace(/Room|Stage/g, '').trim() + ' ' + this.activityCode.groupNumber } else { return this.activityCode.toString() } diff --git a/parser/parser.js b/parser/parser.js index 90cf490..f4ba295 100644 --- a/parser/parser.js +++ b/parser/parser.js @@ -69,6 +69,7 @@ async function parse(text, req, res, ctx, allowParams) { } }) } + out.outputs.push({ type: 'CompetitionWCIF', data: ctx.competition }) } catch (e) { out.outputs.splice(0, 0, {type: 'Exception', data: e.stack}) out.mutations = [] diff --git a/views/dispatch.pug b/views/dispatch.pug index 8fb9d3d..2a523ac 100644 --- a/views/dispatch.pug +++ b/views/dispatch.pug @@ -64,3 +64,6 @@ mixin dispatch(value) +dispatch(data) if value.type == 'ListScriptsOutput' +list_scripts(value.data) + if value.type == 'CompetitionWCIF' + a(href=`data:application/json;charset=utf-8,${encodeURIComponent(JSON.stringify(value.data))}`, target='_blank'). + Open WCIF as JSON in a new tab diff --git a/views/groups.pug b/views/groups.pug index 482733c..f6821fc 100644 --- a/views/groups.pug +++ b/views/groups.pug @@ -18,5 +18,9 @@ mixin groups(data) td a(href='https://wca.link/' + assignment.person.wcaId)= assignment.person.wcaId td= assignment.person.countryIso2 - td= fn.personalBest(assignment.person, data.round).toString() + - var pb = fn.personalBest(assignment.person, data.round) + if pb + td= pb.toString() + else + td= "" td= assignment.set diff --git a/views/index.pug b/views/index.pug index f68ec17..f36f9bd 100644 --- a/views/index.pug +++ b/views/index.pug @@ -1,8 +1,8 @@ html head - title Nats Helper + title Compscript body - h1 Nats Helper + h1 Compscript each competition in competitions p a(href='/'+competition.id)= competition.name diff --git a/views/script.pug b/views/script.pug index 41b7c0c..002fc48 100644 --- a/views/script.pug +++ b/views/script.pug @@ -1,7 +1,7 @@ include dispatch.pug html head - title Nats Helper + title Compscript style include script.css link(rel='stylesheet', href='/cubing-icons.css')