fix(static): file path

This commit is contained in:
cinwell.li 2019-03-31 14:28:42 +08:00
commit 082c68ecee
7 changed files with 151 additions and 160 deletions

View file

@ -362,16 +362,21 @@ function main(config) {
/**
* Cover Page
*/
function cover() {
function cover(ref) {
var style = ref.style;
var text = ref.text;
var hasMask = ref.hasMask;
var SL = ', 100%, 85%';
var bgc =
'linear-gradient(to left bottom, ' +
"hsl(" + (Math.floor(Math.random() * 255) + SL) + ") 0%," +
"hsl(" + (Math.floor(Math.random() * 255) + SL) + ") 100%)";
style =
style ||
'background: linear-gradient(to left bottom, ' +
"hsl(" + (Math.floor(Math.random() * 255) + SL) + ") 0%," +
"hsl(" + (Math.floor(Math.random() * 255) + SL) + ") 100%)";
return (
"<section class=\"cover show\" style=\"background: " + bgc + "\">" +
'<div class="cover-main"><!--cover--></div>' +
"<section class=\"cover show " + (hasMask ? ' has-mask' : '') + "\" style=\"" + style + "\">" +
"<div class=\"cover-main\">" + text + "</div>" +
'<div class="mask"></div>' +
'</section>'
)
@ -3335,11 +3340,7 @@ function getAndRemoveConfig(str) {
str = str
.replace(/^'/, '')
.replace(/'$/, '')
<<<<<<< HEAD
.replace(/(?:^|\s):([\w-]+)=?([\w-]+)?/g, function (m, key, value) {
=======
.replace(/:([\w-]+)=?([\w-]+)?/g, function (m, key, value) {
>>>>>>> [build] 4.8.6
config[key] = (value && value.replace(/&quot;/g, '')) || true;
return ''
})
@ -3487,10 +3488,7 @@ Compiler.prototype.compileEmbed = function compileEmbed (href, title) {
embed = compileMedia[type].call(this, href, title);
embed.type = type;
}
<<<<<<< HEAD
embed.fragment = config.fragment;
=======
>>>>>>> [build] 4.8.6
return embed
}
@ -3641,26 +3639,29 @@ Compiler.prototype._initRenderer = function _initRenderer () {
return ("<img src=\"" + url + "\"data-origin=\"" + href + "\" alt=\"" + text + "\"" + attrs + ">")
};
<<<<<<< HEAD
origin.list = renderer.list = function (body, ordered, start) {
var isTaskList = /<li class="task-list-item">/.test(body.split('class="task-list"')[0]);
var isTaskList = /<li class="task-list-item">/.test(
body.split('class="task-list"')[0]
);
var isStartReq = start && start > 1;
var tag = ordered ? 'ol' : 'ul';
var tagAttrs = [
(isTaskList ? 'class="task-list"' : ''),
(isStartReq ? ("start=\"" + start + "\"") : '')
].join(' ').trim();
isTaskList ? 'class="task-list"' : '',
isStartReq ? ("start=\"" + start + "\"") : ''
]
.join(' ')
.trim();
return ("<" + tag + " " + tagAttrs + ">" + body + "</" + tag + ">")
};
origin.listitem = renderer.listitem = function (text) {
var isTaskItem = /^(<input.*type="checkbox"[^>]*>)/.test(text);
var html = isTaskItem ? ("<li class=\"task-list-item\"><label>" + text + "</label></li>") : ("<li>" + text + "</li>");
var html = isTaskItem ?
("<li class=\"task-list-item\"><label>" + text + "</label></li>") :
("<li>" + text + "</li>");
return html
};
=======
>>>>>>> [build] 4.8.6
renderer.origin = origin;
@ -3719,13 +3720,40 @@ Compiler.prototype.article = function article (text) {
/**
* Compile cover page
*/
Compiler.prototype.cover = function cover$$1 (text) {
var cacheToc = this.toc.slice();
var html = this.compile(text);
Compiler.prototype.cover = function cover$$1 (text, isHTML) {
if ( isHTML === void 0 ) isHTML = false;
this.toc = cacheToc.slice();
var html = text;
if (!isHTML) {
var cacheToc = this.toc.slice();
html = this.compile(text);
this.toc = cacheToc.slice();
}
return html
var m = html
.trim()
.match('<p><img.*?data-origin="(.*?)"[^a]+alt="(.*?)">([^<]*?)</p>$');
var style = '';
var hasMask = false;
if (m) {
if (m[2] === 'color') {
style = "background: " + (m[1] + (m[3] || ''));
} else {
var path = m[1];
hasMask = true;
if (!isAbsolutePath(m[1])) {
path = getPath(this.router.getBasePath(), m[1]);
}
style = "background-image: url(" + path + "); background-size: cover; background-position: center center;";
}
html = html.replace(m[0], '');
}
return cover({
style: style,
hasMask: hasMask,
text: html
})
};
var title = $.title;
@ -3736,12 +3764,9 @@ function btn(el) {
var toggle = function (_) { return body.classList.toggle('close'); };
el = getNode(el);
<<<<<<< HEAD
if (el == null) {
return
}
=======
>>>>>>> [build] 4.8.6
on(el, 'click', function (e) {
e.stopPropagation();
toggle();
@ -3757,13 +3782,9 @@ function btn(el) {
function collapse(el) {
el = getNode(el);
<<<<<<< HEAD
if (el == null) {
return
}
=======
>>>>>>> [build] 4.8.6
on(el, 'click', function (ref) {
var target = ref.target;
@ -3801,15 +3822,10 @@ function sticky() {
*/
function getAndActive(router, el, isParent, autoTitle) {
el = getNode(el);
<<<<<<< HEAD
var links = [];
if (el != null) {
links = findAll(el, 'a');
}
=======
var links = findAll(el, 'a');
>>>>>>> [build] 4.8.6
var hash = decodeURI(router.toURL(router.getCurrentPath()));
var target;
@ -4012,14 +4028,10 @@ function scrollActiveSidebar(router) {
coverHeight = cover ? cover.offsetHeight : 0;
var sidebar = getNode('.sidebar');
<<<<<<< HEAD
var lis = [];
if (sidebar != null) {
lis = findAll(sidebar, 'li');
}
=======
var lis = findAll(sidebar, 'li');
>>>>>>> [build] 4.8.6
for (var i = 0, len = lis.length; i < len; i += 1) {
var li = lis[i];
@ -4103,14 +4115,13 @@ function walkFetchEmbed(ref, cb) {
if (token.embed.type === 'markdown') {
embedToken = compile.lexer(text);
} else if (token.embed.type === 'code') {
<<<<<<< HEAD
if (token.embed.fragment) {
var fragment = token.embed.fragment;
var pattern = new RegExp(("(?:###|\\/\\/\\/)\\s*\\[" + fragment + "\\]([\\s\\S]*)(?:###|\\/\\/\\/)\\s*\\[" + fragment + "\\]"));
text = ((text.match(pattern) || [])[1] || '').trim();
var pattern = new RegExp(
("(?:###|\\/\\/\\/)\\s*\\[" + fragment + "\\]([\\s\\S]*)(?:###|\\/\\/\\/)\\s*\\[" + fragment + "\\]")
);
text = ((text.match(pattern) || [])[1] || '').trim();
}
=======
>>>>>>> [build] 4.8.6
embedToken = compile.lexer(
'```' +
token.embed.lang +
@ -4376,30 +4387,10 @@ function renderMixin(proto) {
}
toggleClass(el, 'add', 'show');
var html = this.coverIsHTML ? text : this.compiler.cover(text);
var html = this.compiler.cover(text, this.coverIsHTML);
var m = html
.trim()
.match('<p><img.*?data-origin="(.*?)"[^a]+alt="(.*?)">([^<]*?)</p>$');
this._renderTo('.cover-placeholder', html, true);
if (m) {
if (m[2] === 'color') {
el.style.background = m[1] + (m[3] || '');
} else {
var path = m[1];
toggleClass(el, 'add', 'has-mask');
if (!isAbsolutePath(m[1])) {
path = getPath(this.router.getBasePath(), m[1]);
}
el.style.backgroundImage = "url(" + path + ")";
el.style.backgroundSize = 'cover';
el.style.backgroundPosition = 'center center';
}
html = html.replace(m[0], '');
}
this._renderTo('.cover-main', html);
sticky();
};
@ -4429,8 +4420,9 @@ function initRender(vm) {
if (config.repo) {
html += corner(config.repo);
}
if (config.coverpage) {
html += cover();
html += '<div class=cover-placeholder></div>';
}
if (config.logo) {
@ -4490,9 +4482,11 @@ function getAlias(path, alias, last) {
}
function getFileName(path, ext) {
return new RegExp(("\\.(" + (ext.replace(/^\./, '')) + "|html)$"), 'g').test(path) ?
return /\.\w+$/.test(path) ?
path :
/\/$/g.test(path) ? (path + "README" + ext) : ("" + path + ext)
/\/$/g.test(path) ?
(path + "README" + ext) :
("" + path + ext)
}
var History = function History(config) {
@ -5075,6 +5069,7 @@ function initGlobalAPI () {
dom: dom,
get: get,
slugify: slugify,
<<<<<<< HEAD
<<<<<<< HEAD
version: '4.9.1'
=======
@ -5084,6 +5079,9 @@ function initGlobalAPI () {
version: '4.8.6'
>>>>>>> [build] 4.8.6
>>>>>>> [build] 4.8.6
=======
version: '4.9.0'
>>>>>>> fix(static): file path
};
window.DocsifyCompiler = Compiler;
window.marked = marked;

View file

@ -1,7 +1,6 @@
(function () {
var INDEXS = {};
<<<<<<< HEAD
var LOCAL_STORAGE = {
EXPIRE_KEY: 'docsify.search.expires',
INDEX_KEY: 'docsify.search.index'
@ -14,8 +13,6 @@ function resolveIndexKey(namespace) {
return namespace ? ((LOCAL_STORAGE.INDEX_KEY) + "/" + namespace) : LOCAL_STORAGE.INDEX_KEY
}
=======
>>>>>>> [build] 4.8.6
function escapeHtml(string) {
var entityMap = {
'&': '&amp;',
@ -49,15 +46,9 @@ function getAllPaths(router) {
return paths
}
<<<<<<< HEAD
function saveData(maxAge, expireKey, indexKey) {
localStorage.setItem(expireKey, Date.now() + maxAge);
localStorage.setItem(indexKey, JSON.stringify(INDEXS));
=======
function saveData(maxAge) {
localStorage.setItem('docsify.search.expires', Date.now() + maxAge);
localStorage.setItem('docsify.search.index', JSON.stringify(INDEXS));
>>>>>>> [build] 4.8.6
}
function genIndex(path, content, router, depth) {
@ -175,7 +166,6 @@ function search(query) {
function init$1(config, vm) {
var isAuto = config.paths === 'auto';
<<<<<<< HEAD
var expireKey = resolveExpireKey(config.namespace);
var indexKey = resolveIndexKey(config.namespace);
@ -183,11 +173,6 @@ function init$1(config, vm) {
var isExpired = localStorage.getItem(expireKey) < Date.now();
INDEXS = JSON.parse(localStorage.getItem(indexKey));
=======
var isExpired = localStorage.getItem('docsify.search.expires') < Date.now();
INDEXS = JSON.parse(localStorage.getItem('docsify.search.index'));
>>>>>>> [build] 4.8.6
if (isExpired) {
INDEXS = {};
@ -208,11 +193,7 @@ function init$1(config, vm) {
.get(vm.router.getFile(path), false, vm.config.requestHeaders)
.then(function (result) {
INDEXS[path] = genIndex(path, result, vm.router, config.depth);
<<<<<<< HEAD
len === ++count && saveData(config.maxAge, expireKey, indexKey);
=======
len === ++count && saveData(config.maxAge);
>>>>>>> [build] 4.8.6
});
});
}
@ -346,12 +327,8 @@ var CONFIG = {
paths: 'auto',
depth: 2,
maxAge: 86400000, // 1 day
<<<<<<< HEAD
hideOtherSidebarContent: false,
namespace: undefined
=======
hideOtherSidebarContent: false
>>>>>>> [build] 4.8.6
};
var install = function (hook, vm) {
@ -367,10 +344,7 @@ var install = function (hook, vm) {
CONFIG.noData = opts.noData || CONFIG.noData;
CONFIG.depth = opts.depth || CONFIG.depth;
CONFIG.hideOtherSidebarContent = opts.hideOtherSidebarContent || CONFIG.hideOtherSidebarContent;
<<<<<<< HEAD
CONFIG.namespace = opts.namespace || CONFIG.namespace;
=======
>>>>>>> [build] 4.8.6
}
var isAuto = CONFIG.paths === 'auto';