Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* Detects preprint provider and allows you to inject that
* provider's theme into parts of your application
*
* @class theme
* @extends Service
*/
export default Service.extend({
store: service(),
session: service(),
headTagsService: service('head-tags'),
// If we're using a provider domain
isDomain: window.isProviderDomain,
// The id of the current provider
id: config.PREPRINTS.defaultProvider,
currentLocation: null,
// The provider object
provider: computed('id', function() {
const id = this.get('id');
const store = this.get('store');
// Check if redirect is enabled for the current provider
if (!window.isProviderDomain && this.get('isProvider')) {
store.findRecord('preprint-provider', id)
.then(this._getproviderDomain.bind(this));
}
return store.findRecord('preprint-provider', id);
}),
savePreprint() {
// Creates a preprint.
let model = this.get('model');
let provider = this.get('store').peekRecord('preprint-provider', config.PREPRINTS.provider);
model.set('primaryFile', this.get('selectedFile'));
model.set('node', this.get('node'));
model.set('provider', provider);
model.set('isPublished', true);
this.set('savingPreprint', true);
if (model.get('doi') === '') {
model.set('doi', null);
}
return model.save()
.then(() => this.transitionToRoute('content', model));
},
}
_getPageNotFound() {
const slug = this.get('slug');
this.set('theme.id', config.PREPRINTS.defaultProvider);
if (slug.length === 5) {
this.transitionTo('content', slug);
} else {
this.replaceWith('page-not-found');
}
},
});