-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #9060 - Update `gscan` - it now extracts custom templates and exposes them to Ghost - Add `custom_template` field to post schema w/ 1.13 migration - Return `templates` array for the active theme in `/themes/` requests - Users with Author/Editor roles can now request `/themes/` - Front-end will render `custom_template` for posts if it exists, template priority is now: 1. `post/page-{{slug}}.hbs` 2. `{{custom_template}}.hbs` 3. `post/page.hbs`
- Loading branch information
1 parent
7999c38
commit 594b0c2
Showing
17 changed files
with
320 additions
and
52 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
30 changes: 30 additions & 0 deletions
30
core/server/data/migrations/versions/1.13/1-custom-template-post.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,30 @@ | ||
'use strict'; | ||
|
||
const Promise = require('bluebird'), | ||
logging = require('../../../../logging'), | ||
commands = require('../../../schema').commands, | ||
table = 'posts', | ||
column = 'custom_template', | ||
message = 'Adding column: ' + table + '.' + column; | ||
|
||
module.exports = function addCustomTemplateField(options) { | ||
let transacting = options.transacting; | ||
|
||
return transacting.schema.hasTable(table) | ||
.then(function (exists) { | ||
if (!exists) { | ||
return Promise.reject(new Error('Table does not exist!')); | ||
} | ||
|
||
return transacting.schema.hasColumn(table, column); | ||
}) | ||
.then(function (exists) { | ||
if (exists) { | ||
logging.warn(message); | ||
return Promise.resolve(); | ||
} | ||
|
||
logging.info(message); | ||
return commands.addColumn(table, column, transacting); | ||
}); | ||
}; |
39 changes: 39 additions & 0 deletions
39
core/server/data/migrations/versions/1.13/2-theme-permissions.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 @@ | ||
var _ = require('lodash'), | ||
utils = require('../../../schema/fixtures/utils'), | ||
permissions = require('../../../../permissions'), | ||
logging = require('../../../../logging'), | ||
resource = 'theme', | ||
_private = {}; | ||
|
||
_private.getPermissions = function getPermissions() { | ||
return utils.findModelFixtures('Permission', {object_type: resource}); | ||
}; | ||
|
||
_private.getRelations = function getRelations() { | ||
return utils.findPermissionRelationsForObject(resource); | ||
}; | ||
|
||
_private.printResult = function printResult(result, message) { | ||
if (result.done === result.expected) { | ||
logging.info(message); | ||
} else { | ||
logging.warn('(' + result.done + '/' + result.expected + ') ' + message); | ||
} | ||
}; | ||
|
||
module.exports = function addRedirectsPermissions(options) { | ||
var modelToAdd = _private.getPermissions(), | ||
relationToAdd = _private.getRelations(), | ||
localOptions = _.merge({ | ||
context: {internal: true} | ||
}, options); | ||
|
||
return utils.addFixturesForModel(modelToAdd, localOptions).then(function (result) { | ||
_private.printResult(result, 'Adding permissions fixtures for ' + resource + 's'); | ||
return utils.addFixturesForRelation(relationToAdd, localOptions); | ||
}).then(function (result) { | ||
_private.printResult(result, 'Adding permissions_roles fixtures for ' + resource + 's'); | ||
}).then(function () { | ||
return permissions.init(localOptions); | ||
}); | ||
}; |
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
Oops, something went wrong.