From b447a268328184494b542f48602af559e18d3b5d Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Wed, 5 Jun 2024 14:47:33 +0100 Subject: [PATCH] Added custom excerpt to post revisions (#20323) closes https://linear.app/tryghost/issue/MOM-170 When the subtitle field is included in the editor it creates a disconnect with post revisions if the underlying custom excerpt data is not included so we'd like to both preview and restore the subtitle when the in-editor subtitle field is enabled. - added `post_revisions.custom_excerpt` column to schema - added migration to add `post_revisions.custom_excerpt` to existing databases - added migration to populate `post_revisions.custom_excerpt` with the current `post.custom_excerpt` value from the associated record - ensures no data is inadvertently lost when restoring an old version - using current data matches what would have happened previously where custom_excerpt was never overwritten when restoring an old version - updated post revisions handling to accept the `custom_excerpt` field - updated Admin's revision preview and restoration to display and set the `custom_excerpt` field --- .../app/components/modal-post-history.hbs | 10 ++- .../app/components/modal-post-history.js | 1 + .../app/components/modals/restore-revision.js | 5 ++ ghost/admin/app/models/post-revision.js | 1 + ghost/admin/app/serializers/post-revision.js | 11 +-- .../acceptance/editor/post-revisions-test.js | 79 +++++++++++++++++-- ...37-add-custom-excerpt-to-post-revisions.js | 7 ++ ...-populate-post-revisions-custom-excerpt.js | 32 ++++++++ ghost/core/core/server/data/schema/schema.js | 3 +- ghost/core/core/server/models/post.js | 1 + .../unit/server/data/schema/integrity.test.js | 2 +- ghost/post-revisions/src/PostRevisions.ts | 6 +- .../post-revisions/test/PostRevisions.test.ts | 22 ++++++ 13 files changed, 160 insertions(+), 20 deletions(-) create mode 100644 ghost/core/core/server/data/migrations/versions/5.84/2024-06-04-11-10-37-add-custom-excerpt-to-post-revisions.js create mode 100644 ghost/core/core/server/data/migrations/versions/5.84/2024-06-05-08-42-34-populate-post-revisions-custom-excerpt.js diff --git a/ghost/admin/app/components/modal-post-history.hbs b/ghost/admin/app/components/modal-post-history.hbs index cdfca99eb7..941b81b9bc 100644 --- a/ghost/admin/app/components/modal-post-history.hbs +++ b/ghost/admin/app/components/modal-post-history.hbs @@ -20,7 +20,15 @@ {{/if}} -
{{this.currentTitle}}
+
+ {{this.currentTitle}} +
+ {{#if (feature "editorSubtitle")}} +
+ {{this.selectedRevision.custom_excerpt}} +
+
+ {{/if}}