From e42d04b327bae4cc0aadacee1c478ced536c3932 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Fri, 13 Oct 2017 01:56:29 -0600 Subject: [PATCH] add HTML page templates - add HTML page templates - fill in UI model to activate all parts of templates - add helpers for use in templates - update build:preview task to apply 404 template to 404 page --- preview-site-src/404.html | 0 preview-site-src/ui-model.yml | 90 ++++++++++++++++++++++++++++++++++++- src/helpers/and.js | 3 ++ src/helpers/eq.js | 3 ++ src/helpers/has-versions.js | 3 ++ src/helpers/inc.js | 3 ++ src/helpers/or.js | 3 ++ src/helpers/page-versions.js | 17 +++++++ src/layouts/404.hbs | 21 +++++++++ src/layouts/default.hbs | 32 ++++++++----- src/partials/article.hbs | 4 ++ src/partials/breadcrumbs.hbs | 16 +++++++ src/partials/footer-content.hbs | 4 ++ src/partials/footer-scripts.hbs | 2 +- src/partials/footer.hbs | 2 + src/partials/head.hbs | 1 + src/partials/header-content.hbs | 46 +++++++++++++++++++ src/partials/header.hbs | 1 + src/partials/main.hbs | 7 +++ src/partials/navigation-domain.hbs | 5 +++ src/partials/navigation-explore.hbs | 20 +++++++++ src/partials/navigation-tree.hbs | 17 +++++++ src/partials/navigation.hbs | 9 ++++ src/partials/page-versions.hbs | 10 +++++ src/partials/toolbar.hbs | 9 ++++ tasks/build-preview.js | 2 +- 26 files changed, 315 insertions(+), 15 deletions(-) create mode 100644 preview-site-src/404.html create mode 100644 src/helpers/and.js create mode 100644 src/helpers/eq.js create mode 100644 src/helpers/has-versions.js create mode 100644 src/helpers/inc.js create mode 100644 src/helpers/or.js create mode 100644 src/helpers/page-versions.js create mode 100644 src/layouts/404.hbs create mode 100644 src/partials/article.hbs create mode 100644 src/partials/breadcrumbs.hbs create mode 100644 src/partials/footer-content.hbs create mode 100644 src/partials/footer.hbs create mode 100644 src/partials/head.hbs create mode 100644 src/partials/header-content.hbs create mode 100644 src/partials/header.hbs create mode 100644 src/partials/main.hbs create mode 100644 src/partials/navigation-domain.hbs create mode 100644 src/partials/navigation-explore.hbs create mode 100644 src/partials/navigation-tree.hbs create mode 100644 src/partials/navigation.hbs create mode 100644 src/partials/page-versions.hbs create mode 100644 src/partials/toolbar.hbs diff --git a/preview-site-src/404.html b/preview-site-src/404.html new file mode 100644 index 0000000..e69de29 diff --git a/preview-site-src/ui-model.yml b/preview-site-src/ui-model.yml index 9ab35c3..b7dfc21 100644 --- a/preview-site-src/ui-model.yml +++ b/preview-site-src/ui-model.yml @@ -1,4 +1,90 @@ site: url: http://localhost:5252 - title: Preview Site -title: Home + title: Brand Docs + domains: + - name: abc + title: Project ABC + versions: + - url: '#' + string: '1.1' + latest: true + - url: '#' + string: '1.0' + - name: xyz + title: Project XYZ + selected: true + versions: &domain_versions + - url: '#' + string: '6.0' + latest: true + selected: true + - url: '#' + string: '5.2' + - url: '#' + string: '5.1' + - url: '#' + string: '5.0' + - name: 123 + title: Project 123 + versions: + - url: '#' + string: '2.2' + latest: true + - url: '#' + string: '2.1' + - url: '#' + string: '2.0' +title: Hardware and Software Requirements +home: false +siteRootUrl: / +editUrl: http://example.com/project-xyz/blob/master/index.adoc +domain: + name: xyz + title: Project XYZ + type: component + version: + string: '6.0' + versioned: true + versions: *domain_versions +breadcrumbs: +- title: Quickstart + url: '#' + currentPath: true +- title: Hardware and Software Requirements + url: '#' + currentPage: true +versions: +- string: '6.0' + url: '#' +- string: '5.2' + url: '#' +- string: '5.1' + url: '#' +navigation: +- title: Project XYZ + url: '#' + currentPath: true + items: + - title: Quickstart + url: '#' + currentPath: true + items: + - title: Hardware and Software Requirements + url: '#' + currentPage: true + items: [] + - title: IDE Integration + url: '#' + items: [] + - title: Application Tutorial + url: '#' + items: [] + - title: Reference + url: '#' + items: + - title: Keyboard Shortcuts + url: '#' + items: [] + - title: Importing and Exporting + url: '#' + items: [] diff --git a/src/helpers/and.js b/src/helpers/and.js new file mode 100644 index 0000000..2ad2237 --- /dev/null +++ b/src/helpers/and.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = (a, b) => a && b diff --git a/src/helpers/eq.js b/src/helpers/eq.js new file mode 100644 index 0000000..16dc287 --- /dev/null +++ b/src/helpers/eq.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = (a, b) => a === b diff --git a/src/helpers/has-versions.js b/src/helpers/has-versions.js new file mode 100644 index 0000000..5b83db0 --- /dev/null +++ b/src/helpers/has-versions.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = (domain) => domain.versioned && domain.versions.length > 1 diff --git a/src/helpers/inc.js b/src/helpers/inc.js new file mode 100644 index 0000000..bb8f7e1 --- /dev/null +++ b/src/helpers/inc.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = (value) => (value || 0) + 1 diff --git a/src/helpers/or.js b/src/helpers/or.js new file mode 100644 index 0000000..354612b --- /dev/null +++ b/src/helpers/or.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = (a, b) => a || b diff --git a/src/helpers/page-versions.js b/src/helpers/page-versions.js new file mode 100644 index 0000000..cb61cd7 --- /dev/null +++ b/src/helpers/page-versions.js @@ -0,0 +1,17 @@ +'use strict' + +// FIXME the UI model should be prepopulated with this collection +module.exports = (domains, domainName, otherPageVersions) => { + const domain = domains.find((candidate) => candidate.name === domainName) + const pageVersions = [] + domain.versions.forEach((domainVersion) => { + const pageVersion = otherPageVersions.find((candidate) => candidate.string === domainVersion.string) + if (pageVersion) { + pageVersions.push(pageVersion) + } else { + pageVersions.push(Object.assign({ missing: true }, domainVersion)) + } + }) + + return pageVersions +} diff --git a/src/layouts/404.hbs b/src/layouts/404.hbs new file mode 100644 index 0000000..c697e1d --- /dev/null +++ b/src/layouts/404.hbs @@ -0,0 +1,21 @@ + + + + + + {{title}}{{#if site.title}} :: {{site.title}}{{/if}} + +{{> head}} + + +{{> header}} +
+
+
+

