mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 03:12:54 +03:00
f795a907f0
No Issue - Move the ghostPaths from base model to utils - Add initializer that injects it into every route, model and controller - Add a adminUrl and apiUrl helper method
29 lines
694 B
JavaScript
29 lines
694 B
JavaScript
var makeRoute = function (root, args) {
|
|
var parts = Array.prototype.slice.call(args, 0).join('/'),
|
|
route = [root, parts].join('/');
|
|
|
|
if (route.slice(-1) !== '/') {
|
|
route += '/';
|
|
}
|
|
|
|
return route;
|
|
};
|
|
|
|
export default function ghostPaths() {
|
|
var path = window.location.pathname,
|
|
subdir = path.substr(0, path.search('/ghost/'));
|
|
|
|
return {
|
|
subdir: subdir,
|
|
adminRoot: subdir + '/ghost',
|
|
apiRoot: subdir + '/ghost/api/v0.1',
|
|
|
|
adminUrl: function () {
|
|
return makeRoute(this.adminRoot, arguments);
|
|
},
|
|
|
|
apiUrl: function () {
|
|
return makeRoute(this.apiRoot, arguments);
|
|
}
|
|
};
|
|
} |