Skip to content

Commit

Permalink
Merge branch 'v.0.46.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
dziudek committed Feb 27, 2025
2 parents f2b3a31 + 0d376e7 commit db7b891
Show file tree
Hide file tree
Showing 41 changed files with 1,635 additions and 582 deletions.
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.46.3 (build 17008)**
**Current version: 0.46.4 (build 17037)**

## Why Publii?
Unlike static-site generators that are often unwieldy and difficult to use, Publii provides an
Expand Down Expand Up @@ -82,4 +82,4 @@ Support this project by becoming a sponsor. Your logo will show up here with a l


## License
Copyright (c) 2024 TidyCustoms. General Public License v3.0, read [LICENSE](https://getpublii.com/license.html) for details.
Copyright (c) 2025 TidyCustoms. General Public License v3.0, read [LICENSE](https://getpublii.com/license.html) for details.
4 changes: 2 additions & 2 deletions app/back-end/builddata.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "0.46.3",
"build": 17009
"version": "0.46.4",
"build": 17037
}
2 changes: 1 addition & 1 deletion app/back-end/modules/backup/backup.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Backup {

let stats = fs.statSync(path.join(backupsPath, file));
let size = Backup.convertToMegabytes(stats.size);
let createdAt = stats.atime;
let createdAt = stats.birthtime || stats.mtime;

files.push({
id: index,
Expand Down
22 changes: 20 additions & 2 deletions app/back-end/modules/render-html/handlebars/helpers/feed-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,32 @@ function feedLink() {
let output = '';

if (!this.siteConfig.deployment || !this.siteConfig.deployment.relativeUrls) {
let feedTitle = this.siteConfig.displayName;

if (
this.siteConfig.advanced &&
this.siteConfig.advanced.feed &&
this.siteConfig.advanced.feed.title === 'customTitle'
) {
feedTitle = this.siteConfig.advanced.feed.titleValue;
}

let rssFeedTitle = '';
let jsonFeedTitle = '';

if (feedTitle) {
rssFeedTitle = 'title="' + Handlebars.Utils.escapeExpression(feedTitle) + ' - RSS"';
jsonFeedTitle = 'title="' + Handlebars.Utils.escapeExpression(feedTitle) + ' - JSON"';
}

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const slug = require('./../../../../helpers/slug');
* - page
* - tag
* - frontpage
* - blogpage
* - tags
* - external
* - internal
Expand Down Expand Up @@ -145,7 +146,7 @@ function menuURLHelper(rendererInstance, Handlebars) {
if (this.type === 'blogpage') {
output = baseUrl + '/';

if (rendererInstance.siteConfig.advanced.usePageAsFrontpage && rendererInstance.siteConfig.advanced.urls.postsPrefix) {
if (rendererInstance.siteConfig.advanced.urls.postsPrefix) {
output = baseUrl + '/' + rendererInstance.siteConfig.advanced.urls.postsPrefix + '/';
}

Expand Down
1 change: 0 additions & 1 deletion app/back-end/modules/render-html/helpers/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,6 @@ class ContentHelper {
if (renderer.cachedItems.authors[authorID].username === authorSlug) {
let link = renderer.cachedItems.authors[authorID].url;
text = text.split(url).join(link);
return text;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/back-end/modules/render-html/helpers/sitemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ class Sitemap {
}

this.outputXML += '<url>' + "\n";
this.outputXML += '<loc>' + domain + url.replace(/index\.html$/, '') + '</loc>' + "\n";
this.outputXML += '<loc>' + (domain + url.replace(/index\.html$/, '')).replace(/\\/gmi, '/') + '</loc>' + "\n";

if (lastMod) {
this.outputXML += '<lastmod>' + lastMod + '</lastmod>' + "\n";
Expand All @@ -760,7 +760,7 @@ class Sitemap {
}

this.outputXML += '<image:image>' + "\n";
this.outputXML += '<image:loc>' + images[i].url + '</image:loc>' + "\n";
this.outputXML += '<image:loc>' + (images[i].url).replace(/\\/gmi, '/') + '</image:loc>' + "\n";
this.outputXML += '<image:title><![CDATA[' + images[i].alt + ']]></image:title>' + "\n";
this.outputXML += '</image:image>' + "\n";
}
Expand Down
75 changes: 40 additions & 35 deletions app/back-end/modules/render-html/items/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ class PageItem {
}

prepareData() {
let pageURL = this.siteConfig.domain + '/' + this.page.slug + '.html';
let preparedText = ContentHelper.prepareContent(this.page.id, this.page.text, this.siteConfig.domain, this.themeConfig, this.renderer, this.metaData.editor);
let preparedExcerpt = ContentHelper.prepareExcerpt(this.themeConfig.config.excerptLength, preparedText);
preparedExcerpt = ContentHelper.setInternalLinks(preparedExcerpt, this.renderer);
let hasCustomExcerpt = false;
let readmoreMatches = preparedText.match(/\<hr\s+id=["']{1}read-more["']{1}[\s\S]*?\/?\>/gmi);

Expand All @@ -63,36 +61,11 @@ class PageItem {
}
}

if (this.siteConfig.advanced.urls.cleanUrls) {
let parentItems = this.renderer.cachedItems.pagesStructureHierarchy[this.page.id];
let pageSlug = this.page.slug;

if (this.renderer.siteConfig.advanced.urls.cleanUrls && parentItems && parentItems.length) {
let slugs = [];

for (let i = 0; i < parentItems.length; i++) {
if (this.renderer.cachedItems.pages[parentItems[i]]) {
slugs.push(this.renderer.cachedItems.pages[parentItems[i]].slug);
}
}

slugs.push(this.page.slug);
pageSlug = slugs.join('/');
}

pageURL = this.siteConfig.domain + '/' + pageSlug + '/';

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

this.pageData = {
id: this.page.id,
title: this.page.title,
author: this.renderer.cachedItems.authors[this.page.authors],
slug: this.page.slug,
url: pageURL,
text: preparedText,
excerpt: preparedExcerpt,
createdAt: this.page.created_at,
Expand All @@ -106,14 +79,6 @@ class PageItem {
subpages: this.subpages
};

if (this.siteConfig.advanced.usePageAsFrontpage && this.siteConfig.advanced.pageAsFrontpage === this.page.id) {
this.pageData.url = this.siteConfig.domain + '/';

if (this.renderer.previewMode || this.renderer.siteConfig.advanced.urls.addIndex) {
this.pageData.url += 'index.html';
}
}

if (this.pageData.template === '*') {
this.pageData.template = this.themeConfig.defaultTemplates.page;
}
Expand Down Expand Up @@ -147,7 +112,47 @@ class PageItem {

setInternalLinks() {
let pageText = this.renderer.cachedItems.pages[this.pageID].text;
let pageExcerpt = this.renderer.cachedItems.pages[this.pageID].excerpt;
this.renderer.cachedItems.pages[this.pageID].text = ContentHelper.setInternalLinks(pageText, this.renderer);
this.renderer.cachedItems.pages[this.pageID].excerpt = ContentHelper.setInternalLinks(pageExcerpt, this.renderer);
}

setHierarchyLinks() {
let pageURL = this.siteConfig.domain + '/' + this.page.slug + '.html';

if (this.siteConfig.advanced.urls.cleanUrls) {
let parentItems = this.renderer.cachedItems.pagesStructureHierarchy[this.page.id];
let pageSlug = this.page.slug;

if (this.renderer.siteConfig.advanced.urls.cleanUrls && parentItems && parentItems.length) {
let slugs = [];

for (let i = 0; i < parentItems.length; i++) {
if (this.renderer.cachedItems.pages[parentItems[i]]) {
slugs.push(this.renderer.cachedItems.pages[parentItems[i]].slug);
}
}

slugs.push(this.page.slug);
pageSlug = slugs.join('/');
}

pageURL = this.siteConfig.domain + '/' + pageSlug + '/';

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

if (this.siteConfig.advanced.usePageAsFrontpage && this.siteConfig.advanced.pageAsFrontpage === this.page.id) {
pageURL = this.siteConfig.domain + '/';

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

this.renderer.cachedItems.pages[this.pageID].url = pageURL;
}

setPageViewConfig(config) {
Expand Down
3 changes: 2 additions & 1 deletion app/back-end/modules/render-html/items/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class PostItem {

let preparedText = ContentHelper.prepareContent(this.post.id, this.post.text, this.siteConfig.domain, this.themeConfig, this.renderer, this.metaData.editor);
let preparedExcerpt = ContentHelper.prepareExcerpt(this.themeConfig.config.excerptLength, preparedText);
preparedExcerpt = ContentHelper.setInternalLinks(preparedExcerpt, this.renderer);
let hasCustomExcerpt = false;
let readmoreMatches = preparedText.match(/\<hr\s+id=["']{1}read-more["']{1}[\s\S]*?\/?\>/gmi);

Expand Down Expand Up @@ -167,7 +166,9 @@ class PostItem {

setInternalLinks() {
let postText = this.renderer.cachedItems.posts[this.postID].text;
let postExcerpt = this.renderer.cachedItems.posts[this.postID].excerpt;
this.renderer.cachedItems.posts[this.postID].text = ContentHelper.setInternalLinks(postText, this.renderer);
this.renderer.cachedItems.posts[this.postID].excerpt = ContentHelper.setInternalLinks(postExcerpt, this.renderer);
}

setPostViewConfig(config) {
Expand Down
1 change: 1 addition & 0 deletions app/back-end/modules/render-html/renderer-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ class RendererCache {

pages.map(page => {
page.setInternalLinks();
page.setHierarchyLinks();
});

let authorIDs = Object.keys(this.renderer.cachedItems.authors);
Expand Down
6 changes: 5 additions & 1 deletion app/back-end/modules/render-html/renderer-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,11 @@ class RendererContext {

return blogBaseUrl + '/' + itemSlug + '.html';
} else {
return blogBaseUrl + '/' + this.siteConfig.advanced.urls.postsPrefix + '/' + itemSlug + '/';
if (this.siteConfig.advanced.urls.postsPrefix) {
return blogBaseUrl + '/' + this.siteConfig.advanced.urls.postsPrefix + '/' + itemSlug + '/';
}

return blogBaseUrl + '/' + itemSlug + '/';
}
} else if (context === 'page') {
if (this.siteConfig.advanced.usePageAsFrontpage && itemContext.page && this.siteConfig.advanced.pageAsFrontpage === itemContext.page.id) {
Expand Down
29 changes: 23 additions & 6 deletions app/back-end/modules/render-html/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ class Renderer {

// When we have blog pagination
if (hasBlogPagination) {
console.time('BLOG PAGINATION');
let addIndexHtml = this.previewMode || this.siteConfig.advanced.urls.addIndex;

// If user set postsPerPage field to -1 - set it for calculations to 999
Expand Down Expand Up @@ -780,6 +781,7 @@ class Renderer {
compiledTemplate = homeCompiledTemplate;
this.menuContext = ['frontpage'];
let context = contextGenerator.getContext(offset, postsPerPage);
additionalContexts.push('homepage');
this.globalContext = this.createGlobalContext('index', additionalContexts, {
pagination,
isFirstPage: currentPage === 1,
Expand Down Expand Up @@ -818,6 +820,7 @@ class Renderer {

this.menuContext = ['frontpage'];
let context = contextGenerator.getContext(offset, postsPerPage);
additionalContexts.push('homepage');
this.globalContext = this.createGlobalContext('index', additionalContexts, {
pagination,
isFirstPage: currentPage === 1,
Expand Down Expand Up @@ -847,8 +850,9 @@ class Renderer {
isLastPage: currentPage === totalPages,
currentPage
}, false, false, context);

let output = this.renderTemplate(postsCompiledTemplate, context, this.globalContext, inputFile);

let templateToUse = this.siteConfig.advanced.urls.postsPrefix !== '' ? postsCompiledTemplate : homeCompiledTemplate;
let output = this.renderTemplate(templateToUse, context, this.globalContext, inputFile);

if (this.plugins.hasModifiers('htmlOutput')) {
output = this.plugins.runModifiers('htmlOutput', this, output, [this.globalContext, context]);
Expand All @@ -858,8 +862,9 @@ class Renderer {
this.templateHelper.saveOutputHomePaginationFile(currentPage, output);
}
}

console.timeEnd('BLOG PAGINATION');
}
console.timeEnd('BLOG PAGINATION');

// When there is no blog pagination
if (!hasBlogPagination) {
Expand All @@ -870,7 +875,7 @@ class Renderer {
if (this.siteConfig.advanced.urls.postsPrefix === '' || !this.siteConfig.advanced.usePageAsFrontpage) {
this.menuContext = ['frontpage'];
let context = contextGenerator.getContext(0, postsPerPage);
this.globalContext = this.createGlobalContext('index', [], false, false, false, context);
this.globalContext = this.createGlobalContext('index', ['homepage'], false, false, false, context);

output = homeCompiledTemplate(context, {
data: this.globalContext
Expand Down Expand Up @@ -1135,7 +1140,13 @@ class Renderer {

inputFile = inputFile.replace('.hbs', '') + (fileSlug === 'DEFAULT' ? '' : '-' + fileSlug) + '.hbs';
let pageConfig = this.overrideItemViewSettings(JSON.parse(JSON.stringify(this.themeConfig.pageConfig)), pageID, 'page', true);
this.globalContext = this.createGlobalContext('page', [], false, pageSlug, pageConfig, context);
let additionalContexts = [];

if (this.siteConfig.advanced.usePageAsFrontpage && parseInt(pageID, 10) === parseInt(this.siteConfig.advanced.pageAsFrontpage, 10)) {
additionalContexts = ['homepage'];
}

this.globalContext = this.createGlobalContext('page', additionalContexts, false, pageSlug, pageConfig, context);
let output = this.renderTemplate(compiledTemplates[fileSlug], context, this.globalContext, inputFile);

if (this.plugins.hasModifiers('htmlOutput')) {
Expand Down Expand Up @@ -1288,7 +1299,13 @@ class Renderer {

inputFile = inputFile.replace('.hbs', '') + (fileSlug === 'DEFAULT' ? '' : '-' + fileSlug) + '.hbs';
let pageViewConfig = this.cachedItems.pages[pageIDs[i]].pageViewConfig;
this.globalContext = this.createGlobalContext('page', [], false, pageSlugs[i], pageViewConfig, context);
let additionalContexts = [];

if (this.siteConfig.advanced.usePageAsFrontpage && parseInt(pageIDs[i], 10) === parseInt(this.siteConfig.advanced.pageAsFrontpage, 10)) {
additionalContexts = ['homepage'];
}

this.globalContext = this.createGlobalContext('page', additionalContexts, false, pageSlugs[i], pageViewConfig, context);
let output = this.renderTemplate(compiledTemplates[fileSlug], context, this.globalContext, inputFile);

if (this.plugins.hasModifiers('htmlOutput')) {
Expand Down
4 changes: 2 additions & 2 deletions app/default-files/default-languages/en-gb/config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "English - default",
"version": "1.7.3",
"version": "1.7.4",
"author": "Publii Team",
"publiiSupport": "0.46.3",
"publiiSupport": "0.46.4",
"momentLocale": "en",
"wysiwygTranslation": false
}
8 changes: 4 additions & 4 deletions app/default-files/default-languages/en-gb/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
"code": "Code",
"conversions": {
"toCode": "Code",
"toHeader": "Header",
"toHeader": "Heading",
"toHTML": "HTML",
"toList": "List",
"toParagraph": "Paragraph",
Expand All @@ -206,7 +206,7 @@
"enterUrlOrEmbedCode": "Enter URL or embed code...",
"errorOccurred": "An error occurred - please try again.",
"gallery": "Gallery",
"header": "Header",
"header": "Heading",
"heading1": "Heading 1",
"heading2": "Heading 2",
"heading3": "Heading 3",
Expand Down Expand Up @@ -616,7 +616,7 @@
"aboutPublii": "About Publii",
"currentPubliiVersion": "Version",
"accept": "Accept",
"copyright": "Copyright 2024 <a href=\"https://tidycustoms.net\" target=\"_blank\" rel=\"noopener noreferrer\">TidyCustoms</a>. All rights reserved.<br>Publii is designed and maintained by core team and is made possible by the <a href=\"https://electronjs.org\" target=\"_blank\" rel=\"noopener noreferrer\">Electron</a> Open Source project and other ",
"copyright": "Copyright 2025 <a href=\"https://tidycustoms.net\" target=\"_blank\" rel=\"noopener noreferrer\">TidyCustoms</a>. All rights reserved.<br>Publii is designed and maintained by core team and is made possible by the <a href=\"https://electronjs.org\" target=\"_blank\" rel=\"noopener noreferrer\">Electron</a> Open Source project and other ",
"creditsIntro": "Publii uses the following third-party Open Source Software:",
"dataCollectionInfo": "<strong>We do not collect any </strong>personal data while you use Publii app; we do not store, track, or allow third parties to collect, personally identifiable information about you. ",
"homepage": "Homepage",
Expand Down Expand Up @@ -866,7 +866,6 @@
"titleDESC": "By title (descending)"
},
"pageAsFrontpage": "Select page",
"pageName": "Page name",
"pageTitle": "Page Title",
"pageTitleVariables": "The following variables can be used: %pagetitle, %sitename, %authorname",
"paginationPhrase": "Pagination phrase:",
Expand Down Expand Up @@ -983,6 +982,7 @@
"versionParameterInfo": "Adds a version parameter in CSS/JS URLs to skip browser cache. This option can cause more files than usual to be synced during deployment.",
"vimeoNoTrack": "Enable 'Do Not Track' mode for Vimeo videos",
"webpLossless": "Enable lossless compression for responsive WebP images",
"websiteName": "Website name",
"websiteSpeed": "Website Speed",
"whatsApp": "WhatsApp",
"youMustReviewGdprSettings": "Make sure to check and review your Privacy Settings, especially the Cookie Banner settings due to some significant changes in Publii v.0.40. <a href=\"https://getpublii.com/blog/release-040.html#cookie-banner\" target=\"_blank\">Read more...</a>",
Expand Down
Loading

0 comments on commit db7b891

Please sign in to comment.