Giter VIP home page Giter VIP logo

ember-osf's Introduction

Ember OSF

master Build Status: Build Status

develop Build Status: Build Status

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

Contributing?

Please read the 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:
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:

<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 on the relevant version of the OSF.

Running the OSF Locally (optional)

For local development, you will need to be running the OSF APIv2. To connect to the APIv2 while using fakecas, 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:

ember generate ember-osf

Usage

Ember Data: Using the OSF models

The models, serializers, adapters bundled in this addon with be available to you automatically. For example, simply do:

this.store.findAll('node')

to fetch all nodes.

Running

We recommend developers target out test server:

  • test (test): matches production features, very stable

Other options include:

  • local (local): for developers running the OSF stack locally
  • staging (stage): contains bleeding edge features, but less stable
  • staging2 (stage2): another version of staging using running a specific feature branch

Then (using test as an example) run: BACKEND=test ember server

and visit your app at http://localhost:4200.

Note: This runs the dummy app contained in /tests/dummy

Running Tests

  • npm test (Runs ember try:testall to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://www.ember-cli.com/.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.