Skip to content

Commit

Permalink
Merge branch 'v.0.45'
Browse files Browse the repository at this point in the history
  • Loading branch information
dziudek committed Mar 4, 2024
2 parents a2ce42f + d61037c commit 8cb60c9
Show file tree
Hide file tree
Showing 75 changed files with 25,353 additions and 22,920 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16.19.1
v18.19.0
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[Publii](https://getpublii.com/) is a desktop-based CMS for Windows, Mac and Linux that makes creating static websites fast
and hassle-free, even for beginners.

**Current version: 0.44.4 (build 16557)**
**Current version: 0.45.0 (build 16606)**

## Why Publii?
Unlike static-site generators that are often unwieldy and difficult to use, Publii provides an
Expand Down Expand Up @@ -41,7 +41,7 @@ If you want to build newest version of Publii or contribute to the Publii code,
## Getting Started
You can learn more about getting started in our [User documentation](https://getpublii.com/docs/) or [Developer documentation](https://getpublii.com/dev/).
If you have any questions or suggestions, or just need some help with using Publii, you can
visit our [Community Hub](https://getpublii.com/forum) or follow us on [Twitter](https://twitter.com/GetPublii)
visit our [Community Hub](https://github.com/GetPublii/Publii/discussions) or follow us on [Twitter](https://twitter.com/GetPublii)

### Learn More

Expand Down
3 changes: 2 additions & 1 deletion app/back-end/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

// Necessary packages
const fs = require('fs-extra');
const os = require('os');
const path = require('path');
const { Database } = require('node-sqlite3-wasm');
const Database = os.platform() === 'linux' ? require('node-sqlite3-wasm').Database : require('better-sqlite3');
const compare = require('node-version-compare');
const normalizePath = require('normalize-path');
const url = require('url');
Expand Down
6 changes: 3 additions & 3 deletions app/back-end/builddata.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "0.44.4",
"build": 16557
}
"version": "0.45.0",
"build": 16606
}
19 changes: 13 additions & 6 deletions app/back-end/events/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const fs = require('fs-extra');
const ipcMain = require('electron').ipcMain;
const Deployment = require('../modules/deploy/deployment.js');
const childProcess = require('child_process');
const stripTags = require('striptags');

class DeployEvents {
constructor(appInstance) {
Expand Down Expand Up @@ -123,14 +124,14 @@ class DeployEvents {
event.sender.send('app-deploy-render-error', {
message: [{
message: errorTitle,
desc: errorDesc
desc: stripTags(errorDesc)
}]
});
}
} else {
event.sender.send(data.type, {
progress: data.progress,
message: data.message
message: stripTags((data.message).toString())
});
}
});
Expand All @@ -156,7 +157,8 @@ class DeployEvents {
type: 'dependencies',
appDir: this.app.appDir,
sitesDir: this.app.sitesDir,
siteConfig: deploymentConfig
siteConfig: deploymentConfig,
useFtpAlt: this.app.appConfig.experimentalFeatureAppAutoBeautifySourceCode
});

this.deploymentProcess.on('message', function(data) {
Expand All @@ -174,9 +176,14 @@ class DeployEvents {
});
}

testConnection(deploymentConfig, siteName, uuid) {
let deployment = new Deployment(this.app.app.getPath('logs'), this.app.sitesDir, deploymentConfig);
deployment.testConnection(this.app, deploymentConfig, siteName, uuid);
async testConnection(deploymentConfig, siteName, uuid) {
let deployment = new Deployment(
this.app.app.getPath('logs'),
this.app.sitesDir,
deploymentConfig,
this.app.appConfig.experimentalFeatureAppFtpAlt
);
await deployment.testConnection(this.app, deploymentConfig, siteName, uuid);
}
}

Expand Down
5 changes: 3 additions & 2 deletions app/back-end/events/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const shell = electron.shell;
const ipcMain = electron.ipcMain;
const childProcess = require('child_process');
const UtilsHelper = require('../helpers/utils.js');
const stripTags = require('striptags');