Page Not Found

+
+
+
+{{> footer}} + + diff --git a/src/layouts/default.hbs b/src/layouts/default.hbs index f013729..4b343a9 100644 --- a/src/layouts/default.hbs +++ b/src/layouts/default.hbs @@ -1,14 +1,24 @@ - - - - - - {{title}}{{#if site.title}} // {{site.title}}{{/if}} - - -{{{contents}}} -{{> footer-scripts}} - + + + + {{title}}{{#if site.title}} :: {{site.title}}{{/if}} + {{#if canonicalUrl}} + + {{/if}} + {{#if description}} + + {{/if}} + {{#if keywords}} + + {{/if}} + +{{> head}} + + +{{> header}} +{{> main}} +{{> footer}} + diff --git a/src/partials/article.hbs b/src/partials/article.hbs new file mode 100644 index 0000000..05c427b --- /dev/null +++ b/src/partials/article.hbs @@ -0,0 +1,4 @@ +
+

{{title}}

+{{{contents}}} +
diff --git a/src/partials/breadcrumbs.hbs b/src/partials/breadcrumbs.hbs new file mode 100644 index 0000000..472c4da --- /dev/null +++ b/src/partials/breadcrumbs.hbs @@ -0,0 +1,16 @@ + diff --git a/src/partials/footer-content.hbs b/src/partials/footer-content.hbs new file mode 100644 index 0000000..dead088 --- /dev/null +++ b/src/partials/footer-content.hbs @@ -0,0 +1,4 @@ + diff --git a/src/partials/footer-scripts.hbs b/src/partials/footer-scripts.hbs index 1aca132..385a43b 100644 --- a/src/partials/footer-scripts.hbs +++ b/src/partials/footer-scripts.hbs @@ -1,2 +1,2 @@ - + diff --git a/src/partials/footer.hbs b/src/partials/footer.hbs new file mode 100644 index 0000000..9d49017 --- /dev/null +++ b/src/partials/footer.hbs @@ -0,0 +1,2 @@ +{{> footer-content}} +{{> footer-scripts}} diff --git a/src/partials/head.hbs b/src/partials/head.hbs new file mode 100644 index 0000000..8036f85 --- /dev/null +++ b/src/partials/head.hbs @@ -0,0 +1 @@ +{{! Add additional tags to head here}} diff --git a/src/partials/header-content.hbs b/src/partials/header-content.hbs new file mode 100644 index 0000000..cc648a6 --- /dev/null +++ b/src/partials/header-content.hbs @@ -0,0 +1,46 @@ + diff --git a/src/partials/header.hbs b/src/partials/header.hbs new file mode 100644 index 0000000..affbeeb --- /dev/null +++ b/src/partials/header.hbs @@ -0,0 +1 @@ +{{> header-content}} diff --git a/src/partials/main.hbs b/src/partials/main.hbs new file mode 100644 index 0000000..80babfa --- /dev/null +++ b/src/partials/main.hbs @@ -0,0 +1,7 @@ +
+{{> navigation}} +
+{{> toolbar}} +{{> article}} +
+
diff --git a/src/partials/navigation-domain.hbs b/src/partials/navigation-domain.hbs new file mode 100644 index 0000000..0b5f61a --- /dev/null +++ b/src/partials/navigation-domain.hbs @@ -0,0 +1,5 @@ + diff --git a/src/partials/navigation-explore.hbs b/src/partials/navigation-explore.hbs new file mode 100644 index 0000000..ff2f511 --- /dev/null +++ b/src/partials/navigation-explore.hbs @@ -0,0 +1,20 @@ + diff --git a/src/partials/navigation-tree.hbs b/src/partials/navigation-tree.hbs new file mode 100644 index 0000000..ca576d4 --- /dev/null +++ b/src/partials/navigation-tree.hbs @@ -0,0 +1,17 @@ +{{#if navigation.length}} + +{{/if}} diff --git a/src/partials/navigation.hbs b/src/partials/navigation.hbs new file mode 100644 index 0000000..5540601 --- /dev/null +++ b/src/partials/navigation.hbs @@ -0,0 +1,9 @@ + diff --git a/src/partials/page-versions.hbs b/src/partials/page-versions.hbs new file mode 100644 index 0000000..de57d1b --- /dev/null +++ b/src/partials/page-versions.hbs @@ -0,0 +1,10 @@ +{{#if (has-versions domain)}} +
+ +
+ {{#each (page-versions site.domains domain.name versions)}} + {{./string}} + {{/each}} +
+
+{{/if}} diff --git a/src/partials/toolbar.hbs b/src/partials/toolbar.hbs new file mode 100644 index 0000000..6898c1f --- /dev/null +++ b/src/partials/toolbar.hbs @@ -0,0 +1,9 @@ + diff --git a/tasks/build-preview.js b/tasks/build-preview.js index 31db775..74fa03b 100644 --- a/tasks/build-preview.js +++ b/tasks/build-preview.js @@ -17,7 +17,7 @@ module.exports = async (src, dest, siteSrc, siteDest) => { .src('**/*.html', { base: siteSrc, cwd: siteSrc }) .pipe( map((file, next) => { - const compiledLayout = layouts['default.hbs'] + const compiledLayout = layouts[file.stem === '404' ? '404.hbs' : 'default.hbs'] const siteRootPath = path.relative(path.dirname(file.path), path.resolve(siteSrc)) mockUIModel['siteRootPath'] = siteRootPath mockUIModel['siteRootUrl'] = path.join(siteRootPath, 'index.html') -- 2.11.0