2014-03-22 21:31:45 -05:00
|
|
|
|
|
|
|
function ghostPaths() {
|
|
|
|
var path = window.location.pathname,
|
|
|
|
subdir = path.substr(0, path.search('/ghost/'));
|
|
|
|
|
|
|
|
return {
|
|
|
|
subdir: subdir,
|
2014-04-07 17:01:46 -05:00
|
|
|
adminRoot: subdir + '/ghost',
|
2014-03-22 21:31:45 -05:00
|
|
|
apiRoot: subdir + '/ghost/api/v0.1'
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
var BaseModel = Ember.Object.extend({
|
2014-03-20 21:55:32 -05:00
|
|
|
|
|
|
|
fetch: function () {
|
|
|
|
return ic.ajax.request(this.url, {
|
|
|
|
type: 'GET'
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
save: function () {
|
|
|
|
return ic.ajax.request(this.url, {
|
|
|
|
type: 'PUT',
|
|
|
|
dataType: 'json',
|
|
|
|
// @TODO: This is passing _oldWillDestory and _willDestroy and should not.
|
|
|
|
data: JSON.stringify(this.getProperties(Ember.keys(this)))
|
|
|
|
});
|
|
|
|
}
|
2014-03-22 21:31:45 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
BaseModel.apiRoot = ghostPaths().apiRoot;
|
|
|
|
BaseModel.subdir = ghostPaths().subdir;
|
2014-04-07 17:01:46 -05:00
|
|
|
BaseModel.adminRoot = ghostPaths().adminRoot;
|
2014-03-22 21:31:45 -05:00
|
|
|
|
|
|
|
export default BaseModel;
|