Skip to content

Commit

Permalink
Merge branch 'master' into refactor/drop-external-linl-boolean-option
Browse files Browse the repository at this point in the history
  • Loading branch information
renbaoshuo authored Sep 18, 2022
2 parents 8e8e005 + 976c897 commit 041fd3e
Show file tree
Hide file tree
Showing 13 changed files with 2 additions and 270 deletions.
1 change: 0 additions & 1 deletion lib/hexo/default_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ module.exports = {
time_format: 'HH:mm:ss',
updated_option: 'mtime',
// * mtime: file modification date (default)
// * date: use_date_for_updated
// * empty: no more update
// Pagination
per_page: 10,
Expand Down
5 changes: 0 additions & 5 deletions lib/hexo/validate_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,5 @@ module.exports = ctx => {
if (config.root.trim().length <= 0) {
throw new TypeError('Invalid config detected: "root" should not be empty!');
}

// Soft deprecate use_date_for_updated
if (typeof config.use_date_for_updated === 'boolean') {
log.warn('Deprecated config detected: "use_date_for_updated" is deprecated, please use "updated_option" instead. See https://hexo.io/docs/configuration for more details.');
}
};

3 changes: 1 addition & 2 deletions lib/plugins/processor/asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ function processPage(ctx, file) {
const doc = Page.findOne({source: path});
const { config } = ctx;
const { timezone: timezoneCfg } = config;
// Deprecated: use_date_for_updated will be removed in future
const updated_option = config.use_date_for_updated === true ? 'date' : config.updated_option;
const updated_option = config.updated_option;

if (file.type === 'skip' && doc) {
return;
Expand Down
3 changes: 1 addition & 2 deletions lib/plugins/processor/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ function processPost(ctx, file) {
const doc = Post.findOne({source: file.path});
const { config } = ctx;
const { timezone: timezoneCfg } = config;
// Deprecated: use_date_for_updated will be removed in future
const updated_option = config.use_date_for_updated === true ? 'date' : config.updated_option;
const updated_option = config.updated_option;
let categories, tags;

if (file.type === 'skip' && doc) {
Expand Down
4 changes: 0 additions & 4 deletions lib/plugins/tag/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ module.exports = ctx => {
tag.register('include_code', includeCode, {async: true});
tag.register('include-code', includeCode, {async: true});

tag.register('jsfiddle', require('./jsfiddle'));

const link = require('./link');

tag.register('a', link);
Expand All @@ -50,8 +48,6 @@ module.exports = ctx => {

tag.register('pullquote', require('./pullquote')(ctx), true);

tag.register('vimeo', require('./vimeo'));

tag.register('youtube', require('./youtube'));
};

Expand Down
33 changes: 0 additions & 33 deletions lib/plugins/tag/jsfiddle.js

This file was deleted.

25 changes: 0 additions & 25 deletions lib/plugins/tag/vimeo.js

This file was deleted.

9 changes: 0 additions & 9 deletions test/scripts/hexo/validate_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,4 @@ describe('Validate config', () => {
e.message.should.eql('Invalid config detected: "root" should not be empty!');
}
});

it('config.use_date_for_updated - depreacte', () => {
hexo.config.use_date_for_updated = true;

validateConfig(hexo);

logSpy.calledOnce.should.be.true;
logSpy.calledWith('Deprecated config detected: "use_date_for_updated" is deprecated, please use "updated_option" instead. See https://hexo.io/docs/configuration for more details.').should.be.true;
});
});
57 changes: 0 additions & 57 deletions test/scripts/processors/asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,63 +359,6 @@ describe('asset', () => {
]);
});

it('page - use_date_for_updated as fallback', async () => {
const body = [
'date: 2011-4-5 14:19:19',
'---'
].join('\n');

const file = newFile({
path: 'hello.njk',
type: 'create',
renderable: true
});

hexo.config.use_date_for_updated = true;

await writeFile(file.source, body);
await process(file);
const stats = await stat(file.source);
const page = Page.findOne({source: file.path});

page.updated.toDate().should.eql(page.date.toDate());
page.updated.toDate().should.not.eql(stats.mtime);

await Promise.all([
page.remove(),
unlink(file.source)
]);
});

it('page - ignore updated_option when use_date_for_updated is set', async () => {
const body = [
'date: 2011-4-5 14:19:19',
'---'
].join('\n');

const file = newFile({
path: 'hello.njk',
type: 'create',
renderable: true
});

hexo.config.use_date_for_updated = true;
hexo.config.updated_option = 'mtime';

await writeFile(file.source, body);
await process(file);
const stats = await stat(file.source);
const page = Page.findOne({source: file.path});

page.updated.toDate().should.eql(page.date.toDate());
page.updated.toDate().should.not.eql(stats.mtime);

await Promise.all([
page.remove(),
unlink(file.source)
]);
});

it('page - permalink', async () => {
const body = [
'title: "Hello world"',
Expand Down
60 changes: 0 additions & 60 deletions test/scripts/processors/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,66 +622,6 @@ describe('post', () => {
]);
});

it('post - use use_date_for_updated as a fallback', async () => {
const body = [
'title: "Hello world"',
'---'
].join('\n');

const file = newFile({
path: 'foo.html',
published: true,
type: 'create',
renderable: true
});

hexo.config.use_date_for_updated = true;

await writeFile(file.source, body);
const stats = await file.stat();
await process(file);
const post = Post.findOne({ source: file.path });

post.date.toDate().setMilliseconds(0).should.eql(stats.birthtime.setMilliseconds(0));
post.updated.toDate().setMilliseconds(0).should.eql(stats.birthtime.setMilliseconds(0));

return Promise.all([
post.remove(),
unlink(file.source)
]);
});

it('post - ignore updated_option when use_date_for_updated is set', async () => {
const body = [
'date: 2011-4-5 14:19:19',
'title: "Hello world"',
'---'
].join('\n');

const file = newFile({
path: 'foo.html',
published: true,
type: 'create',
renderable: true
});

hexo.config.use_date_for_updated = true;
hexo.config.updated_option = 'mtime';

await writeFile(file.source, body);
const stats = await file.stat();
await process(file);
const post = Post.findOne({ source: file.path });

post.updated.toDate().setMilliseconds(0).should.eql(post.date.toDate().setMilliseconds(0));
post.updated.toDate().setMilliseconds(0).should.not.eql(stats.mtime.setMilliseconds(0));

return Promise.all([
post.remove(),
unlink(file.source)
]);
});

it('post - photo is an alias for photos', async () => {
const body = [
'title: "Hello world"',
Expand Down
2 changes: 0 additions & 2 deletions test/scripts/tags/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ describe('Tags', () => {
require('./iframe');
require('./img');
require('./include_code');
require('./jsfiddle');
require('./link');
require('./post_link');
require('./post_path');
require('./pullquote');
require('./vimeo');
require('./youtube');
});
53 changes: 0 additions & 53 deletions test/scripts/tags/jsfiddle.js

This file was deleted.

17 changes: 0 additions & 17 deletions test/scripts/tags/vimeo.js

This file was deleted.

0 comments on commit 041fd3e

Please sign in to comment.