Skip to content

Tom Dale's blog example updated for the Ember CLI

Notifications You must be signed in to change notification settings

jacobq/ember-cli-blog

 
 

Repository files navigation

Myapp

Greenkeeper badge

This README outlines the details of collaborating on this Ember application.

Working example

https://bloggr.exmer.com/

Prerequisites

You will need the following things properly installed on your computer.

Installation

To get up and running with this project:

  • git clone this repository and cd into it cd ember-cli-blog
  • npm install to install npm dependencies
  • ember s to start the server!

Data will be stored in an in memory database and if configured, also replicated to a CouchDB instance.

To setup CouchDB data replication, configure ENV.remote_couch inside ./config/environment.js to point to your CouchDB location.

To setup a CouchDB instance on your own machine:

  • install couchDB from http://couchdb.apache.org/
  • npm install -g add-cors-to-couchdb
  • add-cors-to-couchdb
  • update config/environment.js local_couch and remote_couch to your CouchDB instance name.
  • update config/environment.js ENV.rootURL in the production environment
  • To use deploy create a file .env.deploy.production in the root of this project containing something like db=https://username:[email protected]/bloggr

Running

Running Tests

  • ember test
  • ember test --server

Building

  • ember build (development)
  • ember build --environment production (production)

Deploy

To deploy to your CouchDB cluster

  • ember deploy production (Set your credentials in the .env.deploy.production file)

Authentication

ember-simple-auth-pouch authenticator with custom data adapter to setup push replication after login. See authenticators/pouch.js and adapters/application for further details.

Authorization

CouchDB write protected database:

Registration required example for write persmission: Add users in the normal CouchDB way. For example by adding the following document to the _users database:

{
  "_id": "org.couchdb.user:test",
  "name": "test",
  "password": "test",
  "roles": [
    "bloggr"
  ],
  "type": "user"
}

After that you can protect your bloggr database from unauthorized writes by adding the following design document to the bloggr database.

{
   "_id": "_design/only_users_write",
   "validate_doc_update": "function (newDoc, oldDoc, userCtx) {\n\tif (userCtx.roles.indexOf(\"bloggr\") == -1 && userCtx.roles.indexOf(\"_admin\") == -1) {\n\t\tthrow({unauthorized: \"Only registered users can save data!\"});\n\t}\n}"
}

For cloudant you have to create a _users database and insert the userdocument from above or use the Hoodie CouchDB User Management App

Secret route

There is one secret route setup to demonstrate how to use ember-simple-auth to protect routes. More instructions can be read there.

Further Reading / Useful Links

About

Tom Dale's blog example updated for the Ember CLI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 69.6%
  • HTML 29.1%
  • CSS 1.3%