From d3ca61a6d73ac0c4ff691b16d7c71b376923d603 Mon Sep 17 00:00:00 2001 From: Philippe Virouleau Date: Sun, 19 Nov 2023 17:23:57 +0100 Subject: [PATCH 1/5] Strip Stage/Room from group name --- group.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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() } From 17eed1e95e6ac6c0c57dd3ba62844d0af98cba53 Mon Sep 17 00:00:00 2001 From: Philippe Virouleau Date: Sun, 19 Nov 2023 17:25:15 +0100 Subject: [PATCH 2/5] Add a JSON/WCIF export --- parser/parser.js | 1 + views/dispatch.pug | 3 +++ 2 files changed, 4 insertions(+) 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 From 1dfe7c856fc4f7913e90cfd6b4ef2a54f791287d Mon Sep 17 00:00:00 2001 From: Philippe Virouleau Date: Sun, 19 Nov 2023 17:24:48 +0100 Subject: [PATCH 3/5] Fix displayed PB when non-existent. --- views/groups.pug | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 From 5cc8107bd62808928370491f8ae9182ee130d244 Mon Sep 17 00:00:00 2001 From: Philippe Virouleau Date: Sat, 25 Nov 2023 15:28:02 +0100 Subject: [PATCH 4/5] s/Nats Helper/Compscript --- views/index.pug | 4 ++-- views/script.pug | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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') From 738e8d54bee73d2539f7717a84007cbe2249933c Mon Sep 17 00:00:00 2001 From: Philippe Virouleau Date: Sat, 25 Nov 2023 15:27:35 +0100 Subject: [PATCH 5/5] Fix nested directories browsing --- competition.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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) + } } } }