Skip to content

Commit

Permalink
Merge branch 'hotfix/0.107.5' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
icereval committed Apr 27, 2017
2 parents 826da89 + f646063 commit 3d31e4b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
8 changes: 0 additions & 8 deletions app/controllers/content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import loadAll from 'ember-osf/utils/load-relationship';
import config from 'ember-get-config';
import Analytics from '../../mixins/analytics';
import permissions from 'ember-osf/const/permissions';
import fileDownloadPath from '../../utils/file-download-path';

/**
* Takes an object with query parameter name as the key and value, or [value, maxLength] as the values.
Expand Down Expand Up @@ -143,13 +142,6 @@ export default Ember.Controller.extend(Analytics, {
.replace(/({{copyrightHolders}})/g, copyright_holders.join(', '));
}),

fileDownloadURL: Ember.computed('model.primaryFile', 'node', function() {
return DS.PromiseObject.create({
promise: this.get('model.primaryFile')
.then(file => fileDownloadPath(file, this.get('node')))
});
}),

hasShortenedDescription: Ember.computed('node.description', function() {
const nodeDescription = this.get('node.description');

Expand Down
46 changes: 27 additions & 19 deletions app/routes/content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ import getRedirectUrl from '../../utils/get-redirect-url';

const {
PREPRINTS: {providers},
OSF: {renderUrl}
} = config;

const exportUrl = renderUrl.replace(/render$/, 'export');

// Error handling for API
const handlers = new Map([
// format: ['Message detail', 'page']
Expand All @@ -37,20 +34,21 @@ export default Ember.Route.extend(Analytics, ResetScrollMixin, SetupSubmitContro
headTagsService: Ember.inject.service('head-tags'),
currentUser: Ember.inject.service('currentUser'),

setupController(controller, model) {
controller.set('activeFile', model.get('primaryFile'));
controller.set('node', this.get('node'));
Ember.run.scheduleOnce('afterRender', this, function() {
MathJax.Hub.Queue(['Typeset', MathJax.Hub, [Ember.$('.abstract')[0], Ember.$('#preprintTitle')[0]]]); // jshint ignore:line
});

return this._super(...arguments);
},

afterModel(preprint) {
const {location: {origin}} = window;
let contributors = Ember.A();

const downloadUrl = [
origin,
this.get('theme.isSubRoute') ? `preprints/${this.get('theme.id')}` : null,
preprint.get('id'),
'download'
]
.filter(part => !!part)
.join('/');

this.set('fileDownloadURL', downloadUrl);

return preprint.get('provider')
.then(provider => {
const providerId = provider.get('id');
Expand Down Expand Up @@ -107,11 +105,10 @@ export default Ember.Route.extend(Analytics, ResetScrollMixin, SetupSubmitContro
provider,
node,
preprint.get('license'),
preprint.get('primaryFile'),
loadAll(node, 'contributors', contributors)
]);
})
.then(([provider, node, license, primaryFile]) => {
.then(([provider, node, license]) => {
const title = node.get('title');
const description = node.get('description');
const doi = preprint.get('doi');
Expand Down Expand Up @@ -203,10 +200,7 @@ export default Ember.Route.extend(Analytics, ResetScrollMixin, SetupSubmitContro
['dc.license', license ? license.get('name') : 'No license']
);

highwirePress.push([
'citation_pdf_url',
`${exportUrl}?format=pdf&url=${encodeURIComponent(`${primaryFile.get('links').download}?direct`)}`
]);
highwirePress.push(['citation_pdf_url', `${downloadUrl}?format=pdf`]);

const openGraphTags = openGraph
.map(([property, content]) => ({
Expand Down Expand Up @@ -242,6 +236,20 @@ export default Ember.Route.extend(Analytics, ResetScrollMixin, SetupSubmitContro
});
},

setupController(controller, model) {
controller.setProperties({
activeFile: model.get('primaryFile'),
node: this.get('node'),
fileDownloadURL: this.get('fileDownloadURL'),
});

Ember.run.scheduleOnce('afterRender', this, function() {
MathJax.Hub.Queue(['Typeset', MathJax.Hub, [Ember.$('.abstract')[0], Ember.$('#preprintTitle')[0]]]); // jshint ignore:line
});

return this._super(...arguments);
},

actions: {
error(error) {
// Handle API Errors
Expand Down

0 comments on commit 3d31e4b

Please sign in to comment.