Skip to content

Commit 0229cd5

Browse files
authored
Merge pull request #544 from GetPublii/v.0.35.1
V.0.35.1
2 parents 0be6bec + 0c3c0b3 commit 0229cd5

File tree

335 files changed

+1076
-47671
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

335 files changed

+1076
-47671
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.35.0 (build 11899)**
12+
**Current version: 0.35.1 (build 11963)**
1313

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

app/back-end/builddata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"0.35.0","build":11899,"status":"Beta"}
1+
{"version":"0.35.1","build":11963,"status":"Beta"}

app/back-end/events/site.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const URLHelper = require('../modules/render-html/helpers/url.js');
1717
class SiteEvents {
1818
constructor(appInstance) {
1919
let self = this;
20+
this.regenerateProcess = false;
2021

2122
/*
2223
* Reload site config and data
@@ -352,7 +353,17 @@ class SiteEvents {
352353
*/
353354
ipcMain.on('app-site-regenerate-thumbnails', function(event, config) {
354355
let site = new Site(appInstance, config, true);
355-
site.regenerateThumbnails(event.sender);
356+
self.regenerateProcess = site.regenerateThumbnails(event.sender);
357+
});
358+
359+
ipcMain.on('app-site-abort-regenerate-thumbnails', function(event, config) {
360+
if (self.regenerateProcess) {
361+
self.regenerateProcess.send({
362+
type: 'abort'
363+
});
364+
365+
self.regenerateProcess = false;
366+
}
356367
});
357368

358369
/*

app/back-end/helpers/slug.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,29 @@ slug.defaults.modes['rfc3986-non-unicode-with-dots-no-lower'] = {
3131

3232
slug.defaults.mode = 'rfc3986-non-unicode';
3333

34+
/**
35+
* Define custom slug charmap
36+
*/
37+
slug.defaults.charmap['ä'] = 'ae';
38+
slug.defaults.charmap['Ä'] = 'AE';
39+
slug.defaults.charmap['ö'] = 'oe';
40+
slug.defaults.charmap['Ö'] = 'OE';
41+
slug.defaults.charmap['ü'] = 'ue';
42+
slug.defaults.charmap['Ü'] = 'UE';
43+
slug.defaults.charmap['ß'] = 'ss';
44+
slug.defaults.charmap['ẞ'] = 'SS';
45+
3446
function createSlug(textToSlugify, filenameMode = false, saveLowerChars = false) {
35-
textToSlugify = transliterate(textToSlugify);
47+
textToSlugify = transliterate(textToSlugify, { replace: [
48+
['ä', 'ae'],
49+
['Ä', 'AE'],
50+
['ö', 'oe'],
51+
['Ö', 'OE'],
52+
['ü', 'ue'],
53+
['Ü', 'UE'],
54+
['ß', 'ss'],
55+
['ẞ', 'SS']
56+
] });
3657

3758
if(!filenameMode) {
3859
if(saveLowerChars) {

app/back-end/image.js

Lines changed: 56 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,15 @@ const Themes = require('./themes.js');
1111
const Utils = require('./helpers/utils.js');
1212
const slug = require('./helpers/slug');
1313
const Jimp = require('jimp');
14-
15-
let sharp;
16-
17-
if (process.platform !== 'linux') {
18-
sharp = require('sharp');
19-
}
14+
const sharp = require('sharp');
2015

2116
class Image extends Model {
2217
constructor(appInstance, imageData) {
2318
super(appInstance, imageData);
2419
// Post ID
2520
this.id = parseInt(imageData.id, 10);
2621

27-
if(imageData.id === 'website') {
22+
if (imageData.id === 'website') {
2823
this.id = 'website';
2924
}
3025

@@ -35,7 +30,7 @@ class Image extends Model {
3530
// Image Type
3631
this.imageType = 'contentImages';
3732

38-
if(imageData.imageType) {
33+
if (imageData.imageType) {
3934
this.imageType = imageData.imageType;
4035
}
4136
}
@@ -52,8 +47,9 @@ class Image extends Model {
5247
// Store it in the temp directory
5348
this.id = 'temp';
5449
}
50+
5551
// For images added to existing posts
56-
if(!this.path) {
52+
if (!this.path) {
5753
return;
5854
}
5955

@@ -69,14 +65,14 @@ class Image extends Model {
6965
let galleryDirPath = '';
7066
let responsiveDirPath = '';
7167

72-
if(this.id === 'website') {
68+
if (this.id === 'website') {
7369
dirPath = path.join(this.siteDir, 'input', 'media', 'website');
7470
responsiveDirPath = path.join(this.siteDir, 'input', 'media', 'website', 'responsive');
7571
} else {
7672
dirPath = path.join(this.siteDir, 'input', 'media', 'posts', (this.id).toString());
7773
responsiveDirPath = path.join(this.siteDir, 'input', 'media', 'posts', (this.id).toString(), 'responsive');
7874

79-
if(this.imageType === 'galleryImages') {
75+
if (this.imageType === 'galleryImages') {
8076
galleryDirPath = path.join(this.siteDir, 'input', 'media', 'posts', (this.id).toString(), 'gallery');
8177
}
8278
}
@@ -101,7 +97,7 @@ class Image extends Model {
10197
finalFileName = slug(finalFileName.name, false, true) + finalFileName.ext;
10298
newPath = path.join(dirPath, finalFileName);
10399

104-
if(this.imageType === 'galleryImages') {
100+
if (this.imageType === 'galleryImages') {
105101
newPath = path.join(galleryDirPath, finalFileName);
106102
}
107103

@@ -116,7 +112,7 @@ class Image extends Model {
116112
let pathData = path.parse(newPath);
117113

118114
// Save responsive images
119-
if(generateResponsiveImages && self.allowedImageExtension(pathData.ext)) {
115+
if (generateResponsiveImages && self.allowedImageExtension(pathData.ext)) {
120116
self.createResponsiveImages(newPath, self.imageType);
121117
}
122118

@@ -132,9 +128,10 @@ class Image extends Model {
132128
}
133129
}
134130

131+
// Get image dimensions
135132
let dimensions = [false, false];
136133

137-
if(path.parse(this.path).ext === '.svg') {
134+
if (path.parse(this.path).ext === '.svg') {
138135
dimensions = this.getSvgImageDimensions(this.path);
139136
} else {
140137
try {
@@ -166,26 +163,39 @@ class Image extends Model {
166163
let siteConfig = JSON.parse(fs.readFileSync(siteConfigPath));
167164
let imagesQuality = 60;
168165
let imageExtension = path.parse(originalPath).ext;
166+
let imageDimensions = {
167+
width: false,
168+
height: false
169+
};
169170

170-
if(!this.allowedImageExtension(imageExtension)) {
171+
if (!this.allowedImageExtension(imageExtension)) {
171172
return [];
172173
}
173174

174-
if(
175+
try {
176+
imageDimensions = sizeOf(this.path);
177+
} catch(e) {
178+
imageDimensions = {
179+
width: false,
180+
height: false
181+
};
182+
}
183+
184+
if (
175185
siteConfig.advanced &&
176186
siteConfig.advanced.imagesQuality &&
177187
!isNaN(parseInt(siteConfig.advanced.imagesQuality, 10))
178188
) {
179189
imagesQuality = siteConfig.advanced.imagesQuality;
180190
imagesQuality = parseInt(imagesQuality);
181191

182-
if(imagesQuality < 1 || imagesQuality > 100) {
192+
if (imagesQuality < 1 || imagesQuality > 100) {
183193
imagesQuality = 60;
184194
}
185195
}
186196

187197
// If there is no selected theme
188-
if(currentTheme === 'not selected' && imageType !== 'galleryImages') {
198+
if (currentTheme === 'not selected' && imageType !== 'galleryImages') {
189199
return false;
190200
}
191201

@@ -196,20 +206,20 @@ class Image extends Model {
196206
let dimensions = false;
197207
let dimensionsConfig = false;
198208

199-
if(imageType === 'featuredImages' && Utils.responsiveImagesConfigExists(themeConfig, imageType)) {
209+
if (imageType === 'featuredImages' && Utils.responsiveImagesConfigExists(themeConfig, imageType)) {
200210
dimensions = Utils.responsiveImagesDimensions(themeConfig, 'featuredImages');
201211
dimensionsConfig = Utils.responsiveImagesData(themeConfig, 'featuredImages');
202-
} else if(imageType === 'optionImages' && Utils.responsiveImagesConfigExists(themeConfig, imageType)) {
212+
} else if (imageType === 'optionImages' && Utils.responsiveImagesConfigExists(themeConfig, imageType)) {
203213
dimensions = Utils.responsiveImagesDimensions(themeConfig, 'optionImages');
204214
dimensionsConfig = Utils.responsiveImagesData(themeConfig, 'optionImages');
205-
} else if(imageType === 'contentImages' && Utils.responsiveImagesConfigExists(themeConfig, 'contentImages')) {
215+
} else if (imageType === 'contentImages' && Utils.responsiveImagesConfigExists(themeConfig, 'contentImages')) {
206216
dimensions = Utils.responsiveImagesDimensions(themeConfig, 'contentImages');
207217
dimensionsConfig = Utils.responsiveImagesData(themeConfig, 'contentImages');
208-
} else if(imageType === 'galleryImages' && Utils.responsiveImagesConfigExists(themeConfig, 'galleryImages')) {
218+
} else if (imageType === 'galleryImages' && Utils.responsiveImagesConfigExists(themeConfig, 'galleryImages')) {
209219
dimensions = Utils.responsiveImagesDimensions(themeConfig, 'galleryImages');
210220
dimensionsConfig = Utils.responsiveImagesData(themeConfig, 'galleryImages');
211221

212-
if(!dimensionsConfig) {
222+
if (!dimensionsConfig) {
213223
dimensions = ['thumbnail'];
214224

215225
dimensionsConfig = [];
@@ -221,20 +231,20 @@ class Image extends Model {
221231
}
222232
}
223233

224-
if(!dimensions) {
234+
if (!dimensions) {
225235
return false;
226236
}
227237

228238
let targetImagesDir = path.parse(originalPath).dir;
229239

230-
if(imageType !== 'galleryImages') {
240+
if (imageType !== 'galleryImages') {
231241
targetImagesDir = path.join(targetImagesDir, 'responsive');
232242
}
233243

234244
let promises = [];
235245

236246
// create responsive images for each size
237-
for(let name of dimensions) {
247+
for (let name of dimensions) {
238248
let finalHeight = dimensionsConfig[name].height;
239249
let finalWidth = dimensionsConfig[name].width;
240250
let cropImage = dimensionsConfig[name].crop;
@@ -243,28 +253,36 @@ class Image extends Model {
243253
let destinationPath = path.join(targetImagesDir, filename + '-' + name + extension);
244254
let result;
245255

246-
if(!this.allowedImageExtension(extension)) {
256+
if (!this.allowedImageExtension(extension)) {
247257
continue;
248258
}
249259

250-
if(finalHeight === 'auto') {
260+
if (imageDimensions.width !== false && finalWidth !== 'auto' && finalWidth > imageDimensions.width) {
261+
finalWidth = imageDimensions.width;
262+
}
263+
264+
if (imageDimensions.height !== false && finalHeight !== 'auto' && finalHeight > imageDimensions.height) {
265+
finalHeight = imageDimensions.height;
266+
}
267+
268+
if (finalHeight === 'auto') {
251269
finalHeight = null;
252270

253-
if(this.shouldUseJimp()) {
271+
if (this.shouldUseJimp()) {
254272
finalHeight = Jimp.AUTO;
255273
}
256274
}
257275

258-
if(finalWidth === 'auto') {
276+
if (finalWidth === 'auto') {
259277
finalWidth = null;
260278

261-
if(this.shouldUseJimp()) {
279+
if (this.shouldUseJimp()) {
262280
finalWidth = Jimp.AUTO;
263281
}
264282
}
265283

266-
if(cropImage) {
267-
if(this.shouldUseJimp()) {
284+
if (cropImage) {
285+
if (this.shouldUseJimp()) {
268286
result = new Promise ((resolve, reject) => {
269287
Jimp.read(originalPath, function (err, image) {
270288
if (err) {
@@ -322,7 +340,7 @@ class Image extends Model {
322340
}).catch(err => console.log(err));
323341
}
324342
} else {
325-
if(this.shouldUseJimp()) {
343+
if (this.shouldUseJimp()) {
326344
result = new Promise ((resolve, reject) => {
327345
Jimp.read(originalPath, function (err, image) {
328346
if (err) {
@@ -392,13 +410,13 @@ class Image extends Model {
392410
let svgHeight = svgFileContent.match(/\<svg.*height=['"]{1}(.*?)['"]{1}.*\>/mi);
393411
let svgViewBox = svgFileContent.match(/\<svg.*viewBox=['"]{1}(.*?)['"]{1}.*\>/mi);
394412

395-
if(svgWidth && svgHeight && svgWidth[1].indexOf('%') === 1 && svgHeight[1].indexOf('%') === 1) {
413+
if (svgWidth && svgHeight && svgWidth[1].indexOf('%') === 1 && svgHeight[1].indexOf('%') === 1) {
396414
result.height = parseInt(svgHeight, 10);
397415
result.width = parseInt(svgWidth, 10);
398-
} else if(svgViewBox && svgViewBox[1]) {
416+
} else if (svgViewBox && svgViewBox[1]) {
399417
svgViewBox = svgViewBox[1].split(' ');
400418

401-
if(svgViewBox.length === 4) {
419+
if (svgViewBox.length === 4) {
402420
result.height = svgViewBox[3];
403421
result.width = svgViewBox[2];
404422
}
@@ -420,12 +438,7 @@ class Image extends Model {
420438
* Detect if Jimp should be used
421439
*/
422440
shouldUseJimp() {
423-
return (
424-
process.platform === 'linux' || (
425-
this.appInstance.appConfig.resizeEngine &&
426-
this.appInstance.appConfig.resizeEngine === 'jimp'
427-
)
428-
);
441+
return this.appInstance.appConfig.resizeEngine && this.appInstance.appConfig.resizeEngine === 'jimp';
429442
}
430443
}
431444

app/back-end/modules/custom-changes/ftp/lib/connection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var /*TYPE = {
4949
552: 'Requested file action aborted / Exceeded storage allocation (for current directory or dataset)',
5050
553: 'Requested action not taken / File name not allowed'
5151
},*/
52-
bytesNOOP = new Buffer('NOOP\r\n');
52+
bytesNOOP = Buffer.from('NOOP\r\n');
5353

5454
var FTP = module.exports = function() {
5555
if (!(this instanceof FTP))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ class GitlabPages {
545545
}
546546

547547
readFile (filePath) {
548-
return new Buffer(fs.readFileSync(filePath)).toString('base64');
548+
return Buffer.from(fs.readFileSync(filePath)).toString('base64');
549549
}
550550

551551
isBinaryFile (fullPath) {

0 commit comments

Comments
 (0)