class PreviewEvents {
/**
Expand Down Expand Up @@ -90,7 +91,7 @@ class PreviewEvents {
event.sender.send('app-preview-render-error', {
message: [{
message: errorTitle,
desc: errorDesc
desc: stripTags(errorDesc)
}]
});
}
Expand Down Expand Up @@ -142,7 +143,7 @@ class PreviewEvents {
} else {
event.sender.send(data.type, {
progress: data.progress,
message: data.message
message: stripTags((data.message).toString())
});
}
});
Expand Down
3 changes: 2 additions & 1 deletion app/back-end/events/site.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const fs = require('fs-extra');
const os = require('os');
const path = require('path');
const slug = require('./../helpers/slug');
const passwordSafeStorage = require('keytar');
const ipcMain = require('electron').ipcMain;
const Site = require('../site.js');
const Themes = require('../themes.js');
const { Database } = require('node-sqlite3-wasm');
const Database = os.platform() === 'linux' ? require('node-sqlite3-wasm').Database : require('better-sqlite3');
const DBUtils = require('../helpers/db.utils.js');
const UtilsHelper = require('../helpers/utils.js');
const normalizePath = require('normalize-path');
Expand Down
51 changes: 39 additions & 12 deletions app/back-end/helpers/db.utils.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
const os = require('os');

/*
* Other helper functions
*/
class DBUtils {
constructor (dbInstance) {
this.DB = dbInstance;
this.statement = '';
this.useWASM = os.platform() === 'linux';
}

prepare (sqlStatement) {
Expand All @@ -13,30 +16,54 @@ class DBUtils {
}

get (paramsObject = null) {
if (paramsObject) {
paramsObject = this.transformParams(paramsObject);
return this.DB.get(this.statement, paramsObject);
if (this.useWASM) {
if (paramsObject) {
paramsObject = this.transformParams(paramsObject);
return this.DB.get(this.statement, paramsObject);
}

return this.DB.get(this.statement);
}

return this.DB.get(this.statement);
if (paramsObject !== null) {
return this.DB.prepare(this.statement).get(paramsObject);
}

return this.DB.prepare(this.statement).get();
}

run (paramsObject = null) {
if (paramsObject) {
paramsObject = this.transformParams(paramsObject);
return this.DB.run(this.statement, paramsObject);
if (this.useWASM) {
if (paramsObject) {
paramsObject = this.transformParams(paramsObject);
return this.DB.run(this.statement, paramsObject);
}

return this.DB.run(this.statement);
}

return this.DB.run(this.statement);
if (paramsObject !== null) {
return this.DB.prepare(this.statement).run(paramsObject);
}

return this.DB.prepare(this.statement).run();
}

all (paramsObject = null) {
if (paramsObject) {
paramsObject = this.transformParams(paramsObject);
return this.DB.all(this.statement, paramsObject);
if (this.useWASM) {
if (paramsObject) {
paramsObject = this.transformParams(paramsObject);
return this.DB.all(this.statement, paramsObject);
}

return this.DB.all(this.statement);
}

if (paramsObject !== null) {
return this.DB.prepare(this.statement).all(paramsObject);
}

return this.DB.all(this.statement);
return this.DB.prepare(this.statement).all();
}

exec (sqlQueries) {
Expand Down
5 changes: 4 additions & 1 deletion app/back-end/helpers/slug.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ function createSlug(textToSlugify, filenameMode = false, saveLowerChars = false)
['ü', 'ue'],
['Ü', 'UE'],
['ß', 'ss'],
['ẞ', 'SS']
['ẞ', 'SS'],
['«', ''],
['»', ''],
['$', '']
] });

if(!filenameMode) {
Expand Down
13 changes: 13 additions & 0 deletions app/back-end/helpers/specs/slug.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,17 @@ describe('Slug creation', function() {
assert.strictEqual('indexhtml', slug('index.html', false));
assert.strictEqual('index.html', slug('index.html', true));
});

it('should remove some special characters', function() {
assert.strictEqual('title-with-and-arrows', slug('Title with « and » arrows'));
assert.strictEqual('title-with-typoraphical-quotes-and-normal-quotes', slug('Title with „typoraphical quotes“ and "normal quotes"'));
assert.strictEqual('title-with-brackets-in-different-forms', slug('Title (with) [brackets] {in} ⟨different forms⟩'));
assert.strictEqual('title-with-different-types-of-dashes', slug('Title with different - types – of — dashes'));
assert.strictEqual('title-with-many-apostrophes-many-many', slug('Title with many \' apostrophes \‘ many \’ many'));
assert.strictEqual('title-with-dots-and-commas', slug('Title with dots . and commas,'));
assert.strictEqual('and-another-characters', slug('And another characters ; : ? !'));
assert.strictEqual('also-ellipsis', slug('Also ellipsis…'));
assert.strictEqual('and-slashes', slug('And slashes \/ \\'));
assert.strictEqual('and-other-chars', slug('And other chars * # $ @ ^ % ♥ ☆'));
});
});
2 changes: 1 addition & 1 deletion app/back-end/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const normalizePath = require('normalize-path');
const Themes = require('./themes.js');
const Utils = require('./helpers/utils.js');
const slug = require('./helpers/slug');
const Jimp = require('jimp');
const Jimp = require('./vendor/jimp.custom.js');
// Default config
const defaultAstCurrentSiteConfig = require('./../config/AST.currentSite.config');
let sharp = require('sharp');
Expand Down
3 changes: 2 additions & 1 deletion app/back-end/migrators/site-config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const fs = require('fs');
const path = require('path');
const os = require('os');
const slug = require('./../helpers/slug');
const { Database } = require('node-sqlite3-wasm');
const Database = os.platform() === 'linux' ? require('node-sqlite3-wasm').Database : require('better-sqlite3');
const DBUtils = require('../helpers/db.utils.js');

class SiteConfigMigrator {
Expand Down
24 changes: 19 additions & 5 deletions app/back-end/modules/deploy/deployment.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const normalizePath = require('normalize-path');
const isBinaryFileSync = require('isbinaryfile').isBinaryFileSync;
const slug = require('./../../helpers/slug');
const FTP = require('./ftp.js');
const FTPAlt = require('./ftp-alt.js');
const SFTP = require('./sftp.js');
const S3 = require('./s3.js');
const Git = require('./git.js');
Expand Down Expand Up @@ -37,11 +38,12 @@ class Deployment {
* @param sitesDir
* @param siteConfig
*/
constructor(appDir, sitesDir, siteConfig) {
constructor(appDir, sitesDir, siteConfig, useAltFtp) {
this.appDir = appDir;
this.siteConfig = siteConfig;
this.siteName = this.siteConfig.name;
this.sitesDir = sitesDir;
this.useAltFtp = useAltFtp;
this.progressOfDeleting = 0;
this.progressOfUploading = 0;
this.client = false;
Expand All @@ -58,7 +60,7 @@ class Deployment {
* @param deploymentConfig
* @param siteName
*/
testConnection(app, deploymentConfig, siteName, uuid) {
async testConnection(app, deploymentConfig, siteName, uuid) {
let connection = false;

switch(deploymentConfig.protocol) {
Expand All @@ -70,11 +72,17 @@ class Deployment {
case 'git': connection = new Git(); break;
case 'github-pages': connection = new GithubPages(deploymentConfig); break;
case 'gitlab-pages': connection = new GitlabPages(); break;
default: connection = new FTP(); break;
default:
if (this.useAltFtp) {
connection = new FTPAlt();
} else {
connection = new FTP();
}
break;
}

if (connection) {
connection.testConnection(app, deploymentConfig, siteName, uuid).then(() => true);
await connection.testConnection(app, deploymentConfig, siteName, uuid);
}
}

Expand All @@ -92,7 +100,13 @@ class Deployment {
case 'netlify': this.client = new Netlify(this); break;
case 'google-cloud': this.client = new GoogleCloud(this); break;
case 'manual': this.client = new ManualDeployment(this); break;
default: this.client = new FTP(this); break;
default:
if (this.useAltFtp) {
this.client = new FTPAlt(this);
} else {
this.client = new FTP(this);
}
break;
}

await this.client.initConnection();
Expand Down
Loading

0 comments on commit 8cb60c9

Please sign in to comment.