Skip to content

Commit

Permalink
Add v4.32.1
Browse files Browse the repository at this point in the history
  • Loading branch information
RadoslavGatev committed Jan 7, 2022
1 parent d3c9e90 commit 62c6271
Show file tree
Hide file tree
Showing 39 changed files with 4,411 additions and 4,737 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
.ember-basic-dropdown {
position: relative; }
position: relative;
}

.ember-basic-dropdown, .ember-basic-dropdown-content, .ember-basic-dropdown-content * {
box-sizing: border-box; }
.ember-basic-dropdown,
.ember-basic-dropdown-content,
.ember-basic-dropdown-content * {
box-sizing: border-box;
}

.ember-basic-dropdown-content {
position: absolute;
width: auto;
z-index: 1000;
background-color: #FFF; }
background-color: #fff;
}

.ember-basic-dropdown-content--left {
left: 0; }
left: 0;
}

.ember-basic-dropdown-content--right {
right: 0; }
right: 0;
}

.ember-basic-dropdown-overlay {
position: fixed;
Expand All @@ -24,11 +31,12 @@
z-index: 10;
top: 0;
left: 0;
pointer-events: none; }
pointer-events: none;
}

.ember-basic-dropdown-content-wormhole-origin {
display: inline; }

display: inline;
}
.ember-basic-dropdown {
position: relative; }

