mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 11:34:24 +03:00
af6137248d
fixes #1765 fixes #1811 issue #1833 New UrlFor functions - moved body of url helper to config.path.urlFor, which can generate a URL for various scenarios - urlFor can take a string (name) or object (relativeUrl: '/') as the first argument - this is the first step towards issue #1833 - also added config.path.urlForPost which is async and handles getting permalink setting - frontend controller, ghost_head helper, cache invalidation all now use urlFor or urlForPost all urls should be correct and consistent URL Consistency Improvements - refactored invalidateCache into cacheInvalidationHeader which returns a promise so that url can be generated properly by urlForPost - moved isPost from models to schema, and refactored schema to have a tables object - deleted posts now return the whole object, not just id and slug, ensuring cache invalidation header can be set on delete - frontend controller rss and archive page redirects work properly with subdirectory - removes {{url}} helper from admin and client, and replaced with adminUrl helper which also uses urlFor - in res.locals ghostRoot becomes relativeUrl, and path is removed
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
var migrations = require('../data/migration'),
|
|
_ = require('underscore');
|
|
|
|
module.exports = {
|
|
Post: require('./post').Post,
|
|
User: require('./user').User,
|
|
Role: require('./role').Role,
|
|
Permission: require('./permission').Permission,
|
|
Settings: require('./settings').Settings,
|
|
Tag: require('./tag').Tag,
|
|
Base: require('./base'),
|
|
Session: require('./session').Session,
|
|
|
|
init: function () {
|
|
return migrations.init();
|
|
},
|
|
reset: function () {
|
|
return migrations.reset().then(function () {
|
|
return migrations.init();
|
|
});
|
|
},
|
|
// ### deleteAllContent
|
|
// Delete all content from the database (posts, tags, tags_posts)
|
|
deleteAllContent: function () {
|
|
var self = this;
|
|
|
|
return self.Post.browse().then(function (posts) {
|
|
_.each(posts.toJSON(), function (post) {
|
|
self.Post.destroy(post.id);
|
|
});
|
|
}).then(function () {
|
|
self.Tag.browse().then(function (tags) {
|
|
_.each(tags.toJSON(), function (tag) {
|
|
self.Tag.destroy(tag.id);
|
|
});
|
|
});
|
|
});
|
|
}
|
|
};
|