From 744025efe20883d514a33a46b82a5bdd04731387 Mon Sep 17 00:00:00 2001 From: Rodrigo Fernandes Date: Sun, 9 Oct 2016 16:56:58 +0100 Subject: [PATCH 1/7] Generic website page generation --- scripts/release-website.js | 31 ++++++++++--------- .../{ => pages/demo}/demo-assets.partial.html | 0 .../demo}/demo-scripts.partial.html | 0 .../{ => pages/demo}/demo.partial.html | 0 .../index}/index-scripts.partial.html | 0 .../{ => pages/index}/index.partial.html | 0 6 files changed, 17 insertions(+), 14 deletions(-) rename website/templates/{ => pages/demo}/demo-assets.partial.html (100%) rename website/templates/{ => pages/demo}/demo-scripts.partial.html (100%) rename website/templates/{ => pages/demo}/demo.partial.html (100%) rename website/templates/{ => pages/index}/index-scripts.partial.html (100%) rename website/templates/{ => pages/index}/index.partial.html (100%) diff --git a/scripts/release-website.js b/scripts/release-website.js index 60931a4..c238021 100644 --- a/scripts/release-website.js +++ b/scripts/release-website.js @@ -2,25 +2,28 @@ var fs = require('fs'); var hogan = require('hogan.js'); -var template = hogan.compile(readFile('website/templates/template.mustache')); +var root = 'website/templates'; +var pagesRoot = root + '/pages'; -var index = readFile('website/templates/index.partial.html'); -var indexScripts = readFile('website/templates/index-scripts.partial.html'); +var websitePages = fs.readdirSync(root + '/pages'); -var demo = readFile('website/templates/demo.partial.html'); -var demoAssets = readFile('website/templates/demo-assets.partial.html'); -var demoScripts = readFile('website/templates/demo-scripts.partial.html'); +var template = hogan.compile(readFile(root + '/template.mustache')); -var indexHtml = template.render({assets: '', scripts: indexScripts, content: index}); - -writeFile('docs/index.html', indexHtml); - -var demoHtml = template.render({assets: demoAssets, scripts: demoScripts, content: demo}); - -writeFile('docs/demo.html', demoHtml); +websitePages.map(function(page) { + var pagePartial = readFile(pagesRoot + '/' + page + '/' + page + '.partial.html'); + var pageAssets = readFile(pagesRoot + '/' + page + '/' + page + '-assets.partial.html'); + var pageScripts = readFile(pagesRoot + '/' + page + '/' + page + '-scripts.partial.html'); + var pageHtml = template.render({assets: pageAssets, scripts: pageScripts, content: pagePartial}); + writeFile('docs/' + page + '.html', pageHtml); +}); function readFile(filePath) { - return fs.readFileSync(filePath, 'utf8'); + try { + return fs.readFileSync(filePath, 'utf8'); + } catch (_ignore) { + } + + return ''; } function writeFile(filePath, content) { diff --git a/website/templates/demo-assets.partial.html b/website/templates/pages/demo/demo-assets.partial.html similarity index 100% rename from website/templates/demo-assets.partial.html rename to website/templates/pages/demo/demo-assets.partial.html diff --git a/website/templates/demo-scripts.partial.html b/website/templates/pages/demo/demo-scripts.partial.html similarity index 100% rename from website/templates/demo-scripts.partial.html rename to website/templates/pages/demo/demo-scripts.partial.html diff --git a/website/templates/demo.partial.html b/website/templates/pages/demo/demo.partial.html similarity index 100% rename from website/templates/demo.partial.html rename to website/templates/pages/demo/demo.partial.html diff --git a/website/templates/index-scripts.partial.html b/website/templates/pages/index/index-scripts.partial.html similarity index 100% rename from website/templates/index-scripts.partial.html rename to website/templates/pages/index/index-scripts.partial.html diff --git a/website/templates/index.partial.html b/website/templates/pages/index/index.partial.html similarity index 100% rename from website/templates/index.partial.html rename to website/templates/pages/index/index.partial.html From ba13de46a073ab2f9a38e3e7a42a7513adc8fda5 Mon Sep 17 00:00:00 2001 From: Rodrigo Fernandes Date: Sun, 9 Oct 2016 23:01:01 +0100 Subject: [PATCH 2/7] Add support for online diff prettifier * Initial support for GitHub, Bitbucket and GitLab urls * Also support any Git or unified diffs urls * Special thanks to @kevinsimper for the idea --- docs/demo.html | 1 + docs/index.html | 3 +- docs/main.css | 18 + docs/url.html | 331 ++++++++++++++++++ .../templates/pages/demo/demo.partial.html | 2 +- .../templates/pages/index/index.partial.html | 3 +- .../pages/url/url-assets.partial.html | 5 + .../pages/url/url-scripts.partial.html | 130 +++++++ website/templates/pages/url/url.partial.html | 51 +++ 9 files changed, 541 insertions(+), 3 deletions(-) create mode 100644 docs/url.html create mode 100644 website/templates/pages/url/url-assets.partial.html create mode 100644 website/templates/pages/url/url-scripts.partial.html create mode 100644 website/templates/pages/url/url.partial.html diff --git a/docs/demo.html b/docs/demo.html index a4c9ac9..8b9147f 100644 --- a/docs/demo.html +++ b/docs/demo.html @@ -104,6 +104,7 @@
+