Expand Down Expand Up @@ -1187,7 +1195,7 @@ THE SOFTWARE.
table .occluded-content,
tbody .occluded-content,
thead .occluded-content,
tfoot .occluded-content, {
tfoot .occluded-content {
display: table-row;
position: relative;
width: 100%;
Expand Down

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions core/frontend/apps/amp/lib/views/amp.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -777,11 +777,11 @@
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
font-size: 0.95em;
font-weight: 600;
text-decoration: none !important;
text-decoration: none;
border-radius: 5px;
transition: opacity 0.2s ease-in-out;
background-color: var(--ghost-accent-color);
color: #ffffff !important;
color: #ffffff;
margin: 1.75em 0 0;
}
Expand All @@ -800,12 +800,12 @@
.kg-header-card.kg-style-image a.kg-header-card-button,
.kg-header-card.kg-style-dark a.kg-header-card-button {
background: #ffffff;
color: #15171a !important;
color: #15171a;
}
.kg-header-card.kg-style-accent a.kg-header-card-button {
background: #ffffff;
color: var(--ghost-accent-color) !important;
color: var(--ghost-accent-color);
}
.kg-audio-card {
Expand Down
6 changes: 3 additions & 3 deletions core/frontend/meta/description.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function getDescription(data, root, options = {}) {
|| settingsCache.get('description')
|| '';
} else {
description = data.post.meta_description || '';
description = data.post.meta_description || data.post.custom_excerpt || '';
}
} else if (_.includes(context, 'page') && data.post) {
// Page description dependent on legacy object formatting (https://github.com/TryGhost/Ghost/issues/10042)
Expand All @@ -63,7 +63,7 @@ function getDescription(data, root, options = {}) {
|| settingsCache.get('description')
|| '';
} else {
description = data.post.meta_description || '';
description = data.post.meta_description || data.post.custom_excerpt || '';
}
} else if (_.includes(context, 'page') && data.page) {
if (options.property) {
Expand All @@ -74,7 +74,7 @@ function getDescription(data, root, options = {}) {
|| settingsCache.get('description')
|| '';
} else {
description = data.page.meta_description || '';
description = data.page.meta_description || data.page.custom_excerpt || '';
}
}

Expand Down
39 changes: 21 additions & 18 deletions core/frontend/services/sitemap/base-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ class BaseSiteMapGenerator {
constructor() {
this.nodeLookup = {};
this.nodeTimeLookup = {};
this.siteMapContent = null;
this.siteMapContent = new Map();
this.lastModified = 0;
this.maxNodes = 50000;
this.maxPerPage = 50000;
}

generateXmlFromNodes() {
generateXmlFromNodes(page) {
// Get a mapping of node to timestamp
let nodesToProcess = _.map(this.nodeLookup, (node, id) => {
return {
Expand All @@ -33,20 +33,23 @@ class BaseSiteMapGenerator {
};
});

// Limit to 50k nodes - this is a quick fix to prevent errors in google console
if (this.maxNodes) {
nodesToProcess = nodesToProcess.slice(0, this.maxNodes);
}

// Sort nodes by timestamp
nodesToProcess = _.sortBy(nodesToProcess, 'ts');

// Get the page of nodes that was requested
nodesToProcess = nodesToProcess.slice((page - 1) * this.maxPerPage, page * this.maxPerPage);

// Do not generate empty sitemaps
if (nodesToProcess.length === 0) {
return null;
}

// Grab just the nodes
nodesToProcess = _.map(nodesToProcess, 'node');
const nodes = _.map(nodesToProcess, 'node');

const data = {
// Concat the elements to the _attr declaration
urlset: [XMLNS_DECLS].concat(nodesToProcess)
urlset: [XMLNS_DECLS].concat(nodes)
};

// Generate full xml
Expand All @@ -67,15 +70,15 @@ class BaseSiteMapGenerator {
this.updateLastModified(datum);
this.updateLookups(datum, node);
// force regeneration of xml
this.siteMapContent = null;
this.siteMapContent.clear();
}
}

removeUrl(url, datum) {
this.removeFromLookups(datum);

// force regeneration of xml
this.siteMapContent = null;
this.siteMapContent.clear();
this.lastModified = Date.now();
}

Expand Down Expand Up @@ -152,13 +155,13 @@ class BaseSiteMapGenerator {
return !!imageUrl;
}

getXml() {
if (this.siteMapContent) {
return this.siteMapContent;
getXml(page = 1) {
if (this.siteMapContent.has(page)) {
return this.siteMapContent.get(page);
}

const content = this.generateXmlFromNodes();
this.siteMapContent = content;
const content = this.generateXmlFromNodes(page);
this.siteMapContent.set(page, content);
return content;
}

Expand All @@ -181,7 +184,7 @@ class BaseSiteMapGenerator {
reset() {
this.nodeLookup = {};
this.nodeTimeLookup = {};
this.siteMapContent = null;
this.siteMapContent.clear();
}
}

Expand Down
17 changes: 13 additions & 4 deletions core/frontend/services/sitemap/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const manager = new Manager();
// Responsible for handling requests for sitemap files
module.exports = function handler(siteApp) {
const verifyResourceType = function verifyResourceType(req, res, next) {
if (!Object.prototype.hasOwnProperty.call(manager, req.params.resource)) {
const resourceWithoutPage = req.params.resource.replace(/-\d+$/, '');
if (!Object.prototype.hasOwnProperty.call(manager, resourceWithoutPage)) {
return res.sendStatus(404);
}

Expand All @@ -22,14 +23,22 @@ module.exports = function handler(siteApp) {
});

siteApp.get('/sitemap-:resource.xml', verifyResourceType, function sitemapResourceXML(req, res) {
const type = req.params.resource;
const page = 1;
const type = req.params.resource.replace(/-\d+$/, '');
const pageParam = (req.params.resource.match(/-(\d+)$/) || [null, null])[1];
const page = pageParam ? parseInt(pageParam, 10) : 1;

const content = manager.getSiteMapXml(type, page);
// Prevent x-1.xml as it is a duplicate of x.xml and empty sitemaps
// (except for the first page so that at least one sitemap exists per type)
if (pageParam === '1' || (!content && page !== 1)) {
return res.sendStatus(404);
}

res.set({
'Cache-Control': 'public, max-age=' + config.get('caching:sitemap:maxAge'),
'Content-Type': 'text/xml'
});

res.send(manager.getSiteMapXml(type, page));
res.send(content);
});
};
30 changes: 20 additions & 10 deletions core/frontend/services/sitemap/index-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class SiteMapIndexGenerator {
constructor(options) {
options = options || {};
this.types = options.types;
this.maxPerPage = options.maxPerPage;
}

getXml() {
Expand All @@ -30,16 +31,25 @@ class SiteMapIndexGenerator {

generateSiteMapUrlElements() {
return _.map(this.types, (resourceType) => {
const url = urlUtils.urlFor({relativeUrl: '/sitemap-' + resourceType.name + '.xml'}, true);
const lastModified = resourceType.lastModified;

return {
sitemap: [
{loc: url},
{lastmod: moment(lastModified).toISOString()}
]
};
});
// `|| 1` = even if there are no items we still have an empty sitemap file
const noOfPages = Math.ceil(Object.keys(resourceType.nodeLookup).length / this.maxPerPage) || 1;
const pages = [];

for (let i = 0; i < noOfPages; i++) {
const page = i === 0 ? '' : `-${i + 1}`;
const url = urlUtils.urlFor({relativeUrl: '/sitemap-' + resourceType.name + page + '.xml'}, true);
const lastModified = resourceType.lastModified;

pages.push({
sitemap: [
{loc: url},
{lastmod: moment(lastModified).toISOString()}
]
});
}

return pages;
}).flat();
}
}

Expand Down
13 changes: 8 additions & 5 deletions core/frontend/services/sitemap/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ class SiteMapManager {
constructor(options) {
options = options || {};

options.maxPerPage = options.maxPerPage || 50000;

this.pages = options.pages || this.createPagesGenerator(options);
this.posts = options.posts || this.createPostsGenerator(options);
this.users = this.authors = options.authors || this.createUsersGenerator(options);
this.tags = options.tags || this.createTagsGenerator(options);
this.index = options.index || this.createIndexGenerator();
this.index = options.index || this.createIndexGenerator(options);

events.on('router.created', (router) => {
if (router.name === 'StaticRoutesRouter') {
Expand Down Expand Up @@ -43,14 +45,15 @@ class SiteMapManager {
});
}

createIndexGenerator() {
createIndexGenerator(options) {
return new IndexMapGenerator({
types: {
pages: this.pages,
posts: this.posts,
authors: this.authors,
tags: this.tags
}
},
maxPerPage: options.maxPerPage
});
}

Expand All @@ -74,8 +77,8 @@ class SiteMapManager {
return this.index.getXml();
}

getSiteMapXml(type) {
return this[type].getXml();
getSiteMapXml(type, page) {
return this[type].getXml(page);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const _ = require('lodash');
const hbs = require('../engine');
const urlUtils = require('../../../../shared/url-utils');
const customThemeSettingsCache = require('../../../../shared/custom-theme-settings-cache');
const labs = require('../../../../shared/labs');
const preview = require('../preview');

function updateLocalTemplateOptions(req, res, next) {
Expand All @@ -17,12 +16,8 @@ function updateLocalTemplateOptions(req, res, next) {
const previewData = preview.handle(req, Object.keys(customThemeSettingsCache.getAll()));

// strip custom off of preview data so it doesn't get merged into @site
const customThemeSettingsPreviewData = previewData.custom;
const customData = previewData.custom;
delete previewData.custom;
let customData = {};
if (labs.isSet('customThemeSettings')) {
customData = customThemeSettingsPreviewData;
}

// update site data with any preview values from the request
Object.assign(siteData, previewData);
Expand Down
5 changes: 5 additions & 0 deletions core/frontend/src/cards/css/audio.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.kg-audio-card,
.kg-audio-card * {
box-sizing: border-box;
}

.kg-audio-card {
display: flex;
width: 100%;
Expand Down
5 changes: 5 additions & 0 deletions core/frontend/src/cards/css/bookmark.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.kg-bookmark-card,
.kg-bookmark-card * {
box-sizing: border-box;
}

.kg-bookmark-card,
.kg-bookmark-publisher {
position: relative;
Expand Down
5 changes: 5 additions & 0 deletions core/frontend/src/cards/css/button.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.kg-button-card,
.kg-button-card * {
box-sizing: border-box;
}

.kg-button-card {
display: flex;
position: static;
Expand Down
5 changes: 5 additions & 0 deletions core/frontend/src/cards/css/callout.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.kg-callout-card,
.kg-callout-card * {
box-sizing: border-box;
}

.kg-callout-card {
display: flex;
padding: 1.2em 1.6em;
Expand Down
Loading

0 comments on commit 62c6271

Please sign in to comment.