From f69b8af91a687da80b7063eeadc0d54008117e99 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Fri, 2 Nov 2018 09:01:45 +0800 Subject: [PATCH] fix: remove lib folder --- .gitignore | 5 +- lib/plugins/disqus.js | 54 ---- lib/plugins/disqus.min.js | 1 - lib/plugins/external-script.js | 28 -- lib/plugins/external-script.min.js | 1 - lib/plugins/front-matter.js | 496 ----------------------------- lib/plugins/front-matter.min.js | 1 - lib/plugins/ga.js | 41 --- lib/plugins/ga.min.js | 1 - lib/plugins/gitalk.js | 20 -- lib/plugins/gitalk.min.js | 1 - lib/plugins/zoom-image.js | 40 --- lib/plugins/zoom-image.min.js | 1 - 13 files changed, 3 insertions(+), 687 deletions(-) delete mode 100644 lib/plugins/disqus.js delete mode 100644 lib/plugins/disqus.min.js delete mode 100644 lib/plugins/external-script.js delete mode 100644 lib/plugins/external-script.min.js delete mode 100644 lib/plugins/front-matter.js delete mode 100644 lib/plugins/front-matter.min.js delete mode 100644 lib/plugins/ga.js delete mode 100644 lib/plugins/ga.min.js delete mode 100644 lib/plugins/gitalk.js delete mode 100644 lib/plugins/gitalk.min.js delete mode 100644 lib/plugins/zoom-image.js delete mode 100644 lib/plugins/zoom-image.min.js diff --git a/.gitignore b/.gitignore index 556ff6c..7235d84 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ /themes/* !.gitkeep node_modules -/lib/ -.idea \ No newline at end of file +lib +.idea + diff --git a/lib/plugins/disqus.js b/lib/plugins/disqus.js deleted file mode 100644 index be3d107..0000000 --- a/lib/plugins/disqus.js +++ /dev/null @@ -1,54 +0,0 @@ -(function () { -var fixedPath = location.href.replace('/-/', '/#/'); -if (fixedPath !== location.href) { - location.href = fixedPath; -} - -function install(hook, vm) { - var dom = Docsify.dom; - var disqus = vm.config.disqus; - if (!disqus) { - throw Error('$docsify.disqus is required') - } - - hook.init(function (_) { - var script = dom.create('script'); - - script.async = true; - script.src = "https://" + disqus + ".disqus.com/embed.js"; - script.setAttribute('data-timestamp', Number(new Date())); - dom.appendTo(dom.body, script); - }); - - hook.mounted(function (_) { - var div = dom.create('div'); - div.id = 'disqus_thread'; - var main = dom.getNode('#main'); - div.style = "width: " + (main.clientWidth) + "px; margin: 0 auto 20px;"; - dom.appendTo(dom.find('.content'), div); - - // eslint-disable-next-line - window.disqus_config = function() { - this.page.url = location.origin + '/-' + vm.route.path; - this.page.identifier = vm.route.path; - this.page.title = document.title; - }; - }); - - hook.doneEach(function (_) { - if (typeof window.DISQUS !== 'undefined') { - window.DISQUS.reset({ - reload: true, - config: function () { - this.page.url = location.origin + '/-' + vm.route.path; - this.page.identifier = vm.route.path; - this.page.title = document.title; - } - }); - } - }); -} - -$docsify.plugins = [].concat(install, $docsify.plugins); - -}()); diff --git a/lib/plugins/disqus.min.js b/lib/plugins/disqus.min.js deleted file mode 100644 index d28857f..0000000 --- a/lib/plugins/disqus.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(){var i=location.href.replace("/-/","/#/");i!==location.href&&(location.href=i),$docsify.plugins=[].concat(function(i,o){var n=Docsify.dom,e=o.config.disqus;if(!e)throw Error("$docsify.disqus is required");i.init(function(i){var t=n.create("script");t.async=!0,t.src="https://"+e+".disqus.com/embed.js",t.setAttribute("data-timestamp",Number(new Date)),n.appendTo(n.body,t)}),i.mounted(function(i){var t=n.create("div");t.id="disqus_thread";var e=n.getNode("#main");t.style="width: "+e.clientWidth+"px; margin: 0 auto 20px;",n.appendTo(n.find(".content"),t),window.disqus_config=function(){this.page.url=location.origin+"/-"+o.route.path,this.page.identifier=o.route.path,this.page.title=document.title}}),i.doneEach(function(i){void 0!==window.DISQUS&&window.DISQUS.reset({reload:!0,config:function(){this.page.url=location.origin+"/-"+o.route.path,this.page.identifier=o.route.path,this.page.title=document.title}})})},$docsify.plugins)}(); diff --git a/lib/plugins/external-script.js b/lib/plugins/external-script.js deleted file mode 100644 index 9d0b332..0000000 --- a/lib/plugins/external-script.js +++ /dev/null @@ -1,28 +0,0 @@ -(function () { -function handleExternalScript() { - var container = Docsify.dom.getNode('#main'); - var scripts = Docsify.dom.findAll(container, 'script'); - - for (var i = scripts.length; i--;) { - var script = scripts[i]; - - if (script && script.src) { - var newScript = document.createElement('script'); - - Array.prototype.slice.call(script.attributes).forEach(function (attribute) { - newScript[attribute.name] = attribute.value; - }); - - script.parentNode.insertBefore(newScript, script); - script.parentNode.removeChild(script); - } - } -} - -var install = function (hook) { - hook.doneEach(handleExternalScript); -}; - -window.$docsify.plugins = [].concat(install, window.$docsify.plugins); - -}()); diff --git a/lib/plugins/external-script.min.js b/lib/plugins/external-script.min.js deleted file mode 100644 index c4f8026..0000000 --- a/lib/plugins/external-script.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(){function e(){for(var o=Docsify.dom.getNode("#main"),e=Docsify.dom.findAll(o,"script"),n=e.length;n--;){var i=e[n];if(i&&i.src){var t=document.createElement("script");Array.prototype.slice.call(i.attributes).forEach(function(o){t[o.name]=o.value}),i.parentNode.insertBefore(t,i),i.parentNode.removeChild(i)}}}window.$docsify.plugins=[].concat(function(o){o.doneEach(e)},window.$docsify.plugins)}(); diff --git a/lib/plugins/front-matter.js b/lib/plugins/front-matter.js deleted file mode 100644 index 9a625ab..0000000 --- a/lib/plugins/front-matter.js +++ /dev/null @@ -1,496 +0,0 @@ -(function () { -/** - * Fork https://github.com/egoist/docute/blob/master/src/utils/yaml.js - */ -/* eslint-disable */ -/* -YAML parser for Javascript -Author: Diogo Costa -This program is released under the MIT License as follows: -Copyright (c) 2011 Diogo Costa (costa.h4evr@gmail.com) -Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -/** - * @name YAML - * @namespace -*/ - -var errors = []; -var reference_blocks = []; -var processing_time = 0; -var regex$1 = { - regLevel: new RegExp('^([\\s\\-]+)'), - invalidLine: new RegExp('^\\-\\-\\-|^\\.\\.\\.|^\\s*#.*|^\\s*$'), - dashesString: new RegExp('^\\s*\\"([^\\"]*)\\"\\s*$'), - quotesString: new RegExp("^\\s*\\'([^\\']*)\\'\\s*$"), - float: new RegExp('^[+-]?[0-9]+\\.[0-9]+(e[+-]?[0-9]+(\\.[0-9]+)?)?$'), - integer: new RegExp('^[+-]?[0-9]+$'), - array: new RegExp('\\[\\s*(.*)\\s*\\]'), - map: new RegExp('\\{\\s*(.*)\\s*\\}'), - key_value: new RegExp('([a-z0-9_-][ a-z0-9_-]*):( .+)', 'i'), - single_key_value: new RegExp('^([a-z0-9_-][ a-z0-9_-]*):( .+?)$', 'i'), - key: new RegExp('([a-z0-9_-][ a-z0-9_-]+):( .+)?', 'i'), - item: new RegExp('^-\\s+'), - trim: new RegExp('^\\s+|\\s+$'), - comment: new RegExp('([^\\\'\\"#]+([\\\'\\"][^\\\'\\"]*[\\\'\\"])*)*(#.*)?') - }; - -/** - * @class A block of lines of a given level. - * @param {int} lvl The block's level. - * @private - */ -function Block(lvl) { - return { - /* The block's parent */ - parent: null, - /* Number of children */ - length: 0, - /* Block's level */ - level: lvl, - /* Lines of code to process */ - lines: [], - /* Blocks with greater level */ - children: [], - /* Add a block to the children collection */ - addChild: function(obj) { - this.children.push(obj); - obj.parent = this; - ++this.length; - } - } -} - -function parser$1(str) { - var regLevel = regex$1['regLevel']; - var invalidLine = regex$1['invalidLine']; - var lines = str.split('\n'); - var m; - var level = 0, - curLevel = 0; - - var blocks = []; - - var result = new Block(-1); - var currentBlock = new Block(0); - result.addChild(currentBlock); - var levels = []; - var line = ''; - - blocks.push(currentBlock); - levels.push(level); - - for (var i = 0, len = lines.length; i < len; ++i) { - line = lines[i]; - - if (line.match(invalidLine)) { - continue - } - - if ((m = regLevel.exec(line))) { - level = m[1].length; - } else { level = 0; } - - if (level > curLevel) { - var oldBlock = currentBlock; - currentBlock = new Block(level); - oldBlock.addChild(currentBlock); - blocks.push(currentBlock); - levels.push(level); - } else if (level < curLevel) { - var added = false; - - var k = levels.length - 1; - for (; k >= 0; --k) { - if (levels[k] == level) { - currentBlock = new Block(level); - blocks.push(currentBlock); - levels.push(level); - if (blocks[k].parent != null) { blocks[k].parent.addChild(currentBlock); } - added = true; - break - } - } - - if (!added) { - errors.push('Error: Invalid indentation at line ' + i + ': ' + line); - return - } - } - - currentBlock.lines.push(line.replace(regex$1['trim'], '')); - curLevel = level; - } - - return result -} - -function processValue(val) { - val = val.replace(regex$1['trim'], ''); - var m = null; - - if (val == 'true') { - return true - } else if (val == 'false') { - return false - } else if (val == '.NaN') { - return Number.NaN - } else if (val == 'null') { - return null - } else if (val == '.inf') { - return Number.POSITIVE_INFINITY - } else if (val == '-.inf') { - return Number.NEGATIVE_INFINITY - } else if ((m = val.match(regex$1['dashesString']))) { - return m[1] - } else if ((m = val.match(regex$1['quotesString']))) { - return m[1] - } else if ((m = val.match(regex$1['float']))) { - return parseFloat(m[0]) - } else if ((m = val.match(regex$1['integer']))) { - return parseInt(m[0]) - } else if (!isNaN((m = Date.parse(val)))) { - return new Date(m) - } else if ((m = val.match(regex$1['single_key_value']))) { - var res = {}; - res[m[1]] = processValue(m[2]); - return res - } else if ((m = val.match(regex$1['array']))) { - var count = 0, - c = ' '; - var res = []; - var content = ''; - var str = false; - for (var j = 0, lenJ = m[1].length; j < lenJ; ++j) { - c = m[1][j]; - if (c == "'" || c == '"') { - if (str === false) { - str = c; - content += c; - continue - } else if ((c == "'" && str == "'") || (c == '"' && str == '"')) { - str = false; - content += c; - continue - } - } else if (str === false && (c == '[' || c == '{')) { - ++count; - } else if (str === false && (c == ']' || c == '}')) { - --count; - } else if (str === false && count == 0 && c == ',') { - res.push(processValue(content)); - content = ''; - continue - } - - content += c; - } - - if (content.length > 0) { res.push(processValue(content)); } - return res - } else if ((m = val.match(regex$1['map']))) { - var count = 0, - c = ' '; - var res = []; - var content = ''; - var str = false; - for (var j = 0, lenJ = m[1].length; j < lenJ; ++j) { - c = m[1][j]; - if (c == "'" || c == '"') { - if (str === false) { - str = c; - content += c; - continue - } else if ((c == "'" && str == "'") || (c == '"' && str == '"')) { - str = false; - content += c; - continue - } - } else if (str === false && (c == '[' || c == '{')) { - ++count; - } else if (str === false && (c == ']' || c == '}')) { - --count; - } else if (str === false && count == 0 && c == ',') { - res.push(content); - content = ''; - continue - } - - content += c; - } - - if (content.length > 0) { res.push(content); } - - var newRes = {}; - for (var j = 0, lenJ = res.length; j < lenJ; ++j) { - if ((m = res[j].match(regex$1['key_value']))) { - newRes[m[1]] = processValue(m[2]); - } - } - - return newRes - } else { return val } -} - -function processFoldedBlock(block) { - var lines = block.lines; - var children = block.children; - var str = lines.join(' '); - var chunks = [str]; - for (var i = 0, len = children.length; i < len; ++i) { - chunks.push(processFoldedBlock(children[i])); - } - return chunks.join('\n') -} - -function processLiteralBlock(block) { - var lines = block.lines; - var children = block.children; - var str = lines.join('\n'); - for (var i = 0, len = children.length; i < len; ++i) { - str += processLiteralBlock(children[i]); - } - return str -} - -function processBlock(blocks) { - var m = null; - var res = {}; - var lines = null; - var children = null; - var currentObj = null; - - var level = -1; - - var processedBlocks = []; - - var isMap = true; - - for (var j = 0, lenJ = blocks.length; j < lenJ; ++j) { - if (level != -1 && level != blocks[j].level) { continue } - - processedBlocks.push(j); - - level = blocks[j].level; - lines = blocks[j].lines; - children = blocks[j].children; - currentObj = null; - - for (var i = 0, len = lines.length; i < len; ++i) { - var line = lines[i]; - - if ((m = line.match(regex$1['key']))) { - var key = m[1]; - - if (key[0] == '-') { - key = key.replace(regex$1['item'], ''); - if (isMap) { - isMap = false; - if (typeof res.length === 'undefined') { - res = []; - } - } - if (currentObj != null) { res.push(currentObj); } - currentObj = {}; - isMap = true; - } - - if (typeof m[2] != 'undefined') { - var value = m[2].replace(regex$1['trim'], ''); - if (value[0] == '&') { - var nb = processBlock(children); - if (currentObj != null) { currentObj[key] = nb; } - else { res[key] = nb; } - reference_blocks[value.substr(1)] = nb; - } else if (value[0] == '|') { - if (currentObj != null) - { currentObj[key] = processLiteralBlock(children.shift()); } - else { res[key] = processLiteralBlock(children.shift()); } - } else if (value[0] == '*') { - var v = value.substr(1); - var no = {}; - - if (typeof reference_blocks[v] == 'undefined') { - errors.push("Reference '" + v + "' not found!"); - } else { - for (var k in reference_blocks[v]) { - no[k] = reference_blocks[v][k]; - } - - if (currentObj != null) { currentObj[key] = no; } - else { res[key] = no; } - } - } else if (value[0] == '>') { - if (currentObj != null) - { currentObj[key] = processFoldedBlock(children.shift()); } - else { res[key] = processFoldedBlock(children.shift()); } - } else { - if (currentObj != null) { currentObj[key] = processValue(value); } - else { res[key] = processValue(value); } - } - } else { - if (currentObj != null) { currentObj[key] = processBlock(children); } - else { res[key] = processBlock(children); } - } - } else if (line.match(/^-\s*$/)) { - if (isMap) { - isMap = false; - if (typeof res.length === 'undefined') { - res = []; - } - } - if (currentObj != null) { res.push(currentObj); } - currentObj = {}; - isMap = true; - continue - } else if ((m = line.match(/^-\s*(.*)/))) { - if (currentObj != null) { currentObj.push(processValue(m[1])); } - else { - if (isMap) { - isMap = false; - if (typeof res.length === 'undefined') { - res = []; - } - } - res.push(processValue(m[1])); - } - continue - } - } - - if (currentObj != null) { - if (isMap) { - isMap = false; - if (typeof res.length === 'undefined') { - res = []; - } - } - res.push(currentObj); - } - } - - for (var j = processedBlocks.length - 1; j >= 0; --j) { - blocks.splice.call(blocks, processedBlocks[j], 1); - } - - return res -} - -function semanticAnalysis(blocks) { - var res = processBlock(blocks.children); - return res -} - -function preProcess(src) { - var m; - var lines = src.split('\n'); - - var r = regex$1['comment']; - - for (var i in lines) { - if ((m = lines[i].match(r))) { - /* var cmt = ""; - if(typeof m[3] != "undefined") - lines[i] = m[1]; - else if(typeof m[3] != "undefined") - lines[i] = m[3]; - else - lines[i] = ""; - */ - if (typeof m[3] !== 'undefined') { - lines[i] = m[0].substr(0, m[0].length - m[3].length); - } - } - } - - return lines.join('\n') -} - -function load(str) { - errors = []; - reference_blocks = []; - processing_time = new Date().getTime(); - var pre = preProcess(str); - var doc = parser$1(pre); - var res = semanticAnalysis(doc); - processing_time = new Date().getTime() - processing_time; - - return res -} - -/** - * Fork https://github.com/egoist/docute/blob/master/src/utils/front-matter.js - */ -/* eslint-disable */ -var optionalByteOrderMark = '\\ufeff?'; -var pattern = - '^(' + - optionalByteOrderMark + - '(= yaml =|---)' + - '$([\\s\\S]*?)' + - '(?:\\2|\\.\\.\\.)' + - '$' + - '' + - '(?:\\n)?)'; -// NOTE: If this pattern uses the 'g' flag the `regex` variable definition will -// need to be moved down into the functions that use it. -var regex = new RegExp(pattern, 'm'); - -function extractor(string) { - string = string || ''; - - var lines = string.split(/(\r?\n)/); - if (lines[0] && /= yaml =|---/.test(lines[0])) { - return parse(string) - } else { - return { attributes: {}, body: string } - } -} - -function parse(string) { - var match = regex.exec(string); - - if (!match) { - return { - attributes: {}, - body: string - } - } - - var yaml = match[match.length - 1].replace(/^\s+|\s+$/g, ''); - var attributes = load(yaml) || {}; - var body = string.replace(match[0], ''); - - return { attributes: attributes, body: body, frontmatter: yaml } -} - -var install = function (hook, vm) { - hook.beforeEach(function (content) { - var ref = extractor(content); - var attributes = ref.attributes; - var body = ref.body; - - vm.frontmatter = attributes; - - return body - }); -}; - -$docsify.plugins = [].concat(install, $docsify.plugins); - -}()); diff --git a/lib/plugins/front-matter.min.js b/lib/plugins/front-matter.min.js deleted file mode 100644 index 32f3a13..0000000 --- a/lib/plugins/front-matter.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(){var b=[],y=[],t=0,R={regLevel:new RegExp("^([\\s\\-]+)"),invalidLine:new RegExp("^\\-\\-\\-|^\\.\\.\\.|^\\s*#.*|^\\s*$"),dashesString:new RegExp('^\\s*\\"([^\\"]*)\\"\\s*$'),quotesString:new RegExp("^\\s*\\'([^\\']*)\\'\\s*$"),float:new RegExp("^[+-]?[0-9]+\\.[0-9]+(e[+-]?[0-9]+(\\.[0-9]+)?)?$"),integer:new RegExp("^[+-]?[0-9]+$"),array:new RegExp("\\[\\s*(.*)\\s*\\]"),map:new RegExp("\\{\\s*(.*)\\s*\\}"),key_value:new RegExp("([a-z0-9_-][ a-z0-9_-]*):( .+)","i"),single_key_value:new RegExp("^([a-z0-9_-][ a-z0-9_-]*):( .+?)$","i"),key:new RegExp("([a-z0-9_-][ a-z0-9_-]+):( .+)?","i"),item:new RegExp("^-\\s+"),trim:new RegExp("^\\s+|\\s+$"),comment:new RegExp("([^\\'\\\"#]+([\\'\\\"][^\\'\\\"]*[\\'\\\"])*)*(#.*)?")};function m(e){return{parent:null,length:0,level:e,lines:[],children:[],addChild:function(e){this.children.push(e),++(e.parent=this).length}}}function N(e){var n=null;if("true"==(e=e.replace(R.trim,"")))return!0;if("false"==e)return!1;if(".NaN"==e)return Number.NaN;if("null"==e)return null;if(".inf"==e)return Number.POSITIVE_INFINITY;if("-.inf"==e)return Number.NEGATIVE_INFINITY;if(n=e.match(R.dashesString))return n[1];if(n=e.match(R.quotesString))return n[1];if(n=e.match(R.float))return parseFloat(n[0]);if(n=e.match(R.integer))return parseInt(n[0]);if(isNaN(n=Date.parse(e))){if(n=e.match(R.single_key_value))return(i={})[n[1]]=N(n[2]),i;if(n=e.match(R.array)){for(var t=0,r=" ",i=[],l="",u=!1,a=0,s=n[1].length;a"==d[0]?null!=u?u[v]=_(l.shift()):r[v]=_(l.shift()):null!=u?u[v]=N(d):r[v]=N(d)}else null!=u?u[v]=e(l):r[v]=e(l)}else{if(g.match(/^-\s*$/)){f&&(f=!1,void 0===r.length&&(r=[])),null!=u&&r.push(u),u={},f=!0;continue}if(t=g.match(/^-\s*(.*)/)){null!=u?u.push(N(t[1])):(f&&(f=!1,void 0===r.length&&(r=[])),r.push(N(t[1])));continue}}}null!=u&&(f&&(f=!1,void 0===r.length&&(r=[])),r.push(u))}for(h=s.length-1;0<=h;--h)n.splice.call(n,s[h],1);return r}(e.children)}function l(e){b=[],y=[],t=(new Date).getTime();var n=r(function(e){var n,t=R.regLevel,r=R.invalidLine,i=e.split("\n"),l=0,u=0,a=[],s=new m(-1),f=new m(0);s.addChild(f);var h=[],o="";a.push(f),h.push(l);for(var c=0,p=i.length;cw.scrollOffset&&o(150);}},u=function(a){-1E.scrollOffset&&p(150)}},z=function(e){-1