From d2b5b16d14c432fcb7b295d44cf2cda9e7a41ebd Mon Sep 17 00:00:00 2001 From: Matthias Benkort <5680256+KtorZ@users.noreply.github.com> Date: Tue, 17 Jan 2023 16:13:31 +0100 Subject: [PATCH] Fix website build (#438) * Fix editors parsing + provide better debugging on malformed input data. * Display CIPs by category, if it exists. This also sorts categories such that 'All' is always first and 'Unclassified' is always last. --- CIP-0049/README.md | 20 +++++--------------- CIP-0074/README.md | 2 +- scripts/build.js | 40 ++++++++++++++++++++++++---------------- templates/cips.hbs | 4 ++-- 4 files changed, 32 insertions(+), 34 deletions(-) diff --git a/CIP-0049/README.md b/CIP-0049/README.md index 003854df6..b1081de80 100644 --- a/CIP-0049/README.md +++ b/CIP-0049/README.md @@ -1,25 +1,15 @@ --- -CIP: 49 -Title: ECDSA and Schnorr signatures in Plutus Core -Authors: Koz Ross (koz@mlabs.city), - Michael Peyton-Jones (michael.peyton-jones@iohk.io), - Iñigo Querejeta Azurmendi (querejeta.azurmendi@iohk.io) +CIP: 49 +Title: ECDSA and Schnorr signatures in Plutus Core +Authors: Koz Ross (koz@mlabs.city), Michael Peyton-Jones (michael.peyton-jones@iohk.io), Iñigo Querejeta Azurmendi (querejeta.azurmendi@iohk.io) Discussions-To: koz@mlabs.city -Comments-Summary: -Comments-URI: Status: Proposed Type: Standards Track -Created: 2022-04-27 -* License: -* License-Code: -* Post-History: -* Requires: -* Replaces: -* Superseded-By: +Created: 2022-04-27 --- ## Simple Summary -Support ECDSA and Schnorr signatures over the SECP256k1 curve in Plutus Core; +Support ECDSA and Schnorr signatures over the SECP256k1 curve in Plutus Core; specifically, allow validation of such signatures as builtins. ## Abstract diff --git a/CIP-0074/README.md b/CIP-0074/README.md index 2607a55af..9006f2867 100644 --- a/CIP-0074/README.md +++ b/CIP-0074/README.md @@ -1,7 +1,7 @@ --- CIP: 74 Title: Set minPoolCost to 0 -Author: Robin of Loxley +Authors: Robin of Loxley Comments-URI: https://forum.cardano.org/t/cip-69-set-minpoolcost-to-0/109309 Status: Proposed Type: Standards diff --git a/scripts/build.js b/scripts/build.js index 84740cb97..c13fefe18 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -14,12 +14,16 @@ handlebars.registerHelper('dateFormat', (d, f) => { return moment(d).format(f); }); -handlebars.registerHelper('getAuthors', function (Authors) { +handlebars.registerHelper('getAuthors', function (data) { + if (data.Authors == undefined) { + throw new Error(`No authors: ${JSON.stringify(data)}`); + } - // Temporary fallback for CI to not fail - if(!Authors) return ''; + const authors = Array.isArray(data.Authors) + ? data.Authors + : data.Authors.split(','); - return Authors.split(',').map(author => { + return authors.map(author => { const [_, name, link] = author.trim().match(/^([^<]+)]+)?>?$/) || [] let type = 'url' if (link === undefined) { @@ -99,7 +103,7 @@ function renderHTML(uriPath, template, data) { fs.writeFileSync(path.join(publicPath, uriPath, 'index.html'), hbTemplate(data), { encoding: 'utf8' }) } -const types = { All: [] } +const categories = { All: [] } function slugify(string) { return string.toLowerCase().replace(/\s/g, '-') @@ -117,9 +121,10 @@ function build() { if (asset === 'README.md') { const cip = loadFrontmatter(assetPath) cip.tableOfContents = getTableOfContents(cip.content.split('\n')) - types[cip.data.Type] = types[cip.data.Type] || [] - types[cip.data.Type].push(cip) - types.All.push(cip) + const category = cip.data.Category || "Unclassified"; + categories[category] = categories[category] || [] + categories[category].push(cip) + categories.All.push(cip) } else { const name = item.toLowerCase().replace(/cip-0*([1-9][0-9]*)/g, 'cip$1') const title = `${name.replace(/cip/g, 'CIP ')} - Annexe`; @@ -143,20 +148,23 @@ function build() { const headerData = [] - Object.keys(types).forEach(type => { - headerData.push({ label: type, path: `/${slugify(type)}/` }) + Object.keys(categories).sort((a, b) => { + if ([a,b].includes("All")) { return a === "All" ? -1 : 1 } + if ([a,b].includes("Unclassified")) { return a === "Unclassified" ? 1 : -1 } + return a > b ? 1 : -1; + }).forEach(category => { + headerData.push({ label: category, path: `/${slugify(category)}/` }) }) - Object.keys(types).forEach(type => { + Object.keys(categories).forEach(category => { - renderHTML(`/${slugify(type)}/`, 'cips', { + renderHTML(`/${slugify(category)}/`, 'cips', { headerData, - cips: types[type], - type, - title: type + cips: categories[category], + category }) - types[type].forEach(cip => { + categories[category].forEach(cip => { renderHTML(`/cips/cip${cip.data.CIP}/`, 'cip', { headerData, cip, diff --git a/templates/cips.hbs b/templates/cips.hbs index 66ea4e525..7b9060d4d 100644 --- a/templates/cips.hbs +++ b/templates/cips.hbs @@ -14,10 +14,10 @@ {{{cip.data.Title}}} {{dateFormat cip.data.Created "DD MMMM YYYY"}} - {{{getAuthors cip.data.Authors}}} + {{{getAuthors cip.data}}} {{cip.data.Status}} {{/each}} -{{/main}} \ No newline at end of file +{{/main}}