This is an automated email from the ASF dual-hosted git repository. zregvart pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-website.git
commit 6ecd6a4d49147f0867e1a1b5d28a7e068f0b37e2 Author: Aemie <aemi...@hotmail.co.uk> AuthorDate: Mon May 25 17:03:57 2020 +0530 CAMEL-14578: Reformat files at build time to force compliance with code standards --- .../gulp.d/tasks/build-preview-pages.js | 13 +- antora-ui-camel/gulp.d/tasks/build.js | 38 +++--- antora-ui-camel/package.json | 1 + antora-ui-camel/src/helpers/withMenuData.js | 2 +- antora-ui-camel/src/js/01-nav.js | 2 +- .../src/js/vendor/algoliasearch.bundle.js | 141 ++++++++++++--------- 6 files changed, 114 insertions(+), 83 deletions(-) diff --git a/antora-ui-camel/gulp.d/tasks/build-preview-pages.js b/antora-ui-camel/gulp.d/tasks/build-preview-pages.js index 03b3537..9a282ed 100644 --- a/antora-ui-camel/gulp.d/tasks/build-preview-pages.js +++ b/antora-ui-camel/gulp.d/tasks/build-preview-pages.js @@ -91,13 +91,16 @@ function registerHelpers (src) { } function registerTemplatedHelpers (src) { - return vfs.src('helpers/*.js.template', { base: src, cwd: src }) + return vfs + .src('helpers/*.js.template', { base: src, cwd: src }) .pipe(data(() => ({ manifest: fs.readFileSync('./public/_/data/rev-manifest.json').toString() }))) .pipe(template()) - .pipe(map((file, enc, next) => { - handlebars.registerHelper(file.stem.replace('.js', ''), requireFromString(file.contents.toString())) - next() - })) + .pipe( + map((file, enc, next) => { + handlebars.registerHelper(file.stem.replace('.js', ''), requireFromString(file.contents.toString())) + next() + }) + ) } function compileLayouts (src, layouts) { diff --git a/antora-ui-camel/gulp.d/tasks/build.js b/antora-ui-camel/gulp.d/tasks/build.js index 8909a87..b48f5a0 100644 --- a/antora-ui-camel/gulp.d/tasks/build.js +++ b/antora-ui-camel/gulp.d/tasks/build.js @@ -77,7 +77,8 @@ module.exports = (src, dest, preview) => () => { .pipe(buffer()) .pipe(terser()) .pipe(rev()), - vfs.src('css/site.css', { ...opts, sourcemaps }) + vfs + .src('css/site.css', { ...opts, sourcemaps }) .pipe(postcss(postcssPlugins)) .pipe(rev()), vfs.src('font/*.{ttf,woff*(2)}', opts), @@ -88,29 +89,36 @@ module.exports = (src, dest, preview) => () => { imagemin.gifsicle(), imagemin.jpegtran(), imagemin.optipng(), - imagemin.svgo({ plugins: [ - { removeViewBox: false }, - { cleanupIDs: { remove: false } }, - { removeTitle: false }, - { removeDesc: false }, - ] }), + imagemin.svgo({ + plugins: [ + { removeViewBox: false }, + { cleanupIDs: { remove: false } }, + { removeTitle: false }, + { removeDesc: false }, + ], + }), ]) ), vfs.src('helpers/*.js', opts), vfs.src('layouts/*.hbs', opts), vfs.src('partials/*.hbs', opts) - ).pipe(vfs.dest(dest, { sourcemaps: sourcemaps && '.' })) + ) + .pipe(vfs.dest(dest, { sourcemaps: sourcemaps && '.' })) .pipe(rev.manifest()) .pipe(vfs.dest(path.join(dest, 'data'))) - .pipe(map((file, enc, next) => { - manifest = file.contents.toString() - next(null, null) - })) + .pipe( + map((file, enc, next) => { + manifest = file.contents.toString() + next(null, null) + }) + ) .pipe(vfs.src('helpers/*.js.template', opts)) .pipe(data(() => ({ manifest: manifest }))) .pipe(template()) - .pipe(rename((path) => { - path.extname = '' // strip .template - })) + .pipe( + rename((path) => { + path.extname = '' // strip .template + }) + ) .pipe(vfs.dest(dest)) } diff --git a/antora-ui-camel/package.json b/antora-ui-camel/package.json index 0333c7f..67e3918 100644 --- a/antora-ui-camel/package.json +++ b/antora-ui-camel/package.json @@ -15,6 +15,7 @@ ], "scripts": { "build": "gulp bundle", + "format": "gulp format", "preview": "gulp preview" }, "devDependencies": { diff --git a/antora-ui-camel/src/helpers/withMenuData.js b/antora-ui-camel/src/helpers/withMenuData.js index 3bd96e3..5d179c4 100644 --- a/antora-ui-camel/src/helpers/withMenuData.js +++ b/antora-ui-camel/src/helpers/withMenuData.js @@ -25,7 +25,7 @@ const createMenu = (item) => { } } -const menuData = mainMenu.filter((item) => (typeof (item.parent) === 'undefined')).map(createMenu) +const menuData = mainMenu.filter((item) => typeof item.parent === 'undefined').map(createMenu) module.exports = (options) => { const siteRootPath = options.data.root.siteRootPath diff --git a/antora-ui-camel/src/js/01-nav.js b/antora-ui-camel/src/js/01-nav.js index 6a5f64f..d993125 100644 --- a/antora-ui-camel/src/js/01-nav.js +++ b/antora-ui-camel/src/js/01-nav.js @@ -89,7 +89,7 @@ var rect = panel.getBoundingClientRect() var effectiveHeight = rect.height var navStyle = window.getComputedStyle(nav) - if (navStyle.position === 'sticky') effectiveHeight -= (rect.top - parseFloat(navStyle.top)) + if (navStyle.position === 'sticky') effectiveHeight -= rect.top - parseFloat(navStyle.top) panel.scrollTop = Math.max(0, (el.getBoundingClientRect().height - effectiveHeight) * 0.5 + el.offsetTop) } diff --git a/antora-ui-camel/src/js/vendor/algoliasearch.bundle.js b/antora-ui-camel/src/js/vendor/algoliasearch.bundle.js index 743092d..e92c1a8 100644 --- a/antora-ui-camel/src/js/vendor/algoliasearch.bundle.js +++ b/antora-ui-camel/src/js/vendor/algoliasearch.bundle.js @@ -25,82 +25,101 @@ } } - search.addEventListener('keyup', debounce((key) => { - if (search.value.trim() === '') { - container.className = 'navbar-search results-hidden' - results.innerHTML = '' - cancel.style.display = 'none' - return - } - if (key.which === 27) { - container.className = 'navbar-search results-hidden' - results.innerHTML = '' - return - } - cancel.style.display = 'block' - index.search(search.value, { - hitsPerPage: 10, - }) - .then((results) => { - const hits = results.hits - const data = hits.reduce((data, hit) => { - const d = {} - d.url = hit.url - var breadcrumbs = Object.values(hit.hierarchy).slice(1).filter((lvl) => lvl !== null).join(' » ') - if (breadcrumbs !== '') { - d.breadcrumbs = breadcrumbs - } else { - d.breadcrumbs = hit.hierarchy.lvl0 - } - if (hit._snippetResult !== undefined) { - d.snippet = hit._snippetResult.content.value - } else { - d.snippet = '' - } + search.addEventListener( + 'keyup', + debounce((key) => { + if (search.value.trim() === '') { + container.className = 'navbar-search results-hidden' + results.innerHTML = '' + cancel.style.display = 'none' + return + } + if (key.which === 27) { + container.className = 'navbar-search results-hidden' + results.innerHTML = '' + return + } + cancel.style.display = 'block' + index + .search(search.value, { + hitsPerPage: 10, + }) + .then((results) => { + const hits = results.hits + const data = hits.reduce((data, hit) => { + const d = {} + d.url = hit.url + var breadcrumbs = Object.values(hit.hierarchy) + .slice(1) + .filter((lvl) => lvl !== null) + .join(' » ') + if (breadcrumbs !== '') { + d.breadcrumbs = breadcrumbs + } else { + d.breadcrumbs = hit.hierarchy.lvl0 + } + if (hit._snippetResult !== undefined) { + d.snippet = hit._snippetResult.content.value + } else { + d.snippet = '' + } - const section = hit.hierarchy.lvl0 - data[section] = data[section] || [] - data[section].push(d) + const section = hit.hierarchy.lvl0 + data[section] = data[section] || [] + data[section].push(d) - return data - }, {}) + return data + }, {}) - return data - }) - .then((data) => { - if (Object.entries(data).length === 0 && data.constructor === Object) { - return ` + return data + }) + .then((data) => { + if (Object.entries(data).length === 0 && data.constructor === Object) { + return ` <header class="no_search_results">Nothing Found</header> ` - } else { - return ` + } else { + return ` <dl> - ${Object.keys(data).map((section) => ` + ${Object.keys(data) + .map( + (section) => ` <dt>${section}</dt> - ${data[section].map((hit) => ` + ${data[section] + .map( + (hit) => ` <a href="${hit.url}"> <dd> <header class="result_header">${hit.breadcrumbs}</header> <summary class="result_summary">${hit.snippet}</summary> </dd> </a> - `).join('')} - `).join('')} + ` + ) + .join('')} + ` + ) + .join('')} </dl> ` - } - }) - .then((markup) => { - results.innerHTML = markup - container.className = 'navbar-search' - }) - }, 150)) - window.addEventListener('mouseup', debounce((element) => { - if (element.target !== container && element.target.parentNode !== container) { - container.className = 'navbar-search results-hidden' - results.innerHTML = '' - } - }), 150) + } + }) + .then((markup) => { + results.innerHTML = markup + container.className = 'navbar-search' + }) + }, 150) + ) + window.addEventListener( + 'mouseup', + debounce((element) => { + if (element.target !== container && element.target.parentNode !== container) { + container.className = 'navbar-search results-hidden' + results.innerHTML = '' + } + }), + 150 + ) cancel.addEventListener('click', function () { container.className = 'navbar-search results-hidden' results.innerHTML = ''