forked from TryGhost/Ghost
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Canonical URL support to posts&pages in Admin & Content API v2 (T…
…ryGhost#10594) refs TryGhost#10593 - Added `canonical_url` field to post&pages resources in Admin & Content APIs - Support for canonical URL on metadata layer (used in {{ghost_head}} helper) - Made sure the new field is not accessible from API v0.1 - Added handling same domain relative and absolute URLs
- Loading branch information
Showing
15 changed files
with
167 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
core/server/data/migrations/versions/2.17/2-posts-add-canonical-url.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const Promise = require('bluebird'), | ||
common = require('../../../../lib/common'), | ||
commands = require('../../../schema').commands, | ||
table = 'posts', | ||
columns = ['canonical_url'], | ||
_private = {}; | ||
|
||
_private.handle = function handle(options) { | ||
let type = options.type, | ||
isAdding = type === 'Adding', | ||
operation = isAdding ? commands.addColumn : commands.dropColumn; | ||
|
||
return function (options) { | ||
let connection = options.connection; | ||
|
||
return connection.schema.hasTable(table) | ||
.then(function (exists) { | ||
if (!exists) { | ||
return Promise.reject(new Error('Table does not exist!')); | ||
} | ||
|
||
return Promise.each(columns, function (column) { | ||
return connection.schema.hasColumn(table, column) | ||
.then(function (exists) { | ||
if (exists && isAdding || !exists && !isAdding) { | ||
common.logging.warn(`${type} column ${table}.${column}`); | ||
return Promise.resolve(); | ||
} | ||
|
||
common.logging.info(`${type} column ${table}.${column}`); | ||
return operation(table, column, connection); | ||
}); | ||
}); | ||
}); | ||
}; | ||
}; | ||
|
||
module.exports.up = _private.handle({type: 'Adding'}); | ||
module.exports.down = _private.handle({type: 'Dropping'}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters