Skip to content

Commit

Permalink
Merge branch 'release/0.109.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
brianjgeiger committed Jun 26, 2017
2 parents 42f304c + d06335e commit 5e97fab
Show file tree
Hide file tree
Showing 119 changed files with 2,196 additions and 1,943 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "public/assets/osf-assets"]
path = public/assets/osf-assets
url = https://github.com/CenterForOpenScience/osf-assets.git
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
language: node_js

sudo: false
sudo: required
dist: trusty
addons:
chrome: stable

env:
global:
Expand Down
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,31 @@ ENV GIT_COMMIT ${GIT_COMMIT}

ARG APP_ENV=production
ENV APP_ENV ${APP_ENV}

ARG BACKEND=local
ENV BACKEND ${BACKEND}

ARG OSF_URL=
ENV OSF_URL ${OSF_URL}
ARG OSF_API_URL=
ENV OSF_API_URL ${OSF_API_URL}
ARG OSF_RENDER_URL=
ENV OSF_RENDER_URL ${OSF_RENDER_URL}
ARG OSF_FILE_URL=
ENV OSF_FILE_URL ${OSF_FILE_URL}
ARG OSF_HELP_URL=
ENV OSF_HELP_URL ${OSF_HELP_URL}
ARG OSF_COOKIE_LOGIN_URL=
ENV OSF_COOKIE_LOGIN_URL ${OSF_COOKIE_LOGIN_URL}
ARG OSF_OAUTH_URL=
ENV OSF_OAUTH_URL ${OSF_OAUTH_URL}
ARG SHARE_BASE_URL=
ENV SHARE_BASE_URL ${SHARE_BASE_URL}
ARG SHARE_API_URL=
ENV SHARE_API_URL ${SHARE_API_URL}
ARG SHARE_SEARCH_URL=
ENV SHARE_SEARCH_URL ${SHARE_SEARCH_URL}

RUN ./node_modules/ember-cli/bin/ember build --env ${APP_ENV}

CMD ["yarn", "test"]
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,23 @@ You will need the following things properly installed on your computer.
## Installation

* `git clone` this repository
* To pull in local preprint provider assets as well, use `git clone --recursive` instead (assuming you are using git >= 1.6.5).
* `yarn install --pure-lockfile`
* `bower install`

## Preprint Provider Assets

If you will be using local preprint provider assets (rather than the CDN):

1. If you did not clone the repository using --recursive, run: `git submodule update --init --recursive`
2. Set the PROVIDER_ASSETS_URL environment variable to 'local'

### Updating Assets

* To refresh your local assets, run: `git submodule update`
* To update the assets submodule to the latest assets, run: `npm run update-assets`
* To update to the latest assets and create a hotfix, run: `npm run updates-assets-hotfix`

## Running / Development
For local development, this is designed to run alongside (and from within) the flask application for osf.io.

Expand All @@ -36,8 +50,9 @@ to your `website/settings/local.py` file. Uncomment `'/preprints/': 'http://loca
4. Visit your app at http://localhost:5000/preprints/

### Provider Domains
1. Run `sudo ./scripts/add-domains.js`. This will add the domains to your `/etc/hosts`.
2. Visit your app at one of the provider domains with `https://local.<domain>:4200` (e.g. `http://local.socarxiv.org:4200`)
1. Start the API server
1. Run `sudo ./scripts/add-domains.js`. This will add the domains to your `/etc/hosts`. Use `--dry` for a dry run.
1. Visit your app at one of the provider domains with `https://local.<domain>:4200` (e.g. `http://local.socarxiv.org:4200`)

If you encounter problems, make sure that your version of ember-osf is up to date. If login fails, try logging in from
any other OSF page, then returning to the preprints app.
Expand Down
37 changes: 37 additions & 0 deletions app/components/additional-provider-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import Ember from 'ember';
import Analytics from 'ember-osf/mixins/analytics';
/**
* @module ember-preprints
* @submodule components
*/

