2014-05-15 05:56:43 +04:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2014-06-09 15:02:51 +04:00
|
|
|
function ghostPaths() {
|
2014-05-15 05:56:43 +04:00
|
|
|
var path = window.location.pathname,
|
2014-07-13 08:01:26 +04:00
|
|
|
subdir = path.substr(0, path.search('/ghost/')),
|
|
|
|
adminRoot = subdir + '/ghost',
|
|
|
|
apiRoot = subdir + '/ghost/api/v0.1';
|
|
|
|
|
|
|
|
function assetUrl(src) {
|
|
|
|
return subdir + src;
|
|
|
|
}
|
2014-05-15 05:56:43 +04:00
|
|
|
|
|
|
|
return {
|
|
|
|
subdir: subdir,
|
2014-06-24 03:24:13 +04:00
|
|
|
blogRoot: subdir + '/',
|
2014-07-13 08:01:26 +04:00
|
|
|
adminRoot: adminRoot,
|
|
|
|
apiRoot: apiRoot,
|
|
|
|
|
|
|
|
url: {
|
|
|
|
admin: function () {
|
|
|
|
return makeRoute(adminRoot, arguments);
|
|
|
|
},
|
|
|
|
|
|
|
|
api: function () {
|
|
|
|
return makeRoute(apiRoot, arguments);
|
|
|
|
},
|
|
|
|
|
|
|
|
asset: assetUrl
|
2014-05-15 05:56:43 +04:00
|
|
|
}
|
|
|
|
};
|
2014-06-09 15:02:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
export default ghostPaths;
|