From 87aa590fb68c65a43c75ba80825079e39e308bf1 Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Thu, 4 Feb 2021 03:47:07 +0000 Subject: [PATCH 01/24] First pass at script for new website --- .gitignore | 1 + ...enerate_new_site_learning_path_markdown.js | 135 ++++++++ scripts/package-lock.json | 290 ++++++++++++++++++ scripts/package.json | 1 + 4 files changed, 427 insertions(+) create mode 100644 scripts/generate_new_site_learning_path_markdown.js diff --git a/.gitignore b/.gitignore index 1ccf4fbf..a43e95e9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ \.DS_Store scripts/node_modules scripts/learningpath +scripts/newsite scripts/.env \ No newline at end of file diff --git a/scripts/generate_new_site_learning_path_markdown.js b/scripts/generate_new_site_learning_path_markdown.js new file mode 100644 index 00000000..b82f9f3c --- /dev/null +++ b/scripts/generate_new_site_learning_path_markdown.js @@ -0,0 +1,135 @@ +// TODO: Get thumnails for each video +// TODO: Refactor this and the old script for re-use +// TODO: GitHub Actions - more pertinent now article is rendered at build time not run time +// TODO: Is rendering to HTML, rather than Markdown, acceptable? +// TODO: New site always renders video - current site only renders video for English pages +// TODO: How to handle new _index pages? +// TODO: Add docs around generating for new site + +(async() => { + const fs = require('fs') + const YAML = require('yaml') + const { EOL } = require('os') + const { join } = require('path') + const getContributors = require('./get_contributors') + const asciidoctor = require('asciidoctor')() + + const urls = YAML.parse(fs.readFileSync('../config/urls.yaml', 'utf-8')) + + const mkdirSync = (dir) => { + try { + fs.mkdirSync(dir) + } catch (e) { + if (e.code !== 'EEXIST') { + console.log(e) + } + } + } + + const getArticleFiles = (path) => { + return fs.readdirSync(path).reduce((articles, filename) => { + const filePath = `${path}/${filename}` + if (filePath.match(/\d\d/) && !filePath.includes('-script.asciidoc')) { + return [...articles, { + filePath, + asciiDoc: fs.readFileSync(filePath, 'utf-8') + }] + } else { + return articles + } + }, []) + } + + const writeMarkdownFile = (filePath, frontMatter, body) => { + const frontMatterTerminator = '---' + const originStatement = '' + const output = [frontMatterTerminator, YAML.stringify(frontMatter).trim(), frontMatterTerminator, body, originStatement].join(EOL) + fs.writeFileSync(filePath, output) + } + + const getYouTubeCode = (section, articleNumber) => { + const firstEntryOfGroupIndex = urls.findIndex(entry => entry.section === section.toLowerCase()) + const currentPageIndexOffset = articleNumber - 1 + const youtubeUrl = urls[firstEntryOfGroupIndex + currentPageIndexOffset].video.youtube + return youtubeUrl.replace('https://www.youtube.com/watch?v=', '') + } + + const sections = [ + { + learning_path_group: 'Introduction', + dirName: 'introduction', + workbook: '01-introduction.asciidoc', + translations: ['de', 'it', 'ja', 'zh', 'ru'], + image: "images/learn/LP_thumbnail_introduction.jpg" + }, + { + learning_path_group: 'Trusted Committer', + dirName: 'trusted-committer', + workbook: '02-trusted-committer.asciidoc', + translations: ['de', 'zh'], + image: "images/learn/LP_thumbnail_trustedcommitter.jpg" + }, + { + learning_path_group: 'Contributor', + dirName: 'contributor', + workbook: '04-contributor.asciidoc', + translations: ['ja', 'zh'], + image: "images/learn/LP_thumbnail_contributor.jpg" + }, + { + learning_path_group: 'Product Owner', + dirName: 'product-owner', + workbook: '03-product-owner.asciidoc', + translations: ['zh'], + image: "images/learn/LP_thumbnail_productowner.jpg" + }, + ] + + mkdirSync('./newsite') + + sections.forEach(({ learning_path_group, dirName, workbook, translations, image }) => { + const baseReadPath = `../${dirName}` + const baseWritePath = `./newsite/${dirName}` + mkdirSync(baseWritePath) + + translations.concat('' /* The English original */).forEach(async (translation) => { + const isTranslation = translation !== '' + + const readPath = join(baseReadPath, translation) + const articles = getArticleFiles(readPath) + articles.forEach(async (article) => { + const articleTitle = article.asciiDoc.match(/== (.*)/)[1] + const articleNumber = article.filePath.split('/').pop().split('-')[0] + const fileName = isTranslation ? join(baseWritePath, [articleNumber, translation, 'md'].join('.')) : join(baseWritePath, [articleNumber, 'md'].join('.')) + const contributors = await getContributors(article.filePath.replace('../', '')) + const weight = parseInt(articleNumber) + + const frontMatter = { + title: articleTitle, + contributors, + image, + featured: weight === 1, + weight, + youtubeCode: getYouTubeCode(learning_path_group, weight) + } + + writeMarkdownFile(fileName, frontMatter, asciidoctor.convert(article.asciiDoc)) + }) + + // Workbooks not translated. + if (!isTranslation) { + const workbookFileName = join(baseWritePath, 'workbook.md') + const contributors = await getContributors(`workbook/${workbook}`) + console.log('workbookFileName', workbookFileName) + const workbookFrontMatter = { + title: 'Workbook', + contributors, + image, + weight: articles.length + 2 + } + + writeMarkdownFile(workbookFileName, workbookFrontMatter) + } + }) + }) +})() diff --git a/scripts/package-lock.json b/scripts/package-lock.json index 9d57dfb2..f6f275f1 100644 --- a/scripts/package-lock.json +++ b/scripts/package-lock.json @@ -4,6 +4,15 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@asciidoctor/core": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@asciidoctor/core/-/core-2.2.1.tgz", + "integrity": "sha512-wdVseZjCcBvFfWSsCGyyvJkSQJ9UmXDdTDKnL+HerM12XQq4eWtk7lniSIKO459ipqImcsrueib47EtkzzRjLw==", + "requires": { + "asciidoctor-opal-runtime": "0.3.0", + "unxhr": "1.0.1" + } + }, "@octokit/endpoint": { "version": "6.0.9", "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.9.tgz", @@ -62,6 +71,99 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.6.tgz", "integrity": "sha512-6QlRuqsQ/Ox/aJEQWBEJG7A9+u7oSYl3mem/K8IzxXG/kAGbV1YPD9Bg9Zw3vyxC/YP+zONKwy8hGkSt1jxFMw==" }, + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==" + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "requires": { + "color-convert": "^2.0.1" + } + }, + "asciidoctor": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/asciidoctor/-/asciidoctor-2.2.1.tgz", + "integrity": "sha512-adH/pDPDZCd4eb1ku7N8WepN+O6Yl0lVQPWE/ep7+0BFkBm4P/Sx8DUqzZ+X+nG6WSZlma5Uu0gNuDgrc7etFg==", + "requires": { + "@asciidoctor/cli": "3.4.0", + "@asciidoctor/core": "2.2.1" + }, + "dependencies": { + "@asciidoctor/cli": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/@asciidoctor/cli/-/cli-3.4.0.tgz", + "integrity": "sha512-jOtxA0I6zB+6z+GGwm9+xhlmGTqCTkFPE902L6fauFlE6v7LxjhLYNxvjDVyn0zMrFLybvoSRcAnM3DcticNoQ==", + "requires": { + "yargs": "15.3.1" + } + } + } + }, + "asciidoctor-opal-runtime": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/asciidoctor-opal-runtime/-/asciidoctor-opal-runtime-0.3.0.tgz", + "integrity": "sha512-YapVwl2qbbs6sIe1dvAlMpBzQksFVTSa2HOduOKFNhZlE9bNmn+moDgGVvjWPbzMPo/g8gItyTHfWB2u7bQxag==", + "requires": { + "glob": "7.1.3", + "unxhr": "1.0.1" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" + }, + "cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" + }, "deprecation": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", @@ -72,11 +174,83 @@ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==" }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==" + }, + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" + }, "is-plain-object": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==" }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "requires": { + "p-locate": "^4.1.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, "node-fetch": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", @@ -90,20 +264,136 @@ "wrappy": "1" } }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "requires": { + "p-limit": "^2.2.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==" + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==" + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + }, + "string-width": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", + "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "requires": { + "ansi-regex": "^5.0.0" + } + }, "universal-user-agent": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", "integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==" }, + "unxhr": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/unxhr/-/unxhr-1.0.1.tgz", + "integrity": "sha512-MAhukhVHyaLGDjyDYhy8gVjWJyhTECCdNsLwlMoGFoNJ3o79fpQhtQuzmAE4IxCMDwraF4cW8ZjpAV0m9CRQbg==" + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" + }, + "wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, + "y18n": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.1.tgz", + "integrity": "sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==" + }, "yaml": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.0.tgz", "integrity": "sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg==" + }, + "yargs": { + "version": "15.3.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.3.1.tgz", + "integrity": "sha512-92O1HWEjw27sBfgmXiixJWT5hRBp2eobqXicLtPBIDBhYB+1HpwZlXmbW2luivBJHBzki+7VyCLRtAkScbTBQA==", + "requires": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.1" + } + }, + "yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } } } } diff --git a/scripts/package.json b/scripts/package.json index d436ee54..3fead96c 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -5,6 +5,7 @@ "main": "substitute_article_urls.js", "dependencies": { "@octokit/graphql": "^4.5.7", + "asciidoctor": "^2.2.1", "dotenv": "^8.2.0", "yaml": "^1.10.0" }, From 2a13696f1aa0098b7684ae487df2a2dfecf9847d Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Thu, 4 Feb 2021 03:52:50 +0000 Subject: [PATCH 02/24] Do not render Product Owner articles (as per current website) --- ...generate_new_site_learning_path_markdown.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts/generate_new_site_learning_path_markdown.js b/scripts/generate_new_site_learning_path_markdown.js index b82f9f3c..635b846c 100644 --- a/scripts/generate_new_site_learning_path_markdown.js +++ b/scripts/generate_new_site_learning_path_markdown.js @@ -60,34 +60,38 @@ dirName: 'introduction', workbook: '01-introduction.asciidoc', translations: ['de', 'it', 'ja', 'zh', 'ru'], - image: "images/learn/LP_thumbnail_introduction.jpg" + image: "images/learn/LP_thumbnail_introduction.jpg", + renderArticles: true }, { learning_path_group: 'Trusted Committer', dirName: 'trusted-committer', workbook: '02-trusted-committer.asciidoc', translations: ['de', 'zh'], - image: "images/learn/LP_thumbnail_trustedcommitter.jpg" + image: "images/learn/LP_thumbnail_trustedcommitter.jpg", + renderArticles: true }, { learning_path_group: 'Contributor', dirName: 'contributor', workbook: '04-contributor.asciidoc', translations: ['ja', 'zh'], - image: "images/learn/LP_thumbnail_contributor.jpg" + image: "images/learn/LP_thumbnail_contributor.jpg", + renderArticles: true }, { learning_path_group: 'Product Owner', dirName: 'product-owner', workbook: '03-product-owner.asciidoc', translations: ['zh'], - image: "images/learn/LP_thumbnail_productowner.jpg" + image: "images/learn/LP_thumbnail_productowner.jpg", + renderArticles: false }, ] mkdirSync('./newsite') - sections.forEach(({ learning_path_group, dirName, workbook, translations, image }) => { + sections.forEach(({ learning_path_group, dirName, workbook, translations, image, renderArticles }) => { const baseReadPath = `../${dirName}` const baseWritePath = `./newsite/${dirName}` mkdirSync(baseWritePath) @@ -113,7 +117,9 @@ youtubeCode: getYouTubeCode(learning_path_group, weight) } - writeMarkdownFile(fileName, frontMatter, asciidoctor.convert(article.asciiDoc)) + const body = renderArticles ? asciidoctor.convert(article.asciiDoc) : '' + + writeMarkdownFile(fileName, frontMatter, body) }) // Workbooks not translated. From 72c89f9c145b71fca78994fd1ba50086a76cfca1 Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Thu, 4 Feb 2021 12:10:48 +0000 Subject: [PATCH 03/24] Remove translations and fix workbook for new site --- scripts/generate_new_site_learning_path_markdown.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/generate_new_site_learning_path_markdown.js b/scripts/generate_new_site_learning_path_markdown.js index 635b846c..ceb1cda6 100644 --- a/scripts/generate_new_site_learning_path_markdown.js +++ b/scripts/generate_new_site_learning_path_markdown.js @@ -2,9 +2,12 @@ // TODO: Refactor this and the old script for re-use // TODO: GitHub Actions - more pertinent now article is rendered at build time not run time // TODO: Is rendering to HTML, rather than Markdown, acceptable? -// TODO: New site always renders video - current site only renders video for English pages +// TODO: Translations // TODO: How to handle new _index pages? // TODO: Add docs around generating for new site +// TODO: Article links go to old website +// TODO: Article title is duplicated above and below the video - do we want this? +// TODO: Just path.join everywhere for cross-platform compaibility (async() => { const fs = require('fs') @@ -102,6 +105,8 @@ const readPath = join(baseReadPath, translation) const articles = getArticleFiles(readPath) articles.forEach(async (article) => { + if (isTranslation) return + const articleTitle = article.asciiDoc.match(/== (.*)/)[1] const articleNumber = article.filePath.split('/').pop().split('-')[0] const fileName = isTranslation ? join(baseWritePath, [articleNumber, translation, 'md'].join('.')) : join(baseWritePath, [articleNumber, 'md'].join('.')) @@ -134,7 +139,10 @@ weight: articles.length + 2 } - writeMarkdownFile(workbookFileName, workbookFrontMatter) + const workbookReadPath = join('..', 'workbook', workbook) + const body = asciidoctor.convert(fs.readFileSync(workbookReadPath, 'utf-8')) + + writeMarkdownFile(workbookFileName, workbookFrontMatter, body) } }) }) From 01461de3b2eb417a1832a6a54f2fc03dd3976bc5 Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Thu, 4 Feb 2021 12:14:03 +0000 Subject: [PATCH 04/24] Fix typo --- scripts/generate_new_site_learning_path_markdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate_new_site_learning_path_markdown.js b/scripts/generate_new_site_learning_path_markdown.js index ceb1cda6..af14312d 100644 --- a/scripts/generate_new_site_learning_path_markdown.js +++ b/scripts/generate_new_site_learning_path_markdown.js @@ -1,4 +1,4 @@ -// TODO: Get thumnails for each video +// TODO: Get thumbnails for each video // TODO: Refactor this and the old script for re-use // TODO: GitHub Actions - more pertinent now article is rendered at build time not run time // TODO: Is rendering to HTML, rather than Markdown, acceptable? From 59f68e7e9e9af887af7f6d385d07f0005fb28146 Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Thu, 4 Feb 2021 12:26:07 +0000 Subject: [PATCH 05/24] Fix typo --- scripts/generate_new_site_learning_path_markdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate_new_site_learning_path_markdown.js b/scripts/generate_new_site_learning_path_markdown.js index af14312d..a27f9229 100644 --- a/scripts/generate_new_site_learning_path_markdown.js +++ b/scripts/generate_new_site_learning_path_markdown.js @@ -7,7 +7,7 @@ // TODO: Add docs around generating for new site // TODO: Article links go to old website // TODO: Article title is duplicated above and below the video - do we want this? -// TODO: Just path.join everywhere for cross-platform compaibility +// TODO: Use path.join everywhere for cross-platform compatibility (async() => { const fs = require('fs') From f9cbd3b14019c31e113e604f18b92890ec4703cb Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Fri, 19 Feb 2021 16:35:52 +0000 Subject: [PATCH 06/24] Refactor mkdirSync into a separate file --- scripts/generate_learning_path_markdown.js | 11 +---------- scripts/generate_new_site_learning_path_markdown.js | 11 +---------- scripts/mkdir_sync.js | 11 +++++++++++ 3 files changed, 13 insertions(+), 20 deletions(-) create mode 100644 scripts/mkdir_sync.js diff --git a/scripts/generate_learning_path_markdown.js b/scripts/generate_learning_path_markdown.js index f9505bc9..f77a5240 100644 --- a/scripts/generate_learning_path_markdown.js +++ b/scripts/generate_learning_path_markdown.js @@ -4,16 +4,7 @@ const { EOL } = require('os') const { join } = require('path') const getContributors = require('./get_contributors') - - const mkdirSync = (dir) => { - try { - fs.mkdirSync(dir) - } catch (e) { - if (e.code !== 'EEXIST') { - console.log(e) - } - } - } + const mkdirSync = require('./mkdir_sync') const getArticleFiles = (path) => { return fs.readdirSync(path).reduce((articles, filename) => { diff --git a/scripts/generate_new_site_learning_path_markdown.js b/scripts/generate_new_site_learning_path_markdown.js index a27f9229..c462f81d 100644 --- a/scripts/generate_new_site_learning_path_markdown.js +++ b/scripts/generate_new_site_learning_path_markdown.js @@ -16,19 +16,10 @@ const { join } = require('path') const getContributors = require('./get_contributors') const asciidoctor = require('asciidoctor')() + const mkdirSync = require('./mkdir_sync') const urls = YAML.parse(fs.readFileSync('../config/urls.yaml', 'utf-8')) - const mkdirSync = (dir) => { - try { - fs.mkdirSync(dir) - } catch (e) { - if (e.code !== 'EEXIST') { - console.log(e) - } - } - } - const getArticleFiles = (path) => { return fs.readdirSync(path).reduce((articles, filename) => { const filePath = `${path}/${filename}` diff --git a/scripts/mkdir_sync.js b/scripts/mkdir_sync.js new file mode 100644 index 00000000..3d273b36 --- /dev/null +++ b/scripts/mkdir_sync.js @@ -0,0 +1,11 @@ +const fs = require('fs') + +module.exports = mkdirSync = (dir) => { + try { + fs.mkdirSync(dir) + } catch (e) { + if (e.code !== 'EEXIST') { + console.log(e) + } + } +} \ No newline at end of file From 14223ef54bed52e2a9b80025b1bad18ed4526db0 Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Fri, 19 Feb 2021 16:40:56 +0000 Subject: [PATCH 07/24] Refactor getArticleFiles into a separate file --- scripts/generate_learning_path_markdown.js | 15 +-------------- .../generate_new_site_learning_path_markdown.js | 15 +-------------- scripts/get_article_files.js | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 28 deletions(-) create mode 100644 scripts/get_article_files.js diff --git a/scripts/generate_learning_path_markdown.js b/scripts/generate_learning_path_markdown.js index f77a5240..25823d79 100644 --- a/scripts/generate_learning_path_markdown.js +++ b/scripts/generate_learning_path_markdown.js @@ -5,20 +5,7 @@ const { join } = require('path') const getContributors = require('./get_contributors') const mkdirSync = require('./mkdir_sync') - - const getArticleFiles = (path) => { - return fs.readdirSync(path).reduce((articles, filename) => { - const filePath = `${path}/${filename}` - if (filePath.match(/\d\d/) && !filePath.includes('-script.asciidoc')) { - return [...articles, { - filePath, - asciiDoc: fs.readFileSync(filePath, 'utf-8') - }] - } else { - return articles - } - }, []) - } + const getArticleFiles = require('./get_article_files') const writeMarkdownFile = (filePath, frontMatter) => { const frontMatterTerminator = '---' diff --git a/scripts/generate_new_site_learning_path_markdown.js b/scripts/generate_new_site_learning_path_markdown.js index c462f81d..910a405d 100644 --- a/scripts/generate_new_site_learning_path_markdown.js +++ b/scripts/generate_new_site_learning_path_markdown.js @@ -17,23 +17,10 @@ const getContributors = require('./get_contributors') const asciidoctor = require('asciidoctor')() const mkdirSync = require('./mkdir_sync') + const getArticleFiles = require('./get_article_files') const urls = YAML.parse(fs.readFileSync('../config/urls.yaml', 'utf-8')) - const getArticleFiles = (path) => { - return fs.readdirSync(path).reduce((articles, filename) => { - const filePath = `${path}/${filename}` - if (filePath.match(/\d\d/) && !filePath.includes('-script.asciidoc')) { - return [...articles, { - filePath, - asciiDoc: fs.readFileSync(filePath, 'utf-8') - }] - } else { - return articles - } - }, []) - } - const writeMarkdownFile = (filePath, frontMatter, body) => { const frontMatterTerminator = '---' const originStatement = '' diff --git a/scripts/get_article_files.js b/scripts/get_article_files.js new file mode 100644 index 00000000..65b57c52 --- /dev/null +++ b/scripts/get_article_files.js @@ -0,0 +1,15 @@ +const fs = require('fs') + +module.exports = getArticleFiles = (path) => { + return fs.readdirSync(path).reduce((articles, filename) => { + const filePath = `${path}/${filename}` + if (filePath.match(/\d\d/) && !filePath.includes('-script.asciidoc')) { + return [...articles, { + filePath, + asciiDoc: fs.readFileSync(filePath, 'utf-8') + }] + } else { + return articles + } + }, []) +} \ No newline at end of file From cb82aa8cf119b33ece3a6b08116617400c8ab994 Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Fri, 19 Feb 2021 16:49:33 +0000 Subject: [PATCH 08/24] Refactor writeMarkdownFile into a separate file --- scripts/generate_learning_path_markdown.js | 11 +---------- scripts/generate_new_site_learning_path_markdown.js | 9 +-------- scripts/write_markdown_file.js | 10 ++++++++++ 3 files changed, 12 insertions(+), 18 deletions(-) create mode 100644 scripts/write_markdown_file.js diff --git a/scripts/generate_learning_path_markdown.js b/scripts/generate_learning_path_markdown.js index 25823d79..20bc283e 100644 --- a/scripts/generate_learning_path_markdown.js +++ b/scripts/generate_learning_path_markdown.js @@ -1,18 +1,9 @@ (async() => { - const fs = require('fs') - const YAML = require('yaml') - const { EOL } = require('os') const { join } = require('path') const getContributors = require('./get_contributors') const mkdirSync = require('./mkdir_sync') const getArticleFiles = require('./get_article_files') - - const writeMarkdownFile = (filePath, frontMatter) => { - const frontMatterTerminator = '---' - const originStatement = '' - const output = [frontMatterTerminator, YAML.stringify(frontMatter).trim(), frontMatterTerminator, originStatement].join(EOL) - fs.writeFileSync(filePath, output) - } + const writeMarkdownFile = require('./write_markdown_file') const sections = [ { diff --git a/scripts/generate_new_site_learning_path_markdown.js b/scripts/generate_new_site_learning_path_markdown.js index 910a405d..e5a99d8c 100644 --- a/scripts/generate_new_site_learning_path_markdown.js +++ b/scripts/generate_new_site_learning_path_markdown.js @@ -12,22 +12,15 @@ (async() => { const fs = require('fs') const YAML = require('yaml') - const { EOL } = require('os') const { join } = require('path') const getContributors = require('./get_contributors') const asciidoctor = require('asciidoctor')() const mkdirSync = require('./mkdir_sync') const getArticleFiles = require('./get_article_files') + const writeMarkdownFile = require('./write_markdown_file') const urls = YAML.parse(fs.readFileSync('../config/urls.yaml', 'utf-8')) - const writeMarkdownFile = (filePath, frontMatter, body) => { - const frontMatterTerminator = '---' - const originStatement = '' - const output = [frontMatterTerminator, YAML.stringify(frontMatter).trim(), frontMatterTerminator, body, originStatement].join(EOL) - fs.writeFileSync(filePath, output) - } - const getYouTubeCode = (section, articleNumber) => { const firstEntryOfGroupIndex = urls.findIndex(entry => entry.section === section.toLowerCase()) const currentPageIndexOffset = articleNumber - 1 diff --git a/scripts/write_markdown_file.js b/scripts/write_markdown_file.js new file mode 100644 index 00000000..31bfe985 --- /dev/null +++ b/scripts/write_markdown_file.js @@ -0,0 +1,10 @@ +const fs = require('fs') +const YAML = require('yaml') +const { EOL } = require('os') + +module.exports = writeMarkdownFile = (filePath, frontMatter, body) => { + const frontMatterTerminator = '---' + const originStatement = '' + const output = [frontMatterTerminator, YAML.stringify(frontMatter).trim(), frontMatterTerminator, body, originStatement].join(EOL) + fs.writeFileSync(filePath, output) +} \ No newline at end of file From 680c64df57af73e67e8a5d499f338a75b7a6ec71 Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Fri, 19 Feb 2021 17:09:56 +0000 Subject: [PATCH 09/24] Refactor section data into a separate file --- scripts/generate_learning_path_markdown.js | 33 ++--------------- ...enerate_new_site_learning_path_markdown.js | 36 +------------------ scripts/section_data.json | 34 ++++++++++++++++++ 3 files changed, 37 insertions(+), 66 deletions(-) create mode 100644 scripts/section_data.json diff --git a/scripts/generate_learning_path_markdown.js b/scripts/generate_learning_path_markdown.js index 20bc283e..d36d8756 100644 --- a/scripts/generate_learning_path_markdown.js +++ b/scripts/generate_learning_path_markdown.js @@ -5,36 +5,7 @@ const getArticleFiles = require('./get_article_files') const writeMarkdownFile = require('./write_markdown_file') - const sections = [ - { - learning_path_group: 'Introduction', - dirName: 'introduction', - workbook: '01-introduction.asciidoc', - translations: ['de', 'it', 'ja', 'zh', 'ru'], - renderArticles: true - }, - { - learning_path_group: 'Trusted Committer', - dirName: 'trusted-committer', - workbook: '02-trusted-committer.asciidoc', - translations: ['de', 'zh'], - renderArticles: true - }, - { - learning_path_group: 'Contributor', - dirName: 'contributor', - workbook: '04-contributor.asciidoc', - translations: ['ja', 'zh'], - renderArticles: true - }, - { - learning_path_group: 'Product Owner', - dirName: 'product-owner', - workbook: '03-product-owner.asciidoc', - translations: ['zh'], - renderArticles: true - }, - ] + const sections = require('./section_data.json') mkdirSync('./learningpath') @@ -59,7 +30,7 @@ layout: 'learning-path-page', show_meta: false, title: `Learning Path - ${learning_path_group} - ${articleTitle}`, - learning_path_article: renderArticles ? article.filePath.replace('../', '') : undefined, + learning_path_article: renderArticles || isTranslation ? article.filePath.replace('../', '') : undefined, learning_path_group, learning_path_menu_title: `${articleNumber} - ${articleTitle}`, learning_path_position: parseInt(articleNumber), diff --git a/scripts/generate_new_site_learning_path_markdown.js b/scripts/generate_new_site_learning_path_markdown.js index e5a99d8c..0143aa6f 100644 --- a/scripts/generate_new_site_learning_path_markdown.js +++ b/scripts/generate_new_site_learning_path_markdown.js @@ -19,6 +19,7 @@ const getArticleFiles = require('./get_article_files') const writeMarkdownFile = require('./write_markdown_file') + const sections = require('./section_data.json') const urls = YAML.parse(fs.readFileSync('../config/urls.yaml', 'utf-8')) const getYouTubeCode = (section, articleNumber) => { @@ -28,41 +29,6 @@ return youtubeUrl.replace('https://www.youtube.com/watch?v=', '') } - const sections = [ - { - learning_path_group: 'Introduction', - dirName: 'introduction', - workbook: '01-introduction.asciidoc', - translations: ['de', 'it', 'ja', 'zh', 'ru'], - image: "images/learn/LP_thumbnail_introduction.jpg", - renderArticles: true - }, - { - learning_path_group: 'Trusted Committer', - dirName: 'trusted-committer', - workbook: '02-trusted-committer.asciidoc', - translations: ['de', 'zh'], - image: "images/learn/LP_thumbnail_trustedcommitter.jpg", - renderArticles: true - }, - { - learning_path_group: 'Contributor', - dirName: 'contributor', - workbook: '04-contributor.asciidoc', - translations: ['ja', 'zh'], - image: "images/learn/LP_thumbnail_contributor.jpg", - renderArticles: true - }, - { - learning_path_group: 'Product Owner', - dirName: 'product-owner', - workbook: '03-product-owner.asciidoc', - translations: ['zh'], - image: "images/learn/LP_thumbnail_productowner.jpg", - renderArticles: false - }, - ] - mkdirSync('./newsite') sections.forEach(({ learning_path_group, dirName, workbook, translations, image, renderArticles }) => { diff --git a/scripts/section_data.json b/scripts/section_data.json new file mode 100644 index 00000000..8572092f --- /dev/null +++ b/scripts/section_data.json @@ -0,0 +1,34 @@ +[ + { + "learning_path_group": "Introduction", + "dirName": "introduction", + "workbook": "01-introduction.asciidoc", + "translations": ["de", "it", "ja", "zh", "ru"], + "image": "images/learn/LP_thumbnail_introduction.jpg", + "renderArticles": true + }, + { + "learning_path_group": "Trusted Committer", + "dirName": "trusted-committer", + "workbook": "02-trusted-committer.asciidoc", + "translations": ["de", "zh"], + "image": "images/learn/LP_thumbnail_trustedcommitter.jpg", + "renderArticles": true + }, + { + "learning_path_group": "Contributor", + "dirName": "contributor", + "workbook": "04-contributor.asciidoc", + "translations": ["ja", "zh"], + "image": "images/learn/LP_thumbnail_contributor.jpg", + "renderArticles": true + }, + { + "learning_path_group": "Product Owner", + "dirName": "product-owner", + "workbook": "03-product-owner.asciidoc", + "translations": ["zh"], + "image": "images/learn/LP_thumbnail_productowner.jpg", + "renderArticles": false + } +] \ No newline at end of file From 0da6b057a26aef3f19a6d9e27c408d8eefee0247 Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Fri, 19 Feb 2021 18:23:05 +0000 Subject: [PATCH 10/24] Parameterise and share generator code for old and new site --- scripts/generate_learning_path_markdown.js | 77 ++++++++---------- ...enerate_new_site_learning_path_markdown.js | 78 +++++++------------ ...enerate_old_site_learning_path_markdown.js | 41 ++++++++++ 3 files changed, 103 insertions(+), 93 deletions(-) create mode 100644 scripts/generate_old_site_learning_path_markdown.js diff --git a/scripts/generate_learning_path_markdown.js b/scripts/generate_learning_path_markdown.js index d36d8756..dc74a247 100644 --- a/scripts/generate_learning_path_markdown.js +++ b/scripts/generate_learning_path_markdown.js @@ -1,67 +1,58 @@ -(async() => { - const { join } = require('path') - const getContributors = require('./get_contributors') - const mkdirSync = require('./mkdir_sync') - const getArticleFiles = require('./get_article_files') - const writeMarkdownFile = require('./write_markdown_file') +const { join } = require('path') +const getContributors = require('./get_contributors') +const mkdirSync = require('./mkdir_sync') +const getArticleFiles = require('./get_article_files') - const sections = require('./section_data.json') +const sections = require('./section_data.json') - mkdirSync('./learningpath') +module.exports = async (writeDir, generatorFn, workbookFn, createTranslationFolder) => { + mkdirSync(`./${writeDir}`) + + sections.forEach(section => { + const { dirName, translations } = section - sections.forEach(({ learning_path_group, dirName, workbook, translations, renderArticles }) => { const baseReadPath = `../${dirName}` - const baseWritePath = `./learningpath/${dirName}` + const baseWritePath = `./${writeDir}/${dirName}` mkdirSync(baseWritePath) translations.concat('' /* The English original */).forEach(async (translation) => { const isTranslation = translation !== '' const writePath = join(baseWritePath, translation) - mkdirSync(writePath) + if (createTranslationFolder) mkdirSync(writePath) const readPath = join(baseReadPath, translation) const articles = getArticleFiles(readPath) articles.forEach(async (article) => { const articleTitle = article.asciiDoc.match(/== (.*)/)[1] const articleNumber = article.filePath.split('/').pop().split('-')[0] - const fileName = articleNumber === '01' ? `${writePath}/index.md` : `${writePath}/${articleNumber}.md` const contributors = await getContributors(article.filePath.replace('../', '')) - const frontMatter = { - layout: 'learning-path-page', - show_meta: false, - title: `Learning Path - ${learning_path_group} - ${articleTitle}`, - learning_path_article: renderArticles || isTranslation ? article.filePath.replace('../', '') : undefined, - learning_path_group, - learning_path_menu_title: `${articleNumber} - ${articleTitle}`, - learning_path_position: parseInt(articleNumber), - learning_path_translation: translation, - no_video: isTranslation, // Videos not available translated. - contributors - } - writeMarkdownFile(fileName, frontMatter) + generatorFn({ + section, + articleTitle, + articleNumber, + isTranslation, + article, + translation, + contributors, + writePath, + baseWritePath + }) }) // Workbooks not translated. if (!isTranslation) { - const workbookFileName = `${writePath}/workbook.md` - const contributors = await getContributors(`workbook/${workbook}`) - console.log('workbookFileName', workbookFileName) - const workbookFrontMatter = { - layout: 'learning-path-page', - show_meta: false, - title: `Learning Path - ${learning_path_group} - Workbook`, - learning_path_article: `workbook/${workbook}`, - learning_path_group, - learning_path_menu_title: `${learning_path_group} Workbook`, - learning_path_position: articles.length - articles.filter(Array.isArray).length + 1, - learning_path_translation: translation, - no_video: true, - contributors - } - - writeMarkdownFile(workbookFileName, workbookFrontMatter) + const workbookFileName = join(baseWritePath, 'workbook.md') + const contributors = await getContributors(`workbook/${section.workbook}`) + const workbookPosition = articles.length + 1 + + workbookFn({ + section, + workbookFileName, + contributors, + workbookPosition + }) } }) }) -})() +} diff --git a/scripts/generate_new_site_learning_path_markdown.js b/scripts/generate_new_site_learning_path_markdown.js index 0143aa6f..3af115b1 100644 --- a/scripts/generate_new_site_learning_path_markdown.js +++ b/scripts/generate_new_site_learning_path_markdown.js @@ -13,13 +13,10 @@ const fs = require('fs') const YAML = require('yaml') const { join } = require('path') - const getContributors = require('./get_contributors') const asciidoctor = require('asciidoctor')() - const mkdirSync = require('./mkdir_sync') - const getArticleFiles = require('./get_article_files') const writeMarkdownFile = require('./write_markdown_file') + const generate = require('./generate_learning_path_markdown') - const sections = require('./section_data.json') const urls = YAML.parse(fs.readFileSync('../config/urls.yaml', 'utf-8')) const getYouTubeCode = (section, articleNumber) => { @@ -29,58 +26,39 @@ return youtubeUrl.replace('https://www.youtube.com/watch?v=', '') } - mkdirSync('./newsite') + const generatorFn = ({ isTranslation, baseWritePath, articleNumber, translation, articleTitle, contributors, image, section, article}) => { + if (isTranslation) return // TODO: New site translations - sections.forEach(({ learning_path_group, dirName, workbook, translations, image, renderArticles }) => { - const baseReadPath = `../${dirName}` - const baseWritePath = `./newsite/${dirName}` - mkdirSync(baseWritePath) + const fileName = isTranslation ? join(baseWritePath, [articleNumber, translation, 'md'].join('.')) : join(baseWritePath, [articleNumber, 'md'].join('.')) + const weight = parseInt(articleNumber) - translations.concat('' /* The English original */).forEach(async (translation) => { - const isTranslation = translation !== '' + const frontMatter = { + title: articleTitle, + contributors, + image: section.image, + featured: weight === 1, + weight, + youtubeCode: getYouTubeCode(section.learning_path_group, weight) + } - const readPath = join(baseReadPath, translation) - const articles = getArticleFiles(readPath) - articles.forEach(async (article) => { - if (isTranslation) return + const body = section.renderArticles ? asciidoctor.convert(article.asciiDoc) : '' - const articleTitle = article.asciiDoc.match(/== (.*)/)[1] - const articleNumber = article.filePath.split('/').pop().split('-')[0] - const fileName = isTranslation ? join(baseWritePath, [articleNumber, translation, 'md'].join('.')) : join(baseWritePath, [articleNumber, 'md'].join('.')) - const contributors = await getContributors(article.filePath.replace('../', '')) - const weight = parseInt(articleNumber) - - const frontMatter = { - title: articleTitle, - contributors, - image, - featured: weight === 1, - weight, - youtubeCode: getYouTubeCode(learning_path_group, weight) - } - - const body = renderArticles ? asciidoctor.convert(article.asciiDoc) : '' + writeMarkdownFile(fileName, frontMatter, body) + } - writeMarkdownFile(fileName, frontMatter, body) - }) + const workbookFn = ({ workbookFileName, contributors, section, workbookPosition }) => { + const workbookFrontMatter = { + title: 'Workbook', + contributors, + image: section.image, + weight: workbookPosition + } - // Workbooks not translated. - if (!isTranslation) { - const workbookFileName = join(baseWritePath, 'workbook.md') - const contributors = await getContributors(`workbook/${workbook}`) - console.log('workbookFileName', workbookFileName) - const workbookFrontMatter = { - title: 'Workbook', - contributors, - image, - weight: articles.length + 2 - } + const workbookReadPath = join('..', 'workbook', section.workbook) + const body = asciidoctor.convert(fs.readFileSync(workbookReadPath, 'utf-8')) - const workbookReadPath = join('..', 'workbook', workbook) - const body = asciidoctor.convert(fs.readFileSync(workbookReadPath, 'utf-8')) + writeMarkdownFile(workbookFileName, workbookFrontMatter, body) + } - writeMarkdownFile(workbookFileName, workbookFrontMatter, body) - } - }) - }) + generate('newsite', generatorFn, workbookFn, false) })() diff --git a/scripts/generate_old_site_learning_path_markdown.js b/scripts/generate_old_site_learning_path_markdown.js new file mode 100644 index 00000000..7612d9c3 --- /dev/null +++ b/scripts/generate_old_site_learning_path_markdown.js @@ -0,0 +1,41 @@ +(async() => { + const writeMarkdownFile = require('./write_markdown_file') + const generate = require('./generate_learning_path_markdown') + + const generatorFn = ({ isTranslation, writePath, articleNumber, translation, articleTitle, contributors, section, article}) => { + const fileName = articleNumber === '01' ? `${writePath}/index.md` : `${writePath}/${articleNumber}.md` + + const frontMatter = { + layout: 'learning-path-page', + show_meta: false, + title: `Learning Path - ${section.learning_path_group} - ${articleTitle}`, + learning_path_article: section.renderArticles || isTranslation ? article.filePath.replace('../', '') : undefined, + learning_path_group: section.learning_path_group, + learning_path_menu_title: `${articleNumber} - ${articleTitle}`, + learning_path_position: parseInt(articleNumber), + learning_path_translation: translation, + no_video: isTranslation, // Videos not available translated. + contributors + } + + writeMarkdownFile(fileName, frontMatter) + } + + const workbookFn = ({ workbookFileName, contributors, section, workbookPosition }) => { + const workbookFrontMatter = { + layout: 'learning-path-page', + show_meta: false, + title: `Learning Path - ${section.learning_path_group} - Workbook`, + learning_path_article: `workbook/${section.workbook}`, + learning_path_group: section.learning_path_group, + learning_path_menu_title: `${section.learning_path_group} Workbook`, + learning_path_position: workbookPosition, + no_video: true, + contributors + } + + writeMarkdownFile(workbookFileName, workbookFrontMatter) + } + + generate('learningpath', generatorFn, workbookFn, true) +})() From aaa49208dc33e80264d2057df4d751db9cde36d2 Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Fri, 19 Feb 2021 18:46:14 +0000 Subject: [PATCH 11/24] Tweaks to make old website output consistent with current output --- scripts/generate_old_site_learning_path_markdown.js | 1 + scripts/write_markdown_file.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/generate_old_site_learning_path_markdown.js b/scripts/generate_old_site_learning_path_markdown.js index 7612d9c3..742da7d5 100644 --- a/scripts/generate_old_site_learning_path_markdown.js +++ b/scripts/generate_old_site_learning_path_markdown.js @@ -30,6 +30,7 @@ learning_path_group: section.learning_path_group, learning_path_menu_title: `${section.learning_path_group} Workbook`, learning_path_position: workbookPosition, + learning_path_translation: '', no_video: true, contributors } diff --git a/scripts/write_markdown_file.js b/scripts/write_markdown_file.js index 31bfe985..b8b87a4f 100644 --- a/scripts/write_markdown_file.js +++ b/scripts/write_markdown_file.js @@ -4,7 +4,7 @@ const { EOL } = require('os') module.exports = writeMarkdownFile = (filePath, frontMatter, body) => { const frontMatterTerminator = '---' - const originStatement = '' - const output = [frontMatterTerminator, YAML.stringify(frontMatter).trim(), frontMatterTerminator, body, originStatement].join(EOL) + const originStatement = '' + const output = [frontMatterTerminator, YAML.stringify(frontMatter).trim(), frontMatterTerminator, body, originStatement].filter(item => !!item).join(EOL) fs.writeFileSync(filePath, output) } \ No newline at end of file From e332db80ff60fcbe00c3695f4c97dcaac275e173 Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Fri, 19 Feb 2021 18:51:02 +0000 Subject: [PATCH 12/24] Remove resolved TODOs --- scripts/generate_new_site_learning_path_markdown.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/generate_new_site_learning_path_markdown.js b/scripts/generate_new_site_learning_path_markdown.js index 3af115b1..d408cdc4 100644 --- a/scripts/generate_new_site_learning_path_markdown.js +++ b/scripts/generate_new_site_learning_path_markdown.js @@ -1,9 +1,6 @@ // TODO: Get thumbnails for each video -// TODO: Refactor this and the old script for re-use // TODO: GitHub Actions - more pertinent now article is rendered at build time not run time -// TODO: Is rendering to HTML, rather than Markdown, acceptable? // TODO: Translations -// TODO: How to handle new _index pages? // TODO: Add docs around generating for new site // TODO: Article links go to old website // TODO: Article title is duplicated above and below the video - do we want this? From 013bd5ce8d92b9b8df7f9ff8ae82d86f749e974b Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Fri, 19 Feb 2021 18:56:35 +0000 Subject: [PATCH 13/24] Update docs following refactor --- scripts/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/README.md b/scripts/README.md index decd70b7..2648259f 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -15,7 +15,7 @@ For example, to point all links to innersourcecommons.org: node substitute_article_urls.js isc ``` -## generate_learning_path_markdown.js +## generate_old_site_learning_path_markdown.js A node script to generate markdown files required for hosting Learning Path on innersourcecommons.org. @@ -27,7 +27,7 @@ TOKEN= ### Usage: ``` npm ci -node generate_learning_path_markdown.js +node generate_old_site_learning_path_markdown.js ``` ## How to update innersourcecommons.org with new articles @@ -38,11 +38,11 @@ Anytime there are _new_ articles written, you need to run the script that genera 1. Is this the first time that articles have been written for this section in this language? If so, then do both of the following: - * update the ["sections" config](https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/scripts/generate_learning_path_markdown.js#L37) with the language code of the articles for the appropriate section. + * update the ["sections" config](https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/scripts/section_data.json) with the language code of the articles for the appropriate section. Open a pull request for the change. * update the [Learning Path landing page](https://github.com/InnerSourceCommons/innersourcecommons.org/blob/master/resources/learningpath/index.md) with a link to your new language pages. -3. Run **generate_learning_path_markdown.js** as described above. +3. Run **generate_old_site_learning_path_markdown.js** as described above. 3. `cp -r learningpath/* /resources/learningpath/`. 3. Open a pull request with the modified files in the [InnerSourceCommons/innersourcecommons.org] repo. From 3feef35ec2e62764b0f6751f12dd47e67453e26c Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Fri, 19 Feb 2021 20:05:09 +0000 Subject: [PATCH 14/24] Get video specific thumbnails from YouTube --- scripts/generate_new_site_learning_path_markdown.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/generate_new_site_learning_path_markdown.js b/scripts/generate_new_site_learning_path_markdown.js index d408cdc4..ecbdab6a 100644 --- a/scripts/generate_new_site_learning_path_markdown.js +++ b/scripts/generate_new_site_learning_path_markdown.js @@ -1,4 +1,3 @@ -// TODO: Get thumbnails for each video // TODO: GitHub Actions - more pertinent now article is rendered at build time not run time // TODO: Translations // TODO: Add docs around generating for new site @@ -28,14 +27,15 @@ const fileName = isTranslation ? join(baseWritePath, [articleNumber, translation, 'md'].join('.')) : join(baseWritePath, [articleNumber, 'md'].join('.')) const weight = parseInt(articleNumber) + const youtubeCode = getYouTubeCode(section.learning_path_group, weight) const frontMatter = { title: articleTitle, contributors, - image: section.image, + image: `https://img.youtube.com/vi/${youtubeCode}/mqdefault.jpg`, featured: weight === 1, weight, - youtubeCode: getYouTubeCode(section.learning_path_group, weight) + youtubeCode } const body = section.renderArticles ? asciidoctor.convert(article.asciiDoc) : '' From 9e5400b7e80e1e779770591a974c2937f5e4826f Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Fri, 19 Feb 2021 20:05:30 +0000 Subject: [PATCH 15/24] Add docs around generating for new site --- scripts/README.md | 19 ++++++++++++++++++- ...enerate_new_site_learning_path_markdown.js | 1 - 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/scripts/README.md b/scripts/README.md index 2648259f..1611d32b 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -49,6 +49,23 @@ Open a pull request for the change. Note that these steps only needs to happen when there are new articles written. Changes to existing articles will automatically show up on the [innersourcecommons.org] site. -[innersourcecommons.org]: http://www.innersourcecommons.org/ +## How to update innersourcecommons.net + +Anytime there are _any changes_, you need to run the script that generates the updated pages on the [innersourcecommons.net] site. + +1. Clone the [InnerSourceCommons/InnerSourceLearningPath] and [InnerSourceCommons/innersourcecommons.net] repos. +1. Is this the first time that articles have been written for this section in this language? +If so, then do both of the following: + + * update the ["sections" config](https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/scripts/section_data.json) with the language code of the articles for the appropriate section. +Open a pull request for the change. + +3. Run **generate_new_site_learning_path_markdown.js** as described above. +3. `cp -r newsite/ /content/learn/learning-path/`. +3. Open a pull request with the modified files in the [InnerSourceCommons/innersourcecommons.net] repo. + +[innersourcecommons.org]: https://innersourcecommons.org/ +[innersourcecommons.net]: https://innersourcecommons.net/ [InnerSourceCommons/InnerSourceLearningPath]: https://github.com/InnerSourceCommons/InnerSourceLearningPath/ [InnerSourceCommons/innersourcecommons.org]: https://github.com/InnerSourceCommons/innersourcecommons.org +[InnerSourceCommons/innersourcecommons.net]: https://github.com/InnerSourceCommons/innersourcecommons.net diff --git a/scripts/generate_new_site_learning_path_markdown.js b/scripts/generate_new_site_learning_path_markdown.js index ecbdab6a..1d77de74 100644 --- a/scripts/generate_new_site_learning_path_markdown.js +++ b/scripts/generate_new_site_learning_path_markdown.js @@ -1,6 +1,5 @@ // TODO: GitHub Actions - more pertinent now article is rendered at build time not run time // TODO: Translations -// TODO: Add docs around generating for new site // TODO: Article links go to old website // TODO: Article title is duplicated above and below the video - do we want this? // TODO: Use path.join everywhere for cross-platform compatibility From 72a37760be9f08cc4f001153d2f0faa996ff91e8 Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Fri, 19 Feb 2021 20:15:24 +0000 Subject: [PATCH 16/24] Strip title for new site --- scripts/generate_new_site_learning_path_markdown.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/generate_new_site_learning_path_markdown.js b/scripts/generate_new_site_learning_path_markdown.js index 1d77de74..cae31a8e 100644 --- a/scripts/generate_new_site_learning_path_markdown.js +++ b/scripts/generate_new_site_learning_path_markdown.js @@ -1,7 +1,6 @@ // TODO: GitHub Actions - more pertinent now article is rendered at build time not run time // TODO: Translations // TODO: Article links go to old website -// TODO: Article title is duplicated above and below the video - do we want this? // TODO: Use path.join everywhere for cross-platform compatibility (async() => { @@ -37,7 +36,8 @@ youtubeCode } - const body = section.renderArticles ? asciidoctor.convert(article.asciiDoc) : '' + const titleStripped = article.asciiDoc.replace(/== (.*)/, '') + const body = section.renderArticles ? asciidoctor.convert(titleStripped) : '' writeMarkdownFile(fileName, frontMatter, body) } From 989d594a0fb376b56d7bfdeb08c7312d4c4462e3 Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Fri, 19 Feb 2021 20:50:43 +0000 Subject: [PATCH 17/24] Add isc.net urls --- config/urls.yaml | 54 +++++++++++++++++++ ...enerate_new_site_learning_path_markdown.js | 1 - 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/config/urls.yaml b/config/urls.yaml index 55604915..45a7ff28 100644 --- a/config/urls.yaml +++ b/config/urls.yaml @@ -9,6 +9,8 @@ video: # URL on the innersourcecommons.org site. isc: https://innersourcecommons.org/resources/learningpath/introduction/index + # URL on the innersourcecommons.net site. + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/01 # URL on the O'Reilly learning plarform. oreilly: https://learning.oreilly.com/videos/introduction-to-innersource/9781492041504/9781492041504-video321606 # URL on YouTube. @@ -20,255 +22,307 @@ github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/introduction/01-introduction.asciidoc # URL on the innersourcecommons.org site. isc: https://innersourcecommons.org/resources/learningpath/introduction/index + # URL on the innersourcecommons.net site. + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/01 # URL on the O'Reilly learning plarform. oreilly: '' - section: introduction video: isc: https://innersourcecommons.org/resources/learningpath/introduction/02/ + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/02/ oreilly: https://learning.oreilly.com/videos/introduction-to-innersource/9781492041504/9781492041504-video321607 youtube: https://www.youtube.com/watch?v=v9fL-E3ZVdc article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/introduction/02-problems-solved.asciidoc isc: https://innersourcecommons.org/resources/learningpath/introduction/02/ + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/02/ oreilly: '' - section: introduction video: isc: https://innersourcecommons.org/resources/learningpath/introduction/03/ + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/03/ oreilly: https://learning.oreilly.com/videos/introduction-to-innersource/9781492041504/9781492041504-video321608 youtube: https://www.youtube.com/watch?v=jPPwnaEBd8U article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/introduction/03-how-works.asciidoc isc: https://innersourcecommons.org/resources/learningpath/introduction/03/ + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/03/ oreilly: '' - section: introduction video: isc: https://innersourcecommons.org/resources/learningpath/introduction/04/ + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/04/ oreilly: https://learning.oreilly.com/videos/introduction-to-innersource/9781492041504/9781492041504-video321609 youtube: https://www.youtube.com/watch?v=PFLmOWCEpi4 article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/introduction/04-benefits.asciidoc isc: https://innersourcecommons.org/resources/learningpath/introduction/04/ + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/04/ oreilly: '' - section: introduction video: isc: https://innersourcecommons.org/resources/learningpath/introduction/05/ + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/05/ oreilly: https://learning.oreilly.com/videos/introduction-to-innersource/9781492041504/9781492041504-video321610 youtube: https://www.youtube.com/watch?v=rLiDsM3w5YM article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/introduction/05-principles.asciidoc isc: https://innersourcecommons.org/resources/learningpath/introduction/05/ + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/05/ oreilly: '' - section: introduction video: isc: https://innersourcecommons.org/resources/learningpath/introduction/06/ + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/06/ oreilly: https://learning.oreilly.com/videos/introduction-to-innersource/9781492041504/9781492041504-video321611 youtube: https://www.youtube.com/watch?v=cFmg-c9IunM article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/introduction/06-conclusion.asciidoc isc: https://innersourcecommons.org/resources/learningpath/introduction/06/ + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/06/ oreilly: '' - section: trusted committer video: isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/index + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/01 oreilly: https://learning.oreilly.com/videos/the-trusted-committer/9781492047599/9781492047599-video323925 youtube: https://www.youtube.com/watch?v=2FdD9Gup6Yc article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/trusted-committer/01-introduction.asciidoc isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/index + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/01 oreilly: '' - section: trusted committer video: isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/02/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/02/ oreilly: https://learning.oreilly.com/videos/the-trusted-committer/9781492047599/9781492047599-video323926 youtube: https://www.youtube.com/watch?v=QQ1z9DHlbhg article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/trusted-committer/02-ensuring-product-quality.asciidoc isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/02/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/02/ oreilly: '' - section: trusted committer video: isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/03/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/03/ oreilly: https://learning.oreilly.com/videos/the-trusted-committer/9781492047599/9781492047599-video323927 youtube: https://www.youtube.com/watch?v=aLGtTTzkQec article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/trusted-committer/03-keeping-the-community-healthy.asciidoc isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/03/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/03/ oreilly: '' - section: trusted committer video: isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/04/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/04/ oreilly: https://learning.oreilly.com/videos/the-trusted-committer/9781492047599/9781492047599-video323928 youtube: https://www.youtube.com/watch?v=452IVT7TKsE article: anchor: pass:[#upleveling] github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/trusted-committer/04-uplevelling-community-members.asciidoc isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/04/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/04/ oreilly: '' - section: trusted committer video: isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/05/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/05/ oreilly: https://learning.oreilly.com/videos/the-trusted-committer/9781492047599/9781492047599-video323929 youtube: https://www.youtube.com/watch?v=0Ztb6k5Y17o article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/trusted-committer/05-lowering-the-barriers-to-entry.asciidoc isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/05/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/05/ oreilly: '' - section: trusted committer video: isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/06/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/06/ oreilly: https://learning.oreilly.com/videos/the-trusted-committer/9781492047599/9781492047599-video323930 youtube: https://www.youtube.com/watch?v=sqE-Uif_giA article: anchor: pass:[#advocating] github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/trusted-committer/06-advocating-for-the-communitys-needs.asciidoc isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/06/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/06/ oreilly: '' - section: trusted committer video: isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/07/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/07/ oreilly: https://learning.oreilly.com/videos/the-trusted-committer/9781492047599/9781492047599-video323931 youtube: https://www.youtube.com/watch?v=nZp8jlr9l-k article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/trusted-committer/07-becoming-a-trusted-committer.asciidoc isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/07/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/07/ oreilly: '' - section: trusted committer video: isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/08/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/08/ oreilly: https://learning.oreilly.com/videos/the-trusted-committer/9781492047599/9781492047599-video323932 youtube: https://www.youtube.com/watch?v=qlVpZn_2KMs article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/trusted-committer/08-conclusion.asciidoc isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/08/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/08/ oreilly: '' - section: product owner video: isc: https://innersourcecommons.org/resources/learningpath/product-owner/index + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/01 oreilly: https://learning.oreilly.com/videos/innersource-product-owners/9781492046707/9781492046707-video325229 youtube: https://www.youtube.com/watch?v=urbkSMsJXZ0 article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/product-owner/01-opening-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/product-owner/index + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/01 oreilly: '' - section: product owner video: isc: https://innersourcecommons.org/resources/learningpath/product-owner/02/ + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/02/ oreilly: https://learning.oreilly.com/videos/innersource-product-owners/9781492046707/9781492046707-video325230 youtube: https://www.youtube.com/watch?v=PQwlatm5Kak article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/product-owner/02-how-difficult-it-is-to-be-a-middle-manager-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/product-owner/02/ + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/02/ oreilly: '' - section: product owner video: isc: https://innersourcecommons.org/resources/learningpath/product-owner/03/ + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/03/ oreilly: https://learning.oreilly.com/videos/innersource-product-owners/9781492046707/9781492046707-video325231 youtube: https://www.youtube.com/watch?v=UGX7khGbtx0 article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/product-owner/03-major-benefits-are-built-into-the-innersource-process-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/product-owner/03/ + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/03/ oreilly: '' - section: product owner video: isc: https://innersourcecommons.org/resources/learningpath/product-owner/04/ + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/04/ oreilly: https://learning.oreilly.com/videos/innersource-product-owners/9781492046707/9781492046707-video325232 youtube: https://www.youtube.com/watch?v=afXNJjt2ReI article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/product-owner/04-new-roles-and-responsibilities-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/product-owner/04/ + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/04/ oreilly: '' - section: product owner video: isc: https://innersourcecommons.org/resources/learningpath/product-owner/05/ + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/05/ oreilly: https://learning.oreilly.com/videos/innersource-product-owners/9781492046707/9781492046707-video325233 youtube: https://www.youtube.com/watch?v=LO5ouFdgyBY article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/product-owner/05-recap-takeaways-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/product-owner/05/ + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/05/ oreilly: '' - section: product owner video: isc: https://innersourcecommons.org/resources/learningpath/product-owner/06/ + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/06/ oreilly: https://learning.oreilly.com/videos/innersource-product-owners/9781492046707/9781492046707-video325234 youtube: https://www.youtube.com/watch?v=0beNc9V-tro article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/product-owner/06-closing-and-contact-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/product-owner/06/ + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/06/ oreilly: '' - section: contributor video: isc: https://innersourcecommons.org/resources/learningpath/contributor/index + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/01 oreilly: https://learning.oreilly.com/learning-paths/learning-path-the/0636920338833/0636920338802-video329499 youtube: https://www.youtube.com/watch?v=ncPO1fz5fRg article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/contributor/01-introduction-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/contributor/index + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/01 oreilly: '' - section: contributor video: isc: https://innersourcecommons.org/resources/learningpath/contributor/02/ + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/02/ oreilly: https://learning.oreilly.com/learning-paths/learning-path-the/0636920338833/0636920338802-video329500 youtube: https://www.youtube.com/watch?v=v3aRZkbTSmY article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/contributor/02-becoming-a-contributor-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/contributor/02/ + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/02/ oreilly: '' - section: contributor video: isc: https://innersourcecommons.org/resources/learningpath/contributor/03/ + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/03/ oreilly: https://learning.oreilly.com/learning-paths/learning-path-the/0636920338833/0636920338802-video329501 youtube: https://www.youtube.com/watch?v=iQu-l3j2kCg article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/contributor/03-contributor-ethos-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/contributor/03/ + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/03/ oreilly: '' - section: contributor video: isc: https://innersourcecommons.org/resources/learningpath/contributor/04/ + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/04/ oreilly: https://learning.oreilly.com/learning-paths/learning-path-the/0636920338833/0636920338802-video329502 youtube: https://www.youtube.com/watch?v=wv3uylJC4K0 article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/contributor/04-mechanics-of-contributing-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/contributor/04/ + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/04/ oreilly: '' - section: contributor video: isc: https://innersourcecommons.org/resources/learningpath/contributor/05/ + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/05/ oreilly: https://learning.oreilly.com/learning-paths/learning-path-the/0636920338833/0636920338802-video329503 youtube: https://www.youtube.com/watch?v=HMBW0B1XPi0 article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/contributor/05-benefits-of-contribution-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/contributor/05/ + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/05/ oreilly: '' - section: contributor video: isc: https://innersourcecommons.org/resources/learningpath/contributor/06/ + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/06/ oreilly: https://learning.oreilly.com/learning-paths/learning-path-the/0636920338833/0636920338802-video329504 youtube: https://www.youtube.com/watch?v=5SztKQyeUiM article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/contributor/06-conclusion-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/contributor/06/ + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/06/ oreilly: '' diff --git a/scripts/generate_new_site_learning_path_markdown.js b/scripts/generate_new_site_learning_path_markdown.js index cae31a8e..b7277b4c 100644 --- a/scripts/generate_new_site_learning_path_markdown.js +++ b/scripts/generate_new_site_learning_path_markdown.js @@ -1,6 +1,5 @@ // TODO: GitHub Actions - more pertinent now article is rendered at build time not run time // TODO: Translations -// TODO: Article links go to old website // TODO: Use path.join everywhere for cross-platform compatibility (async() => { From bba404afab68eea4f0533ef39959958c39b1d49e Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Fri, 19 Feb 2021 20:56:06 +0000 Subject: [PATCH 18/24] Add .node-version file - some scripts use node 12 features --- scripts/.node-version | 1 + 1 file changed, 1 insertion(+) create mode 100644 scripts/.node-version diff --git a/scripts/.node-version b/scripts/.node-version new file mode 100644 index 00000000..3cacc0b9 --- /dev/null +++ b/scripts/.node-version @@ -0,0 +1 @@ +12 \ No newline at end of file From 60f4929f282724b1626ebb13dfea0875df99474f Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Fri, 19 Feb 2021 21:38:44 +0000 Subject: [PATCH 19/24] Make scripts cross-platform friendly --- scripts/generate_learning_path_markdown.js | 12 ++++++------ scripts/generate_new_site_learning_path_markdown.js | 3 +-- scripts/generate_old_site_learning_path_markdown.js | 5 +++-- scripts/get_article_files.js | 3 ++- scripts/substitute_article_urls.js | 7 ++++--- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/scripts/generate_learning_path_markdown.js b/scripts/generate_learning_path_markdown.js index dc74a247..97c1722b 100644 --- a/scripts/generate_learning_path_markdown.js +++ b/scripts/generate_learning_path_markdown.js @@ -1,4 +1,4 @@ -const { join } = require('path') +const { join, basename, relative } = require('path') const getContributors = require('./get_contributors') const mkdirSync = require('./mkdir_sync') const getArticleFiles = require('./get_article_files') @@ -6,13 +6,13 @@ const getArticleFiles = require('./get_article_files') const sections = require('./section_data.json') module.exports = async (writeDir, generatorFn, workbookFn, createTranslationFolder) => { - mkdirSync(`./${writeDir}`) + mkdirSync(join('.', writeDir)) sections.forEach(section => { const { dirName, translations } = section - const baseReadPath = `../${dirName}` - const baseWritePath = `./${writeDir}/${dirName}` + const baseReadPath = join('..', dirName) + const baseWritePath = join('.', writeDir, dirName) mkdirSync(baseWritePath) translations.concat('' /* The English original */).forEach(async (translation) => { @@ -24,8 +24,8 @@ module.exports = async (writeDir, generatorFn, workbookFn, createTranslationFold const articles = getArticleFiles(readPath) articles.forEach(async (article) => { const articleTitle = article.asciiDoc.match(/== (.*)/)[1] - const articleNumber = article.filePath.split('/').pop().split('-')[0] - const contributors = await getContributors(article.filePath.replace('../', '')) + const articleNumber = basename(article.filePath).split('-')[0] + const contributors = await getContributors(relative('..', article.filePath)) generatorFn({ section, diff --git a/scripts/generate_new_site_learning_path_markdown.js b/scripts/generate_new_site_learning_path_markdown.js index b7277b4c..4bc94bb8 100644 --- a/scripts/generate_new_site_learning_path_markdown.js +++ b/scripts/generate_new_site_learning_path_markdown.js @@ -1,6 +1,5 @@ // TODO: GitHub Actions - more pertinent now article is rendered at build time not run time // TODO: Translations -// TODO: Use path.join everywhere for cross-platform compatibility (async() => { const fs = require('fs') @@ -10,7 +9,7 @@ const writeMarkdownFile = require('./write_markdown_file') const generate = require('./generate_learning_path_markdown') - const urls = YAML.parse(fs.readFileSync('../config/urls.yaml', 'utf-8')) + const urls = YAML.parse(fs.readFileSync(join('..', 'config', 'urls.yaml'), 'utf-8')) const getYouTubeCode = (section, articleNumber) => { const firstEntryOfGroupIndex = urls.findIndex(entry => entry.section === section.toLowerCase()) diff --git a/scripts/generate_old_site_learning_path_markdown.js b/scripts/generate_old_site_learning_path_markdown.js index 742da7d5..f17db471 100644 --- a/scripts/generate_old_site_learning_path_markdown.js +++ b/scripts/generate_old_site_learning_path_markdown.js @@ -1,15 +1,16 @@ (async() => { const writeMarkdownFile = require('./write_markdown_file') const generate = require('./generate_learning_path_markdown') + const path = require('path') const generatorFn = ({ isTranslation, writePath, articleNumber, translation, articleTitle, contributors, section, article}) => { - const fileName = articleNumber === '01' ? `${writePath}/index.md` : `${writePath}/${articleNumber}.md` + const fileName = articleNumber === '01' ? path.join(writePath, 'index.md') : path.join(writePath, `${articleNumber}.md`) const frontMatter = { layout: 'learning-path-page', show_meta: false, title: `Learning Path - ${section.learning_path_group} - ${articleTitle}`, - learning_path_article: section.renderArticles || isTranslation ? article.filePath.replace('../', '') : undefined, + learning_path_article: section.renderArticles || isTranslation ? path.relative('..', article.filePath) : undefined, learning_path_group: section.learning_path_group, learning_path_menu_title: `${articleNumber} - ${articleTitle}`, learning_path_position: parseInt(articleNumber), diff --git a/scripts/get_article_files.js b/scripts/get_article_files.js index 65b57c52..798a3ee6 100644 --- a/scripts/get_article_files.js +++ b/scripts/get_article_files.js @@ -1,8 +1,9 @@ const fs = require('fs') +const { join } = require('path') module.exports = getArticleFiles = (path) => { return fs.readdirSync(path).reduce((articles, filename) => { - const filePath = `${path}/${filename}` + const filePath = join(path, filename) if (filePath.match(/\d\d/) && !filePath.includes('-script.asciidoc')) { return [...articles, { filePath, diff --git a/scripts/substitute_article_urls.js b/scripts/substitute_article_urls.js index 4de8cada..e5559389 100644 --- a/scripts/substitute_article_urls.js +++ b/scripts/substitute_article_urls.js @@ -1,14 +1,15 @@ const fs = require('fs') const YAML = require('yaml') +const { join } = require('path') const target = process.argv[2] -const urlsFile = fs.readFileSync('../config/urls.yaml', 'utf8') +const urlsFile = fs.readFileSync(join('..', 'config', 'urls.yaml'), 'utf8') const urls = YAML.parse(urlsFile).map(({ video, article }) => [video, article]).flat() const getArticleFiles = (path) => { return fs.readdirSync(path).map((filename) => { - const filePath = `${path}/${filename}` + const filePath = join(path, filename) if (fs.lstatSync(filePath).isDirectory()) { return getArticleFiles(filePath) } else { @@ -19,7 +20,7 @@ const getArticleFiles = (path) => { } }).flat() } -const articleFiles = [getArticleFiles('../introduction'), getArticleFiles('../product-owner'), getArticleFiles('../trusted-committer'), getArticleFiles('../contributor')].flat() +const articleFiles = [getArticleFiles(join('..', 'introduction')), getArticleFiles(join('..', 'product-owner')), getArticleFiles(join('..', 'trusted-committer')), getArticleFiles(join('..', 'contributor'))].flat() const substituted = articleFiles.map((articleFile) => { let asciiDoc = articleFile.asciiDoc From 0b10074da8a29fd10c6cdd0b76aa18eca89ceaf7 Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Fri, 19 Feb 2021 21:43:28 +0000 Subject: [PATCH 20/24] Update README --- scripts/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/README.md b/scripts/README.md index 1611d32b..d4421193 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -15,11 +15,11 @@ For example, to point all links to innersourcecommons.org: node substitute_article_urls.js isc ``` -## generate_old_site_learning_path_markdown.js +## generate_old_site_learning_path_markdown.js, generate_new_site_learning_path_markdown.js -A node script to generate markdown files required for hosting Learning Path on innersourcecommons.org. +Node scripts to generate markdown files required for hosting Learning Path on innersourcecommons.org and innersourcecommons.net. -This script requires a [GitHub access token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token), as it uses the GitHub API to get Learning Path contributors. Your token does not require any scopes, as the Learning Path is Open Source. To provide this, create a `.env` file in this directory in the following format: +These scripts require a [GitHub access token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token), as they use the GitHub API to get Learning Path contributors. Your token does not require any scopes, as the Learning Path is Open Source. To provide this, create a `.env` file in this directory in the following format: ``` TOKEN= ``` @@ -28,6 +28,7 @@ TOKEN= ``` npm ci node generate_old_site_learning_path_markdown.js +node generate_new_site_learning_path_markdown.js ``` ## How to update innersourcecommons.org with new articles From d7fec7a96dfd51b27911ecda18d6f645c0309b8e Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Sat, 20 Feb 2021 16:41:45 +0000 Subject: [PATCH 21/24] New website translations --- scripts/generate_new_site_learning_path_markdown.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/generate_new_site_learning_path_markdown.js b/scripts/generate_new_site_learning_path_markdown.js index 4bc94bb8..bca764b9 100644 --- a/scripts/generate_new_site_learning_path_markdown.js +++ b/scripts/generate_new_site_learning_path_markdown.js @@ -1,5 +1,4 @@ // TODO: GitHub Actions - more pertinent now article is rendered at build time not run time -// TODO: Translations (async() => { const fs = require('fs') @@ -19,8 +18,6 @@ } const generatorFn = ({ isTranslation, baseWritePath, articleNumber, translation, articleTitle, contributors, image, section, article}) => { - if (isTranslation) return // TODO: New site translations - const fileName = isTranslation ? join(baseWritePath, [articleNumber, translation, 'md'].join('.')) : join(baseWritePath, [articleNumber, 'md'].join('.')) const weight = parseInt(articleNumber) const youtubeCode = getYouTubeCode(section.learning_path_group, weight) @@ -35,7 +32,7 @@ } const titleStripped = article.asciiDoc.replace(/== (.*)/, '') - const body = section.renderArticles ? asciidoctor.convert(titleStripped) : '' + const body = section.renderArticles || isTranslation ? asciidoctor.convert(titleStripped) : '' writeMarkdownFile(fileName, frontMatter, body) } From 1b76ec03730c89dc669317cd623230e14de73d66 Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Sat, 20 Feb 2021 16:47:42 +0000 Subject: [PATCH 22/24] Update README with instructions for translations and links --- scripts/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/README.md b/scripts/README.md index d4421193..31ac81c5 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -58,9 +58,10 @@ Anytime there are _any changes_, you need to run the script that generates the u 1. Is this the first time that articles have been written for this section in this language? If so, then do both of the following: - * update the ["sections" config](https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/scripts/section_data.json) with the language code of the articles for the appropriate section. -Open a pull request for the change. + * update the ["sections" config](https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/scripts/section_data.json) with the language code of the articles for the appropriate section and open a pull request for the change + * make sure this language appears in the [website config](https://github.com/InnerSourceCommons/innersourcecommons.net/blob/master/config.yaml) and there are the relevant [index pages](https://github.com/InnerSourceCommons/innersourcecommons.net/blob/master/content/learn/_index.ru.md) +3. Run `node substitute_article_urls.js isc.net` as described above. This changes the asciidoc source files' links to point at [innnersourcecommons.net] - do not commit this change! 3. Run **generate_new_site_learning_path_markdown.js** as described above. 3. `cp -r newsite/ /content/learn/learning-path/`. 3. Open a pull request with the modified files in the [InnerSourceCommons/innersourcecommons.net] repo. From cae0708177cb6aa95c4b18e990178f75c5025f5c Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Sat, 27 Feb 2021 17:21:09 +0000 Subject: [PATCH 23/24] Rename scripts to hugo/jekyll --- scripts/README.md | 10 +++++----- ...down.js => generate_hugo_learning_path_markdown.js} | 0 ...wn.js => generate_jekyll_learning_path_markdown.js} | 0 3 files changed, 5 insertions(+), 5 deletions(-) rename scripts/{generate_new_site_learning_path_markdown.js => generate_hugo_learning_path_markdown.js} (100%) rename scripts/{generate_old_site_learning_path_markdown.js => generate_jekyll_learning_path_markdown.js} (100%) diff --git a/scripts/README.md b/scripts/README.md index 31ac81c5..d997c465 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -15,7 +15,7 @@ For example, to point all links to innersourcecommons.org: node substitute_article_urls.js isc ``` -## generate_old_site_learning_path_markdown.js, generate_new_site_learning_path_markdown.js +## generate_jekyll_learning_path_markdown.js, generate_hugo_learning_path_markdown.js Node scripts to generate markdown files required for hosting Learning Path on innersourcecommons.org and innersourcecommons.net. @@ -27,8 +27,8 @@ TOKEN= ### Usage: ``` npm ci -node generate_old_site_learning_path_markdown.js -node generate_new_site_learning_path_markdown.js +node generate_jekyll_learning_path_markdown.js +node generate_hugo_learning_path_markdown.js ``` ## How to update innersourcecommons.org with new articles @@ -43,7 +43,7 @@ If so, then do both of the following: Open a pull request for the change. * update the [Learning Path landing page](https://github.com/InnerSourceCommons/innersourcecommons.org/blob/master/resources/learningpath/index.md) with a link to your new language pages. -3. Run **generate_old_site_learning_path_markdown.js** as described above. +3. Run **generate_jekyll_learning_path_markdown.js** as described above. 3. `cp -r learningpath/* /resources/learningpath/`. 3. Open a pull request with the modified files in the [InnerSourceCommons/innersourcecommons.org] repo. @@ -62,7 +62,7 @@ If so, then do both of the following: * make sure this language appears in the [website config](https://github.com/InnerSourceCommons/innersourcecommons.net/blob/master/config.yaml) and there are the relevant [index pages](https://github.com/InnerSourceCommons/innersourcecommons.net/blob/master/content/learn/_index.ru.md) 3. Run `node substitute_article_urls.js isc.net` as described above. This changes the asciidoc source files' links to point at [innnersourcecommons.net] - do not commit this change! -3. Run **generate_new_site_learning_path_markdown.js** as described above. +3. Run **generate_hugo_learning_path_markdown.js** as described above. 3. `cp -r newsite/ /content/learn/learning-path/`. 3. Open a pull request with the modified files in the [InnerSourceCommons/innersourcecommons.net] repo. diff --git a/scripts/generate_new_site_learning_path_markdown.js b/scripts/generate_hugo_learning_path_markdown.js similarity index 100% rename from scripts/generate_new_site_learning_path_markdown.js rename to scripts/generate_hugo_learning_path_markdown.js diff --git a/scripts/generate_old_site_learning_path_markdown.js b/scripts/generate_jekyll_learning_path_markdown.js similarity index 100% rename from scripts/generate_old_site_learning_path_markdown.js rename to scripts/generate_jekyll_learning_path_markdown.js From ba4513e61aeec76d249e389fbd24af7fdee67de8 Mon Sep 17 00:00:00 2001 From: Tom Sadler Date: Sat, 27 Feb 2021 17:22:09 +0000 Subject: [PATCH 24/24] Update script link in origin statement --- scripts/write_markdown_file.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/write_markdown_file.js b/scripts/write_markdown_file.js index b8b87a4f..c2a5189f 100644 --- a/scripts/write_markdown_file.js +++ b/scripts/write_markdown_file.js @@ -4,7 +4,7 @@ const { EOL } = require('os') module.exports = writeMarkdownFile = (filePath, frontMatter, body) => { const frontMatterTerminator = '---' - const originStatement = '' + const originStatement = '' const output = [frontMatterTerminator, YAML.stringify(frontMatter).trim(), frontMatterTerminator, body, originStatement].filter(item => !!item).join(EOL) fs.writeFileSync(filePath, output) } \ No newline at end of file