From 72e8ffafa6ab8d7155d820911f2f3d7a4bc1e4e9 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Mon, 19 Apr 2021 14:51:45 +0800 Subject: [PATCH] Exclude JS source code from the output --- .../commons}/back-to-top.js | 0 .../commons}/checkbox.js | 0 .../commons}/copy-link.js | 0 .../commons}/img-link.js | 0 .../commons}/search-display.js | 0 .../commons}/sidebar.js | 0 .../commons}/tooltip-loader.js | 0 .../commons}/topbar-switch.js | 0 .../commons}/topbar-title.js | 0 assets/js/_copyright => _javascript/copyright | 0 .../utils}/category-collapse.js | 0 .../utils}/lang-badge.js | 0 .../_utils => _javascript/utils}/pageviews.js | 3 +- .../utils}/smooth-scroll.js | 0 .../_utils => _javascript/utils}/timeago.js | 0 gulpfile.js/tasks/js.js | 40 +++++++++---------- tools/bump.sh | 4 +- 17 files changed, 24 insertions(+), 23 deletions(-) rename {assets/js/_commons => _javascript/commons}/back-to-top.js (100%) rename {assets/js/_commons => _javascript/commons}/checkbox.js (100%) rename {assets/js/_commons => _javascript/commons}/copy-link.js (100%) rename {assets/js/_commons => _javascript/commons}/img-link.js (100%) rename {assets/js/_commons => _javascript/commons}/search-display.js (100%) rename {assets/js/_commons => _javascript/commons}/sidebar.js (100%) rename {assets/js/_commons => _javascript/commons}/tooltip-loader.js (100%) rename {assets/js/_commons => _javascript/commons}/topbar-switch.js (100%) rename {assets/js/_commons => _javascript/commons}/topbar-title.js (100%) rename assets/js/_copyright => _javascript/copyright (100%) rename {assets/js/_utils => _javascript/utils}/category-collapse.js (100%) rename {assets/js/_utils => _javascript/utils}/lang-badge.js (100%) rename {assets/js/_utils => _javascript/utils}/pageviews.js (99%) rename {assets/js/_utils => _javascript/utils}/smooth-scroll.js (100%) rename {assets/js/_utils => _javascript/utils}/timeago.js (100%) diff --git a/assets/js/_commons/back-to-top.js b/_javascript/commons/back-to-top.js similarity index 100% rename from assets/js/_commons/back-to-top.js rename to _javascript/commons/back-to-top.js diff --git a/assets/js/_commons/checkbox.js b/_javascript/commons/checkbox.js similarity index 100% rename from assets/js/_commons/checkbox.js rename to _javascript/commons/checkbox.js diff --git a/assets/js/_commons/copy-link.js b/_javascript/commons/copy-link.js similarity index 100% rename from assets/js/_commons/copy-link.js rename to _javascript/commons/copy-link.js diff --git a/assets/js/_commons/img-link.js b/_javascript/commons/img-link.js similarity index 100% rename from assets/js/_commons/img-link.js rename to _javascript/commons/img-link.js diff --git a/assets/js/_commons/search-display.js b/_javascript/commons/search-display.js similarity index 100% rename from assets/js/_commons/search-display.js rename to _javascript/commons/search-display.js diff --git a/assets/js/_commons/sidebar.js b/_javascript/commons/sidebar.js similarity index 100% rename from assets/js/_commons/sidebar.js rename to _javascript/commons/sidebar.js diff --git a/assets/js/_commons/tooltip-loader.js b/_javascript/commons/tooltip-loader.js similarity index 100% rename from assets/js/_commons/tooltip-loader.js rename to _javascript/commons/tooltip-loader.js diff --git a/assets/js/_commons/topbar-switch.js b/_javascript/commons/topbar-switch.js similarity index 100% rename from assets/js/_commons/topbar-switch.js rename to _javascript/commons/topbar-switch.js diff --git a/assets/js/_commons/topbar-title.js b/_javascript/commons/topbar-title.js similarity index 100% rename from assets/js/_commons/topbar-title.js rename to _javascript/commons/topbar-title.js diff --git a/assets/js/_copyright b/_javascript/copyright similarity index 100% rename from assets/js/_copyright rename to _javascript/copyright diff --git a/assets/js/_utils/category-collapse.js b/_javascript/utils/category-collapse.js similarity index 100% rename from assets/js/_utils/category-collapse.js rename to _javascript/utils/category-collapse.js diff --git a/assets/js/_utils/lang-badge.js b/_javascript/utils/lang-badge.js similarity index 100% rename from assets/js/_utils/lang-badge.js rename to _javascript/utils/lang-badge.js diff --git a/assets/js/_utils/pageviews.js b/_javascript/utils/pageviews.js similarity index 99% rename from assets/js/_utils/pageviews.js rename to _javascript/utils/pageviews.js index b647c34..1b71508 100644 --- a/assets/js/_utils/pageviews.js +++ b/_javascript/utils/pageviews.js @@ -40,7 +40,8 @@ const PvOpts = (function () { hasLocalMeta() { return hasContent("meta[name=pv-cache-path]"); } - } + }; + }()); const PvStorage = (function () { diff --git a/assets/js/_utils/smooth-scroll.js b/_javascript/utils/smooth-scroll.js similarity index 100% rename from assets/js/_utils/smooth-scroll.js rename to _javascript/utils/smooth-scroll.js diff --git a/assets/js/_utils/timeago.js b/_javascript/utils/timeago.js similarity index 100% rename from assets/js/_utils/timeago.js rename to _javascript/utils/timeago.js diff --git a/gulpfile.js/tasks/js.js b/gulpfile.js/tasks/js.js index c9880f1..7b76cae 100644 --- a/gulpfile.js/tasks/js.js +++ b/gulpfile.js/tasks/js.js @@ -10,27 +10,27 @@ const uglify = require('gulp-uglify'); const insert = require('gulp-insert'); const fs = require('fs'); -const JS_ROOT = 'assets/js'; -const jsDest = `${ JS_ROOT }/dist/`; +const JS_SRC = '_javascript'; +const JS_DEST = `assets/js/dist/`; function concatJs(files, output) { return src(files) .pipe(concat(output)) .pipe(rename({ extname: '.min.js' })) - .pipe(dest(jsDest)); + .pipe(dest(JS_DEST)); } function minifyJs() { - return src(`${ jsDest }/*.js`) - .pipe(insert.prepend(fs.readFileSync(`${ JS_ROOT }/_copyright`, 'utf8'))) + return src(`${ JS_DEST }/*.js`) + .pipe(insert.prepend(fs.readFileSync(`${ JS_SRC }/copyright`, 'utf8'))) .pipe(uglify({output: {comments: /^!|@preserve|@license|@cc_on/i}})) - .pipe(dest(jsDest)); + .pipe(dest(JS_DEST)); } const homeJs = () => { return concatJs([ - `${JS_ROOT}/_commons/*.js`, - `${JS_ROOT}/_utils/timeago.js` + `${JS_SRC}/commons/*.js`, + `${JS_SRC}/utils/timeago.js` ], 'home' ); @@ -38,34 +38,34 @@ const homeJs = () => { const postJs = () => { return concatJs([ - `${JS_ROOT}/_commons/*.js`, - `${JS_ROOT}/_utils/timeago.js`, - `${JS_ROOT}/_utils/lang-badge.js`, + `${JS_SRC}/commons/*.js`, + `${JS_SRC}/utils/timeago.js`, + `${JS_SRC}/utils/lang-badge.js`, // 'smooth-scroll.js' must be called after ToC is ready - `${JS_ROOT}/_utils/smooth-scroll.js` + `${JS_SRC}/utils/smooth-scroll.js` ], 'post' ); }; const categoriesJs = () => { return concatJs([ - `${JS_ROOT}/_commons/*.js`, - `${JS_ROOT}/_utils/category-collapse.js` + `${JS_SRC}/commons/*.js`, + `${JS_SRC}/utils/category-collapse.js` ], 'categories' ); }; const pageJs = () => { return concatJs([ - `${JS_ROOT}/_commons/*.js`, - `${JS_ROOT}/_utils/smooth-scroll.js` + `${JS_SRC}/commons/*.js`, + `${JS_SRC}/utils/smooth-scroll.js` ], 'page' ); }; // GA pageviews report const pvreportJs = () => { - return concatJs(`${JS_ROOT}/_utils/pageviews.js`, 'pvreport'); + return concatJs(`${JS_SRC}/utils/pageviews.js`, 'pvreport'); }; const buildJs = parallel(homeJs, postJs, categoriesJs, pageJs, pvreportJs); @@ -76,9 +76,9 @@ exports.liveRebuild = () => { buildJs(); watch([ - `${ JS_ROOT }/_commons/*.js`, - `${ JS_ROOT }/_utils/*.js`, - `${ JS_ROOT }/lib/*.js` + `${ JS_SRC }/commons/*.js`, + `${ JS_SRC }/utils/*.js`, + `${ JS_SRC }/lib/*.js` ], buildJs ) diff --git a/tools/bump.sh b/tools/bump.sh index e71f7ad..5d87f57 100755 --- a/tools/bump.sh +++ b/tools/bump.sh @@ -4,7 +4,7 @@ # # 1. Bump latest version number to files: # - _sass/jekyll-theme-chirpy.scss -# - assets/js/_copyright.js +# - _javascript/copyright # - assets/js/dist/*.js (will be built by gulp later) # - jekyll-theme-chirpy.gemspec # - package.json @@ -28,7 +28,7 @@ manual_release=false ASSETS=( "_sass/jekyll-theme-chirpy.scss" - "assets/js/_copyright" + "_javascript/copyright" ) GEM_SPEC="jekyll-theme-chirpy.gemspec"