<commit_before># Ember OSF

`master` Build Status: [![Build Status](https://travis-ci.org/CenterForOpenScience/ember-osf.svg?branch=master)](https://travis-ci.org/CenterForOpenScience/ember-osf)

`develop` Build Status: [![Build Status](https://travis-ci.org/CenterForOpenScience/ember-osf.svg?branch=develop)](https://travis-ci.org/CenterForOpenScience/ember-osf)

This repo contains code for interacting with the OSF APIv2 inside of an Ember app.

## Contributing?

Please read the [CONTRIBUTING.md](https://github.com/CenterForOpenScience/ember-osf/blob/develop/.github/CONTRIBUTING.md)

## Installation (for Development)

* `git clone` this repository
* `npm install`
* `bower install`

## Using this code in an Ember app

1. Clone the repository: `git clone https://github.com/CenterForOpenScience/ember-osf.git`
2. From the consuming Ember app:
  - install the addon and it's dependencies: `ember install ../ember-osf`
	- this generates a config/local.yml file (see 'Configuration' below)
  - link the app for local development: `npm link ../ember-osf`
  - Import code from ember-osf like:
  ```javascript
  import Ember from 'ember';
  import OsfTokenLoginRouteMixin from 'ember-osf/mixins/osf-token-login-route';

  export default Ember.Route.extend(OsfLoginRouteMixin);
  ```

> **Note**: Running ember install will automatically install all bower and npm dependencies for ember-osf.

## Configuration

#### local.yml settings

This file is structured like:
```yaml
<backend>:
  CLIENT_ID: null
  PERSONAL_ACCESS_TOKEN: null
  OAUTH_SCOPES: osf.full_read osf.full_write
  REDIRECT_URI: http://localhost:4200/login
```

You will need to fill out options for each backend you want to use (see 'Running' below).
We recommend using the 'test' backend for development and testing as it is the most stable
of our environments.  When configuring your application, make sure that your login redirect
uri is correct.  If it needs a trailing slash, be sure to include a trailing slash!

Edit the new file (installed in the config directory) and set:
- `CLIENT_ID` to the client id of your developer application
- `PERSONAL_ACCESS_TOKEN` to the newly generated token (if applicable, optional for staging development)
- REDIRECT_URI: Must exactly match the redirect URI used to register the OAuth developer application. 
Default value is appropriate for local development using `ember server`, with a login page at `/login` 

#### Using the Test API

To do this, you will need to [create a developer application](https://test.osf.io/settings/applications/) on the relevant version of the OSF.

#### Running the OSF Locally (optional)

For local development, you will need to be running the [OSF APIv2](https://github.com/CenterForOpenScience/osf.io#running-the-api-server).
To connect to the APIv2 while using [fakecas](https://github.com/CenterForOpenScience/osf.io#running-the-osf), you will need to generate a
personal access token on your local OSF instance ([here](http://localhost:5000/settings/tokens/-- go ahead and grant access to all scopes)).

#### Create a local settings file

If for some reason you don't have a config/local.yml you can generate one. To do this:
```bash
ember generate ember-osf
```

## Usage

#### Ember Data: Using the OSF models
<commit_msg>Clarify README: tokens are sensitive info<commit_after># Ember OSF

`master` Build Status: [![Build Status](https://travis-ci.org/CenterForOpenScience/ember-osf.svg?branch=master)](https://travis-ci.org/CenterForOpenScience/ember-osf)

`develop` Build Status: [![Build Status](https://travis-ci.org/CenterForOpenScience/ember-osf.svg?branch=develop)](https://travis-ci.org/CenterForOpenScience/ember-osf)

This repo contains code for interacting with the OSF APIv2 inside of an Ember app.

## Contributing?

Please read the [CONTRIBUTING.md](https://github.com/CenterForOpenScience/ember-osf/blob/develop/.github/CONTRIBUTING.md)

## Installation (for Development)

* `git clone` this repository
* `npm install`
* `bower install`

## Using this code in an Ember app

1. Clone the repository: `git clone https://github.com/CenterForOpenScience/ember-osf.git`
2. From the consuming Ember app:
  - install the addon and it's dependencies: `ember install ../ember-osf`
	- this generates a config/local.yml file (see 'Configuration' below)
  - link the app for local development: `npm link ../ember-osf`
  - Import code from ember-osf like:
  ```javascript
  import Ember from 'ember';
  import OsfTokenLoginRouteMixin from 'ember-osf/mixins/osf-token-login-route';

  export default Ember.Route.extend(OsfLoginRouteMixin);
  ```

> **Note**: Running ember install will automatically install all bower and npm dependencies for ember-osf.

## Configuration

#### local.yml settings

This file is structured like:
```yaml
<backend>:
  CLIENT_ID: null
  PERSONAL_ACCESS_TOKEN: null
  OAUTH_SCOPES: osf.full_read osf.full_write
  REDIRECT_URI: http://localhost:4200/login
```

You will need to fill out options for each backend you want to use (see 'Running' below).
We recommend using the 'test' backend for development and testing as it is the most stable
of our environments.  When configuring your application, make sure that your login redirect
uri is correct.  If it needs a trailing slash, be sure to include a trailing slash!

Edit the new file (installed in the config directory) and set:
- `CLIENT_ID` to the client id of your developer application
- `PERSONAL_ACCESS_TOKEN` to the newly generated token (Only required or recognized for the LOCAL backend; do not set this value for staging. production, or test backends)
- REDIRECT_URI: Must exactly match the redirect URI used to register the OAuth developer application. 
Default value is appropriate for local development using `ember server`, with a login page at `/login` 

Because of the potential for this file to include sensitive information, we strongly recommend adding this file to 
`.gitignore` for your project.

#### Using the Test API

To do this, you will need to [create a developer application](https://test.osf.io/settings/applications/) on the relevant version of the OSF.

#### Running the OSF Locally (optional)

For local development, you will need to be running the [OSF APIv2](https://github.com/CenterForOpenScience/osf.io#running-the-api-server).
To connect to the APIv2 while using [fakecas](https://github.com/CenterForOpenScience/osf.io#running-the-osf), you will need to generate a
personal access token on your local OSF instance ([here](http://localhost:5000/settings/tokens/-- go ahead and grant access to all scopes)).

#### Create a local settings file

If for some reason you don't have a config/local.yml you can generate one. To do this:
```bash
ember generate ember-osf
```

## Usage

#### Ember Data: Using the OSF models

{'fraction_non_alphanumeric': 0.09871813761603064, 'fraction_numerical': 0.003830853101517607, 'mean_word_length': 4.694630872483222, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 18, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '34204', 'n_tokens_mistral': 2060, 'n_tokens_neox': 1967, 'n_words': 772}