mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Added ?force_rerender=true
param to posts edit endpoint
no issue - there are various situations where we adapt/fix/improve our mobiledoc->html output over time but we didn't have a way of updating old content without manually editing the mobiledoc and saving, or running an expensive migration to re-render all old content - this adds a `?force_rerender=true` query param to the `PUT .../admin/posts/:id/` endpoint that allows the `html` field to be re-generated without modifying the `mobiledoc` field contents
This commit is contained in:
parent
5d0d0b397e
commit
008f86fc29
2 changed files with 8 additions and 2 deletions
|
@ -126,6 +126,7 @@ module.exports = {
|
|||
'id',
|
||||
'source',
|
||||
'send_email_when_published',
|
||||
'force_rerender',
|
||||
// NOTE: only for internal context
|
||||
'forUpdate',
|
||||
'transacting'
|
||||
|
|
|
@ -405,8 +405,13 @@ Post = ghostBookshelf.Model.extend({
|
|||
});
|
||||
|
||||
// CASE: mobiledoc has changed, generate html
|
||||
// CASE: ?force_rerender=true passed via Admin API
|
||||
// CASE: html is null, but mobiledoc exists (only important for migrations & importing)
|
||||
if (this.hasChanged('mobiledoc') || (!this.get('html') && (options.migrating || options.importing))) {
|
||||
if (
|
||||
this.hasChanged('mobiledoc')
|
||||
|| options.force_rerender
|
||||
|| (!this.get('html') && (options.migrating || options.importing))
|
||||
) {
|
||||
try {
|
||||
this.set('html', mobiledocLib.mobiledocHtmlRenderer.render(JSON.parse(this.get('mobiledoc'))));
|
||||
} catch (err) {
|
||||
|
@ -781,7 +786,7 @@ Post = ghostBookshelf.Model.extend({
|
|||
findPage: ['status'],
|
||||
findAll: ['columns', 'filter'],
|
||||
destroy: ['destroyAll', 'destroyBy'],
|
||||
edit: ['filter', 'send_email_when_published']
|
||||
edit: ['filter', 'send_email_when_published', 'force_rerender']
|
||||
};
|
||||
|
||||
// The post model additionally supports having a formats option
|
||||
|
|
Loading…
Reference in a new issue