Skip to content

Commit c053042

Browse files
authored
Merge pull request #576 from GetPublii/v.0.35.2
V.0.35.2
2 parents 85f819c + 381e03a commit c053042

35 files changed

+1789
-217
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ npm-debug.log
66
/node_modules/
77
/app/node_modules/
88
/coverage
9-
/dist/
9+
/dist
1010
/app/dist/
1111
/cache/
1212
/StaticBlog-darwin-x64/

app/back-end/app.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const compare = require('node-version-compare');
1212
const normalizePath = require('normalize-path');
1313
// Electron classes
1414
const electron = require('electron');
15+
const Menu = electron.Menu;
1516
const BrowserWindow = electron.BrowserWindow;
1617
// Collection classes
1718
const Posts = require('./posts.js');
@@ -318,8 +319,12 @@ class App {
318319
let account = passwordData[1];
319320
let retrievedPassword = '';
320321

321-
if(passwordSafeStorage) {
322-
retrievedPassword = await passwordSafeStorage.getPassword(service, account);
322+
if (passwordSafeStorage) {
323+
try {
324+
retrievedPassword = await passwordSafeStorage.getPassword(service, account);
325+
} catch (e) {
326+
console.log('(!) Cannot retrieve password via keytar');
327+
}
323328
}
324329

325330
if (retrievedPassword === null || retrievedPassword === true || retrievedPassword === false) {
@@ -484,8 +489,10 @@ class App {
484489
windowParams.icon = path.join(__dirname, '..', 'src', 'assets', 'installation', '1024x1024.png');
485490
}
486491

492+
Menu.setApplicationMenu(null);
487493
this.mainWindow = new BrowserWindow(windowParams);
488494
this.mainWindow.setMenu(null);
495+
this.mainWindow.removeMenu();
489496
this.mainWindow.loadURL('file://' + this.basedir + '/index.html');
490497

491498
this.mainWindow.webContents.on('did-finish-load', function() {

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.1","build":11963,"status":"Beta"}
1+
{"version":"0.35.2","build":12011,"status":"Beta"}

app/back-end/events/_modules.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ module.exports = {
88
PostEvents: require('./post.js'),
99
SiteEvents: require('./site.js'),
1010
TagEvents: require('./tag.js'),
11+
TagsEvents: require('./tags.js'),
1112
DeployEvents: require('./deploy.js'),
1213
SyncEvents: require('./sync.js'),
1314
MenuEvents: require('./menu.js'),
1415
PreviewEvents: require('./preview.js'),
1516
NotificationsEvents: require('./notifications.js'),
1617
BackupEvents: require('./backup.js'),
1718
AuthorEvents: require('./author.js'),
19+
AuthorsEvents: require('./authors.js'),
1820
ImportEvents: require('./import.js'),
1921
FileManagerEvents: require('./file-manager.js')
2022
};

app/back-end/events/authors.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const ipcMain = require('electron').ipcMain;
2+
const Posts = require('../posts.js');
3+
const Authors = require('../authors.js');
4+
5+
/*
6+
* Events for the IPC communication regarding authors list
7+
*/
8+
9+
class AuthorsEvents {
10+
constructor(appInstance) {
11+
// Load
12+
ipcMain.on('app-tags-load', function (event, siteData) {
13+
let postsData = new Posts(appInstance, siteData);
14+
let authorsData = new Authors(appInstance, siteData);
15+
16+
event.sender.send('app-tags-loaded', {
17+
authors: authorsData.load(),
18+
postsAuthors: postsData.loadAuthorsXRef()
19+
});
20+
});
21+
}
22+
}
23+
24+
module.exports = AuthorsEvents;

app/back-end/events/backup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ class BackupEvents {
6969
});
7070
}
7171

72-
removeBackups(siteName, backupsNames, event) {
73-
let result = Backup.remove(siteName, backupsNames, this.app.appConfig.backupsLocation);
72+
async removeBackups(siteName, backupsNames, event) {
73+
let result = await Backup.remove(siteName, backupsNames, this.app.appConfig.backupsLocation);
7474

7575
event.sender.send('app-backup-removed', {
7676
status: result.status,

app/back-end/events/tags.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const ipcMain = require('electron').ipcMain;
2+
const Posts = require('../posts.js');
3+
const Tags = require('../tags.js');
4+
5+
/*
6+
* Events for the IPC communication regarding tags list
7+
*/
8+
9+
class TagsEvents {
10+
constructor(appInstance) {
11+
// Load
12+
ipcMain.on('app-tags-load', function (event, siteData) {
13+
let postsData = new Posts(appInstance, siteData);
14+
let tagsData = new Tags(appInstance, siteData);
15+
16+
event.sender.send('app-tags-loaded', {
17+
tags: tagsData.load(),
18+
postsTags: postsData.loadTagsXRef()
19+
});
20+
});
21+
}
22+
}
23+
24+
module.exports = TagsEvents;

app/back-end/modules/backup/backup.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
*/
44

55
const fs = require('fs-extra');
6+
const os = require('os');
67
const path = require('path');
78
const Utils = require('./../../helpers/utils.js');
89
const moment = require('moment');
910
const archiver = require('archiver');
1011
const tar = require('tar');
12+
const trash = require('trash');
1113

1214
class Backup {
1315
/**
@@ -148,7 +150,7 @@ class Backup {
148150
* @param backupsDir
149151
* @returns {{status: boolean, backups: *}}
150152
*/
151-
static remove(siteName, backupsNames, backupsDir) {
153+
static async remove(siteName, backupsNames, backupsDir) {
152154
for(let backupName of backupsNames) {
153155
let backupFilePath = path.join(backupsDir, siteName, backupName);
154156

@@ -160,19 +162,31 @@ class Backup {
160162
}
161163

162164
try {
163-
fs.unlinkSync(backupFilePath);
165+
if (
166+
os.platform() !== 'darwin' ||
167+
(
168+
os.platform() === 'darwin' &&
169+
parseInt(os.release().split('.')[0], 10) >= 16
170+
)
171+
) {
172+
await (async () => {
173+
await trash(backupFilePath);
174+
})();
175+
} else {
176+
fs.unlinkSync(backupFilePath);
177+
}
164178
} catch (e) {
165-
return {
179+
return Promise.resolve({
166180
status: false,
167181
backups: Backup.loadList(siteName, backupsDir)
168-
};
182+
});
169183
}
170184
}
171185

172-
return {
186+
return Promise.resolve({
173187
status: true,
174188
backups: Backup.loadList(siteName, backupsDir)
175-
};
189+
});
176190
}
177191

178192
/**

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
const fs = require('fs-extra');
66
const path = require('path');
7-
const md5 = require('md5');
87
const ftpClient = require('./../custom-changes/ftp');
98
const passwordSafeStorage = require('keytar');
109
const slug = require('./../../helpers/slug');
@@ -48,7 +47,8 @@ class FTP {
4847
host: this.deployment.siteConfig.deployment.server,
4948
port: this.deployment.siteConfig.deployment.port,
5049
user: this.deployment.siteConfig.deployment.username,
51-
password: ftpPassword
50+
password: ftpPassword,
51+
rejectUnauthorized: this.deployment.siteConfig.deployment.rejectUnauthorized
5252
},
5353
connTimeout: 15000,
5454
pasvTimeout: 15000,
@@ -122,7 +122,10 @@ class FTP {
122122

123123
process.send({
124124
type: 'web-contents',
125-
message: 'app-connection-error'
125+
message: 'app-connection-error',
126+
value: {
127+
additionalMessage: err.message
128+
}
126129
});
127130

128131
setTimeout(function () {
@@ -470,7 +473,8 @@ class FTP {
470473
host: deploymentConfig.server,
471474
port: deploymentConfig.port,
472475
user: deploymentConfig.username,
473-
password: ftpPassword
476+
password: ftpPassword,
477+
rejectUnauthorized: deploymentConfig.rejectUnauthorized
474478
},
475479
connTimeout: 10000,
476480
pasvTimeout: 10000
@@ -533,7 +537,7 @@ class FTP {
533537
if(waitForTimeout) {
534538
waitForTimeout = false;
535539
client.destroy();
536-
app.mainWindow.webContents.send('app-deploy-test-error');
540+
app.mainWindow.webContents.send('app-deploy-test-error', { message: err.message });
537541
}
538542
});
539543

app/back-end/modules/render-html/handlebars/helpers/menu-item-classes.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ function hasActiveChild(items, context) {
138138

139139
if(items[i].items.length) {
140140
result = hasActiveChild(items[i].items, context);
141+
142+
if (result) {
143+
return true;
144+
}
141145
}
142146
}
143147

0 commit comments

Comments
 (0)