Skip to content

Commit

Permalink
Merge branch 'v.0.36.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
dziudek committed Jun 18, 2020
2 parents 2a3b03f + 97df9e3 commit 2467af4
Show file tree
Hide file tree
Showing 39 changed files with 464 additions and 303 deletions.
2 changes: 1 addition & 1 deletion 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.36.0 (build 13213)**
**Current version: 0.36.1 (build 13320)**

## Why Publii?
Unlike static-site generators that are often unwieldy and difficult to use, Publii provides an
Expand Down
54 changes: 42 additions & 12 deletions app/back-end/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ const sqlite = require('better-sqlite3');
const compare = require('node-version-compare');
const normalizePath = require('normalize-path');
// Electron classes
const electron = require('electron');
const shell = electron.shell;
const Menu = electron.Menu;
const dialog = electron.dialog;
const BrowserWindow = electron.BrowserWindow;
const { screen, shell, nativeTheme, Menu, dialog, BrowserWindow } = require('electron');
// Collection classes
const Posts = require('./posts.js');
const Tags = require('./tags.js');
Expand Down Expand Up @@ -343,7 +339,7 @@ class App {
}

if (!this.windowBounds) {
let screens = electron.screen.getAllDisplays();
let screens = screen.getAllDisplays();
let width = screens[0].workAreaSize.width;
let height = screens[0].workAreaSize.height;

Expand Down Expand Up @@ -442,14 +438,15 @@ class App {
nodeIntegration: true,
webviewTag: true,
spellcheck: true,
preload: path.join(__dirname, 'app-preload.js')
preload: path.join(__dirname, 'app-preload.js'),
icon: path.join(__dirname, 'assets', 'icon.png')
};

if (this.appConfig.appTheme === 'dark') {
if (this.appConfig.appTheme === 'dark' || (this.appConfig.appTheme === 'system' && nativeTheme.shouldUseDarkColors)) {
windowParams.backgroundColor = '#202128';
}

let displays = electron.screen.getAllDisplays();
let displays = screen.getAllDisplays();
let externalDisplay = displays.find((display) => {
return display.bounds.x !== 0 || display.bounds.y !== 0;
});
Expand All @@ -459,9 +456,9 @@ class App {
!externalDisplay &&
(
windowParams.x < 0 ||
windowParams.x > electron.screen.getPrimaryDisplay().workAreaSize.width ||
windowParams.x > screen.getPrimaryDisplay().workAreaSize.width ||
windowParams.y < 0 ||
windowParams.y > electron.screen.getPrimaryDisplay().workAreaSize.height
windowParams.y > screen.getPrimaryDisplay().workAreaSize.height
)
) {
windowParams.x = 0;
Expand Down Expand Up @@ -535,12 +532,35 @@ class App {

if (process.platform === 'linux') {
this.mainWindow.webContents.on('before-input-event', (event, input) => {
if (input.control && input.code === 'KeyQ') {
if (input.control && input.key === 'a') {
this.app.quit();
}
});
}

this.mainWindow.on('close', function(e) {
let currentWindowURL = e.sender.webContents.getURL();

if (
currentWindowURL.indexOf('/posts/editor/blockeditor/') === -1 &&
currentWindowURL.indexOf('/posts/editor/markdown/') === -1 &&
currentWindowURL.indexOf('/posts/editor/tinymce/') === -1
) {
return;
}

const choice = dialog.showMessageBoxSync(this, {
type: 'question',
buttons: ['Yes', 'No'],
title: 'Confirm',
message: "Are you sure you want to quit? \nAll unsaved changes will be lost."
});

if (choice === 1) {
e.preventDefault();
}
});

// Open Dev Tools
if(this.appConfig.openDevToolsInMain) {
this.mainWindow.webContents.openDevTools();
Expand Down Expand Up @@ -596,6 +616,16 @@ class App {

return true;
}

/**
* Function used to add sites to the back-end sites list
*
* @param {string} siteCatalog
* @param {onkject} siteData
*/
addSite (siteCatalog, siteData) {
this.sites[siteCatalog] = siteData;
}
}

module.exports = App;
Binary file added app/back-end/assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/back-end/builddata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"0.36.0","build":13213,"status":"beta"}
{"version":"0.36.1","build":13320,"status":"beta"}
9 changes: 5 additions & 4 deletions app/back-end/modules/deploy/libraries/netlify-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class NetlifyAPI {
let hashesOfFilesToUpload = deployData.body.required;
let filesToUpload = this.getFilesToUpload(localFilesList, hashesOfFilesToUpload);
this.events.onStart(filesToUpload.length);

for (let i = 0; i < filesToUpload.length; i++) {
let filePath = filesToUpload[i];

Expand Down Expand Up @@ -79,7 +79,7 @@ class NetlifyAPI {

async makeApiRequest (method, endpoint, data) {
let endpointUrl = this.apiUrl + endpoint.replace(':site_id', this.siteID);

return asyncRequest({
method: method,
uri: endpointUrl,
Expand All @@ -99,12 +99,13 @@ class NetlifyAPI {
let endpointUrl = this.apiUrl + 'deploys/' + deployID + '/files' + filePath;
let fullFilePath = this.getFilePath(this.inputDir, filePath, true);
let fileContent = await asyncReadFile(fullFilePath);

return asyncRequest({
method: 'PUT',
uri: endpointUrl,
headers: {
'User-Agent': 'Publii'
'User-Agent': 'Publii',
'Content-Type': 'application/octet-stream'
},
body: fileContent,
auth: {
Expand Down
3 changes: 2 additions & 1 deletion app/back-end/modules/import/wxr-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ class WxrParser {
let postSlug = slug(posts[i].title);
let postAuthor = this.temp.authors[slug(posts[i]['dc:creator'])];
let postText = this.preparePostText(posts[i]['content:encoded'], postImages);
let postStatus = posts[i]['wp:status'] === 'draft' ? 'draft' : 'published'
let postTags = '';
let postTitle = typeof posts[i].title === 'string' ? posts[i].title : 'Untitled';

Expand Down Expand Up @@ -396,7 +397,7 @@ class WxrParser {
title: postTitle,
slug: postSlug,
author: postAuthor,
status: 'published',
status: postStatus,
tags: postTags,
text: postText,
creationDate: moment(posts[i]['wp:post_date']).format('x'),
Expand Down
43 changes: 7 additions & 36 deletions app/back-end/modules/render-html/contexts/feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,54 +39,25 @@ class RendererContextFeed extends RendererContext {
prepareData() {
let self = this;
this.posts = this.posts || [];
this.posts = this.posts.map(post => this.renderer.cachedItems.posts[post.id]);

this.posts = this.posts.map(post => {
let postURL = self.siteConfig.domain + '/' + post.slug + '.html';
let domainMediaPath = self.siteConfig.domain + '/media/posts/' + post.id + '/';
let preparedText = post.text.split('#DOMAIN_NAME#').join(domainMediaPath);
preparedText = ContentHelper.parseText(preparedText, post.editor);
let contentMode = self.siteConfig.advanced.feed.showFullText ? 'fullText' : 'excerpt';
let text = this.cleanUpText(preparedText);
text = ContentHelper.setInternalLinks(text, self.renderer);
let excerpt = ContentHelper.prepareExcerpt(this.themeConfig.config.excerptLength, preparedText);
excerpt = ContentHelper.setInternalLinks(excerpt, self.renderer);
let authorData = this.getAuthor('post', post.id);

if(contentMode !== 'fullText') {
text = false;
}

if(self.siteConfig.advanced.urls.cleanUrls) {
postURL = self.siteConfig.domain + '/' + post.slug + '/';

if(self.renderer.previewMode || self.siteConfig.advanced.urls.addIndex) {
postURL += 'index.html';
}
}

return {
title: post.title,
url: postURL,
author: authorData,
text: text,
excerpt: excerpt,
url: post.url,
author: this.getAuthor('post', post.id),
text: contentMode === 'fullText' ? post.text : false,
excerpt: post.excerpt,
createdAt: post.created_at,
// Get higher date - created_at or modified_at
modifiedAt: post.created_at > post.modified_at ? post.created_at : post.modified_at,
modifiedAt: post.created_at > post.modified_at ? post.created_at : post.modified_at, // Get higher date - created_at or modified_at
categories: this.getPostCategories(post.id),
thumbnail: this.getPostThumbnail(post.id)
}
});
}

cleanUpText (text) {
text = text.replace(/\<hr\s+id=["']{1}read-more["']{1}\s?\/?\>/gmi, '');
text = text.replace(/contenteditable="false"/gmi, '');
text = text.replace(/contenteditable="true"/gmi, '');
text = text.replace(/data\-[a-z\-0-9]{1,}=".*?"/gmi, '');

return text;
}

setContext() {
this.loadData();
this.prepareData();
Expand Down
4 changes: 2 additions & 2 deletions app/back-end/modules/render-html/helpers/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ContentHelper {
preparedText = ContentHelper.parseText(preparedText, editor);

// Remove content for AMP or non-AMP depending from ampMode value
if(ampMode) {
if (ampMode) {
preparedText = preparedText.replace(/<publii-non-amp>[\s\S]*?<\/publii-non-amp>/gmi, '');
preparedText = preparedText.replace(/<publii-amp>/gmi, '');
preparedText = preparedText.replace(/<\/publii-amp>/gmi, '');
Expand Down Expand Up @@ -74,7 +74,7 @@ class ContentHelper {
}

// Add loading="lazy" attributes to img, video, audio, iframe tags
if (renderer.siteConfig.advanced.mediaLazyLoad) {
if (renderer.siteConfig.advanced.mediaLazyLoad && !ampMode) {
preparedText = preparedText.replace(/<img\s/gmi, '<img loading="lazy" ');
preparedText = preparedText.replace(/<video\s/gmi, '<video loading="lazy" ');
preparedText = preparedText.replace(/<audio\s/gmi, '<audio loading="lazy" ');
Expand Down
2 changes: 1 addition & 1 deletion app/back-end/modules/render-html/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Renderer {
this.errorLog = [];
this.previewMode = false;
this.ampMode = false;
this.useRelativeUrls = siteConfig.deployment.relativeUrls;
this.useRelativeUrls = false; // siteConfig.deployment.relativeUrls;
this.translations = {
user: false,
theme: false
Expand Down
6 changes: 5 additions & 1 deletion app/back-end/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,11 @@ class Site {
let newSitePath = path.join(appInstance.sitesDir, newCatalogFreeName);
fs.copySync(sitePath, newSitePath);
Site.updateNameInSiteConfig(newSitePath, newCatalogFreeName, siteName);

let configFilePath = path.join(newSitePath, 'input', 'config', 'site.config.json');
let siteConfig = fs.readFileSync(configFilePath);
siteConfig = JSON.parse(siteConfig);
appInstance.addSite(newCatalogFreeName, siteConfig);

return {
siteName: siteName,
siteCatalog: newCatalogName
Expand Down
3 changes: 2 additions & 1 deletion app/config/AST.app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const AstAppConfig = {
showPostSlugs: false,
postsOrdering: 'id DESC',
tagsOrdering: 'id DESC',
authorsOrdering: 'id DESC'
authorsOrdering: 'id DESC',
appTheme: 'system'
};

module.exports = AstAppConfig;
28 changes: 9 additions & 19 deletions app/default-files/default-themes/simple/assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1148,14 +1148,14 @@ textarea {
.navbar .navbar__submenu li span[aria-haspopup=true]:focus,
.navbar .navbar__submenu li span[aria-haspopup=true]:hover {
background: rgba(var(--white-rgb), 0.05);
color: var(var(--white)) !important;
color: var(--white) !important;
}
.navbar .navbar__submenu li span {
color: rgba(var(--white-rgb), 0.7) !important;
padding: 0.5666666667rem 1.4166666667rem;
}
.navbar .navbar__submenu li:hover > a, .navbar .navbar__submenu li:hover > span[aria-haspopup=true] {
color: var(var(--white)) !important;
color: var(--white) !important;
}
.navbar .navbar__toggle {
background: var(--dark);
Expand Down Expand Up @@ -1270,7 +1270,7 @@ textarea {
}

.navbar_mobile_overlay {
background: var(var(--white));
background: var(--white);
height: calc(100vh - 4.4rem);
left: 0;
opacity: 1;
Expand Down Expand Up @@ -1299,7 +1299,7 @@ textarea {
}
.navbar_mobile_overlay .navbar__menu li a,
.navbar_mobile_overlay .navbar__menu li span {
color: var(var(--dark));
color: var(--dark);
display: block;
padding: 0.5666666667rem;
position: relative;
Expand All @@ -1308,7 +1308,7 @@ textarea {
.navbar_mobile_overlay .navbar__menu li span:active,
.navbar_mobile_overlay .navbar__menu li span:focus,
.navbar_mobile_overlay .navbar__menu li span:hover {
color: var(var(--dark));
color: var(--dark);
}
.navbar_mobile_overlay .navbar__menu li a[aria-haspopup=true]::after,
.navbar_mobile_overlay .navbar__menu li span[aria-haspopup=true]::after {
Expand Down Expand Up @@ -1340,7 +1340,7 @@ textarea {
}

.navbar_mobile_sidebar {
background: var(var(--white));
background: var(--white);
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.25);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.25);
height: 100vh;
Expand Down Expand Up @@ -1371,7 +1371,7 @@ textarea {
}
.navbar_mobile_sidebar .navbar__menu li a,
.navbar_mobile_sidebar .navbar__menu li .is-separator {
color: var(var(--dark));
color: var(--dark);
display: block;
padding: 10px 20px 10px 0;
position: relative;
Expand All @@ -1380,7 +1380,7 @@ textarea {
.navbar_mobile_sidebar .navbar__menu li .is-separator:active,
.navbar_mobile_sidebar .navbar__menu li .is-separator:focus,
.navbar_mobile_sidebar .navbar__menu li .is-separator:hover {
color: var(var(--dark));
color: var(--dark);
}
.navbar_mobile_sidebar .navbar__menu li a[aria-haspopup=true]::after,
.navbar_mobile_sidebar .navbar__menu li .is-separator[aria-haspopup=true]::after {
Expand Down Expand Up @@ -1928,7 +1928,7 @@ textarea {
.post__video--1by1::before, .post__iframe--1by1::before {
padding-top: 100%;
}
.post__video > iframe, .post__iframe > iframe {
.post__video > iframe, .post__video > video, .post__iframe > iframe, .post__iframe > video {
border: none;
height: 100%;
left: 0;
Expand Down Expand Up @@ -2170,16 +2170,6 @@ textarea {
flex-wrap: wrap;
}
}
@media all and (min-width: 56.25em) {
.gallery--wide {
margin-left: -var(--page-margin);
margin-right: -var(--page-margin);
}
}
.gallery--full {
margin-left: calc(-50vw + 50%);
margin-right: calc(-50vw + 50%);
}
@media all and (min-width: 56.25em) {
.gallery-wrapper--wide {
margin-left: calc(-1 * var(--page-margin));
Expand Down
Loading

0 comments on commit 2467af4

Please sign in to comment.