[build] 4.0.1 next

This commit is contained in:
qingwei.li 2017-05-30 06:34:35 +08:00
parent b764b6e32c
commit 3db4841da3
No known key found for this signature in database
GPG Key ID: B6DDC2F7AE80B2F4
5 changed files with 36 additions and 36 deletions

View File

@ -2732,17 +2732,6 @@ function stringifyQuery (obj) {
return qs.length ? ("?" + (qs.join('&'))) : ''
}
var getBasePath = cached(function (base) {
if ( base === void 0 ) base = '';
// TODO
var path = inBrowser ? window.location.pathname : '';
return /^(\/|https?:)/g.test(base)
? base
: cleanPath(path + '/' + base)
});
function getPath () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
@ -2774,7 +2763,7 @@ var Compiler = function Compiler (config, router) {
this.cacheTree = {};
this.toc = [];
this.linkTarget = config.externalLinkTarget || '_blank';
this.contentBase = getBasePath(config.basePath);
this.contentBase = router.getBasePath();
var renderer = this._initRenderer();
var compile;
@ -3233,7 +3222,7 @@ function renderMixin (proto) {
toggleClass(el, 'add', 'has-mask');
if (!isAbsolutePath(m[1])) {
path = getPath(getBasePath(this.config.basePath), m[1]);
path = getPath(this.router.getBasePath(), m[1]);
}
el.style.backgroundImage = "url(" + path + ")";
el.style.backgroundSize = 'cover';
@ -3317,10 +3306,14 @@ var History = function History (config) {
this.config = config;
};
History.prototype.getBasePath = function getBasePath () {
return this.config.basePath
};
History.prototype.getFile = function getFile (path) {
var ref = this;
var config = ref.config;
var base = getBasePath(config.basePath);
var base = this.getBasePath();
path = config.alias ? getAlias(path, config.alias) : path;
path = getFileName(path);
@ -3365,6 +3358,15 @@ var HashHistory = (function (History$$1) {
HashHistory.prototype = Object.create( History$$1 && History$$1.prototype );
HashHistory.prototype.constructor = HashHistory;
HashHistory.prototype.getBasePath = function getBasePath () {
var path = window.location.pathname || '';
var base = this.config.basePath;
return /^(\/|https?:)/g.test(base)
? base
: cleanPath(path + '/' + base)
};
HashHistory.prototype.getCurrentPath = function getCurrentPath () {
// We can't use location.hash here because it's not
// consistent across browsers - Firefox will pre-decode it!
@ -3628,6 +3630,7 @@ function fetchMixin (proto) {
var root = getParentPath(this.route.path);
var path = this.router.getFile(root + coverpage);
console.log(this.route.path, root, path);
if (this.route.path !== '/' || !coverpage) {
this._renderCover();
return
@ -3705,7 +3708,6 @@ var util = Object.freeze({
supportsPushState: supportsPushState,
parseQuery: parseQuery,
stringifyQuery: stringifyQuery,
getBasePath: getBasePath,
getPath: getPath,
isAbsolutePath: isAbsolutePath,
getParentPath: getParentPath,

4
lib/docsify.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -47,13 +47,12 @@ function genIndex (path, content, router) {
var tokens = window.marked.lexer(content);
var slugify = window.Docsify.slugify;
var toURL = router.toURL;
var index = {};
var slug;
tokens.forEach(function (token) {
if (token.type === 'heading' && token.depth <= 2) {
slug = toURL(path, { id: slugify(token.text) });
slug = router.toURL(path, { id: slugify(token.text) });
index[slug] = { slug: slug, title: token.text, body: '' };
} else {
if (!slug) { return }
@ -169,13 +168,12 @@ function init$1 (config, vm) {
});
}
var dom;
var NO_DATA_TEXT = '';
function style () {
var code = "\n.sidebar {\n padding-top: 0;\n}\n\n.search {\n margin-bottom: 20px;\n padding: 6px;\n border-bottom: 1px solid #eee;\n}\n\n.search .results-panel {\n display: none;\n}\n\n.search .results-panel.show {\n display: block;\n}\n\n.search input {\n outline: none;\n border: none;\n width: 100%;\n padding: 7px;\n line-height: 22px;\n font-size: 14px;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n.search h2 {\n font-size: 17px;\n margin: 10px 0;\n}\n\n.search a {\n text-decoration: none;\n color: inherit;\n}\n\n.search .matching-post {\n border-bottom: 1px solid #eee;\n}\n\n.search .matching-post:last-child {\n border-bottom: 0;\n}\n\n.search p {\n font-size: 14px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n}\n\n.search p.empty {\n text-align: center;\n}";
var style = dom.create('style', code);
dom.appendTo(dom.head, style);
var style = Docsify.dom.create('style', code);
Docsify.dom.appendTo(Docsify.dom.head, style);
}
function tpl (opts, defaultValue) {
@ -185,16 +183,16 @@ function tpl (opts, defaultValue) {
"<input type=\"search\" value=\"" + defaultValue + "\" />" +
'<div class="results-panel"></div>' +
'</div>';
var el = dom.create('div', html);
var aside = dom.find('aside');
var el = Docsify.dom.create('div', html);
var aside = Docsify.dom.find('aside');
dom.toggleClass(el, 'search');
dom.before(aside, el);
Docsify.dom.toggleClass(el, 'search');
Docsify.dom.before(aside, el);
}
function doSearch (value) {
var $search = dom.find('div.search');
var $panel = dom.find($search, '.results-panel');
var $search = Docsify.dom.find('div.search');
var $panel = Docsify.dom.find($search, '.results-panel');
if (!value) {
$panel.classList.remove('show');
@ -213,22 +211,23 @@ function doSearch (value) {
}
function bindEvents () {
var $search = dom.find('div.search');
var $input = dom.find($search, 'input');
var $search = Docsify.dom.find('div.search');
var $input = Docsify.dom.find($search, 'input');
var timeId;
// Prevent to Fold sidebar
dom.on($search, 'click',
Docsify.dom.on($search, 'click',
function (e) { return e.target.tagName !== 'A' && e.stopPropagation(); });
dom.on($input, 'input', function (e) {
Docsify.dom.on($input, 'input', function (e) {
clearTimeout(timeId);
timeId = setTimeout(function (_) { return doSearch(e.target.value.trim()); }, 100);
});
}
function updatePlaceholder (text, path) {
var $input = dom.getNode('.search input[type="search"]');
var $input = Docsify.dom.getNode('.search input[type="search"]');
if (!$input) { return }
if (typeof text === 'string') {
$input.placeholder = text;
} else {
@ -247,7 +246,6 @@ function updateNoData (text, path) {
}
function init$$1 (opts, vm) {
dom = Docsify.dom;
var keywords = vm.router.parse().query.s;
style();

View File

@ -1 +1 @@
this.D=this.D||{},function(){"use strict";function e(e){var n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};return String(e).replace(/[&<>"'\/]/g,function(e){return n[e]})}function n(e){var n=[];return d.dom.findAll("a:not([data-nosearch])").map(function(t){var r=t.href,a=t.getAttribute("href"),o=e.parse(r).path;o&&-1===n.indexOf(o)&&!Docsify.util.isAbsolutePath(a)&&n.push(o)}),n}function t(e){localStorage.setItem("docsify.search.expires",Date.now()+e),localStorage.setItem("docsify.search.index",JSON.stringify(v))}function r(e,n,t){void 0===n&&(n="");var r,a=window.marked.lexer(n),o=window.Docsify.slugify,i=t.toURL,s={};return a.forEach(function(n){if("heading"===n.type&&n.depth<=2)r=i(e,{id:o(n.text)}),s[r]={slug:r,title:n.text,body:""};else{if(!r)return;s[r]?s[r].body?s[r].body+="\n"+(n.text||""):s[r].body=n.text:s[r]={slug:r,title:"",body:""}}}),o.clear(),s}function a(n){var t=[],r=[];Object.keys(v).forEach(function(e){r=r.concat(Object.keys(v[e]).map(function(n){return v[e][n]}))}),n=[].concat(n,n.trim().split(/[\s\-\\\\/]+/));for(var a=0;a<r.length;a++)!function(a){var o=r[a],i=!1,s="",c=o.title&&o.title.trim(),l=o.body&&o.body.trim(),u=o.slug||"";if(c&&l&&(n.forEach(function(n,t){var r=new RegExp(n,"gi"),a=-1,o=-1;if(a=c&&c.search(r),o=l&&l.search(r),a<0&&o<0)i=!1;else{i=!0,o<0&&(o=0);var u=0,p=0;u=o<11?0:o-10,p=0===u?70:o+n.length+60,p>l.length&&(p=l.length);var f="..."+e(l).substring(u,p).replace(r,'<em class="search-keyword">'+n+"</em>")+"...";s+=f}}),i)){var p={title:e(c),content:s,url:u};t.push(p)}}(a);return t}function o(e,a){d=Docsify;var o="auto"===e.paths,i=localStorage.getItem("docsify.search.expires")<Date.now();if(v=JSON.parse(localStorage.getItem("docsify.search.index")),i)v={};else if(!o)return;var s=o?n(a.router):e.paths,c=s.length,l=0;s.forEach(function(n){if(v[n])return l++;d.get(a.router.getFile(n)).then(function(o){v[n]=r(n,o,a.router),c===++l&&t(e.maxAge)})})}function i(){var e=g.create("style","\n.sidebar {\n padding-top: 0;\n}\n\n.search {\n margin-bottom: 20px;\n padding: 6px;\n border-bottom: 1px solid #eee;\n}\n\n.search .results-panel {\n display: none;\n}\n\n.search .results-panel.show {\n display: block;\n}\n\n.search input {\n outline: none;\n border: none;\n width: 100%;\n padding: 7px;\n line-height: 22px;\n font-size: 14px;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n.search h2 {\n font-size: 17px;\n margin: 10px 0;\n}\n\n.search a {\n text-decoration: none;\n color: inherit;\n}\n\n.search .matching-post {\n border-bottom: 1px solid #eee;\n}\n\n.search .matching-post:last-child {\n border-bottom: 0;\n}\n\n.search p {\n font-size: 14px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n}\n\n.search p.empty {\n text-align: center;\n}");g.appendTo(g.head,e)}function s(e,n){void 0===n&&(n="");var t='<input type="search" value="'+n+'" /><div class="results-panel"></div></div>',r=g.create("div",t),a=g.find("aside");g.toggleClass(r,"search"),g.before(a,r)}function c(e){var n=g.find("div.search"),t=g.find(n,".results-panel");if(!e)return t.classList.remove("show"),void(t.innerHTML="");var r=a(e),o="";r.forEach(function(e){o+='<div class="matching-post">\n<h2><a href="'+e.url+'">'+e.title+"</a></h2>\n<p>"+e.content+"</p>\n</div>"}),t.classList.add("show"),t.innerHTML=o||'<p class="empty">'+y+"</p>"}function l(){var e,n=g.find("div.search"),t=g.find(n,"input");g.on(n,"click",function(e){return"A"!==e.target.tagName&&e.stopPropagation()}),g.on(t,"input",function(n){clearTimeout(e),e=setTimeout(function(e){return c(n.target.value.trim())},100)})}function u(e,n){var t=g.getNode('.search input[type="search"]');if("string"==typeof e)t.placeholder=e;else{var r=Object.keys(e).filter(function(e){return n.indexOf(e)>-1})[0];t.placeholder=e[r]}}function p(e,n){if("string"==typeof e)y=e;else{var t=Object.keys(e).filter(function(e){return n.indexOf(e)>-1})[0];y=e[t]}}function f(e,n){g=Docsify.dom;var t=n.router.parse().query.s;i(),s(e,t),l(),t&&setTimeout(function(e){return c(t)},500)}function h(e,n){u(e.placeholder,n.route.path),p(e.noData,n.route.path)}var d,g,v={},y="",m={placeholder:"Type to search",noData:"No Results!",paths:"auto",maxAge:864e5},x=function(e,n){var t=Docsify.util,r=n.config.search||m;Array.isArray(r)?m.paths=r:"object"==typeof r&&(m.paths=Array.isArray(r.paths)?r.paths:"auto",m.maxAge=t.isPrimitive(r.maxAge)?r.maxAge:m.maxAge,m.placeholder=r.placeholder||m.placeholder,m.noData=r.noData||m.noData);var a="auto"===m.paths;e.mounted(function(e){f(m,n),!a&&o(m,n)}),e.doneEach(function(e){h(m,n),a&&o(m,n)})};$docsify.plugins=[].concat(x,$docsify.plugins)}();
this.D=this.D||{},function(){"use strict";function e(e){var n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};return String(e).replace(/[&<>"'\/]/g,function(e){return n[e]})}function n(e){var n=[];return h.dom.findAll("a:not([data-nosearch])").map(function(t){var o=t.href,i=t.getAttribute("href"),r=e.parse(o).path;r&&-1===n.indexOf(r)&&!Docsify.util.isAbsolutePath(i)&&n.push(r)}),n}function t(e){localStorage.setItem("docsify.search.expires",Date.now()+e),localStorage.setItem("docsify.search.index",JSON.stringify(y))}function o(e,n,t){void 0===n&&(n="");var o,i=window.marked.lexer(n),r=window.Docsify.slugify,a={};return i.forEach(function(n){if("heading"===n.type&&n.depth<=2)o=t.toURL(e,{id:r(n.text)}),a[o]={slug:o,title:n.text,body:""};else{if(!o)return;a[o]?a[o].body?a[o].body+="\n"+(n.text||""):a[o].body=n.text:a[o]={slug:o,title:"",body:""}}}),r.clear(),a}function i(n){var t=[],o=[];Object.keys(y).forEach(function(e){o=o.concat(Object.keys(y[e]).map(function(n){return y[e][n]}))}),n=[].concat(n,n.trim().split(/[\s\-\\\\/]+/));for(var i=0;i<o.length;i++)!function(i){var r=o[i],a=!1,s="",c=r.title&&r.title.trim(),f=r.body&&r.body.trim(),l=r.slug||"";if(c&&f&&(n.forEach(function(n,t){var o=new RegExp(n,"gi"),i=-1,r=-1;if(i=c&&c.search(o),r=f&&f.search(o),i<0&&r<0)a=!1;else{a=!0,r<0&&(r=0);var l=0,d=0;l=r<11?0:r-10,d=0===l?70:r+n.length+60,d>f.length&&(d=f.length);var u="..."+e(f).substring(l,d).replace(o,'<em class="search-keyword">'+n+"</em>")+"...";s+=u}}),a)){var d={title:e(c),content:s,url:l};t.push(d)}}(i);return t}function r(e,i){h=Docsify;var r="auto"===e.paths,a=localStorage.getItem("docsify.search.expires")<Date.now();if(y=JSON.parse(localStorage.getItem("docsify.search.index")),a)y={};else if(!r)return;var s=r?n(i.router):e.paths,c=s.length,f=0;s.forEach(function(n){if(y[n])return f++;h.get(i.router.getFile(n)).then(function(r){y[n]=o(n,r,i.router),c===++f&&t(e.maxAge)})})}function a(){var e=Docsify.dom.create("style","\n.sidebar {\n padding-top: 0;\n}\n\n.search {\n margin-bottom: 20px;\n padding: 6px;\n border-bottom: 1px solid #eee;\n}\n\n.search .results-panel {\n display: none;\n}\n\n.search .results-panel.show {\n display: block;\n}\n\n.search input {\n outline: none;\n border: none;\n width: 100%;\n padding: 7px;\n line-height: 22px;\n font-size: 14px;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n.search h2 {\n font-size: 17px;\n margin: 10px 0;\n}\n\n.search a {\n text-decoration: none;\n color: inherit;\n}\n\n.search .matching-post {\n border-bottom: 1px solid #eee;\n}\n\n.search .matching-post:last-child {\n border-bottom: 0;\n}\n\n.search p {\n font-size: 14px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n}\n\n.search p.empty {\n text-align: center;\n}");Docsify.dom.appendTo(Docsify.dom.head,e)}function s(e,n){void 0===n&&(n="");var t='<input type="search" value="'+n+'" /><div class="results-panel"></div></div>',o=Docsify.dom.create("div",t),i=Docsify.dom.find("aside");Docsify.dom.toggleClass(o,"search"),Docsify.dom.before(i,o)}function c(e){var n=Docsify.dom.find("div.search"),t=Docsify.dom.find(n,".results-panel");if(!e)return t.classList.remove("show"),void(t.innerHTML="");var o=i(e),r="";o.forEach(function(e){r+='<div class="matching-post">\n<h2><a href="'+e.url+'">'+e.title+"</a></h2>\n<p>"+e.content+"</p>\n</div>"}),t.classList.add("show"),t.innerHTML=r||'<p class="empty">'+m+"</p>"}function f(){var e,n=Docsify.dom.find("div.search"),t=Docsify.dom.find(n,"input");Docsify.dom.on(n,"click",function(e){return"A"!==e.target.tagName&&e.stopPropagation()}),Docsify.dom.on(t,"input",function(n){clearTimeout(e),e=setTimeout(function(e){return c(n.target.value.trim())},100)})}function l(e,n){var t=Docsify.dom.getNode('.search input[type="search"]');if(t)if("string"==typeof e)t.placeholder=e;else{var o=Object.keys(e).filter(function(e){return n.indexOf(e)>-1})[0];t.placeholder=e[o]}}function d(e,n){if("string"==typeof e)m=e;else{var t=Object.keys(e).filter(function(e){return n.indexOf(e)>-1})[0];m=e[t]}}function u(e,n){var t=n.router.parse().query.s;a(),s(e,t),f(),t&&setTimeout(function(e){return c(t)},500)}function p(e,n){l(e.placeholder,n.route.path),d(e.noData,n.route.path)}var h,y={},m="",g={placeholder:"Type to search",noData:"No Results!",paths:"auto",maxAge:864e5},v=function(e,n){var t=Docsify.util,o=n.config.search||g;Array.isArray(o)?g.paths=o:"object"==typeof o&&(g.paths=Array.isArray(o.paths)?o.paths:"auto",g.maxAge=t.isPrimitive(o.maxAge)?o.maxAge:g.maxAge,g.placeholder=o.placeholder||g.placeholder,g.noData=o.noData||g.noData);var i="auto"===g.paths;e.mounted(function(e){u(g,n),!i&&r(g,n)}),e.doneEach(function(e){p(g,n),i&&r(g,n)})};$docsify.plugins=[].concat(v,$docsify.plugins)}();

View File

@ -1,6 +1,6 @@
{
"name": "docsify-server-renderer",
"version": "4.0.0",
"version": "4.0.1",
"description": "docsify server renderer",
"author": {
"name": "qingwei-li",