0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Revert "migrated excerpt fix"

This reverts commit 35ab123499.
This commit is contained in:
Ronald Langeveld 2022-07-06 12:42:22 +02:00
parent f20618679a
commit 9e8bbc028d
5 changed files with 62 additions and 264 deletions

View file

@ -3,60 +3,31 @@ const readingMinutes = require('@tryghost/helpers').utils.readingMinutes;
module.exports.forPost = (frame, model, attrs) => {
const _ = require('lodash');
// This function is split up in 3 conditions for 3 different purposes:
// 1. Gets excerpt from post's plaintext. If custom_excerpt exists, it overrides the excerpt but the key remains excerpt.
if (Object.prototype.hasOwnProperty.call(frame.options, 'columns') || _.includes(frame.options.columns, 'excerpt') || _.includes(frame.options.columns, 'excerpt') && frame.options.formats && frame.options.formats.includes('plaintext')) {
if (_.includes(frame.options.columns, 'excerpt')) {
if (!attrs.custom_excerpt || attrs.custom_excerpt === null) {
let plaintext = model.get('plaintext');
if (plaintext) {
attrs.excerpt = plaintext.substring(0, 500);
} else {
attrs.excerpt = null;
}
if (!frame.options.columns.includes('custom_excerpt')) {
delete attrs.custom_excerpt;
}
if (!Object.prototype.hasOwnProperty.call(frame.options, 'columns') ||
(frame.options.columns.includes('excerpt') && frame.options.formats && frame.options.formats.includes('plaintext'))) {
if (_.isEmpty(attrs.custom_excerpt)) {
let plaintext = model.get('plaintext');
if (plaintext) {
attrs.excerpt = plaintext.substring(0, 500);
} else {
attrs.excerpt = attrs.custom_excerpt;
if (!_.includes(frame.options.columns, 'custom_excerpt')) {
delete attrs.custom_excerpt;
}
attrs.excerpt = null;
}
}
}
// 2. Displays plaintext if requested by user as a field. Also works if used as format.
if (_.includes(frame.options.columns, 'plaintext') || frame.options.formats && frame.options.formats.includes('plaintext')) {
let plaintext = model.get('plaintext');
if (plaintext){
attrs.plaintext = plaintext;
} else {
delete attrs.plaintext;
attrs.excerpt = attrs.custom_excerpt;
}
}
// 3. Displays excerpt if no columns was requested - specifically needed for the Admin Posts API.
if (!Object.prototype.hasOwnProperty.call(frame.options, 'columns')) {
let plaintext = model.get('plaintext');
if (plaintext){
attrs.excerpt = plaintext.substring(0, 500);
} else {
attrs.excerpt = null;
}
}
// reading_time still only works when used along with formats=html.
if (!Object.prototype.hasOwnProperty.call(frame.options, 'columns') ||
(frame.options.columns.includes('reading_time'))) {
(frame.options.columns.includes('reading_time'))) {
if (attrs.html) {
let additionalImages = 0;
if (attrs.feature_image) {
additionalImages += 1;
}
attrs.reading_time = readingMinutes(attrs.html, additionalImages);
}
}
};
};

View file

@ -7,16 +7,6 @@ const messages = {
couldNotUnderstandRequest: 'Could not understand request.'
};
// If user requested an excerpt we need to ensure plaintext and custom_excerpt is also included so we can include it when we query the database.
const requiredForExcerpt = (requestedColumns) => {
if (requestedColumns){
if (requestedColumns.includes('excerpt') && !requestedColumns.includes('plaintext') && !requestedColumns.includes('plaintext') || !requestedColumns) {
requestedColumns.push('plaintext');
requestedColumns.push('custom_excerpt');
}
}
};
/**
* @param {Bookshelf} Bookshelf
*/

View file

@ -23,11 +23,7 @@ Object {
"custom_excerpt": "We've crammed the most important information to help you get started with Ghost into this one post. It's your cheat-sheet to get started, and your shortcut to advanced features.",
"custom_template": null,
"email_subject": null,
"excerpt": "Hey there, welcome to your new home on the web!
Unlike social networks, this one is all yours. Publish your work on a custom domain, invite your audience to subscribe, send them new content by email newsletter, and offer premium subscriptions to generate sustainable recurring revenue to fund your work.
Ghost is an independent, open source app, which means you can customize absolutely everything. Inside the admin area, you'll find straightforward controls for changing themes, colors, navigation",
"excerpt": "We've crammed the most important information to help you get started with Ghost into this one post. It's your cheat-sheet to get started, and your shortcut to advanced features.",
"feature_image": "https://static.ghost.org/v4.0.0/images/welcome-to-ghost.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -60,7 +56,7 @@ exports[`Posts Content API Can filter by published date 2: [headers] 1`] = `
Object {
"access-control-allow-origin": "*",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "4886",
"content-length": "4559",
"content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Accept-Encoding",
@ -91,9 +87,7 @@ Object {
"custom_excerpt": "How to tweak a few settings in Ghost to transform your site from a generic template to a custom brand with style and personality.",
"custom_template": null,
"email_subject": null,
"excerpt": "As discussed in the introduction post, one of the best things about Ghost is just how much you can customize to turn your site into something unique. Everything about your layout and design can be changed, so you're not stuck with yet another clone of a social network profile.
How far you want to go with customization is completely up to you, there's no right or wrong approach! The majority of people use one of Ghost's built-in themes to get started, and then progress to something more bespoke ",
"excerpt": "How to tweak a few settings in Ghost to transform your site from a generic template to a custom brand with style and personality.",
"feature_image": "https://static.ghost.org/v4.0.0/images/publishing-options.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -138,7 +132,7 @@ exports[`Posts Content API Can filter by published date 4: [headers] 1`] = `
Object {
"access-control-allow-origin": "*",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "6223",
"content-length": "5850",
"content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Accept-Encoding",
@ -169,11 +163,7 @@ Object {
"custom_excerpt": "We've crammed the most important information to help you get started with Ghost into this one post. It's your cheat-sheet to get started, and your shortcut to advanced features.",
"custom_template": null,
"email_subject": null,
"excerpt": "Hey there, welcome to your new home on the web!
Unlike social networks, this one is all yours. Publish your work on a custom domain, invite your audience to subscribe, send them new content by email newsletter, and offer premium subscriptions to generate sustainable recurring revenue to fund your work.
Ghost is an independent, open source app, which means you can customize absolutely everything. Inside the admin area, you'll find straightforward controls for changing themes, colors, navigation",
"excerpt": "We've crammed the most important information to help you get started with Ghost into this one post. It's your cheat-sheet to get started, and your shortcut to advanced features.",
"feature_image": "https://static.ghost.org/v4.0.0/images/welcome-to-ghost.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -206,7 +196,7 @@ exports[`Posts Content API Can filter by published date 6: [headers] 1`] = `
Object {
"access-control-allow-origin": "*",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "4887",
"content-length": "4560",
"content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Accept-Encoding",
@ -347,11 +337,7 @@ Definition listConsectetur adipisicing elit, sed do eiusmod tempor incididunt ut
"custom_excerpt": "We've crammed the most important information to help you get started with Ghost into this one post. It's your cheat-sheet to get started, and your shortcut to advanced features.",
"custom_template": null,
"email_subject": null,
"excerpt": "Hey there, welcome to your new home on the web!
Unlike social networks, this one is all yours. Publish your work on a custom domain, invite your audience to subscribe, send them new content by email newsletter, and offer premium subscriptions to generate sustainable recurring revenue to fund your work.
Ghost is an independent, open source app, which means you can customize absolutely everything. Inside the admin area, you'll find straightforward controls for changing themes, colors, navigation",
"excerpt": "We've crammed the most important information to help you get started with Ghost into this one post. It's your cheat-sheet to get started, and your shortcut to advanced features.",
"feature_image": "https://static.ghost.org/v4.0.0/images/welcome-to-ghost.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -418,9 +404,7 @@ Ghost is an independent, open source app, which means you can customize absolute
"custom_excerpt": "How to tweak a few settings in Ghost to transform your site from a generic template to a custom brand with style and personality.",
"custom_template": null,
"email_subject": null,
"excerpt": "As discussed in the introduction post, one of the best things about Ghost is just how much you can customize to turn your site into something unique. Everything about your layout and design can be changed, so you're not stuck with yet another clone of a social network profile.
How far you want to go with customization is completely up to you, there's no right or wrong approach! The majority of people use one of Ghost's built-in themes to get started, and then progress to something more bespoke ",
"excerpt": "How to tweak a few settings in Ghost to transform your site from a generic template to a custom brand with style and personality.",
"feature_image": "https://static.ghost.org/v4.0.0/images/publishing-options.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -499,9 +483,7 @@ How far you want to go with customization is completely up to you, there's no ri
"custom_excerpt": "A full overview of all the features built into the Ghost editor, including powerful workflow automations to speed up your creative process.",
"custom_template": null,
"email_subject": null,
"excerpt": "Ghost comes with a best-in-class editor which does its very best to get out of the way, and let you focus on your content. Don't let its minimal looks fool you, though, beneath the surface lies a powerful editing toolset designed to accommodate the extensive needs of modern creators.
For many, the base canvas of the Ghost editor will feel familiar. You can start writing as you would expect, highlight content to access the toolbar you would expect, and generally use all of the keyboard shortcuts",
"excerpt": "A full overview of all the features built into the Ghost editor, including powerful workflow automations to speed up your creative process.",
"feature_image": "https://static.ghost.org/v4.0.0/images/writing-posts-with-ghost.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -568,9 +550,7 @@ For many, the base canvas of the Ghost editor will feel familiar. You can start
"custom_excerpt": "How Ghost allows you to turn anonymous readers into an audience of active subscribers, so you know what's working and what isn't.",
"custom_template": null,
"email_subject": null,
"excerpt": "What sets Ghost apart from other products is that you can publish content and grow your audience using the same platform. Rather than just endlessly posting and hoping someone is listening, you can track real signups against your work and have them subscribe to be notified of future posts. The feature that makes all this possible is called Portal.
Portal is an embedded interface for your audience to sign up to your site. It works on every Ghost site, with every theme, and for any type of publis",
"excerpt": "How Ghost allows you to turn anonymous readers into an audience of active subscribers, so you know what's working and what isn't.",
"feature_image": "https://static.ghost.org/v4.0.0/images/creating-a-custom-theme.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -721,13 +701,7 @@ Most successful subscription businesses publish a mix of free and paid posts to
"custom_excerpt": "A guide to collaborating with other staff users to publish, and some resources to help you with the next steps of growing your business",
"custom_template": null,
"email_subject": null,
"excerpt": "As you grow, you'll probably want to start inviting team members and collaborators to your site. Ghost has a number of different user roles for your team:
Contributors
This is the base user level in Ghost. Contributors can create and edit their own draft posts, but they are unable to edit drafts of others or publish posts. Contributors are untrusted users with the most basic access to your publication.
Authors
Authors are the 2nd user level in Ghost. Authors can write, edit and publish their o",
"excerpt": "A guide to collaborating with other staff users to publish, and some resources to help you with the next steps of growing your business",
"feature_image": "https://static.ghost.org/v4.0.0/images/admin-settings.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -794,11 +768,7 @@ Authors are the 2nd user level in Ghost. Authors can write, edit and publish the
"custom_excerpt": "Work with all your favorite apps and tools or create your own custom integrations using the Ghost API.",
"custom_template": null,
"email_subject": null,
"excerpt": "It's possible to extend your Ghost site and connect it with hundreds of the most popular apps and tools using integrations.
Whether you need to automatically publish new posts on social media, connect your favorite analytics tool, sync your community or embed forms into your content — our integrations library has got it all covered with hundreds of integration tutorials.
Many integrations are as simple as inserting an embed by pasting a link, or copying a snippet of code directly from an app a",
"excerpt": "Work with all your favorite apps and tools or create your own custom integrations using the Ghost API.",
"feature_image": "https://static.ghost.org/v4.0.0/images/app-integrations.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -1018,9 +988,7 @@ Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac tu
"custom_excerpt": "This is my custom excerpt!",
"custom_template": null,
"email_subject": null,
"excerpt": "HTML Ipsum Presents
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum o",
"excerpt": "This is my custom excerpt!",
"feature_image": "https://example.com/super_photo.jpg",
"feature_image_alt": null,
"feature_image_caption": null,
@ -1068,7 +1036,7 @@ exports[`Posts Content API Can filter posts by authors 2: [headers] 1`] = `
Object {
"access-control-allow-origin": "*",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "57406",
"content-length": "54719",
"content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Accept-Encoding",
@ -1344,9 +1312,7 @@ Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac tu
"custom_excerpt": "This is my custom excerpt!",
"custom_template": null,
"email_subject": null,
"excerpt": "HTML Ipsum Presents
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum o",
"excerpt": "This is my custom excerpt!",
"feature_image": "https://example.com/super_photo.jpg",
"feature_image_alt": null,
"feature_image_caption": null,
@ -1444,7 +1410,7 @@ exports[`Posts Content API Can filter posts by tag 2: [headers] 1`] = `
Object {
"access-control-allow-origin": "*",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "14385",
"content-length": "13909",
"content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Accept-Encoding",
@ -1476,11 +1442,7 @@ Object {
"custom_excerpt": "We've crammed the most important information to help you get started with Ghost into this one post. It's your cheat-sheet to get started, and your shortcut to advanced features.",
"custom_template": null,
"email_subject": null,
"excerpt": "Hey there, welcome to your new home on the web!
Unlike social networks, this one is all yours. Publish your work on a custom domain, invite your audience to subscribe, send them new content by email newsletter, and offer premium subscriptions to generate sustainable recurring revenue to fund your work.
Ghost is an independent, open source app, which means you can customize absolutely everything. Inside the admin area, you'll find straightforward controls for changing themes, colors, navigation",
"excerpt": "We've crammed the most important information to help you get started with Ghost into this one post. It's your cheat-sheet to get started, and your shortcut to advanced features.",
"feature_image": "https://static.ghost.org/v4.0.0/images/welcome-to-ghost.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -1553,9 +1515,7 @@ Ghost is an independent, open source app, which means you can customize absolute
"custom_excerpt": "How to tweak a few settings in Ghost to transform your site from a generic template to a custom brand with style and personality.",
"custom_template": null,
"email_subject": null,
"excerpt": "As discussed in the introduction post, one of the best things about Ghost is just how much you can customize to turn your site into something unique. Everything about your layout and design can be changed, so you're not stuck with yet another clone of a social network profile.
How far you want to go with customization is completely up to you, there's no right or wrong approach! The majority of people use one of Ghost's built-in themes to get started, and then progress to something more bespoke ",
"excerpt": "How to tweak a few settings in Ghost to transform your site from a generic template to a custom brand with style and personality.",
"feature_image": "https://static.ghost.org/v4.0.0/images/publishing-options.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -1640,9 +1600,7 @@ How far you want to go with customization is completely up to you, there's no ri
"custom_excerpt": "A full overview of all the features built into the Ghost editor, including powerful workflow automations to speed up your creative process.",
"custom_template": null,
"email_subject": null,
"excerpt": "Ghost comes with a best-in-class editor which does its very best to get out of the way, and let you focus on your content. Don't let its minimal looks fool you, though, beneath the surface lies a powerful editing toolset designed to accommodate the extensive needs of modern creators.
For many, the base canvas of the Ghost editor will feel familiar. You can start writing as you would expect, highlight content to access the toolbar you would expect, and generally use all of the keyboard shortcuts",
"excerpt": "A full overview of all the features built into the Ghost editor, including powerful workflow automations to speed up your creative process.",
"feature_image": "https://static.ghost.org/v4.0.0/images/writing-posts-with-ghost.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -1715,9 +1673,7 @@ For many, the base canvas of the Ghost editor will feel familiar. You can start
"custom_excerpt": "How Ghost allows you to turn anonymous readers into an audience of active subscribers, so you know what's working and what isn't.",
"custom_template": null,
"email_subject": null,
"excerpt": "What sets Ghost apart from other products is that you can publish content and grow your audience using the same platform. Rather than just endlessly posting and hoping someone is listening, you can track real signups against your work and have them subscribe to be notified of future posts. The feature that makes all this possible is called Portal.
Portal is an embedded interface for your audience to sign up to your site. It works on every Ghost site, with every theme, and for any type of publis",
"excerpt": "How Ghost allows you to turn anonymous readers into an audience of active subscribers, so you know what's working and what isn't.",
"feature_image": "https://static.ghost.org/v4.0.0/images/creating-a-custom-theme.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -1880,13 +1836,7 @@ Most successful subscription businesses publish a mix of free and paid posts to
"custom_excerpt": "A guide to collaborating with other staff users to publish, and some resources to help you with the next steps of growing your business",
"custom_template": null,
"email_subject": null,
"excerpt": "As you grow, you'll probably want to start inviting team members and collaborators to your site. Ghost has a number of different user roles for your team:
Contributors
This is the base user level in Ghost. Contributors can create and edit their own draft posts, but they are unable to edit drafts of others or publish posts. Contributors are untrusted users with the most basic access to your publication.
Authors
Authors are the 2nd user level in Ghost. Authors can write, edit and publish their o",
"excerpt": "A guide to collaborating with other staff users to publish, and some resources to help you with the next steps of growing your business",
"feature_image": "https://static.ghost.org/v4.0.0/images/admin-settings.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -1959,11 +1909,7 @@ Authors are the 2nd user level in Ghost. Authors can write, edit and publish the
"custom_excerpt": "Work with all your favorite apps and tools or create your own custom integrations using the Ghost API.",
"custom_template": null,
"email_subject": null,
"excerpt": "It's possible to extend your Ghost site and connect it with hundreds of the most popular apps and tools using integrations.
Whether you need to automatically publish new posts on social media, connect your favorite analytics tool, sync your community or embed forms into your content — our integrations library has got it all covered with hundreds of integration tutorials.
Many integrations are as simple as inserting an embed by pasting a link, or copying a snippet of code directly from an app a",
"excerpt": "Work with all your favorite apps and tools or create your own custom integrations using the Ghost API.",
"feature_image": "https://static.ghost.org/v4.0.0/images/app-integrations.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -2265,9 +2211,7 @@ Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac tu
"custom_excerpt": "This is my custom excerpt!",
"custom_template": null,
"email_subject": null,
"excerpt": "HTML Ipsum Presents
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum o",
"excerpt": "This is my custom excerpt!",
"feature_image": "https://example.com/super_photo.jpg",
"feature_image_alt": null,
"feature_image_caption": null,
@ -2337,7 +2281,7 @@ exports[`Posts Content API Can include relations 2: [headers] 1`] = `
Object {
"access-control-allow-origin": "*",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "67735",
"content-length": "65048",
"content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Accept-Encoding",
@ -2358,9 +2302,7 @@ Object {
"custom_excerpt": "This is my custom excerpt!",
"custom_template": null,
"email_subject": null,
"excerpt": "HTML Ipsum Presents
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum o",
"excerpt": "This is my custom excerpt!",
"feature_image": "https://example.com/super_photo.jpg",
"feature_image_alt": null,
"feature_image_caption": null,
@ -2393,7 +2335,7 @@ exports[`Posts Content API Can request a single post 2: [headers] 1`] = `
Object {
"access-control-allow-origin": "*",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "2821",
"content-length": "2345",
"content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Accept-Encoding",
@ -2486,11 +2428,7 @@ Object {
"custom_excerpt": "We've crammed the most important information to help you get started with Ghost into this one post. It's your cheat-sheet to get started, and your shortcut to advanced features.",
"custom_template": null,
"email_subject": null,
"excerpt": "Hey there, welcome to your new home on the web!
Unlike social networks, this one is all yours. Publish your work on a custom domain, invite your audience to subscribe, send them new content by email newsletter, and offer premium subscriptions to generate sustainable recurring revenue to fund your work.
Ghost is an independent, open source app, which means you can customize absolutely everything. Inside the admin area, you'll find straightforward controls for changing themes, colors, navigation",
"excerpt": "We've crammed the most important information to help you get started with Ghost into this one post. It's your cheat-sheet to get started, and your shortcut to advanced features.",
"feature_image": "https://static.ghost.org/v4.0.0/images/welcome-to-ghost.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -2525,9 +2463,7 @@ Ghost is an independent, open source app, which means you can customize absolute
"custom_excerpt": "How to tweak a few settings in Ghost to transform your site from a generic template to a custom brand with style and personality.",
"custom_template": null,
"email_subject": null,
"excerpt": "As discussed in the introduction post, one of the best things about Ghost is just how much you can customize to turn your site into something unique. Everything about your layout and design can be changed, so you're not stuck with yet another clone of a social network profile.
How far you want to go with customization is completely up to you, there's no right or wrong approach! The majority of people use one of Ghost's built-in themes to get started, and then progress to something more bespoke ",
"excerpt": "How to tweak a few settings in Ghost to transform your site from a generic template to a custom brand with style and personality.",
"feature_image": "https://static.ghost.org/v4.0.0/images/publishing-options.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -2574,9 +2510,7 @@ How far you want to go with customization is completely up to you, there's no ri
"custom_excerpt": "A full overview of all the features built into the Ghost editor, including powerful workflow automations to speed up your creative process.",
"custom_template": null,
"email_subject": null,
"excerpt": "Ghost comes with a best-in-class editor which does its very best to get out of the way, and let you focus on your content. Don't let its minimal looks fool you, though, beneath the surface lies a powerful editing toolset designed to accommodate the extensive needs of modern creators.
For many, the base canvas of the Ghost editor will feel familiar. You can start writing as you would expect, highlight content to access the toolbar you would expect, and generally use all of the keyboard shortcuts",
"excerpt": "A full overview of all the features built into the Ghost editor, including powerful workflow automations to speed up your creative process.",
"feature_image": "https://static.ghost.org/v4.0.0/images/writing-posts-with-ghost.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -2611,9 +2545,7 @@ For many, the base canvas of the Ghost editor will feel familiar. You can start
"custom_excerpt": "How Ghost allows you to turn anonymous readers into an audience of active subscribers, so you know what's working and what isn't.",
"custom_template": null,
"email_subject": null,
"excerpt": "What sets Ghost apart from other products is that you can publish content and grow your audience using the same platform. Rather than just endlessly posting and hoping someone is listening, you can track real signups against your work and have them subscribe to be notified of future posts. The feature that makes all this possible is called Portal.
Portal is an embedded interface for your audience to sign up to your site. It works on every Ghost site, with every theme, and for any type of publis",
"excerpt": "How Ghost allows you to turn anonymous readers into an audience of active subscribers, so you know what's working and what isn't.",
"feature_image": "https://static.ghost.org/v4.0.0/images/creating-a-custom-theme.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -2700,13 +2632,7 @@ Most successful subscription businesses publish a mix of free and paid posts to
"custom_excerpt": "A guide to collaborating with other staff users to publish, and some resources to help you with the next steps of growing your business",
"custom_template": null,
"email_subject": null,
"excerpt": "As you grow, you'll probably want to start inviting team members and collaborators to your site. Ghost has a number of different user roles for your team:
Contributors
This is the base user level in Ghost. Contributors can create and edit their own draft posts, but they are unable to edit drafts of others or publish posts. Contributors are untrusted users with the most basic access to your publication.
Authors
Authors are the 2nd user level in Ghost. Authors can write, edit and publish their o",
"excerpt": "A guide to collaborating with other staff users to publish, and some resources to help you with the next steps of growing your business",
"feature_image": "https://static.ghost.org/v4.0.0/images/admin-settings.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -2741,11 +2667,7 @@ Authors are the 2nd user level in Ghost. Authors can write, edit and publish the
"custom_excerpt": "Work with all your favorite apps and tools or create your own custom integrations using the Ghost API.",
"custom_template": null,
"email_subject": null,
"excerpt": "It's possible to extend your Ghost site and connect it with hundreds of the most popular apps and tools using integrations.
Whether you need to automatically publish new posts on social media, connect your favorite analytics tool, sync your community or embed forms into your content — our integrations library has got it all covered with hundreds of integration tutorials.
Many integrations are as simple as inserting an embed by pasting a link, or copying a snippet of code directly from an app a",
"excerpt": "Work with all your favorite apps and tools or create your own custom integrations using the Ghost API.",
"feature_image": "https://static.ghost.org/v4.0.0/images/app-integrations.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -2915,9 +2837,7 @@ Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac tu
"custom_excerpt": "This is my custom excerpt!",
"custom_template": null,
"email_subject": null,
"excerpt": "HTML Ipsum Presents
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum o",
"excerpt": "This is my custom excerpt!",
"feature_image": "https://example.com/super_photo.jpg",
"feature_image_alt": null,
"feature_image_caption": null,
@ -2950,7 +2870,7 @@ exports[`Posts Content API Can request posts 2: [headers] 1`] = `
Object {
"access-control-allow-origin": "*",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "48854",
"content-length": "46167",
"content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Accept-Encoding",
@ -2981,11 +2901,7 @@ Object {
"custom_excerpt": "We've crammed the most important information to help you get started with Ghost into this one post. It's your cheat-sheet to get started, and your shortcut to advanced features.",
"custom_template": null,
"email_subject": null,
"excerpt": "Hey there, welcome to your new home on the web!
Unlike social networks, this one is all yours. Publish your work on a custom domain, invite your audience to subscribe, send them new content by email newsletter, and offer premium subscriptions to generate sustainable recurring revenue to fund your work.
Ghost is an independent, open source app, which means you can customize absolutely everything. Inside the admin area, you'll find straightforward controls for changing themes, colors, navigation",
"excerpt": "We've crammed the most important information to help you get started with Ghost into this one post. It's your cheat-sheet to get started, and your shortcut to advanced features.",
"feature_image": "https://static.ghost.org/v4.0.0/images/welcome-to-ghost.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -3020,9 +2936,7 @@ Ghost is an independent, open source app, which means you can customize absolute
"custom_excerpt": "How to tweak a few settings in Ghost to transform your site from a generic template to a custom brand with style and personality.",
"custom_template": null,
"email_subject": null,
"excerpt": "As discussed in the introduction post, one of the best things about Ghost is just how much you can customize to turn your site into something unique. Everything about your layout and design can be changed, so you're not stuck with yet another clone of a social network profile.
How far you want to go with customization is completely up to you, there's no right or wrong approach! The majority of people use one of Ghost's built-in themes to get started, and then progress to something more bespoke ",
"excerpt": "How to tweak a few settings in Ghost to transform your site from a generic template to a custom brand with style and personality.",
"feature_image": "https://static.ghost.org/v4.0.0/images/publishing-options.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -3069,9 +2983,7 @@ How far you want to go with customization is completely up to you, there's no ri
"custom_excerpt": "A full overview of all the features built into the Ghost editor, including powerful workflow automations to speed up your creative process.",
"custom_template": null,
"email_subject": null,
"excerpt": "Ghost comes with a best-in-class editor which does its very best to get out of the way, and let you focus on your content. Don't let its minimal looks fool you, though, beneath the surface lies a powerful editing toolset designed to accommodate the extensive needs of modern creators.
For many, the base canvas of the Ghost editor will feel familiar. You can start writing as you would expect, highlight content to access the toolbar you would expect, and generally use all of the keyboard shortcuts",
"excerpt": "A full overview of all the features built into the Ghost editor, including powerful workflow automations to speed up your creative process.",
"feature_image": "https://static.ghost.org/v4.0.0/images/writing-posts-with-ghost.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -3106,9 +3018,7 @@ For many, the base canvas of the Ghost editor will feel familiar. You can start
"custom_excerpt": "How Ghost allows you to turn anonymous readers into an audience of active subscribers, so you know what's working and what isn't.",
"custom_template": null,
"email_subject": null,
"excerpt": "What sets Ghost apart from other products is that you can publish content and grow your audience using the same platform. Rather than just endlessly posting and hoping someone is listening, you can track real signups against your work and have them subscribe to be notified of future posts. The feature that makes all this possible is called Portal.
Portal is an embedded interface for your audience to sign up to your site. It works on every Ghost site, with every theme, and for any type of publis",
"excerpt": "How Ghost allows you to turn anonymous readers into an audience of active subscribers, so you know what's working and what isn't.",
"feature_image": "https://static.ghost.org/v4.0.0/images/creating-a-custom-theme.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -3195,13 +3105,7 @@ Most successful subscription businesses publish a mix of free and paid posts to
"custom_excerpt": "A guide to collaborating with other staff users to publish, and some resources to help you with the next steps of growing your business",
"custom_template": null,
"email_subject": null,
"excerpt": "As you grow, you'll probably want to start inviting team members and collaborators to your site. Ghost has a number of different user roles for your team:
Contributors
This is the base user level in Ghost. Contributors can create and edit their own draft posts, but they are unable to edit drafts of others or publish posts. Contributors are untrusted users with the most basic access to your publication.
Authors
Authors are the 2nd user level in Ghost. Authors can write, edit and publish their o",
"excerpt": "A guide to collaborating with other staff users to publish, and some resources to help you with the next steps of growing your business",
"feature_image": "https://static.ghost.org/v4.0.0/images/admin-settings.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -3236,11 +3140,7 @@ Authors are the 2nd user level in Ghost. Authors can write, edit and publish the
"custom_excerpt": "Work with all your favorite apps and tools or create your own custom integrations using the Ghost API.",
"custom_template": null,
"email_subject": null,
"excerpt": "It's possible to extend your Ghost site and connect it with hundreds of the most popular apps and tools using integrations.
Whether you need to automatically publish new posts on social media, connect your favorite analytics tool, sync your community or embed forms into your content — our integrations library has got it all covered with hundreds of integration tutorials.
Many integrations are as simple as inserting an embed by pasting a link, or copying a snippet of code directly from an app a",
"excerpt": "Work with all your favorite apps and tools or create your own custom integrations using the Ghost API.",
"feature_image": "https://static.ghost.org/v4.0.0/images/app-integrations.png",
"feature_image_alt": null,
"feature_image_caption": null,
@ -3410,9 +3310,7 @@ Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac tu
"custom_excerpt": "This is my custom excerpt!",
"custom_template": null,
"email_subject": null,
"excerpt": "HTML Ipsum Presents
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum o",
"excerpt": "This is my custom excerpt!",
"feature_image": "https://example.com/super_photo.jpg",
"feature_image_alt": null,
"feature_image_caption": null,
@ -3445,50 +3343,10 @@ exports[`Posts Content API Can request posts from different origin 2: [headers]
Object {
"access-control-allow-origin": "*",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "48854",
"content-length": "46167",
"content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Accept-Encoding",
"x-powered-by": "Express",
}
`;
exports[`Posts Content API Can use post excerpt as field 1: [body] 1`] = `
Object {
"meta": Object {
"pagination": Object {
"limit": 1,
"next": 2,
"page": 1,
"pages": 15,
"prev": null,
"total": 15,
},
},
"posts": Array [
Object {
"excerpt": "",
},
],
}
`;
exports[`Posts Content API Can use post plaintext as field 1: [body] 1`] = `
Object {
"meta": Object {
"pagination": Object {
"limit": 1,
"next": 2,
"page": 1,
"pages": 15,
"prev": null,
"total": 15,
},
},
"posts": Array [
Object {
"plaintext": "",
},
],
}
`;

View file

@ -309,17 +309,4 @@ describe('Posts Content API', function () {
tiersPostData.tiers.length.should.eql(1);
});
it('Can use post excerpt as field', async function () {
await agent
.get(`posts/?fields=excerpt&limit=1`)
.expectStatus(200)
.matchBodySnapshot();
});
it('Can use post plaintext as field', async function () {
await agent
.get(`posts/?fields=plaintext&limit=1`)
.expectStatus(200)
.matchBodySnapshot();
});
});

View file

@ -2,12 +2,9 @@ const should = require('should');
const sinon = require('sinon');
const extraAttrsUtil = require('../../../../../../../../core/server/api/endpoints/utils/serializers/output/utils/extra-attrs');
describe('Unit: canary/utils/serializers/output/utils/extra-attrs', function () {
describe('Unit: endpoints/utils/serializers/output/utils/extra-attrs', function () {
const frame = {
// Question: is it okay to use actual column values here that the forPost function in extra-attrs would expect?
options: {
columns: ['excerpt', 'custom_excerpt', 'plaintext']
}
options: {}
};
let model;
@ -21,7 +18,10 @@ describe('Unit: canary/utils/serializers/output/utils/extra-attrs', function ()
describe('for post', function () {
it('respects custom excerpt', function () {
const attrs = {custom_excerpt: 'custom excerpt'};
extraAttrsUtil.forPost(frame, model, attrs);
model.get.called.should.be.false();
attrs.excerpt.should.eql(attrs.custom_excerpt);
});
@ -36,22 +36,14 @@ describe('Unit: canary/utils/serializers/output/utils/extra-attrs', function ()
it('has excerpt when plaintext is null', function () {
model.get.withArgs('plaintext').returns(null);
const attrs = {};
extraAttrsUtil.forPost(frame, model, attrs);
model.get.called.should.be.true();
attrs.should.have.property('excerpt');
(attrs.excerpt === null).should.be.true();
});
it('has excerpt when no columns are passed', function () {
delete frame.options.columns;
const attrs = {};
extraAttrsUtil.forPost(frame, model, attrs);
model.get.called.should.be.true();
attrs.should.have.property('excerpt');
});
});
});