mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 01:41:46 +03:00
5c9a824d53
no issue - drops the `var Foo = Ember.Thing.extend({}); export default Foo;` syntax in favour of exporting directly, eg: `export default Ember.Thing.extend({})` - discussion on this change [here](https://github.com/TryGhost/Ghost/pull/5340#issuecomment-105828423) and [here](https://github.com/TryGhost/Ghost/pull/5694#discussion-diff-37511606)
60 lines
1.5 KiB
JavaScript
60 lines
1.5 KiB
JavaScript
var makeRoute = function (root, args) {
|
|
var slashAtStart,
|
|
slashAtEnd,
|
|
parts,
|
|
route;
|
|
|
|
slashAtStart = /^\//;
|
|
slashAtEnd = /\/$/;
|
|
route = root.replace(slashAtEnd, '');
|
|
parts = Array.prototype.slice.call(args, 0);
|
|
|
|
parts.forEach(function (part) {
|
|
if (part) {
|
|
route = [route, part.replace(slashAtStart, '').replace(slashAtEnd, '')].join('/');
|
|
}
|
|
});
|
|
return route += '/';
|
|
};
|
|
|
|
export default function () {
|
|
var path = window.location.pathname,
|
|
subdir = path.substr(0, path.search('/ghost/')),
|
|
adminRoot = subdir + '/ghost',
|
|
apiRoot = subdir + '/ghost/api/v0.1';
|
|
|
|
function assetUrl(src) {
|
|
return subdir + src;
|
|
}
|
|
|
|
return {
|
|
subdir: subdir,
|
|
blogRoot: subdir + '/',
|
|
adminRoot: adminRoot,
|
|
apiRoot: apiRoot,
|
|
|
|
url: {
|
|
admin: function () {
|
|
return makeRoute(adminRoot, arguments);
|
|
},
|
|
|
|
api: function () {
|
|
return makeRoute(apiRoot, arguments);
|
|
},
|
|
|
|
join: function () {
|
|
if (arguments.length > 1) {
|
|
return makeRoute(arguments[0], Array.prototype.slice.call(arguments, 1));
|
|
} else if (arguments.length === 1) {
|
|
var arg = arguments[0];
|
|
return arg.slice(-1) === '/' ? arg : arg + '/';
|
|
}
|
|
return '/';
|
|
},
|
|
|
|
asset: assetUrl
|
|
},
|
|
count: 'https://ghost.org/count/'
|
|
};
|
|
}
|