2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00

🔥 Removed V1 code/references in frontend helpers/meta layers (#11080)

no issue

- Removed deprecated 'blog' reference from frontend data. The alias (site->blog) stays till next version (v4) as it's not leaving much of technical debt but would ease the migration process for anybody still using it. 
- The follow up to this is substitute of all references to `options.data.blog` with `options.data.site` in "frontend"
- Fixed test utils helper to use `site` instead of `blog`
- Removed 0.1 flag checks in {{get}} helper
- Removed user aliasing from {{get}} helper
- Removed unused translation for {{get}} helper
- Added a note to excerpt changes in metadata for future reference
- Removed page alias used in description helper. The mix of page context with post object in the metadata was only possible in v0.1
- Changed mock in ghost_head helper to use v2
- Removed unneeded test for body class helper
This commit is contained in:
Naz Gargol 2019-09-10 11:37:04 +02:00 committed by GitHub
parent 1752132051
commit a9050f68ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 221 additions and 768 deletions

View file

@ -12,7 +12,7 @@ module.exports = function (date, options) {
if (!options && Object.prototype.hasOwnProperty.call(date, 'hash')) {
options = date;
date = undefined;
timezone = options.data.blog.timezone;
timezone = options.data.site.timezone;
// set to published_at by default, if it's available
// otherwise, this will print the current date
@ -28,7 +28,7 @@ module.exports = function (date, options) {
// ensure that context is undefined, not null, as that can cause errors
date = date === null ? undefined : date;
timezone = options.data.blog.timezone;
timezone = options.data.site.timezone;
const timeNow = moment().tz(timezone);
// i18n: Making dates, including month names, translatable to any language.

View file

@ -8,7 +8,7 @@ const {socialUrls, localUtils} = require('./proxy');
module.exports = function facebook_url(username, options) { // eslint-disable-line camelcase
if (!options) {
options = username;
username = localUtils.findKey('facebook', this, options.data.blog);
username = localUtils.findKey('facebook', this, options.data.site);
}
if (username) {

View file

@ -13,16 +13,9 @@ var proxy = require('./proxy'),
createFrame = proxy.hbs.handlebars.createFrame,
api = proxy.api,
labs = proxy.labs,
pathAliases,
get;
/**
* v0.1: users, posts, tags
* v2: authors, pagesPublic, posts, tagsPublic
*
* @NOTE: if you use "users" in v2, we should fallback to authors
*/
const RESOURCES = {
posts: {
alias: 'postsPublic',
@ -32,10 +25,6 @@ const RESOURCES = {
alias: 'tagsPublic',
resource: 'tags'
},
users: {
alias: 'authorsPublic',
resource: 'users'
},
pages: {
alias: 'pagesPublic',
resource: 'posts'
@ -209,27 +198,4 @@ get = function get(resource, options) {
});
};
module.exports = function getLabsWrapper() {
const self = this;
const args = arguments;
const apiVersion = _.get(args, '[1].data.root._locals.apiVersion');
// If the API version is v0.1 return the labs enabled version of the helper
if (apiVersion === 'v0.1') {
return labs.enabledHelper({
flagKey: 'publicAPI',
flagName: 'Public API',
helperName: 'get',
// Even though this is a labs enabled helper, really we want users to upgrade to v2 API.
errMessagePath: 'warnings.helpers.get.apiRequired.message',
errContextPath: 'warnings.helpers.get.apiRequired.context',
helpUrl: 'https://ghost.org/docs/api/handlebars-themes/packagejson/',
async: true
}, function executeHelper() {
return get.apply(self, args);
});
}
// Else, we just apply the helper normally
return get.apply(self, args);
};
module.exports = get;

View file

@ -43,18 +43,6 @@ function finaliseStructuredData(metaData) {
return head;
}
function getAjaxHelper(clientId, clientSecret) {
return '<script src="' +
getAssetUrl('public/ghost-sdk.js', true) +
'"></script>\n' +
'<script>\n' +
'ghost.init({\n' +
'\tclientId: "' + clientId + '",\n' +
'\tclientSecret: "' + clientSecret + '"\n' +
'});\n' +
'</script>';
}
function getMembersHelper() {
return `
<script src="https://js.stripe.com/v3/"></script>
@ -83,7 +71,7 @@ function getMembersHelper() {
* hbs forwards the data to any hbs helper like this
* {
* data: {
* blog: {},
* site: {},
* labs: {},
* config: {},
* root: {
@ -93,7 +81,7 @@ function getMembersHelper() {
* }
* }
*
* `blog`, `labs` and `config` are the templateOptions, search for `hbs.updateTemplateOptions` in the code base.
* `site`, `labs` and `config` are the templateOptions, search for `hbs.updateTemplateOptions` in the code base.
* Also see how the root object gets created, https://github.com/wycats/handlebars.js/blob/v4.0.6/lib/handlebars/runtime.js#L259
*/
// We use the name ghost_head to match the helper for consistency:
@ -108,7 +96,6 @@ module.exports = function ghost_head(options) { // eslint-disable-line camelcase
var head = [],
dataRoot = options.data.root,
context = dataRoot._locals.context ? dataRoot._locals.context : null,
client = dataRoot._locals.client,
safeVersion = dataRoot._locals.safeVersion,
postCodeInjection = dataRoot && dataRoot.post ? dataRoot.post.codeinjection_head : null,
globalCodeinjection = settingsCache.get('ghost_head'),
@ -176,10 +163,6 @@ module.exports = function ghost_head(options) { // eslint-disable-line camelcase
}
}
if (client && client.id && client.secret && !_.includes(context, 'amp')) {
head.push(getAjaxHelper(client.id, client.secret));
}
if (!_.includes(context, 'amp') && labs.isSet('members')) {
head.push(getMembersHelper());
}
@ -189,7 +172,7 @@ module.exports = function ghost_head(options) { // eslint-disable-line camelcase
escapeExpression(safeVersion) + '" />');
head.push('<link rel="alternate" type="application/rss+xml" title="' +
escapeExpression(metaData.blog.title) + '" href="' +
escapeExpression(metaData.site.title) + '" href="' +
escapeExpression(metaData.rssUrl) + '" />');
// no code injection for amp context!!!

View file

@ -119,7 +119,7 @@ module.exports = function has(options) {
var self = this,
attrs = _.pick(options.hash, validAttrs),
data = _.pick(options.data, ['blog', 'config', 'labs']),
data = _.pick(options.data, ['site', 'config', 'labs']),
checks = {
tag: function () {
return handleTag(self, attrs);

View file

@ -16,7 +16,7 @@ module.exports = function navigation(options) {
options.hash = options.hash || {};
options.data = options.data || {};
var navigationData = options.data.blog.navigation,
var navigationData = options.data.site.navigation,
currentUrl = options.data.root.relativeUrl,
self = this,
output;

View file

@ -10,7 +10,7 @@ var proxy = require('./proxy'),
module.exports = function twitter_url(username, options) { // eslint-disable-line camelcase
if (!options) {
options = username;
username = localUtils.findKey('twitter', this, options.data.blog);
username = localUtils.findKey('twitter', this, options.data.site);
}
if (username) {

View file

@ -36,14 +36,6 @@ function getDescription(data, root, options) {
} else {
description = data.post.meta_description || '';
}
} else if (_.includes(context, 'page') && data.post) {
// @NOTE: v0.1
if (options && options.property) {
postSdDescription = options.property + '_description';
description = data.post[postSdDescription] || '';
} else {
description = data.post.meta_description || '';
}
} else if (_.includes(context, 'page') && data.page) {
if (options && options.property) {
postSdDescription = options.property + '_description';

View file

@ -6,7 +6,7 @@ var Promise = require('bluebird'),
* Get Image dimensions
* @param {object} metaData
* @returns {object} metaData
* @description for image properties in meta data (coverImage, authorImage and blog.logo), `getCachedImageSizeFromUrl` is
* @description for image properties in meta data (coverImage, authorImage and site.logo), `getCachedImageSizeFromUrl` is
* called to receive image width and height
*/
function getImageDimensions(metaData) {
@ -14,7 +14,7 @@ function getImageDimensions(metaData) {
coverImage: imageLib.imageSizeCache(metaData.coverImage.url),
authorImage: imageLib.imageSizeCache(metaData.authorImage.url),
ogImage: imageLib.imageSizeCache(metaData.ogImage.url),
logo: imageLib.imageSizeCache(metaData.blog.logo.url)
logo: imageLib.imageSizeCache(metaData.site.logo.url)
};
return Promise
@ -28,7 +28,7 @@ function getImageDimensions(metaData) {
// we will fake it in some cases or not produce an imageObject at all.
if (value === 'logo') {
if (key.height <= 60 && key.width <= 600) {
_.assign(metaData.blog[value], {
_.assign(metaData.site[value], {
dimensions: {
width: key.width,
height: key.height
@ -36,7 +36,7 @@ function getImageDimensions(metaData) {
});
} else if (key.width === key.height) {
// CASE: the logo is too large, but it is a square. We fake it...
_.assign(metaData.blog[value], {
_.assign(metaData.site[value], {
dimensions: {
width: 60,
height: 60

View file

@ -58,7 +58,7 @@ function getMetaData(data, root) {
modifiedDate: getModifiedDate(data),
ogType: getOgType(data),
// @TODO: pass into each meta helper - wrap each helper
blog: {
site: {
title: settingsCache.get('title'),
description: settingsCache.get('description'),
url: urlUtils.urlFor('home', true),
@ -77,17 +77,17 @@ function getMetaData(data, root) {
fallbackExcerpt;
// TODO: cleanup these if statements
if (data.post) {
if (data.post || data.page) {
// There's a specific order for description fields (not <meta name="description" /> !!) in structured data
// and schema.org which is used the description fields (see https://github.com/TryGhost/Ghost/issues/8793):
// 1. CASE: custom_excerpt is populated via the UI
// 2. CASE: no custom_excerpt, but meta_description is poplated via the UI
// 3. CASE: fall back to automated excerpt of 50 words if neither custom_excerpt nor meta_description is provided
// @NOTE: v2 returns a calculated `post.excerpt`. v0.1 does not
// @TODO: simplify or remove if we drop v0.1
customExcerpt = data.post.excerpt || data.post.custom_excerpt;
metaDescription = data.post.meta_description;
fallbackExcerpt = data.post.html ? getExcerpt(data.post.html, {words: 50}) : '';
// @TODO: https://github.com/TryGhost/Ghost/issues/10062
const prop = data.post ? 'post' : 'page';
customExcerpt = data[prop].excerpt || data[prop].custom_excerpt;
metaDescription = data[prop].meta_description;
fallbackExcerpt = data[prop].html ? getExcerpt(data[prop].html, {words: 50}) : '';
metaData.excerpt = customExcerpt ? customExcerpt : metaDescription ? metaDescription : fallbackExcerpt;
}

View file

@ -76,8 +76,8 @@ function getPostSchema(metaData, data) {
'@type': 'Article',
publisher: {
'@type': 'Organization',
name: escapeExpression(metaData.blog.title),
logo: schemaImageObject(metaData.blog.logo) || null
name: escapeExpression(metaData.site.title),
logo: schemaImageObject(metaData.site.logo) || null
},
author: {
'@type': 'Person',
@ -99,7 +99,7 @@ function getPostSchema(metaData, data) {
description: description,
mainEntityOfPage: {
'@type': 'WebPage',
'@id': metaData.blog.url || null
'@id': metaData.site.url || null
}
};
schema.author = trimSchema(schema.author);
@ -112,14 +112,14 @@ function getHomeSchema(metaData) {
'@type': 'WebSite',
publisher: {
'@type': 'Organization',
name: escapeExpression(metaData.blog.title),
logo: schemaImageObject(metaData.blog.logo) || null
name: escapeExpression(metaData.site.title),
logo: schemaImageObject(metaData.site.logo) || null
},
url: metaData.url,
image: schemaImageObject(metaData.coverImage),
mainEntityOfPage: {
'@type': 'WebPage',
'@id': metaData.blog.url || null
'@id': metaData.site.url || null
},
description: metaData.metaDescription ?
escapeExpression(metaData.metaDescription) :
@ -134,15 +134,15 @@ function getTagSchema(metaData, data) {
'@type': 'Series',
publisher: {
'@type': 'Organization',
name: escapeExpression(metaData.blog.title),
logo: schemaImageObject(metaData.blog.logo) || null
name: escapeExpression(metaData.site.title),
logo: schemaImageObject(metaData.site.logo) || null
},
url: metaData.url,
image: schemaImageObject(metaData.coverImage),
name: data.tag.name,
mainEntityOfPage: {
'@type': 'WebPage',
'@id': metaData.blog.url || null
'@id': metaData.site.url || null
},
description: metaData.metaDescription ?
escapeExpression(metaData.metaDescription) :
@ -162,7 +162,7 @@ function getAuthorSchema(metaData, data) {
image: schemaImageObject(metaData.coverImage),
mainEntityOfPage: {
'@type': 'WebPage',
'@id': metaData.blog.url || null
'@id': metaData.site.url || null
},
description: metaData.metaDescription ?
escapeExpression(metaData.metaDescription) :

View file

@ -9,7 +9,7 @@ function getStructuredData(metaData) {
}
structuredData = {
'og:site_name': metaData.blog.title,
'og:site_name': metaData.site.title,
'og:type': metaData.ogType,
'og:title': metaData.ogTitle || metaData.metaTitle,
// CASE: metaData.excerpt for post context is populated by either the custom excerpt,
@ -21,7 +21,7 @@ function getStructuredData(metaData) {
'article:published_time': metaData.publishedDate,
'article:modified_time': metaData.modifiedDate,
'article:tag': metaData.keywords,
'article:publisher': metaData.blog.facebook ? socialUrls.facebook(metaData.blog.facebook) : undefined,
'article:publisher': metaData.site.facebook ? socialUrls.facebook(metaData.site.facebook) : undefined,
'article:author': metaData.authorFacebook ? socialUrls.facebook(metaData.authorFacebook) : undefined,
'twitter:card': card,
'twitter:title': metaData.twitterTitle || metaData.metaTitle,
@ -32,7 +32,7 @@ function getStructuredData(metaData) {
'twitter:data1': metaData.authorName,
'twitter:label2': metaData.keywords ? 'Filed under' : undefined,
'twitter:data2': metaData.keywords ? metaData.keywords.join(', ') : undefined,
'twitter:site': metaData.blog.twitter || undefined,
'twitter:site': metaData.site.twitter || undefined,
'twitter:creator': metaData.creatorTwitter || undefined
};

View file

@ -7,7 +7,7 @@ const settingsCache = require('../../../server/services/settings/cache');
const activeTheme = require('./active');
// ### Ensure Active Theme
// Ensure there's a properly set & mounted active theme before attempting to serve a blog request
// Ensure there's a properly set & mounted active theme before attempting to serve a site request
// If there is no active theme, throw an error
// Else, ensure the active theme is mounted
function ensureActiveTheme(req, res, next) {
@ -21,7 +21,7 @@ function ensureActiveTheme(req, res, next) {
}));
}
// CASE: bootstrap theme validation failed, we would like to show the errors on the blog [only production]
// CASE: bootstrap theme validation failed, we would like to show the errors on the site [only production]
if (activeTheme.get().error && config.get('env') === 'production') {
return next(new common.errors.InternalServerError({
// We use the settingsCache here, because the setting will be set,
@ -51,7 +51,7 @@ function updateGlobalTemplateOptions(req, res, next) {
};
// @TODO: only do this if something changed?
// @TODO: remove blog if we drop v0.1 (Ghost 3.0)
// @TODO: remove blog if we drop v2 (Ghost 4.0)
hbs.updateTemplateOptions({
data: {
blog: siteData,
@ -79,6 +79,7 @@ function updateLocalTemplateOptions(req, res, next) {
};
hbs.updateLocalTemplateOptions(res.locals, _.merge({}, localTemplateOptions, {
// @TODO: remove blog if we drop v2 (Ghost 4.0)
data: {
member: req.member,
site: siteData,

View file

@ -585,11 +585,7 @@
"iteratorNeeded": "Need to pass an iterator to #foreach"
},
"get": {
"invalidResource": "Invalid resource given to get helper",
"apiRequired": {
"message": "The \\{\\{#get\\}\\} helper requires your theme to have API access.",
"context": "Please enable the v2 API via your theme's package.json file."
}
"invalidResource": "Invalid resource given to get helper"
},
"has": {
"invalidAttribute": "Invalid or no attribute given to has helper"

View file

@ -189,17 +189,6 @@ describe('getMetaDescription', function () {
description.should.equal('Best AMP post ever!');
});
it('v0.1: should return data post meta description if on root context contains page', function () {
var description = getMetaDescription({
post: {
meta_description: 'Best page ever!'
}
}, {
context: ['page']
});
description.should.equal('Best page ever!');
});
it('v2: should return data page meta description if on root context contains page', function () {
var description = getMetaDescription({
page: {

View file

@ -25,7 +25,7 @@ describe('getImageDimensions', function () {
ogImage: {
url: 'http://mysite.com/content/image/super-facebook-image.jpg'
},
blog: {
site: {
logo: {
url: 'http://mysite.com/author/image/url/logo.jpg'
}
@ -45,7 +45,7 @@ describe('getImageDimensions', function () {
sizeOfStub.calledWith(metaData.coverImage.url).should.be.true();
sizeOfStub.calledWith(metaData.authorImage.url).should.be.true();
sizeOfStub.calledWith(metaData.ogImage.url).should.be.true();
sizeOfStub.calledWith(metaData.blog.logo.url).should.be.true();
sizeOfStub.calledWith(metaData.site.logo.url).should.be.true();
result.coverImage.should.have.property('dimensions');
result.coverImage.should.have.property('url');
result.coverImage.dimensions.should.have.property('width', 50);
@ -58,10 +58,10 @@ describe('getImageDimensions', function () {
result.ogImage.should.have.property('url');
result.ogImage.dimensions.should.have.property('width', 50);
result.ogImage.dimensions.should.have.property('height', 50);
result.blog.logo.should.have.property('dimensions');
result.blog.logo.should.have.property('url');
result.blog.logo.dimensions.should.have.property('width', 50);
result.blog.logo.dimensions.should.have.property('height', 50);
result.site.logo.should.have.property('dimensions');
result.site.logo.should.have.property('url');
result.site.logo.dimensions.should.have.property('width', 50);
result.site.logo.dimensions.should.have.property('height', 50);
done();
}).catch(done);
});
@ -80,7 +80,7 @@ describe('getImageDimensions', function () {
twitterImage: {
url: null
},
blog: {
site: {
logo: {
url: 'noUrl'
}
@ -96,15 +96,15 @@ describe('getImageDimensions', function () {
sizeOfStub.calledWith(metaData.coverImage.url).should.be.true();
sizeOfStub.calledWith(metaData.authorImage.url).should.be.true();
sizeOfStub.calledWith(metaData.ogImage.url).should.be.true();
sizeOfStub.calledWith(metaData.blog.logo.url).should.be.true();
sizeOfStub.calledWith(metaData.site.logo.url).should.be.true();
result.coverImage.should.not.have.property('dimensions');
result.coverImage.should.have.property('url');
result.authorImage.should.not.have.property('dimensions');
result.authorImage.should.have.property('url');
result.ogImage.should.not.have.property('dimensions');
result.ogImage.should.have.property('url');
result.blog.logo.should.not.have.property('dimensions');
result.blog.logo.should.have.property('url');
result.site.logo.should.not.have.property('dimensions');
result.site.logo.should.have.property('url');
done();
}).catch(done);
});
@ -120,7 +120,7 @@ describe('getImageDimensions', function () {
ogImage: {
url: 'http://mysite.com/content/image/super-facebook-image.jpg'
},
blog: {
site: {
logo: {
url: 'http://mysite.com/author/image/url/favicon.ico'
}
@ -140,15 +140,15 @@ describe('getImageDimensions', function () {
sizeOfStub.calledWith(metaData.coverImage.url).should.be.true();
sizeOfStub.calledWith(metaData.authorImage.url).should.be.true();
sizeOfStub.calledWith(metaData.ogImage.url).should.be.true();
sizeOfStub.calledWith(metaData.blog.logo.url).should.be.true();
sizeOfStub.calledWith(metaData.site.logo.url).should.be.true();
result.coverImage.should.have.property('url');
result.coverImage.should.have.property('dimensions');
result.coverImage.dimensions.should.have.property('height', 480);
result.coverImage.dimensions.should.have.property('width', 480);
result.blog.logo.should.have.property('url');
result.blog.logo.should.have.property('dimensions');
result.blog.logo.dimensions.should.have.property('height', 60);
result.blog.logo.dimensions.should.have.property('width', 60);
result.site.logo.should.have.property('url');
result.site.logo.should.have.property('dimensions');
result.site.logo.dimensions.should.have.property('height', 60);
result.site.logo.dimensions.should.have.property('width', 60);
result.authorImage.should.have.property('url');
result.authorImage.should.have.property('dimensions');
result.authorImage.dimensions.should.have.property('height', 480);
@ -172,7 +172,7 @@ describe('getImageDimensions', function () {
ogImage: {
url: 'http://mysite.com/content/image/super-facebook-image.jpg'
},
blog: {
site: {
logo: {
url: 'http://mysite.com/author/image/url/logo.jpg'
}
@ -192,7 +192,7 @@ describe('getImageDimensions', function () {
sizeOfStub.calledWith(metaData.coverImage.url).should.be.true();
sizeOfStub.calledWith(metaData.authorImage.url).should.be.true();
sizeOfStub.calledWith(metaData.ogImage.url).should.be.true();
sizeOfStub.calledWith(metaData.blog.logo.url).should.be.true();
sizeOfStub.calledWith(metaData.site.logo.url).should.be.true();
result.coverImage.should.have.property('dimensions');
result.coverImage.should.have.property('url');
result.coverImage.dimensions.should.have.property('height', 480);
@ -205,8 +205,8 @@ describe('getImageDimensions', function () {
result.ogImage.should.have.property('url');
result.ogImage.dimensions.should.have.property('height', 480);
result.ogImage.dimensions.should.have.property('width', 80);
result.blog.logo.should.have.property('url');
result.blog.logo.should.not.have.property('dimensions');
result.site.logo.should.have.property('url');
result.site.logo.should.not.have.property('dimensions');
done();
}).catch(done);
});

View file

@ -5,8 +5,8 @@ var should = require('should'),
describe('getSchema', function () {
it('should return post schema if context starts with post', function (done) {
var metadata = {
blog: {
title: 'Blog Title',
site: {
title: 'Site Title',
url: 'http://mysite.com',
logo: {
url: 'http://mysite.com/author/image/url/logo.jpg',
@ -89,7 +89,7 @@ describe('getSchema', function () {
},
publisher: {
'@type': 'Organization',
name: 'Blog Title',
name: 'Site Title',
logo: {
'@type': 'ImageObject',
url: 'http://mysite.com/author/image/url/logo.jpg',
@ -104,8 +104,8 @@ describe('getSchema', function () {
it('should return page schema if context starts with page', function (done) {
var metadata = {
blog: {
title: 'Blog Title',
site: {
title: 'Site Title',
url: 'http://mysite.com',
logo: {
url: 'http://mysite.com/author/image/url/logo.jpg',
@ -189,7 +189,7 @@ describe('getSchema', function () {
},
publisher: {
'@type': 'Organization',
name: 'Blog Title',
name: 'Site Title',
logo: {
'@type': 'ImageObject',
url: 'http://mysite.com/author/image/url/logo.jpg',
@ -204,8 +204,8 @@ describe('getSchema', function () {
it('should return post schema if context starts with amp', function (done) {
var metadata = {
blog: {
title: 'Blog Title',
site: {
title: 'Site Title',
url: 'http://mysite.com',
logo: {
url: 'http://mysite.com/author/image/url/logo.jpg',
@ -292,7 +292,7 @@ describe('getSchema', function () {
},
publisher: {
'@type': 'Organization',
name: 'Blog Title',
name: 'Site Title',
logo: {
'@type': 'ImageObject',
url: 'http://mysite.com/author/image/url/logo.jpg',
@ -307,8 +307,8 @@ describe('getSchema', function () {
it('should return post schema removing null or undefined values', function (done) {
var metadata = {
blog: {
title: 'Blog Title'
site: {
title: 'Site Title'
},
authorImage: null,
authorFacebook: undefined,
@ -354,7 +354,7 @@ describe('getSchema', function () {
},
publisher: {
'@type': 'Organization',
name: 'Blog Title',
name: 'Site Title',
logo: null
},
url: 'http://mysite.com/post/my-post-slug/'
@ -364,8 +364,8 @@ describe('getSchema', function () {
it('should return image url instead of ImageObjects if no dimensions supplied', function (done) {
var metadata = {
blog: {
title: 'Blog Title',
site: {
title: 'Site Title',
url: 'http://mysite.com',
logo: {
url: 'http://mysite.com/author/image/url/logo.jpg'
@ -428,7 +428,7 @@ describe('getSchema', function () {
},
publisher: {
'@type': 'Organization',
name: 'Blog Title',
name: 'Site Title',
logo: 'http://mysite.com/author/image/url/logo.jpg'
},
url: 'http://mysite.com/post/my-post-slug/'
@ -438,8 +438,8 @@ describe('getSchema', function () {
it('should return home schema if context starts with home', function () {
var metadata = {
blog: {
title: 'Blog Title'
site: {
title: 'Site Title'
},
url: 'http://mysite.com/post/my-post-slug/',
coverImage: {
@ -470,7 +470,7 @@ describe('getSchema', function () {
},
publisher: {
'@type': 'Organization',
name: 'Blog Title',
name: 'Site Title',
logo: null
},
url: 'http://mysite.com/post/my-post-slug/'
@ -479,8 +479,8 @@ describe('getSchema', function () {
it('should return tag schema if context starts with tag', function () {
var metadata = {
blog: {
title: 'Blog Title'
site: {
title: 'Site Title'
},
url: 'http://mysite.com/post/my-post-slug/',
coverImage: {
@ -515,7 +515,7 @@ describe('getSchema', function () {
name: 'Great Tag',
publisher: {
'@type': 'Organization',
name: 'Blog Title',
name: 'Site Title',
logo: null
},
url: 'http://mysite.com/post/my-post-slug/'
@ -524,8 +524,8 @@ describe('getSchema', function () {
it('should return author schema if context starts with author', function () {
var metadata = {
blog: {
title: 'Blog Title',
site: {
title: 'Site Title',
url: 'http://mysite.com'
},
authorImage: {

View file

@ -4,8 +4,8 @@ var should = require('should'),
describe('getStructuredData', function () {
it('should return structured data from metadata per post', function (done) {
var metadata = {
blog: {
title: 'Blog Title',
site: {
title: 'Site Title',
facebook: 'testuser',
twitter: '@testuser'
},
@ -46,7 +46,7 @@ describe('getStructuredData', function () {
'og:image': 'http://mysite.com/content/image/mypostcoverimage.jpg',
'og:image:width': 500,
'og:image:height': 500,
'og:site_name': 'Blog Title',
'og:site_name': 'Site Title',
'og:title': 'Post Title',
'og:type': 'article',
'og:url': 'http://mysite.com/post/my-post-slug/',
@ -67,8 +67,8 @@ describe('getStructuredData', function () {
it('should return structured data from metadata with provided og and twitter images only per post', function (done) {
var metadata = {
blog: {
title: 'Blog Title',
site: {
title: 'Site Title',
facebook: 'testuser',
twitter: '@testuser'
},
@ -106,7 +106,7 @@ describe('getStructuredData', function () {
'og:image': 'http://mysite.com/content/image/mypostogimage.jpg',
'og:image:width': 20,
'og:image:height': 100,
'og:site_name': 'Blog Title',
'og:site_name': 'Site Title',
'og:title': 'Custom Facebook title',
'og:type': 'article',
'og:url': 'http://mysite.com/post/my-post-slug/',
@ -127,8 +127,8 @@ describe('getStructuredData', function () {
it('should return structured data from metadata with no nulls', function (done) {
var metadata = {
blog: {
title: 'Blog Title',
site: {
title: 'Site Title',
facebook: '',
twitter: ''
},
@ -156,7 +156,7 @@ describe('getStructuredData', function () {
should.deepEqual(structuredData, {
'article:modified_time': '2016-01-21T22:13:05.412Z',
'og:site_name': 'Blog Title',
'og:site_name': 'Site Title',
'og:title': 'Post Title',
'og:type': 'article',
'og:url': 'http://mysite.com/post/my-post-slug/',

View file

@ -226,16 +226,6 @@ describe('getTitle', function () {
title.should.equal('My awesome post!');
});
it('v0.1: should return post title if in page context', function () {
var title = getTitle({
post: {
title: 'My awesome page!'
}
}, {context: ['page']});
title.should.equal('My awesome page!');
});
it('v2: should return page title if in page context', function () {
var title = getTitle({
page: {
@ -266,9 +256,10 @@ describe('getTitle', function () {
title.should.equal('My awesome page!');
});
// NOTE: this case is unlikely as Ghost doesn't support AMP for static pages
it('should return post title if in amp and page context', function () {
var title = getTitle({
post: {
page: {
title: 'My awesome page!'
}
}, {context: ['amp', 'page']});

View file

@ -133,15 +133,6 @@ describe('{{body_class}} helper', function () {
rendered.string.should.equal('post-template tag-foo tag-bar');
});
it('v0.1: a static page', function () {
var rendered = callBodyClassWithContext(
['page'],
{relativeUrl: '/about', post: {page: true, slug: 'about'}}
);
rendered.string.should.equal('page-template page-about');
});
it('v2: a static page', function () {
var rendered = callBodyClassWithContext(
['page'],

View file

@ -19,7 +19,7 @@ describe('{{date}} helper', function () {
format: format
},
data: {
blog: {
site: {
timezone: 'Europe/Dublin'
}
}
@ -47,7 +47,7 @@ describe('{{date}} helper', function () {
timeago: true
},
data: {
blog: {
site: {
timezone: 'Europe/Dublin'
}
}

View file

@ -4,26 +4,26 @@ var should = require('should'),
helpers = require('../../../frontend/helpers');
describe('{{facebook_url}} helper', function () {
var options = {data: {blog: {}}};
var options = {data: {site: {}}};
beforeEach(function () {
options.data.blog = {facebook: ''};
options.data.site = {facebook: ''};
});
it('should output the facebook url for @blog, if no other facebook username is provided', function () {
options.data.blog = {facebook: 'hey'};
it('should output the facebook url for @site, if no other facebook username is provided', function () {
options.data.site = {facebook: 'hey'};
helpers.facebook_url.call({}, options).should.equal('https://www.facebook.com/hey');
});
it('should output the facebook url for the local object, if it has one', function () {
options.data.blog = {facebook: 'hey'};
options.data.site = {facebook: 'hey'};
helpers.facebook_url.call({facebook: 'you/there'}, options).should.equal('https://www.facebook.com/you/there');
});
it('should output the facebook url for the provided username when it is explicitly passed in', function () {
options.data.blog = {facebook: 'hey'};
options.data.site = {facebook: 'hey'};
helpers.facebook_url.call({facebook: 'you/there'}, 'i/see/you/over/there', options)
.should.equal('https://www.facebook.com/i/see/you/over/there');

View file

@ -10,7 +10,7 @@ var should = require('should'),
labs = require('../../../server/services/labs');
describe('{{#get}} helper', function () {
var fn, inverse, labsStub;
var fn, inverse;
let locals = {};
before(function () {
@ -20,378 +20,34 @@ describe('{{#get}} helper', function () {
beforeEach(function () {
fn = sinon.spy();
inverse = sinon.spy();
labsStub = sinon.stub(labs, 'isSet').returns(true);
locals = {root: {_locals: {apiVersion: 'v0.1'}}, globalProp: {foo: 'bar'}};
locals = {root: {_locals: {apiVersion: 'v2'}}, globalProp: {foo: 'bar'}};
});
afterEach(function () {
sinon.restore();
});
it('errors correctly if labs flag not set', function (done) {
labsStub.returns(false);
helpers.get.call(
{},
'posts',
{hash: {}, data: locals, fn: fn, inverse: inverse}
).then(function (result) {
labsStub.calledOnce.should.be.true();
fn.called.should.be.false();
inverse.called.should.be.false();
should.exist(result);
result.should.be.an.Object().with.property(
'string',
'<script>console.error("The {{#get}} helper requires your theme to have API access. ' +
'Please enable the v2 API via your theme\'s package.json file. ' +
'See https://ghost.org/docs/api/handlebars-themes/packagejson/");</script>'
);
done();
}).catch(done);
});
describe('posts v0.1', function () {
var browsePostsStub, readPostsStub, readTagsStub, readUsersStub, testPostsArr = [
{id: 1, title: 'Test Post 1', author: {slug: 'cameron'}},
{id: 2, title: 'Test Post 2', author: {slug: 'cameron'}, featured: true},
{id: 3, title: 'Test Post 3', tags: [{slug: 'test'}]},
{id: 4, title: 'Test Post 4'}
],
meta = {pagination: {}};
beforeEach(function () {
browsePostsStub = sinon.stub(api['v0.1'].posts, 'browse');
readPostsStub = sinon.stub(api['v0.1'].posts, 'read');
readTagsStub = sinon.stub(api['v0.1'].tags, 'read').returns(new Promise.resolve({tags: []}));
readUsersStub = sinon.stub(api['v0.1'].users, 'read').returns(new Promise.resolve({users: []}));
browsePostsStub.returns(new Promise.resolve({posts: testPostsArr, meta: meta}));
browsePostsStub.withArgs({limit: '3'}).returns(new Promise.resolve({
posts: testPostsArr.slice(0, 3),
meta: meta
}));
browsePostsStub.withArgs({limit: '1'}).returns(new Promise.resolve({posts: testPostsArr.slice(0, 1)}));
browsePostsStub.withArgs({filter: 'tags:test'}).returns(new Promise.resolve({posts: testPostsArr.slice(2, 3)}));
browsePostsStub.withArgs({filter: 'tags:none'}).returns(new Promise.resolve({posts: []}));
browsePostsStub.withArgs({filter: 'author:cameron'}).returns(new Promise.resolve({posts: testPostsArr.slice(0, 2)}));
browsePostsStub.withArgs({filter: 'featured:true'}).returns(new Promise.resolve({posts: testPostsArr.slice(2, 3)}));
readPostsStub.withArgs({id: '2'}).returns(new Promise.resolve({posts: testPostsArr.slice(1, 2)}));
});
it('should handle default browse posts call', function (done) {
helpers.get.call(
{},
'posts',
{hash: {}, data: locals, fn: fn, inverse: inverse}
).then(function () {
labsStub.calledOnce.should.be.true();
fn.called.should.be.true();
fn.firstCall.args[0].should.be.an.Object().with.property('posts');
fn.firstCall.args[0].posts.should.eql(testPostsArr);
fn.firstCall.args[0].posts.should.have.lengthOf(4);
inverse.called.should.be.false();
done();
}).catch(done);
});
it('should return pagination and meta pagination with default browse posts call', function (done) {
helpers.get.call(
{},
'posts',
{hash: {}, data: locals, fn: fn, inverse: inverse}
).then(function () {
fn.firstCall.args[0].pagination.should.be.an.Object();
fn.firstCall.args[0].meta.should.be.an.Object();
fn.firstCall.args[0].meta.pagination.should.be.an.Object();
inverse.called.should.be.false();
done();
}).catch(done);
});
it('should not return pagination if meta pagination does not exist', function (done) {
helpers.get.call(
{},
'posts',
{hash: {limit: '1'}, data: locals, fn: fn, inverse: inverse}
).then(function () {
should.not.exist(fn.firstCall.args[0].pagination);
should.not.exist(fn.firstCall.args[0].meta);
inverse.called.should.be.false();
done();
}).catch(done);
});
it('should handle browse posts call with limit 3', function (done) {
helpers.get.call(
{},
'posts',
{hash: {limit: '3'}, data: locals, fn: fn, inverse: inverse}
).then(function () {
fn.calledOnce.should.be.true();
fn.firstCall.args[0].should.be.an.Object().with.property('posts');
fn.firstCall.args[0].posts.should.have.lengthOf(3);
fn.firstCall.args[0].posts.should.eql(testPostsArr.slice(0, 3));
inverse.called.should.be.false();
done();
}).catch(done);
});
it('should handle browse posts call with limit 1', function (done) {
helpers.get.call(
{},
'posts',
{hash: {limit: '1'}, data: locals, fn: fn, inverse: inverse}
).then(function () {
fn.calledOnce.should.be.true();
fn.firstCall.args[0].should.be.an.Object().with.property('posts');
fn.firstCall.args[0].posts.should.have.lengthOf(1);
fn.firstCall.args[0].posts.should.eql(testPostsArr.slice(0, 1));
inverse.called.should.be.false();
done();
}).catch(done);
});
it('should handle browse posts call with limit 1', function (done) {
helpers.get.call(
{},
'posts',
{hash: {limit: '1'}, data: locals, fn: fn, inverse: inverse}
).then(function () {
fn.calledOnce.should.be.true();
fn.firstCall.args[0].should.be.an.Object().with.property('posts');
fn.firstCall.args[0].posts.should.have.lengthOf(1);
fn.firstCall.args[0].posts.should.eql(testPostsArr.slice(0, 1));
inverse.called.should.be.false();
done();
}).catch(done);
});
it('should handle browse post call with explicit tag', function (done) {
helpers.get.call(
{},
'posts',
{hash: {filter: 'tags:test'}, data: locals, fn: fn, inverse: inverse}
).then(function () {
fn.calledOnce.should.be.true();
fn.firstCall.args[0].should.be.an.Object().with.property('posts');
fn.firstCall.args[0].posts.should.have.lengthOf(1);
fn.firstCall.args[0].posts.should.eql(testPostsArr.slice(2, 3));
inverse.called.should.be.false();
done();
}).catch(done);
});
it('should handle browse post call with explicit author', function (done) {
helpers.get.call(
{},
'posts',
{hash: {filter: 'author:cameron'}, data: locals, fn: fn, inverse: inverse}
).then(function () {
fn.calledOnce.should.be.true();
fn.firstCall.args[0].should.be.an.Object().with.property('posts');
fn.firstCall.args[0].posts.should.have.lengthOf(2);
fn.firstCall.args[0].posts.should.eql(testPostsArr.slice(0, 2));
inverse.called.should.be.false();
done();
}).catch(done);
});
it('should handle browse post call with featured:true', function (done) {
helpers.get.call(
{},
'posts',
{hash: {filter: 'featured:true'}, data: locals, fn: fn, inverse: inverse}
).then(function () {
fn.calledOnce.should.be.true();
fn.firstCall.args[0].should.be.an.Object().with.property('posts');
fn.firstCall.args[0].posts.should.have.lengthOf(1);
fn.firstCall.args[0].posts.should.eql(testPostsArr.slice(2, 3));
inverse.called.should.be.false();
done();
}).catch(done);
});
it('should handle read post by id call', function (done) {
helpers.get.call(
{},
'posts',
{hash: {id: '2'}, data: locals, fn: fn, inverse: inverse}
).then(function () {
fn.calledOnce.should.be.true();
fn.firstCall.args[0].should.be.an.Object().with.property('posts');
fn.firstCall.args[0].posts.should.have.lengthOf(1);
fn.firstCall.args[0].posts.should.eql(testPostsArr.slice(1, 2));
inverse.called.should.be.false();
done();
}).catch(done);
});
it('should handle empty result set', function (done) {
helpers.get.call(
{},
'posts',
{hash: {filter: 'tags:none'}, data: locals, fn: fn, inverse: inverse}
).then(function () {
fn.calledOnce.should.be.true();
fn.firstCall.args[0].should.be.an.Object().with.property('posts');
fn.firstCall.args[0].posts.should.have.lengthOf(0);
inverse.called.should.be.false();
done();
}).catch(done);
});
});
describe('users v0.1', function () {
let browseUsersStub;
const meta = {pagination: {}};
beforeEach(function () {
browseUsersStub = sinon.stub(api['v0.1'].users, 'browse');
browseUsersStub.returns(new Promise.resolve({users: [], meta: meta}));
});
it('browse users v0.1', function (done) {
helpers.get.call(
{},
'users',
{hash: {}, data: locals, fn: fn, inverse: inverse}
).then(function () {
labsStub.calledOnce.should.be.true();
fn.called.should.be.true();
fn.firstCall.args[0].should.be.an.Object().with.property('users');
fn.firstCall.args[0].users.should.eql([]);
inverse.called.should.be.false();
done();
}).catch(done);
});
});
describe('authors v0.1', function () {
let browseUsersStub;
const meta = {pagination: {}};
beforeEach(function () {
browseUsersStub = sinon.stub(api['v0.1'].users, 'browse');
browseUsersStub.returns(new Promise.resolve({users: [], meta: meta}));
});
it('browse users v0.1', function (done) {
helpers.get.call(
{},
'authors',
{hash: {}, data: locals, fn: fn, inverse: inverse}
).then(function () {
inverse.calledOnce.should.be.true();
should.exist(inverse.args[0][1].data.error);
done();
}).catch(done);
});
});
describe('users v2', function () {
let browseUsersStub;
const meta = {pagination: {}};
beforeEach(function () {
locals = {root: {_locals: {apiVersion: 'v2'}}};
browseUsersStub = sinon.stub(api.v2, 'authorsPublic').get(() => {
return {
browse: sinon.stub().resolves({authors: [], meta: meta})
};
});
});
it('browse users', function (done) {
helpers.get.call(
{},
'users',
{hash: {}, data: locals, fn: fn, inverse: inverse}
).then(function () {
// We don't use the labs helper for v2
labsStub.calledOnce.should.be.false();
fn.called.should.be.true();
fn.firstCall.args[0].should.be.an.Object().with.property('authors');
fn.firstCall.args[0].authors.should.eql([]);
inverse.called.should.be.false();
done();
}).catch(done);
});
});
describe('authors v2', function () {
let browseUsersStub;
let browseAuthorsStub;
const meta = {pagination: {}};
beforeEach(function () {
locals = {root: {_locals: {apiVersion: 'v2'}}};
browseUsersStub = sinon.stub(api.v2, 'authorsPublic').get(() => {
browseAuthorsStub = sinon.stub(api.v2, 'authorsPublic').get(() => {
return {
browse: sinon.stub().resolves({authors: [], meta: meta})
};
});
});
it('browse users', function (done) {
it('browse authors', function (done) {
helpers.get.call(
{},
'authors',
{hash: {}, data: locals, fn: fn, inverse: inverse}
).then(function () {
// We don't use the labs helper for v2
labsStub.calledOnce.should.be.false();
fn.called.should.be.true();
fn.firstCall.args[0].should.be.an.Object().with.property('authors');
fn.firstCall.args[0].authors.should.eql([]);
inverse.called.should.be.false();
done();
}).catch(done);
});
});
describe('users canary', function () {
let browseUsersStub;
const meta = {pagination: {}};
beforeEach(function () {
locals = {root: {_locals: {apiVersion: 'canary'}}};
browseUsersStub = sinon.stub(api.canary, 'authorsPublic').get(() => {
return {
browse: sinon.stub().resolves({authors: [], meta: meta})
};
});
});
it('browse users', function (done) {
helpers.get.call(
{},
'users',
{hash: {}, data: locals, fn: fn, inverse: inverse}
).then(function () {
// We don't use the labs helper for canary
labsStub.calledOnce.should.be.false();
fn.called.should.be.true();
fn.firstCall.args[0].should.be.an.Object().with.property('authors');
fn.firstCall.args[0].authors.should.eql([]);
@ -403,61 +59,25 @@ describe('{{#get}} helper', function () {
});
describe('authors canary', function () {
let browseUsersStub;
let browseAuthorsStub;
const meta = {pagination: {}};
beforeEach(function () {
locals = {root: {_locals: {apiVersion: 'canary'}}};
browseUsersStub = sinon.stub(api.canary, 'authorsPublic').get(() => {
browseAuthorsStub = sinon.stub(api.canary, 'authorsPublic').get(() => {
return {
browse: sinon.stub().resolves({authors: [], meta: meta})
};
});
});
it('browse users', function (done) {
it('browse authors', function (done) {
helpers.get.call(
{},
'authors',
{hash: {}, data: locals, fn: fn, inverse: inverse}
).then(function () {
// We don't use the labs helper for canary
labsStub.calledOnce.should.be.false();
fn.called.should.be.true();
fn.firstCall.args[0].should.be.an.Object().with.property('authors');
fn.firstCall.args[0].authors.should.eql([]);
inverse.called.should.be.false();
done();
}).catch(done);
});
});
describe('users v3', function () {
let browseUsersStub;
const meta = {pagination: {}};
beforeEach(function () {
locals = {root: {_locals: {apiVersion: 'v3'}}};
browseUsersStub = sinon.stub(api.v3, 'authorsPublic').get(() => {
return {
browse: sinon.stub().resolves({authors: [], meta: meta})
};
});
});
it('browse users', function (done) {
helpers.get.call(
{},
'users',
{hash: {}, data: locals, fn: fn, inverse: inverse}
).then(function () {
// We don't use the labs helper for v3
labsStub.calledOnce.should.be.false();
fn.called.should.be.true();
fn.firstCall.args[0].should.be.an.Object().with.property('authors');
fn.firstCall.args[0].authors.should.eql([]);
@ -469,28 +89,25 @@ describe('{{#get}} helper', function () {
});
describe('authors v3', function () {
let browseUsersStub;
let browseAuthorsStub;
const meta = {pagination: {}};
beforeEach(function () {
locals = {root: {_locals: {apiVersion: 'v3'}}};
browseUsersStub = sinon.stub(api.v3, 'authorsPublic').get(() => {
browseAuthorsStub = sinon.stub(api.v3, 'authorsPublic').get(() => {
return {
browse: sinon.stub().resolves({authors: [], meta: meta})
};
});
});
it('browse users', function (done) {
it('browse authors', function (done) {
helpers.get.call(
{},
'authors',
{hash: {}, data: locals, fn: fn, inverse: inverse}
).then(function () {
// We don't use the labs helper for v3
labsStub.calledOnce.should.be.false();
fn.called.should.be.true();
fn.firstCall.args[0].should.be.an.Object().with.property('authors');
fn.firstCall.args[0].authors.should.eql([]);
@ -522,7 +139,7 @@ describe('{{#get}} helper', function () {
helpers.get.call(
{},
'posts',
{hash: {status: 'thing!'}, data: locals, fn: fn, inverse: inverse}
{hash: {slug: 'thing!'}, data: locals, fn: fn, inverse: inverse}
).then(function () {
fn.called.should.be.false();
inverse.calledOnce.should.be.true();
@ -556,8 +173,14 @@ describe('{{#get}} helper', function () {
};
beforeEach(function () {
browseStub = sinon.stub(api['v0.1'].posts, 'browse').returns(new Promise.resolve());
readStub = sinon.stub(api['v0.1'].posts, 'read').returns(new Promise.resolve());
browseStub = sinon.stub().resolves();
readStub = sinon.stub().resolves();
sinon.stub(api.v2, 'postsPublic').get(() => {
return {
browse: browseStub,
read: readStub
};
});
});
it('should resolve post.tags alias', function (done) {

View file

@ -126,7 +126,7 @@ describe('{{ghost_head}} helper', function () {
/** POSTS */
posts.push(createPost({// Post 0
meta_description: 'all about our blog',
meta_description: 'all about our site',
title: 'About',
feature_image: '/content/images/test-image-about.png',
page: true,
@ -135,7 +135,7 @@ describe('{{ghost_head}} helper', function () {
}));
posts.push(createPost({// Post 1
meta_description: 'all about our blog',
meta_description: 'all about our site',
title: 'About',
feature_image: '/content/images/test-image-about.png',
og_image: '/content/images/test-og-image.png',
@ -150,7 +150,7 @@ describe('{{ghost_head}} helper', function () {
}));
posts.push(createPost({// Post 2
meta_description: 'blog description',
meta_description: 'site description',
title: 'Welcome to Ghost',
feature_image: '/content/images/test-image.png',
og_title: 'Custom Facebook title',
@ -168,7 +168,7 @@ describe('{{ghost_head}} helper', function () {
}));
posts.push(createPost({// Post 3
meta_description: 'blog description',
meta_description: 'site description',
custom_excerpt: 'post custom excerpt',
title: 'Welcome to Ghost',
feature_image: '/content/images/test-image.png',
@ -196,7 +196,7 @@ describe('{{ghost_head}} helper', function () {
}));
posts.push(createPost({// Post 5
meta_description: 'blog description',
meta_description: 'site description',
title: 'Welcome to Ghost',
feature_image: '/content/images/test-image.png',
og_image: '/content/images/test-facebook-image.png',
@ -215,7 +215,7 @@ describe('{{ghost_head}} helper', function () {
}));
posts.push(createPost({// Post 6
meta_description: 'blog "test" description',
meta_description: 'site "test" description',
title: 'title',
meta_title: 'Welcome to Ghost "test"',
feature_image: '/content/images/test-image.png',
@ -231,7 +231,7 @@ describe('{{ghost_head}} helper', function () {
}));
posts.push(createPost({// Post 7
meta_description: 'blog description',
meta_description: 'site description',
title: 'Welcome to Ghost',
feature_image: '/content/images/test-image.png',
tags: [],
@ -242,7 +242,7 @@ describe('{{ghost_head}} helper', function () {
}));
posts.push(createPost({// Post 8
meta_description: 'blog description',
meta_description: 'site description',
title: 'Welcome to Ghost',
feature_image: null,
tags: [
@ -280,13 +280,13 @@ describe('{{ghost_head}} helper', function () {
sinon.stub(routing.registry, 'getRssUrl').returns('http://localhost:65530/rss/');
sinon.stub(imageLib.imageSize, 'getImageSizeFromUrl').resolves();
sinon.stub(themes, 'getActive').returns({
engine: () => 'v0.1'
engine: () => 'v2'
});
sinon.stub(settingsCache, 'get');
settingsCache.get.withArgs('title').returns('Ghost');
settingsCache.get.withArgs('description').returns('blog description');
settingsCache.get.withArgs('cover_image').returns('/content/images/blog-cover.png');
settingsCache.get.withArgs('description').returns('site description');
settingsCache.get.withArgs('cover_image').returns('/content/images/site-cover.png');
settingsCache.get.withArgs('amp').returns(true);
makeFixtures();
@ -344,18 +344,18 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/" \/>/);
rendered.string.should.match(/<meta name="referrer" content="no-referrer-when-downgrade" \/>/);
rendered.string.should.match(/<meta name="description" content="blog description" \/>/);
rendered.string.should.match(/<meta name="description" content="site description" \/>/);
rendered.string.should.match(/<meta property="og:site_name" content="Ghost" \/>/);
rendered.string.should.match(/<meta property="og:type" content="website" \/>/);
rendered.string.should.match(/<meta property="og:title" content="Ghost" \/>/);
rendered.string.should.match(/<meta property="og:description" content="blog description" \/>/);
rendered.string.should.match(/<meta property="og:description" content="site description" \/>/);
rendered.string.should.match(/<meta property="og:url" content="http:\/\/localhost:65530\/" \/>/);
rendered.string.should.match(/<meta property="og:image" content="http:\/\/localhost:65530\/content\/images\/blog-cover.png" \/>/);
rendered.string.should.match(/<meta property="og:image" content="http:\/\/localhost:65530\/content\/images\/site-cover.png" \/>/);
rendered.string.should.match(/<meta name="twitter:card" content="summary_large_image" \/>/);
rendered.string.should.match(/<meta name="twitter:title" content="Ghost" \/>/);
rendered.string.should.match(/<meta name="twitter:description" content="blog description" \/>/);
rendered.string.should.match(/<meta name="twitter:description" content="site description" \/>/);
rendered.string.should.match(/<meta name="twitter:url" content="http:\/\/localhost:65530\/" \/>/);
rendered.string.should.match(/<meta name="twitter:image" content="http:\/\/localhost:65530\/content\/images\/blog-cover.png" \/>/);
rendered.string.should.match(/<meta name="twitter:image" content="http:\/\/localhost:65530\/content\/images\/site-cover.png" \/>/);
rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/);
rendered.string.should.match(/<link rel="alternate" type="application\/rss\+xml" title="Ghost" href="http:\/\/localhost:65530\/rss\/" \/>/);
rendered.string.should.match(/<script type=\"application\/ld\+json\">/);
@ -363,8 +363,8 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/"@type": "WebSite"/);
rendered.string.should.match(/"publisher": {\n "@type": "Organization",\n "name": "Ghost",/);
rendered.string.should.match(/"url": "http:\/\/localhost:65530\/"/);
rendered.string.should.match(/"image": "http:\/\/localhost:65530\/content\/images\/blog-cover.png"/);
rendered.string.should.match(/"description": "blog description"/);
rendered.string.should.match(/"image": "http:\/\/localhost:65530\/content\/images\/site-cover.png"/);
rendered.string.should.match(/"description": "site description"/);
done();
}).catch(done);
@ -411,7 +411,7 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/"@type": "WebSite"/);
rendered.string.should.match(/"publisher": {\n "@type": "Organization",\n "name": "Ghost",/);
rendered.string.should.match(/"url": "http:\/\/localhost:65530\/"/);
rendered.string.should.match(/"image": "http:\/\/localhost:65530\/content\/images\/blog-cover.png"/);
rendered.string.should.match(/"image": "http:\/\/localhost:65530\/content\/images\/site-cover.png"/);
rendered.string.should.match(/"description": "site SEO description"/);
done();
@ -420,7 +420,7 @@ describe('{{ghost_head}} helper', function () {
it('returns structured data on static page', function (done) {
var renderObject = {
post: posts[0]
page: posts[0]
};
helpers.ghost_head(testUtils.createHbsResponse({
@ -435,18 +435,18 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/about\/" \/>/);
rendered.string.should.match(/<meta name="referrer" content="no-referrer-when-downgrade" \/>/);
rendered.string.should.match(/<meta name="description" content="all about our blog" \/>/);
rendered.string.should.match(/<meta name="description" content="all about our site" \/>/);
rendered.string.should.match(/<meta property="og:site_name" content="Ghost" \/>/);
rendered.string.should.match(/<meta property="og:type" content="website" \/>/);
rendered.string.should.match(/<meta property="og:title" content="About" \/>/);
rendered.string.should.match(/<meta property="og:description" content="all about our blog" \/>/);
rendered.string.should.match(/<meta property="og:description" content="all about our site" \/>/);
rendered.string.should.match(/<meta property="og:url" content="http:\/\/localhost:65530\/about\/" \/>/);
rendered.string.should.match(/<meta property="og:image" content="http:\/\/localhost:65530\/content\/images\/test-image-about.png" \/>/);
rendered.string.should.match(/<meta property="article:author" content="https:\/\/www.facebook.com\/testuser" \/>/);
rendered.string.should.match(/<meta name="twitter:card" content="summary_large_image" \/>/);
rendered.string.should.match(/<meta name="twitter:title" content="About" \/>/);
rendered.string.should.match(/<meta name="twitter:creator" content="@testuser" \/>/);
rendered.string.should.match(/<meta name="twitter:description" content="all about our blog" \/>/);
rendered.string.should.match(/<meta name="twitter:description" content="all about our site" \/>/);
rendered.string.should.match(/<meta name="twitter:url" content="http:\/\/localhost:65530\/about\/" \/>/);
rendered.string.should.match(/<meta name="twitter:image" content="http:\/\/localhost:65530\/content\/images\/test-image-about.png" \/>/);
rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/);
@ -461,7 +461,7 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/"sameAs": \[\n "http:\/\/authorwebsite.com",\n "https:\/\/www.facebook.com\/testuser",\n "https:\/\/twitter.com\/testuser"\n \]/);
rendered.string.should.match(/"image": "http:\/\/localhost:65530\/content\/images\/test-image-about.png"/);
rendered.string.should.match(/"image\": \"http:\/\/localhost:65530\/content\/images\/test-author-image.png\"/);
rendered.string.should.match(/"description": "all about our blog"/);
rendered.string.should.match(/"description": "all about our site"/);
done();
}).catch(done);
@ -469,7 +469,7 @@ describe('{{ghost_head}} helper', function () {
it('returns structured data on static page with custom post structured data', function (done) {
var renderObject = {
post: posts[1]
page: posts[1]
};
helpers.ghost_head(testUtils.createHbsResponse({
@ -484,7 +484,7 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/about\/" \/>/);
rendered.string.should.match(/<meta name="referrer" content="no-referrer-when-downgrade" \/>/);
rendered.string.should.match(/<meta name="description" content="all about our blog" \/>/);
rendered.string.should.match(/<meta name="description" content="all about our site" \/>/);
rendered.string.should.match(/<meta property="og:site_name" content="Ghost" \/>/);
rendered.string.should.match(/<meta property="og:type" content="website" \/>/);
rendered.string.should.match(/<meta property="og:title" content="Custom Facebook title" \/>/);
@ -510,7 +510,7 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/"sameAs": \[\n "http:\/\/authorwebsite.com",\n "https:\/\/www.facebook.com\/testuser",\n "https:\/\/twitter.com\/testuser"\n \]/);
rendered.string.should.match(/"image": "http:\/\/localhost:65530\/content\/images\/test-image-about.png"/);
rendered.string.should.match(/"image\": \"http:\/\/localhost:65530\/content\/images\/test-author-image.png\"/);
rendered.string.should.match(/"description": "all about our blog"/);
rendered.string.should.match(/"description": "all about our site"/);
done();
}).catch(done);
@ -538,7 +538,7 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/post\/" \/>/);
rendered.string.should.match(/<link rel="amphtml" href="http:\/\/localhost:65530\/post\/amp\/" \/>/);
rendered.string.should.match(/<meta name="description" content="blog description" \/>/);
rendered.string.should.match(/<meta name="description" content="site description" \/>/);
rendered.string.should.match(/<meta property="og:site_name" content="Ghost" \/>/);
rendered.string.should.match(/<meta property="og:type" content="article" \/>/);
rendered.string.should.match(/<meta property="og:title" content="Custom Facebook title" \/>/);
@ -552,7 +552,7 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/<meta property="article:tag" content="tag3" \/>/);
rendered.string.should.match(/<meta property="article:author" content="https:\/\/www.facebook.com\/testuser" \/>/);
rendered.string.should.match(/<meta name="twitter:title" content="Welcome to Ghost" \/>/);
rendered.string.should.match(/<meta name="twitter:description" content="blog description" \/>/);
rendered.string.should.match(/<meta name="twitter:description" content="site description" \/>/);
rendered.string.should.match(/<meta name="twitter:url" content="http:\/\/localhost:65530\/post\/" \/>/);
rendered.string.should.match(/<meta name="twitter:image" content="http:\/\/localhost:65530\/content\/images\/test-twitter-image.png" \/>/);
rendered.string.should.match(/<meta name="twitter:creator" content="@testuser" \/>/);
@ -574,7 +574,7 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(re4);
rendered.string.should.match(/"image": "http:\/\/localhost:65530\/content\/images\/test-image.png"/);
rendered.string.should.match(/"keywords": "tag1, tag2, tag3"/);
rendered.string.should.match(/"description": "blog description"/);
rendered.string.should.match(/"description": "site description"/);
rendered.string.should.match(/"@context": "https:\/\/schema.org"/);
rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/);
rendered.string.should.match(/<link rel="alternate" type="application\/rss\+xml" title="Ghost" href="http:\/\/localhost:65530\/rss\/" \/>/);
@ -602,7 +602,7 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/post\/" \/>/);
rendered.string.should.match(/<link rel="amphtml" href="http:\/\/localhost:65530\/post\/amp\/" \/>/);
rendered.string.should.match(/<meta name="description" content="blog description" \/>/);
rendered.string.should.match(/<meta name="description" content="site description" \/>/);
rendered.string.should.match(/<meta property="og:site_name" content="Ghost" \/>/);
rendered.string.should.match(/<meta property="og:type" content="article" \/>/);
rendered.string.should.match(/<meta property="og:title" content="Welcome to Ghost" \/>/);
@ -662,7 +662,7 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/post\/" \/>/);
rendered.string.should.match(/<link rel="amphtml" href="http:\/\/localhost:65530\/post\/amp\/" \/>/);
rendered.string.should.not.match(/<meta name="description" content="blog description" \/>/);
rendered.string.should.not.match(/<meta name="description" content="site description" \/>/);
rendered.string.should.match(/<meta property="og:site_name" content="Ghost" \/>/);
rendered.string.should.match(/<meta property="og:type" content="article" \/>/);
rendered.string.should.match(/<meta property="og:title" content="Welcome to Ghost" \/>/);
@ -711,11 +711,11 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/post\/" \/>/);
rendered.string.should.not.match(/<link rel="amphtml" href="http:\/\/localhost:65530\/post\/amp\/" \/>/);
rendered.string.should.match(/<meta name="description" content="blog description" \/>/);
rendered.string.should.match(/<meta name="description" content="site description" \/>/);
rendered.string.should.match(/<meta property="og:site_name" content="Ghost" \/>/);
rendered.string.should.match(/<meta property="og:type" content="article" \/>/);
rendered.string.should.match(/<meta property="og:title" content="Custom Facebook title" \/>/);
rendered.string.should.match(/<meta property="og:description" content="blog description" \/>/);
rendered.string.should.match(/<meta property="og:description" content="site description" \/>/);
rendered.string.should.match(/<meta property="og:url" content="http:\/\/localhost:65530\/post\/" \/>/);
rendered.string.should.match(/<meta property="og:image" content="http:\/\/localhost:65530\/content\/images\/test-facebook-image.png" \/>/);
rendered.string.should.match(/<meta property="article:tag" content="tag1" \/>/);
@ -723,7 +723,7 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/<meta property="article:tag" content="tag3" \/>/);
rendered.string.should.match(/<meta property="article:author" content="https:\/\/www.facebook.com\/testuser" \/>/);
rendered.string.should.match(/<meta name="twitter:title" content="Custom Twitter title" \/>/);
rendered.string.should.match(/<meta name="twitter:description" content="blog description" \/>/);
rendered.string.should.match(/<meta name="twitter:description" content="site description" \/>/);
rendered.string.should.match(/<meta name="twitter:url" content="http:\/\/localhost:65530\/post\/" \/>/);
rendered.string.should.match(/<meta name="twitter:image" content="http:\/\/localhost:65530\/content\/images\/test-twitter-image.png" \/>/);
rendered.string.should.match(/<meta name="twitter:creator" content="@testuser" \/>/);
@ -743,7 +743,7 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/"url": "http:\/\/localhost:65530\/post\/"/);
rendered.string.should.match(/"image": "http:\/\/localhost:65530\/content\/images\/test-image.png"/);
rendered.string.should.match(/"keywords": "tag1, tag2, tag3"/);
rendered.string.should.match(/"description": "blog description"/);
rendered.string.should.match(/"description": "site description"/);
rendered.string.should.match(/"@context": "https:\/\/schema.org"/);
rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/);
rendered.string.should.match(/<link rel="alternate" type="application\/rss\+xml" title="Ghost" href="http:\/\/localhost:65530\/rss\/" \/>/);
@ -771,11 +771,11 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/post\/" \/>/);
rendered.string.should.match(/<link rel="amphtml" href="http:\/\/localhost:65530\/post\/amp\/" \/>/);
rendered.string.should.match(/<meta name="description" content="blog &quot;test&quot; description" \/>/);
rendered.string.should.match(/<meta name="description" content="site &quot;test&quot; description" \/>/);
rendered.string.should.match(/<meta property="og:site_name" content="Ghost" \/>/);
rendered.string.should.match(/<meta property="og:type" content="article" \/>/);
rendered.string.should.match(/<meta property="og:title" content="Welcome to Ghost &quot;test&quot;" \/>/);
rendered.string.should.match(/<meta property="og:description" content="blog &quot;test&quot; description" \/>/);
rendered.string.should.match(/<meta property="og:description" content="site &quot;test&quot; description" \/>/);
rendered.string.should.match(/<meta property="og:url" content="http:\/\/localhost:65530\/post\/" \/>/);
rendered.string.should.match(/<meta property="og:image" content="http:\/\/localhost:65530\/content\/images\/test-image.png" \/>/);
rendered.string.should.match(/<meta property="article:author" content="https:\/\/www.facebook.com\/testuser" \/>/);
@ -784,7 +784,7 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/<meta property="article:tag" content="tag3" \/>/);
rendered.string.should.match(/<meta name="twitter:card" content="summary_large_image" \/>/);
rendered.string.should.match(/<meta name="twitter:title" content="Welcome to Ghost &quot;test&quot;" \/>/);
rendered.string.should.match(/<meta name="twitter:description" content="blog &quot;test&quot; description" \/>/);
rendered.string.should.match(/<meta name="twitter:description" content="site &quot;test&quot; description" \/>/);
rendered.string.should.match(/<meta name="twitter:url" content="http:\/\/localhost:65530\/post\/" \/>/);
rendered.string.should.match(/<meta name="twitter:creator" content="@testuser" \/>/);
rendered.string.should.match(/<meta name="twitter:image" content="http:\/\/localhost:65530\/content\/images\/test-image.png" \/>/);
@ -805,7 +805,7 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/"@context": "https:\/\/schema.org"/);
rendered.string.should.match(/"image": "http:\/\/localhost:65530\/content\/images\/test-image.png"/);
rendered.string.should.match(/"keywords": "tag1, tag2, tag3"/);
rendered.string.should.match(/"description": "blog &quot;test&quot; description"/);
rendered.string.should.match(/"description": "site &quot;test&quot; description"/);
rendered.string.should.match(/"@context": "https:\/\/schema.org"/);
rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/);
rendered.string.should.match(/<link rel="alternate" type="application\/rss\+xml" title="Ghost" href="http:\/\/localhost:65530\/rss\/" \/>/);
@ -831,18 +831,18 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/post\/" \/>/);
rendered.string.should.match(/<link rel="amphtml" href="http:\/\/localhost:65530\/post\/amp\/" \/>/);
rendered.string.should.match(/<meta name="description" content="blog description" \/>/);
rendered.string.should.match(/<meta name="description" content="site description" \/>/);
rendered.string.should.match(/<meta property="og:site_name" content="Ghost" \/>/);
rendered.string.should.match(/<meta property="og:type" content="article" \/>/);
rendered.string.should.match(/<meta property="og:title" content="Welcome to Ghost" \/>/);
rendered.string.should.match(/<meta property="og:description" content="blog description" \/>/);
rendered.string.should.match(/<meta property="og:description" content="site description" \/>/);
rendered.string.should.match(/<meta property="og:url" content="http:\/\/localhost:65530\/post\/" \/>/);
rendered.string.should.match(/<meta property="og:image" content="http:\/\/localhost:65530\/content\/images\/test-image.png" \/>/);
rendered.string.should.match(/<meta property="article:author" content="https:\/\/www.facebook.com\/testuser" \/>/);
rendered.string.should.not.match(/<meta property="article:tag"/);
rendered.string.should.match(/<meta name="twitter:card" content="summary_large_image" \/>/);
rendered.string.should.match(/<meta name="twitter:title" content="Welcome to Ghost" \/>/);
rendered.string.should.match(/<meta name="twitter:description" content="blog description" \/>/);
rendered.string.should.match(/<meta name="twitter:description" content="site description" \/>/);
rendered.string.should.match(/<meta name="twitter:url" content="http:\/\/localhost:65530\/post\/" \/>/);
rendered.string.should.match(/<meta name="twitter:image" content="http:\/\/localhost:65530\/content\/images\/test-image.png" \/>/);
rendered.string.should.match(/<meta name="twitter:creator" content="@testuser" \/>/);
@ -862,7 +862,7 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/"@context": "https:\/\/schema.org"/);
rendered.string.should.match(/"image": "http:\/\/localhost:65530\/content\/images\/test-image.png"/);
rendered.string.should.not.match(/"keywords":/);
rendered.string.should.match(/"description": "blog description"/);
rendered.string.should.match(/"description": "site description"/);
rendered.string.should.match(/"@context": "https:\/\/schema.org"/);
rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/);
rendered.string.should.match(/<link rel="alternate" type="application\/rss\+xml" title="Ghost" href="http:\/\/localhost:65530\/rss\/" \/>/);
@ -888,11 +888,11 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/post\/" \/>/);
rendered.string.should.match(/<link rel="amphtml" href="http:\/\/localhost:65530\/post\/amp\/" \/>/);
rendered.string.should.match(/<meta name="description" content="blog description" \/>/);
rendered.string.should.match(/<meta name="description" content="site description" \/>/);
rendered.string.should.match(/<meta property="og:site_name" content="Ghost" \/>/);
rendered.string.should.match(/<meta property="og:type" content="article" \/>/);
rendered.string.should.match(/<meta property="og:title" content="Welcome to Ghost" \/>/);
rendered.string.should.match(/<meta property="og:description" content="blog description" \/>/);
rendered.string.should.match(/<meta property="og:description" content="site description" \/>/);
rendered.string.should.match(/<meta property="og:url" content="http:\/\/localhost:65530\/post\/" \/>/);
rendered.string.should.match(/<meta property="article:author" content="https:\/\/www.facebook.com\/testuser" \/>/);
rendered.string.should.not.match(/<meta property="og:image"/);
@ -901,7 +901,7 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/<meta property="article:tag" content="tag3" \/>/);
rendered.string.should.match(/<meta name="twitter:card" content="summary" \/>/);
rendered.string.should.match(/<meta name="twitter:title" content="Welcome to Ghost" \/>/);
rendered.string.should.match(/<meta name="twitter:description" content="blog description" \/>/);
rendered.string.should.match(/<meta name="twitter:description" content="site description" \/>/);
rendered.string.should.match(/<meta name="twitter:url" content="http:\/\/localhost:65530\/post\/" \/>/);
rendered.string.should.match(/<meta name="twitter:creator" content="@testuser" \/>/);
rendered.string.should.not.match(/<meta name="twitter:image"/);
@ -920,7 +920,7 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/"headline": "Welcome to Ghost"/);
rendered.string.should.match(/"url": "http:\/\/localhost:65530\/post\/"/);
rendered.string.should.match(/"keywords": "tag1, tag2, tag3"/);
rendered.string.should.match(/"description": "blog description"/);
rendered.string.should.match(/"description": "site description"/);
rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/);
rendered.string.should.match(/<link rel="alternate" type="application\/rss\+xml" title="Ghost" href="http:\/\/localhost:65530\/rss\/" \/>/);
@ -1294,7 +1294,7 @@ describe('{{ghost_head}} helper', function () {
});
});
describe('with /blog subdirectory', function () {
describe('with /site subdirectory', function () {
let sandbox;
before(function () {
@ -1302,9 +1302,9 @@ describe('{{ghost_head}} helper', function () {
settingsCache.get.withArgs('icon').returns('/content/images/favicon.png');
testUrlUtils.stubUrlUtils({url: 'http://localhost:65530/blog'}, sandbox);
testUrlUtils.stubUrlUtils({url: 'http://localhost:65530/site'}, sandbox);
routing.registry.getRssUrl.returns('http://localhost:65530/blog/rss/');
routing.registry.getRssUrl.returns('http://localhost:65530/site/rss/');
});
after(function () {
@ -1320,10 +1320,10 @@ describe('{{ghost_head}} helper', function () {
}
})).then(function (rendered) {
should.exist(rendered);
rendered.string.should.match(/<link rel="shortcut icon" href="\/blog\/favicon.png" type="image\/png" \/>/);
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/blog\/" \/>/);
rendered.string.should.match(/<link rel="shortcut icon" href="\/site\/favicon.png" type="image\/png" \/>/);
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/site\/" \/>/);
rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/);
rendered.string.should.match(/<link rel="alternate" type="application\/rss\+xml" title="Ghost" href="http:\/\/localhost:65530\/blog\/rss\/" \/>/);
rendered.string.should.match(/<link rel="alternate" type="application\/rss\+xml" title="Ghost" href="http:\/\/localhost:65530\/site\/rss\/" \/>/);
rendered.string.should.not.match(/<meta name="description" /);
done();
@ -1343,7 +1343,7 @@ describe('{{ghost_head}} helper', function () {
referrerPolicy: 'origin'
});
testUrlUtils.stubUrlUtils({url: 'http://localhost:65530/blog'}, sandbox);
testUrlUtils.stubUrlUtils({url: 'http://localhost:65530/site'}, sandbox);
});
after(function () {
@ -1358,7 +1358,7 @@ describe('{{ghost_head}} helper', function () {
}
})).then(function (rendered) {
should.exist(rendered);
rendered.string.should.match(/<link rel="shortcut icon" href="\/blog\/favicon.png" type="image\/png" \/>/);
rendered.string.should.match(/<link rel="shortcut icon" href="\/site\/favicon.png" type="image\/png" \/>/);
rendered.string.should.match(/<meta name="referrer" content="origin" \/>/);
rendered.string.should.not.match(/<meta name="description" /);
@ -1404,7 +1404,7 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.png" type="image\/png" \/>/);
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/post\/" \/>/);
rendered.string.should.match(/<link rel="amphtml" href="http:\/\/localhost:65530\/post\/amp\/" \/>/);
rendered.string.should.match(/<meta name="description" content="blog description" \/>/);
rendered.string.should.match(/<meta name="description" content="site description" \/>/);
rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/);
rendered.string.should.match(/<link rel="alternate" type="application\/rss\+xml" title="Ghost" href="http:\/\/localhost:65530\/rss\/" \/>/);
rendered.string.should.not.match(/<meta property="og/);
@ -1538,84 +1538,6 @@ describe('{{ghost_head}} helper', function () {
});
});
describe('with Ajax Helper', function () {
let sandbox;
before(function () {
sandbox = sinon.createSandbox();
testUrlUtils.stubUrlUtils({url: 'http://localhost:65530/'}, sandbox);
});
after(function () {
sandbox.restore();
});
it('renders script tag with src', function (done) {
helpers.ghost_head(testUtils.createHbsResponse({
renderObject: {
post: false
},
locals: {
context: ['paged', 'index'],
safeVersion: '0.3',
client: testUtils.DataGenerator.forKnex.createClient()
}
})).then(function (rendered) {
should.exist(rendered);
rendered.string.should.match(/<script src="\/public\/ghost-sdk\.js\?v=/);
done();
});
});
it('renders script tag with init correctly', function (done) {
helpers.ghost_head(testUtils.createHbsResponse({
renderObject: {
post: false
},
locals: {
context: ['paged', 'index'],
safeVersion: '0.3',
client: testUtils.DataGenerator.forKnex.createClient()
}
})).then(function (rendered) {
should.exist(rendered);
rendered.string.should.match(/<script src="/);
rendered.string.should.match(/ghost\.init\(\{/);
rendered.string.should.match(/\tclientId: "/);
rendered.string.should.match(/\tclientSecret: "/);
rendered.string.should.match(/}\);\n/);
rendered.string.should.match(/\n<\/script>/);
done();
});
});
it('does not render script tag with for amp context', function (done) {
var renderObject = {
post: posts[1]
};
helpers.ghost_head(testUtils.createHbsResponse({
renderObject: renderObject,
locals: {
context: ['amp', 'post'],
safeVersion: '0.3'
}
})).then(function (rendered) {
should.exist(rendered);
rendered.string.should.not.match(/<script src="/);
rendered.string.should.not.match(/ghost\.init\(\{/);
rendered.string.should.not.match(/\tclientId: "/);
rendered.string.should.not.match(/\tclientSecret: "/);
rendered.string.should.not.match(/}\);\n/);
rendered.string.should.not.match(/\n<\/script>/);
done();
});
});
});
describe('amp is disabled', function () {
before(function () {
settingsCache.get.withArgs('amp').returns(false);

View file

@ -620,15 +620,15 @@ describe('{{#has}} helper', function () {
it('matches on global properties (pass)', function () {
thisCtx = {};
handlebarsOptions.data = {
blog: {
site: {
twitter: 'foo',
facebook: '',
website: null
}
};
// {{#has any="@blog.twitter, @blog.facebook,@blog.website"}}
callHasHelper(thisCtx, {any: '@blog.twitter, @blog.facebook,@blog.website'});
// {{#has any="@site.twitter, @site.facebook,@site.website"}}
callHasHelper(thisCtx, {any: '@site.twitter, @site.facebook,@site.website'});
fn.called.should.be.true();
inverse.called.should.be.false();
@ -637,15 +637,15 @@ describe('{{#has}} helper', function () {
it('matches on global properties (fail)', function () {
thisCtx = {};
handlebarsOptions.data = {
blog: {
site: {
twitter: 'foo',
facebook: '',
website: null
}
};
// {{#has any="@blog.facebook,@blog.website, @blog.foo"}}
callHasHelper(thisCtx, {any: '@blog.facebook,@blog.website, @not.foo'});
// {{#has any="@site.facebook,@site.website, @site.foo"}}
callHasHelper(thisCtx, {any: '@site.facebook,@site.website, @not.foo'});
fn.called.should.be.false();
inverse.called.should.be.true();
@ -744,15 +744,15 @@ describe('{{#has}} helper', function () {
it('matches on global properties (pass)', function () {
thisCtx = {};
handlebarsOptions.data = {
blog: {
site: {
twitter: 'foo',
facebook: 'bar',
website: null
}
};
// {{#has all="@blog.twitter, @blog.facebook"}}
callHasHelper(thisCtx, {all: '@blog.twitter, @blog.facebook'});
// {{#has all="@site.twitter, @site.facebook"}}
callHasHelper(thisCtx, {all: '@site.twitter, @site.facebook'});
fn.called.should.be.true();
inverse.called.should.be.false();
@ -761,15 +761,15 @@ describe('{{#has}} helper', function () {
it('matches on global properties (fail)', function () {
thisCtx = {};
handlebarsOptions.data = {
blog: {
site: {
twitter: 'foo',
facebook: 'bar',
website: null
}
};
// {{#has all="@blog.facebook,@blog.website, @blog.foo"}}
callHasHelper(thisCtx, {all: '@blog.facebook,@blog.website, @not.foo'});
// {{#has all="@site.facebook,@site.website, @site.foo"}}
callHasHelper(thisCtx, {all: '@site.facebook,@site.website, @not.foo'});
fn.called.should.be.false();
inverse.called.should.be.true();

View file

@ -61,7 +61,7 @@ describe('{{meta_title}} helper', function () {
it('returns correct title for a page with meta_title set', function () {
var rendered = helpers.meta_title.call(
{post: {title: 'About Page', meta_title: 'All about my awesomeness', page: true}},
{page: {title: 'About Page', meta_title: 'All about my awesomeness', page: true}},
{data: {root: {context: ['page']}}}
);

View file

@ -30,7 +30,7 @@ describe('{{navigation}} helper', function () {
beforeEach(function () {
optionsData = {
data: {
blog: {
site: {
navigation: []
},
root: {
@ -42,20 +42,20 @@ describe('{{navigation}} helper', function () {
it('should throw errors on invalid data', function () {
// Test 1: navigation = string
optionsData.data.blog.navigation = 'not an object';
optionsData.data.site.navigation = 'not an object';
runHelperThunk(optionsData).should.throwError('navigation data is not an object or is a function');
// Test 2: navigation = function
optionsData.data.blog.navigation = function () {
optionsData.data.site.navigation = function () {
};
runHelperThunk(optionsData).should.throwError('navigation data is not an object or is a function');
// Test 3: invalid label
optionsData.data.blog.navigation = [{label: 1, url: 'bar'}];
optionsData.data.site.navigation = [{label: 1, url: 'bar'}];
runHelperThunk(optionsData).should.throwError('Invalid value, Url and Label must be strings');
// Test 4: invalid url
optionsData.data.blog.navigation = [{label: 'foo', url: 1}];
optionsData.data.site.navigation = [{label: 'foo', url: 1}];
runHelperThunk(optionsData).should.throwError('Invalid value, Url and Label must be strings');
});
@ -71,7 +71,7 @@ describe('{{navigation}} helper', function () {
rendered;
delete optionsData.data.root.relativeUrl;
optionsData.data.blog.navigation = [singleItem];
optionsData.data.site.navigation = [singleItem];
rendered = runHelper(optionsData);
rendered.string.should.containEql('li');
rendered.string.should.containEql('nav-foo');
@ -83,7 +83,7 @@ describe('{{navigation}} helper', function () {
testUrl = 'href="' + configUtils.config.get('url') + '/foo"',
rendered;
optionsData.data.blog.navigation = [singleItem];
optionsData.data.site.navigation = [singleItem];
rendered = runHelper(optionsData);
should.exist(rendered);
@ -99,7 +99,7 @@ describe('{{navigation}} helper', function () {
testUrl2 = 'href="' + configUtils.config.get('url') + '/qux"',
rendered;
optionsData.data.blog.navigation = [firstItem, secondItem];
optionsData.data.site.navigation = [firstItem, secondItem];
rendered = runHelper(optionsData);
should.exist(rendered);
@ -114,7 +114,7 @@ describe('{{navigation}} helper', function () {
secondItem = {label: 'Bar', url: '/qux'},
rendered;
optionsData.data.blog.navigation = [firstItem, secondItem];
optionsData.data.site.navigation = [firstItem, secondItem];
optionsData.data.root.relativeUrl = '/foo';
rendered = runHelper(optionsData);
@ -130,7 +130,7 @@ describe('{{navigation}} helper', function () {
secondItem = {label: 'Bar', url: '/qux'},
rendered;
optionsData.data.blog.navigation = [firstItem, secondItem];
optionsData.data.site.navigation = [firstItem, secondItem];
optionsData.data.root.relativeUrl = '/foo/';
rendered = runHelper(optionsData);
@ -145,7 +145,7 @@ describe('{{navigation}} helper', function () {
var firstItem = {label: 'Foo', url: '/?foo=bar&baz=qux'},
rendered;
optionsData.data.blog.navigation = [firstItem];
optionsData.data.site.navigation = [firstItem];
rendered = runHelper(optionsData);
should.exist(rendered);
@ -158,7 +158,7 @@ describe('{{navigation}} helper', function () {
var firstItem = {label: 'Foo', url: '/?foo=space bar&<script>alert("gotcha")</script>'},
rendered;
optionsData.data.blog.navigation = [firstItem];
optionsData.data.site.navigation = [firstItem];
rendered = runHelper(optionsData);
should.exist(rendered);
@ -171,7 +171,7 @@ describe('{{navigation}} helper', function () {
var firstItem = {label: 'Foo', url: '/?foo=space%20bar'},
rendered;
optionsData.data.blog.navigation = [firstItem];
optionsData.data.site.navigation = [firstItem];
rendered = runHelper(optionsData);
should.exist(rendered);
@ -195,7 +195,7 @@ describe('{{navigation}} helper with custom template', function () {
beforeEach(function () {
optionsData = {
data: {
blog: {
site: {
navigation: [{label: 'Foo', url: '/foo'}]
},
root: {
@ -205,12 +205,12 @@ describe('{{navigation}} helper with custom template', function () {
};
});
it('can render one item and @blog title', function () {
it('can render one item and @site title', function () {
var testUrl = 'href="' + configUtils.config.get('url') + '/foo"',
rendered;
// Set @blog.title
optionsData.data.blog.title = 'Chaos is a ladder.';
// Set @site.title
optionsData.data.site.title = 'Chaos is a ladder.';
rendered = runHelper(optionsData);

View file

@ -129,13 +129,13 @@ describe('{{pagination}} helper with custom template', function () {
});
});
it('can render single page with @blog.title', function () {
it('can render single page with @site.title', function () {
var rendered = helpers.pagination.call({
pagination: {page: 1, prev: null, next: null, limit: 15, total: 8, pages: 1},
tag: {slug: 'slug'}
}, {
data: {
blog: {
site: {
title: 'Chaos is a ladder.'
}
}
@ -154,7 +154,7 @@ describe('{{pagination}} helper with custom template', function () {
}, {
hash: {isHeader: true},
data: {
blog: {}
site: {}
}
});
should.exist(rendered);

View file

@ -1,4 +1,4 @@
{{@blog.title}}
{{@site.title}}
{{#if isHeader}}isHeader is set{{/if}}

View file

@ -1,4 +1,4 @@
{{@blog.title}}
{{@site.title}}
{{#if isHeader}}isHeader is set{{/if}}

View file

@ -4,26 +4,26 @@ var should = require('should'),
helpers = require('../../../frontend/helpers');
describe('{{twitter_url}} helper', function () {
var options = {data: {blog: {}}};
var options = {data: {site: {}}};
beforeEach(function () {
options.data.blog = {twitter: ''};
options.data.site = {twitter: ''};
});
it('should output the twitter url for @blog, if no other twitter username is provided', function () {
options.data.blog = {twitter: '@hey'};
it('should output the twitter url for @site, if no other twitter username is provided', function () {
options.data.site = {twitter: '@hey'};
helpers.twitter_url.call({}, options).should.equal('https://twitter.com/hey');
});
it('should output the twitter url for the local object, if it has one', function () {
options.data.blog = {twitter: '@hey'};
options.data.site = {twitter: '@hey'};
helpers.twitter_url.call({twitter: '@youthere'}, options).should.equal('https://twitter.com/youthere');
});
it('should output the twitter url for the provided username when it is explicitly passed in', function () {
options.data.blog = {twitter: '@hey'};
options.data.site = {twitter: '@hey'};
helpers.twitter_url.call({twitter: '@youthere'}, '@iseeyouoverthere', options)
.should.equal('https://twitter.com/iseeyouoverthere');

View file

@ -121,7 +121,7 @@ describe('Themes middleware', function () {
const templateOptions = hbs.updateTemplateOptions.firstCall.args[0];
const data = templateOptions.data;
data.should.be.an.Object().with.properties('site', 'blog', 'labs', 'config');
data.should.be.an.Object().with.properties('site', 'labs', 'config');
// Check Theme Config
data.config.should.be.an.Object()
@ -134,7 +134,6 @@ describe('Themes middleware', function () {
should.deepEqual(data.labs, fakeLabsData);
should.equal(data.site, fakeSiteData);
should.equal(data.blog, fakeSiteData);
done();
});

View file

@ -1162,7 +1162,7 @@ module.exports = {
locals = options.locals || {},
hbsStructure = {
data: {
blog: {},
site: {},
config: {},
labs: {},
root: {