Skip to content

Commit

Permalink
Merge branch 'master' into issue/3225/vimeo-responsive-video
Browse files Browse the repository at this point in the history
  • Loading branch information
Xaviju committed Oct 24, 2018
2 parents d373713 + 8d33f3c commit de7ec24
Show file tree
Hide file tree
Showing 138 changed files with 1,944 additions and 1,907 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ environment:
matrix:
- nodejs_version: "6"
- nodejs_version: "8"
- nodejs_version: "9"
- nodejs_version: "10"

matrix:
fast_finish: true
Expand Down
3 changes: 1 addition & 2 deletions lib/box/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const pathFn = require('path');
const Promise = require('bluebird');
const _ = require('lodash');
const File = require('./file');
const util = require('hexo-util');
const fs = require('hexo-fs');
Expand All @@ -19,7 +18,7 @@ const defaultPattern = new Pattern(() => ({}));
function Box(ctx, base, options) {
EventEmitter.call(this);

this.options = _.assign({
this.options = Object.assign({
persistent: true
}, options);

Expand Down
12 changes: 7 additions & 5 deletions lib/hexo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const loadDatabase = require('./load_database');
const multiConfigPath = require('./multi_config_path');
const resolve = require('resolve');

const { cloneDeep, debounce } = _;

const libDir = pathFn.dirname(__dirname);
const sep = pathFn.sep;
const dbVersion = 1;
Expand Down Expand Up @@ -64,7 +66,7 @@ function Hexo(base = process.cwd(), args = {}) {
tag: new extend.Tag()
};

this.config = _.cloneDeep(defaultConfig);
this.config = cloneDeep(defaultConfig);

this.log = logger(this.env);

Expand Down Expand Up @@ -260,7 +262,7 @@ Hexo.prototype.load = function(callback) {
Hexo.prototype.watch = function(callback) {
const self = this;

this._watchBox = _.debounce(() => self._generate({cache: false}), 100);
this._watchBox = debounce(() => self._generate({cache: false}), 100);

return loadDatabase(this).then(() => {
self.log.info('Start processing');
Expand Down Expand Up @@ -321,7 +323,7 @@ Hexo.prototype._generate = function(options) {
}

Locals.prototype.config = config;
Locals.prototype.theme = _.assign({}, config, theme.config, config.theme_config);
Locals.prototype.theme = Object.assign({}, config, theme.config, config.theme_config);
Locals.prototype._ = _;
Locals.prototype.layout = 'layout';
Locals.prototype.cache = options.cache;
Expand Down Expand Up @@ -362,7 +364,7 @@ Hexo.prototype._generate = function(options) {
}

if (Array.isArray(layout)) {
layout = _.uniq(layout);
layout = layout.filter((item, index, self) => self.indexOf(item) === index);
} else {
layout = [layout];
}
Expand Down Expand Up @@ -398,7 +400,7 @@ Hexo.prototype._generate = function(options) {
});
}).then(() => {
// Remove old routes
const removed = _.difference(routeList, newRouteList);
const removed = routeList.filter(item => !newRouteList.includes(item));

for (let i = 0, len = removed.length; i < len; i++) {
route.remove(removed[i]);
Expand Down
4 changes: 2 additions & 2 deletions lib/hexo/load_config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const _ = require('lodash');
const merge = require('lodash/merge');
const pathFn = require('path');
const tildify = require('tildify');
const Theme = require('../theme');
Expand Down Expand Up @@ -28,7 +28,7 @@ module.exports = ctx => {

ctx.log.debug('Config loaded: %s', chalk.magenta(tildify(configPath)));

config = _.merge(ctx.config, config);
config = merge(ctx.config, config);
ctx.config_path = configPath;

config.root = config.root.replace(/\/*$/, '/');
Expand Down
6 changes: 3 additions & 3 deletions lib/hexo/multi_config_path.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const pathFn = require('path');
const fs = require('hexo-fs');
const _ = require('lodash');
const merge = require('lodash/merge');
const yml = require('js-yaml');

module.exports = ctx => function multiConfigPath(base, configPaths, outputDir) {
Expand Down Expand Up @@ -55,10 +55,10 @@ module.exports = ctx => function multiConfigPath(base, configPaths, outputDir) {
const ext = pathFn.extname(paths[i]).toLowerCase();

if (ext === '.yml') {
_.merge(combinedConfig, yml.load(file));
merge(combinedConfig, yml.load(file));
count++;
} else if (ext === '.json') {
_.merge(combinedConfig, yml.safeLoad(file, {json: true}));
merge(combinedConfig, yml.safeLoad(file, {json: true}));
count++;
} else {
log.w(`Config file ${paths[i]} not supported type.`);
Expand Down
9 changes: 5 additions & 4 deletions lib/hexo/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
const moment = require('moment');
const Promise = require('bluebird');
const pathFn = require('path');
const _ = require('lodash');
const assignIn = require('lodash/assignIn');
const clone = require('lodash/clone');
const yaml = require('js-yaml');
const { slugize, escapeRegExp } = require('hexo-util');
const fs = require('hexo-fs');
Expand Down Expand Up @@ -111,7 +112,7 @@ Post.prototype._renderScaffold = function(data) {
let yfmSplit;

return this._getScaffold(data.layout).then(scaffold => {
const frontMatter = prepareFrontMatter(_.clone(data));
const frontMatter = prepareFrontMatter(clone(data));
yfmSplit = yfm.split(scaffold);

return tag.render(yfmSplit.data, frontMatter);
Expand All @@ -129,7 +130,7 @@ Post.prototype._renderScaffold = function(data) {

// Add data which are not in the front-matter
for (const key of Object.keys(data)) {
if (!_.includes(preservedKeys, key) && obj[key] == null) {
if (!preservedKeys.includes(key) && obj[key] == null) {
obj[key] = data[key];
}
}
Expand Down Expand Up @@ -197,7 +198,7 @@ Post.prototype.publish = function(data, replace, callback) {
return fs.readFile(src);
}).then(content => {
// Create post
_.extend(data, yfm(content));
assignIn(data, yfm(content));
data.content = data._content;
delete data._content;

Expand Down
9 changes: 4 additions & 5 deletions lib/models/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const Schema = require('warehouse').Schema;
const moment = require('moment');
const pathFn = require('path');
const Promise = require('bluebird');
const _ = require('lodash');
const Moment = require('./types/moment');

function pickID(data) {
Expand Down Expand Up @@ -51,11 +50,11 @@ module.exports = ctx => {
});

Post.virtual('permalink').get(function() {
const self = _.assign({}, ctx.extend.helper.list(), ctx);
const self = Object.assign({}, ctx.extend.helper.list(), ctx);
const config = ctx.config;
let partial_url = self.url_for(this.path);
if (config.relative_link) partial_url = `/${partial_url}`;
return config.url + _.replace(partial_url, config.root, '/');
return config.url + partial_url.replace(config.root, '/');
});

Post.virtual('full_source').get(function() {
Expand Down Expand Up @@ -109,7 +108,7 @@ module.exports = ctx => {
});
}).then(tags => {
// Remove old tags
const deleted = _.difference(existed, tags.map(pickID));
const deleted = existed.filter(item => !tags.map(pickID).includes(item));
return deleted;
}).map(tag => PostTag.removeById(tag));
});
Expand Down Expand Up @@ -190,7 +189,7 @@ module.exports = ctx => {
category_id: catId
});
}).then(postCats => // Remove old categories
_.difference(existed, postCats.map(pickID))).map(cat => PostCategory.removeById(cat));
existed.filter(item => !postCats.map(pickID).includes(item))).map(cat => PostCategory.removeById(cat));
});

// Remove PostTag references
Expand Down
3 changes: 1 addition & 2 deletions lib/models/post_asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const Schema = require('warehouse').Schema;
const pathFn = require('path');
const _ = require('lodash');

module.exports = ctx => {
const PostAsset = new Schema({
Expand All @@ -21,7 +20,7 @@ module.exports = ctx => {
// PostAsset.path is file path relative to `public_dir`
// no need to urlescape, #1562
// strip /\.html?$/ extensions on permalink, #2134
return pathFn.join(_.replace(post.path, /\.html?$/, ''), this.slug);
return pathFn.join(post.path.replace(/\.html?$/, ''), this.slug);
});

PostAsset.virtual('source').get(function() {
Expand Down
7 changes: 4 additions & 3 deletions lib/plugins/console/deploy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const _ = require('lodash');
const assignIn = require('lodash/assignIn');
const clone = require('lodash/clone');
const fs = require('hexo-fs');
const chalk = require('chalk');
const Promise = require('bluebird');
Expand All @@ -23,7 +24,7 @@ function deployConsole(args) {
}

return new Promise((resolve, reject) => {
const generateArgs = _.clone(args);
const generateArgs = clone(args);
generateArgs.d = false;
generateArgs.deploy = false;

Expand Down Expand Up @@ -52,7 +53,7 @@ function deployConsole(args) {

self.log.info('Deploying: %s', chalk.magenta(type));

return deployers[type].call(self, _.extend({}, item, args)).then(() => {
return deployers[type].call(self, assignIn({}, item, args)).then(() => {
self.log.info('Deploy done: %s', chalk.magenta(type));
});
}).then(() => {
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/filter/new_post_path.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const pathFn = require('path');
const moment = require('moment');
const _ = require('lodash');
const defaults = require('lodash/defaults');
const Promise = require('bluebird');
const util = require('hexo-util');
const fs = require('hexo-fs');
Expand Down Expand Up @@ -77,7 +77,7 @@ function newPostPathFilter(data = {}, replace) {
}

target = pathFn.join(postDir, permalink.stringify(
_.defaults(filenameData, permalinkDefaults)));
defaults(filenameData, permalinkDefaults)));
}
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/filter/post_permalink.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const _ = require('lodash');
const defaults = require('lodash/defaults');
const util = require('hexo-util');
const pathFn = require('path');
const Permalink = util.Permalink;
Expand Down Expand Up @@ -44,7 +44,7 @@ function postPermalinkFilter(data) {
Object.defineProperty(meta, key, Object.getOwnPropertyDescriptor(data, key));
}

return permalink.stringify(_.defaults(meta, config.permalink_defaults));
return permalink.stringify(defaults(meta, config.permalink_defaults));
}

module.exports = postPermalinkFilter;
2 changes: 1 addition & 1 deletion lib/plugins/helper/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const moment = require('moment-timezone');
const isMoment = moment.isMoment;
const isDate = require('lodash').isDate;
const isDate = require('lodash/isDate');

function getMoment(date, lang, timezone) {
if (date == null) date = moment();
Expand Down
5 changes: 2 additions & 3 deletions lib/plugins/helper/partial.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const pathFn = require('path');
const _ = require('lodash');
const chalk = require('chalk');

module.exports = ctx => function partial(name, locals, options) {
Expand All @@ -22,9 +21,9 @@ module.exports = ctx => function partial(name, locals, options) {
}

if (options.only) {
_.assign(viewLocals, locals);
Object.assign(viewLocals, locals);
} else {
_.assign(viewLocals, this, locals);
Object.assign(viewLocals, this, locals);
}

// Partial don't need layout
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/helper/toc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

let cheerio;
const _ = require('lodash');
const escape = require('lodash/escape');

function tocHelper(str, options = {}) {
if (!cheerio) cheerio = require('cheerio');
Expand All @@ -24,7 +24,7 @@ function tocHelper(str, options = {}) {
headings.each(function() {
const level = +this.name[1];
const id = $(this).attr('id');
const text = _.escape($(this).text());
const text = escape($(this).text());

lastNumber[level - 1]++;

Expand Down
3 changes: 1 addition & 2 deletions lib/plugins/helper/url_for.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const url = require('url');
const _ = require('lodash');

function urlForHelper(path = '/', options) {
if (path[0] === '#' || path.startsWith('//')) {
Expand All @@ -12,7 +11,7 @@ function urlForHelper(path = '/', options) {
const root = config.root;
const data = url.parse(path);

options = _.assign({
options = Object.assign({
relative: config.relative_link
}, options);

Expand Down
5 changes: 2 additions & 3 deletions lib/plugins/processor/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
const Pattern = require('hexo-util').Pattern;
const moment = require('moment-timezone');
const minimatch = require('minimatch');
const _ = require('lodash');

const DURATION_MINUTE = 1000 * 60;

Expand All @@ -13,7 +12,7 @@ function isTmpFile(path) {
}

function isHiddenFile(path) {
return /(^|\/)[_\.]/.test(path); // eslint-disable-line no-useless-escape
return /(^|\/)[_.]/.test(path);
}

exports.ignoreTmpAndHiddenFile = new Pattern(path => {
Expand Down Expand Up @@ -51,7 +50,7 @@ exports.isMatch = (path, patterns) => {
if (!patterns) return false;
if (!Array.isArray(patterns)) patterns = [patterns];

patterns = _.compact(patterns);
patterns = patterns.filter(value => value);
if (!patterns.length) return false;

for (let i = 0, len = patterns.length; i < len; i++) {
Expand Down
7 changes: 3 additions & 4 deletions lib/plugins/processor/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const Promise = require('bluebird');
const yfm = require('hexo-front-matter');
const pathFn = require('path');
const fs = require('hexo-fs');
const _ = require('lodash');
const util = require('hexo-util');
const slugize = util.slugize;
const Pattern = util.Pattern;
Expand Down Expand Up @@ -193,7 +192,7 @@ module.exports = ctx => {
for (let i = 0, len = posts.length; i < len; i++) {
post = posts[i];

if (_.startsWith(file.source, post.asset_dir)) {
if (file.source.startsWith(post.asset_dir)) {
return PostAsset.save({
_id: id,
slug: file.source.substring(post.asset_dir.length),
Expand All @@ -215,12 +214,12 @@ module.exports = ctx => {

let result;

if (_.startsWith(path, postDir)) {
if (path.startsWith(postDir)) {
result = {
published: true,
path: path.substring(postDir.length)
};
} else if (_.startsWith(path, draftDir)) {
} else if (path.startsWith(draftDir)) {
result = {
published: false,
path: path.substring(draftDir.length)
Expand Down
Loading

0 comments on commit de7ec24

Please sign in to comment.