Skip to content

Commit 75626e6

Browse files
committed
Merge branch 'v.0.46.5'
2 parents 12f0976 + df23dce commit 75626e6

File tree

39 files changed

+904
-352
lines changed

39 files changed

+904
-352
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[Publii](https://getpublii.com/) is a desktop-based CMS for Windows, Mac and Linux that makes creating static websites fast
1010
and hassle-free, even for beginners.
1111

12-
**Current version: 0.46.4 (build 17037)**
12+
**Current version: 0.46.5 (build 17089)**
1313

1414
## Why Publii?
1515
Unlike static-site generators that are often unwieldy and difficult to use, Publii provides an

app/back-end/author.js

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ class Author extends Model {
3131
this.additionalData = authorData.additionalData;
3232
}
3333

34+
if (authorData.imageConfigFields) {
35+
this.imageConfigFields = authorData.imageConfigFields;
36+
}
37+
3438
if(authorData.name || authorData.name === '') {
3539
this.name = authorData.name;
3640
this.username = authorData.username;
@@ -89,11 +93,11 @@ class Author extends Model {
8993
}
9094

9195
if (this.id !== 0) {
96+
this.checkAndCleanImages();
9297
return this.updateAuthor();
9398
}
9499

95100
this.checkAndCleanImages();
96-
97101
return this.addAuthor();
98102
}
99103

@@ -291,23 +295,26 @@ class Author extends Model {
291295
*/
292296
cleanImages(images, imagesDir, cancelEvent) {
293297
let authorDir = this.id;
294-
let featuredImage = false;
295-
298+
let featuredImage = '';
299+
let viewConfig = {};
300+
296301
if (this.additionalData && this.additionalData.featuredImage) {
297302
featuredImage = path.parse(this.additionalData.featuredImage).base;
298303
}
299304

305+
if (this.additionalData && this.additionalData.viewConfig) {
306+
viewConfig = this.additionalData.viewConfig;
307+
}
308+
300309
// If author is cancelled - get the previous featured image
301310
if (cancelEvent && this.id !== 0) {
302-
let featuredImageSqlQuery = `SELECT additional_data FROM authors WHERE id = @id`;
303-
304-
let featuredImageResult = this.db.prepare(featuredImageSqlQuery).all({
305-
id: this.id
306-
});
311+
let additionalDataQuery = `SELECT additional_data FROM authors WHERE id = @id`;
312+
let additionalDataResult = this.db.prepare(additionalDataQuery).all({ id: this.id });
307313

308-
if (featuredImageResult && featuredImageResult[0]) {
314+
if (additionalDataResult) {
309315
try {
310-
featuredImage = JSON.parse(featuredImageResult[0].additional_data).featuredImage;
316+
featuredImage = JSON.parse(additionalDataResult[0].additional_data).featuredImage;
317+
viewConfig = JSON.parse(additionalDataResult[0].additional_data).viewConfig;
311318
} catch (e) {
312319
console.log('(!) An issue occurred during parsing author additional data', this.id);
313320
}
@@ -318,11 +325,13 @@ class Author extends Model {
318325
authorDir = 'temp';
319326
}
320327

321-
let imagesInAuthorViewSettings = [];
328+
let imagesInViewSettings = [];
322329

323-
if (this.additionalData && this.additionalData.viewConfig) {
324-
imagesInAuthorViewSettings = Object.values(this.additionalData.viewConfig).filter(item => item.type === "image").map(item => item.value);
325-
}
330+
imagesInViewSettings = Object.keys(viewConfig).filter((fieldName) => {
331+
return this.imageConfigFields.indexOf(fieldName) !== -1 && viewConfig[fieldName] !== '';
332+
}).map((fieldName) => {
333+
return viewConfig[fieldName];
334+
});
326335

327336
// Iterate through images
328337
for (let i in images) {
@@ -335,10 +344,10 @@ class Author extends Model {
335344
}
336345

337346
// Remove files which does not exist as featured image and authorViewSettings
338-
if(
347+
if (
339348
(cancelEvent && authorDir === 'temp') ||
340349
(
341-
imagesInAuthorViewSettings.indexOf(imagePath) === -1 &&
350+
imagesInViewSettings.indexOf(imagePath) === -1 &&
342351
featuredImage !== imagePath
343352
)
344353
) {

app/back-end/builddata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"version": "0.46.4",
3-
"build": 17048
2+
"version": "0.46.5",
3+
"build": 17089
44
}

app/back-end/image.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const normalizePath = require('normalize-path');
1010
const Themes = require('./themes.js');
1111
const Utils = require('./helpers/utils.js');
1212
const slug = require('./helpers/slug');
13-
const Jimp = require('./vendor/jimp.custom.js');
13+
const Jimp = require('jimp');
1414
// Default config
1515
const defaultAstCurrentSiteConfig = require('./../config/AST.currentSite.config');
1616
let sharp = require('sharp');

app/back-end/modules/deploy/gitlab-pages.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,13 @@ class GitlabPages {
193193
this.projectID = projects[0].id;
194194

195195
this.client.RepositoryFiles.showRaw(this.projectID, 'publii-files.json', this.branch).then(response => {
196-
let remoteListToCheck = fs.readFileSync(path.join(this.deployment.configDir, 'files-remote.json'), 'utf-8');
196+
let remoteListToCheck = '';
197+
198+
if (typeof response === 'Buffer') {
199+
remoteListToCheck = response.toString();
200+
} else {
201+
remoteListToCheck = response;
202+
}
197203

198204
try {
199205
if (remoteListToCheck.length) {

app/back-end/modules/deploy/s3.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,22 @@ class S3 {
305305

306306
try {
307307
await this.connection.send(new DeleteObjectCommand(params));
308-
console.log(`[${new Date().toUTCString()}] DEL ${input}`);
309308
this.deployment.currentOperationNumber++;
310309
console.log(`[${ new Date().toUTCString() }] DEL ${input}`);
311310
this.deployment.progressOfDeleting += this.deployment.progressPerFile;
312311
this.sendProgress(8 + Math.floor(this.deployment.progressOfDeleting));
313312
await this.removeFile();
314313
} catch (err) {
314+
// Handle case when specific file no longer exists in the bucket - don't block sync
315+
if (err.name === 'NoSuchKey') {
316+
this.deployment.currentOperationNumber++;
317+
console.log(`[${ new Date().toUTCString() }] DEL ${input} - NoSuchKey`);
318+
this.deployment.progressOfDeleting += this.deployment.progressPerFile;
319+
this.sendProgress(8 + Math.floor(this.deployment.progressOfDeleting));
320+
await this.removeFile();
321+
return;
322+
}
323+
315324
console.error(`[${new Date().toUTCString()}] Error deleting ${input}`, err);
316325
this.onError(err, true);
317326
}

app/back-end/modules/import/wxr-parser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ class WxrParser {
581581
});
582582

583583
let featuredPageID = newPage.db.prepare('SELECT last_insert_rowid() AS id').get().id;
584-
let featuredPageIdUpdate = newPage.db.prepare(`UPDATE posts SET featured_image_id = @featuredPostID WHERE id = @newPageID`);
584+
let featuredPageIdUpdate = newPage.db.prepare(`UPDATE posts SET featured_image_id = @featuredPageID WHERE id = @newPageID`);
585585

586586
featuredPageIdUpdate.run({
587587
featuredPageID,
@@ -819,7 +819,7 @@ class WxrParser {
819819
text = text.replace(/\[\/caption\]/g, '');
820820

821821
// Replace <!-- more --> with Publii separator
822-
text = text.replace(/<!--more-->/g, '<hr id="read-more" />');
822+
text = text.replace(/<!--more-->/g, '<hr id="read-more">');
823823

824824
if(this.autop) {
825825
console.log('(i) Used automatic paragraphs for the post content');

app/back-end/modules/plugins/plugins-helpers.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ class PluginsHelpers {
4545
}
4646

4747
if (pluginConfig.assets && pluginConfig.assets.front) {
48-
pluginConfig.assets.front = pluginConfig.assets.front.map(fileName => fileName.replace(/[^a-zA-Z0-9\-\_\.\*\@\+]/gmi, ''));
48+
pluginConfig.assets.front = pluginConfig.assets.front.map(fileName => fileName.split('/'));
4949
return pluginConfig.assets.front.map(fileName => ({
50-
input: path.join(pluginsDir, pluginName, 'front-assets', fileName),
51-
output: fileName
50+
input: path.join(pluginsDir, pluginName, 'front-assets', ...fileName),
51+
output: fileName.join('/')
5252
}));
5353
}
5454

5555
return [];
5656
}
5757
}
5858

59-
module.exports = PluginsHelpers;
59+
module.exports = PluginsHelpers;

app/back-end/modules/render-html/handlebars/helpers/feed-link.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ function feedLink() {
3131

3232
if (this.siteConfig.advanced.feed.enableRss) {
3333
let rssUrl = Handlebars.Utils.escapeExpression(this.siteConfig.domain + '/feed.xml');
34-
output += '<link rel="alternate" type="application/atom+xml" href="' + rssUrl + '" ' + rssFeedTitle + ' />' + "\n";
34+
output += '<link rel="alternate" type="application/atom+xml" href="' + rssUrl + '" ' + rssFeedTitle + '>' + "\n";
3535
}
3636

3737
if (this.siteConfig.advanced.feed.enableJson) {
3838
let jsonUrl = Handlebars.Utils.escapeExpression(this.siteConfig.domain + '/feed.json');
39-
output += '<link rel="alternate" type="application/json" href="' + jsonUrl + '" ' + jsonFeedTitle + ' />' + "\n";
39+
output += '<link rel="alternate" type="application/json" href="' + jsonUrl + '" ' + jsonFeedTitle + '>' + "\n";
4040
}
4141
}
4242

app/back-end/modules/render-html/handlebars/helpers/meta-description.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function metaDescription(options) {
1313
return '';
1414
}
1515

16-
let output = '<meta name="description" content="' + options.data.root.metaDescriptionRaw.replace(/"/g, "'") + '" />';
16+
let output = '<meta name="description" content="' + options.data.root.metaDescriptionRaw.replace(/"/g, "'") + '">';
1717
return new Handlebars.SafeString(output);
1818
}
1919

0 commit comments

Comments
 (0)