/**
* Displays additional SHARE sources for preprints index page
*
* Sample usage:
* ```handlebars
* {{additional-provider-list
* additionalProviders=additionalProviders
* }}
* ```
* @class additional-provider-list
*/
export default Ember.Component.extend(Analytics, {
theme: Ember.inject.service(),
sortedList: Ember.computed('additionalProviders', function() {
if (!this.get('additionalProviders')) {
return;
}
const sortedList = this.get('additionalProviders').sort();
const pairedList = [];
for (let i = 0; i < sortedList.get('length'); i += 2) {
let pair = [];
pair.pushObject(sortedList.objectAt(i));
if (sortedList.objectAt(i + 1)) {
pair.pushObject(sortedList.objectAt(i + 1));
}
pairedList.pushObject(pair);
}
return pairedList;
})
});
19 changes: 13 additions & 6 deletions app/components/provider-carousel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Ember from 'ember';
import Analytics from 'ember-osf/mixins/analytics';

/**
* @module ember-preprints
* @submodule components
Expand All @@ -25,16 +24,25 @@ export default Ember.Component.extend(Analytics, {
providers: Ember.A(), // Pass in preprint providers
itemsPerSlide: 5, // Default
lightLogo: true, // Light logos by default, for Index page.
numProviders: Ember.computed('providers', function() {
return this.get('providers').length;
editedProviders: Ember.computed('providers', function() {
let newProviders = Ember.A()
for (const provider of this.get('providers')) {
if (provider && provider.get('id')!== 'asu') {
newProviders.pushObject(provider)
}
}
return newProviders;
}),
numProviders: Ember.computed('editedProviders', function() {
return this.get('editedProviders').length;
}),
numSlides: Ember.computed('numProviders', 'itemsPerSlide', function() {
return Math.ceil(this.get('numProviders') / this.get('itemsPerSlide'));
}),
slides: Ember.computed('numSlides', 'providers', 'itemsPerSlide', function() {
slides: Ember.computed('numSlides', 'editedProviders', 'itemsPerSlide', function() {
const numSlides = this.get('numSlides');
const itemsPerSlide = this.get('itemsPerSlide');
return new Array(numSlides).fill().map((_, i) => this.get('providers').slice(i * itemsPerSlide, i * itemsPerSlide + itemsPerSlide));
return new Array(numSlides).fill().map((_, i) => this.get('editedProviders').slice(i * itemsPerSlide, i * itemsPerSlide + itemsPerSlide));
}),
columnOffset: Ember.computed('numProviders', 'itemsPerSlide', function() {
// If only one slide of providers, center the provider logos by adding a column offset.
Expand Down Expand Up @@ -86,4 +94,3 @@ export default Ember.Component.extend(Analytics, {
}
}
});

1 change: 1 addition & 0 deletions app/components/search-preprints.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Ember from 'ember';
*/
export default Ember.Component.extend({
metrics: Ember.inject.service(),
theme: Ember.inject.service(),
actions: {
search() {
let query = Ember.$.trim(this.$('#searchBox').val());
Expand Down
22 changes: 22 additions & 0 deletions app/components/supplementary-file-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,28 @@ export default Ember.Component.extend(Analytics, {
this.set('indexes', this.get('files').map(each => each.id));
});
}.observes('preprint'),

selectedFileChanged: Ember.observer('selectedFile', function() {
const eventData = {
file_views: {
preprint: {
type: 'preprint',
id: this.get('preprint.id')
},
file: {
id: this.get('selectedFile.id'),
primaryFile: this.get('preprint.primaryFile.id') === this.get('selectedFile.id'),
version: this.get('selectedFile.currentVersion')
}
}
};
Ember.get(this, 'metrics').invoke('trackSpecificCollection', 'Keen', {
collection: 'preprint-file-views',
eventData: eventData,
node: this.get('node'),
});
}),

_chosenFile: Ember.observer('chosenFile', 'indexes', function() {
let fid = this.get('chosenFile');
let index = this.get('indexes').indexOf(fid);
Expand Down
53 changes: 53 additions & 0 deletions app/controllers/content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ function queryStringify(queryParams) {
export default Ember.Controller.extend(Analytics, {
theme: Ember.inject.service(),
fullScreenMFR: false,
currentUser: Ember.inject.service(),
expandedAuthors: true,
showLicenseText: false,
expandedAbstract: navigator.userAgent.includes('Prerender'),
queryParams: {
Expand Down Expand Up @@ -207,6 +209,57 @@ export default Ember.Controller.extend(Analytics, {

window.open(href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=600,height=400');
return false;
},
// Sends Event to GA/Keen as normal. Sends second event to Keen under "non-contributor-preprint-downloads" collection
// to track non contributor preprint downloads specifically.
dualTrackNonContributors(category, label, url, primary) {
this.send('click', category, label, url); // Sends event to both Google Analytics and Keen.
const authors = this.get('authors');
let userIsContrib = false;

const eventData = {
download_info: {
preprint: {
type: 'preprint',
id: this.get('model.id')
},
file: {
id: primary ? this.get('model.primaryFile.id') : this.get('activeFile.id'),
primaryFile: primary,
version: primary ? this.get('model.primaryFile.currentVersion') : this.get('activeFile.currentVersion')
}
},
interaction: {
category: category,
action: 'click',
label: `${label} as Non-Contributor`,
url: url
}
};

const keenPayload = {
collection: 'non-contributor-preprint-downloads',
eventData: eventData,
node: this.get('node'),
};

this.get('currentUser').load()
.then(user => {
if (user) {
const userId = user.id;
authors.forEach((author) => {
if (author.get('userId') === userId) {
userIsContrib = true;
}
});
}
if (!userIsContrib) {
Ember.get(this, 'metrics').invoke('trackSpecificCollection', 'Keen', keenPayload); // Sends event to Keen if logged-in user is not a contributor
}
})
.catch(() => {
Ember.get(this, 'metrics').invoke('trackSpecificCollection', 'Keen', keenPayload); // Sends event to Keen for non-authenticated user
});
}
},
});
62 changes: 50 additions & 12 deletions app/controllers/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,34 @@ export default Ember.Controller.extend(Analytics, {
i18n: Ember.inject.service(),
theme: Ember.inject.service(),
activeFilters: { providers: [], subjects: [] },
additionalProviders: Ember.computed('themeProvider', function() { // Do additionalProviders exist?
// for now, using this property to alter many pieces of the landing/discover page
return (this.get('themeProvider.additionalProviders') || []).length > 1;
}),
consumingService: 'preprints', // Consuming service - preprints here
detailRoute: 'content', // Name of detail route for this application
discoverHeader: Ember.computed('i18n', function() { // Header for preprints discover page
return this.get('i18n').t('discover.search.heading');
discoverHeader: Ember.computed('i18n', 'additionalProviders', function() { // Header for preprints discover page
// If additionalProviders, use more generic Repository Search page title
return this.get('additionalProviders') ? this.get('i18n').t('discover.search.heading_repository_search') : this.get('i18n').t('discover.search.heading');
}),
end: '', // End query param. Must be passed to component, so can be reflected in the URL
externalProviders: Ember.computed('model', function() {
return this.get('model').filter(item => item.id !== 'osf');
}),
facets: Ember.computed('i18n.locale', function() { //List of facets available for preprints
return [
{ key: 'sources', title: `${this.get('i18n').t('discover.main.providers')}`, component: 'search-facet-provider' },
{ key: 'subjects', title: `${this.get('i18n').t('discover.main.subject')}`, component: 'search-facet-taxonomy' }]
facets: Ember.computed('i18n.locale', 'additionalProviders', function() { // List of facets available for preprints
if (this.get('additionalProviders')) { // if additionalProviders exist, use subset of SHARE facets
return [
{ key: 'sources', title: this.get('i18n').t('discover.main.source'), component: 'search-facet-source'},
{ key: 'date', title: this.get('i18n').t('discover.main.date'), component: 'search-facet-daterange'},
{ key: 'type', title: this.get('i18n').t('discover.main.type'), component: 'search-facet-worktype'},
{ key: 'tags', title: this.get('i18n').t('discover.main.tag'), component: 'search-facet-typeahead'},
];
} else { // Regular preprints and branded preprints get provider and taxonomy facets
return [
{ key: 'sources', title: `${this.get('i18n').t('discover.main.providers')}`, component: 'search-facet-provider' },
{ key: 'subjects', title: `${this.get('i18n').t('discover.main.subject')}`, component: 'search-facet-taxonomy' }
]
}
}),
filterMap: { // Map active filters to facet names expected by SHARE
providers: 'sources',
Expand All @@ -38,15 +57,21 @@ export default Ember.Controller.extend(Analytics, {
OSF: 'OSF Preprints',
'Research Papers in Economics': 'RePEc'
},
lockedParams: {types: 'preprint'}, // Parameter names which cannot be changed
lockedParams: Ember.computed('additionalProviders', function() { // Query parameters that cannot be changed.
// if additionalProviders, open up search results to all types of results instead of just preprints.
return this.get('additionalProviders') ? {} : {types: 'preprint'};
}),
page: 1, // Page query param. Must be passed to component, so can be reflected in URL
provider: '', // Provider query param. Must be passed to component, so can be reflected in URL
q: '', // q query param. Must be passed to component, so can be reflected in URL
queryParams: ['page', 'q', 'subject', 'provider'], // Pass in the list of queryParams for this component
searchPlaceholder: Ember.computed('i18n', function() { // Search bar placeholder
return this.get('i18n').t('discover.search.placeholder');
queryParams: ['page', 'q', 'sources', 'tags', 'type', 'start', 'end', 'subject', 'provider'], // Pass in the list of queryParams for this component
searchPlaceholder: Ember.computed('i18n', 'additionalProviders', function() { // Search bar placeholder
return this.get('additionalProviders') ? this.get('i18n').t('discover.search.repository_placeholder'): this.get('i18n').t('discover.search.placeholder');
}),
showActiveFilters: Ember.computed('additionalProviders', function() { // Whether Active Filters should be displayed.
// additionalProviders are using SHARE facets which do not work with Active Filters at this time
return !this.get('additionalProviders');
}),
showActiveFilters: true, // Whether Active Filters should be displayed.
sortOptions: Ember.computed('i18n.locale', function() { // Sort options for preprints
const i18n = this.get('i18n');
return [{
Expand All @@ -60,7 +85,20 @@ export default Ember.Controller.extend(Analytics, {
sortBy: '-date_updated'
}];
}),
subject: '',// Subject query param. Must be passed to component, so can be reflected in URL,
sources: '', // Sources query param. Must be passed to component, so can be reflected in the URL
start: '', // Start query param. Must be passed to component, so can be reflected in the URL
subject: '', // Subject query param. Must be passed to component, so can be reflected in URL
tags: '', // Tags query param. Must be passed to component, so can be reflected in URL
themeProvider: Ember.computed('model', function() { // Pulls the preprint provider from the already loaded model
let themeProvider = null;
this.get('model').forEach(provider => {
if (provider.id === this.get('theme.id')) {
themeProvider = provider;
}
});
return themeProvider;
}),
type: '', //Type query param. Must be passed to component, so can be reflected in URL
_clearFilters() {
this.set('activeFilters', {
providers: [],
Expand Down
11 changes: 11 additions & 0 deletions app/helpers/provider-asset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Ember from 'ember';
import config from 'ember-get-config';
import buildProviderAssetPath from '../utils/build-provider-asset-path';

export default Ember.Helper.extend({
theme: Ember.inject.service(),
compute(params) {
let [providerId, assetName] = params;
return buildProviderAssetPath(config, providerId, assetName, this.get('theme.isDomain'));
}
});
3 changes: 2 additions & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@

{{content-for "head-footer"}}
<script type="text/javascript"
src="//cdnjs.cloudflare.com/ajax/libs/mathjax/2.6.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
src="//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']], processEscapes: true},
skipStartupTypeset: true
});
</script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
</head>
<body>
{{content-for "body"}}
Expand Down
Loading

0 comments on commit 5e97fab

Please sign in to comment.