npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

ember-contentful

v0.3.1

Published

The default blueprint for ember-cli addons.

Readme

Ember Contentful addon

Ember Contentful is an Ember CLI addon that should facilitate working with Contentful's Content Management API.

Basics

Alright, this repo is missing a lot of documentation and I'm afraid that a the structure and encapsulation of this addon and it's dependencies still needs a lot of work, but... it's a start.

What is in this addon:

  • Initializer: a simple initializer setting up contentful and contentful-management and injecting them into Routes and Components

  • Authenticator: A custom authenticator based on the Ember Simple Auth package.

  • Routes:

    • auth/contentful as a callback route for the Contentful API
    • contentful-entry as a base template for a Route that loads an Entry from Contentful
  • Mixins:

    • contentful-space
      • connectSpace() - async function returning a Promise that resolves to a Contentful space. The function uses the space ID and the authentication token from the current session.
    • contentful-content-types
      • loadContentTypes - async function returning a Promise that resolves to the content types loaded from the Contentful API. The function uses the space ID and auth token from the current user session. The return value is a hash/map in the form of { typeId : { ...fields }, ... }. When loading the content types the HTTP header X-Contentful-Skip-Transformation: true is used, so that the response contains the field ID and the field name.
      • getContentType( id ) - async function returning a Promise that resolves to a single content type object. It expects the ID of the content type as a parameter.
      • ensureContentFieldsArePresent( entry, locale ) - async func returning a Promise that resolves to an Entry with all properties defined in the content type set (even if empty). Normally Contentful's API responses skip empty fields altogether, but for Ember's Observers and Computed Properties to work we need at least an empty object to bind against. So this function prepares an Entry to be used in an Ember environment.
      • getContentTypeName( id ) - maps a content type's Id to it's apiName/field name. This function uses the map currently expected in config/environment. A likely use case is to auto-generate route names from content type ids.
      • getContentTypeId( name ) - maps a content type's name to it's Contentful ID. This function uses the map currently expected in config/environment. A likely use case would be to map a route name to an API request that needs the content type id.
    • contentful-entries
      • getEditorUI( contentTypeId )
      • reduceEntriesToLinks( entry, locale)
      • resolveAssets(entries, assets)
      • listEntryChildren(entry, hash includedTypes, locale)
      • publishEntryWithChildren(entry, includedTypes, controller)
      • publishEntry(entry)
      • unpublishEntry(entry)
      • archiveEntry(entry)
    • contentful-assets
      • createAsset(locale)
      • updateAssetWithFile(asset, file, locale)
      • saveAsset(asset)
      • changeAsset(assetField, file, locale)
      • watchAsset(asset, locale)
      • smartImageUrl(asset, locale, maxWidth)
      • aspectRatio(asset, locale)
    • contentful-validations
      • validateAssets(assets, locale)
      • validateEntries(entries, locale)
      • validateEntry(entry, contentType, locale)
      • validateRule(field, rule, checkItems)
      • translateError(error)

Installation

  • ember install ember-contentful

Don't forget the dependencies...
Important! As of 0.3.0 the minimum version of Simple Auth is 0.8.0

  • ember install ember-cli-simple-auth
  • ember install ember-cli-simple-auth-oauth2
  • bower install lodash and add it to your Brocfile (better solution to come)

Configuration

You'll need a lot of stuff in your config file for this addon:

  var ENV = {
	// ...
    Contentful: {
      clientId: 'xxxx',
      redirectUrl: 'http://localhost:4200/auth/contentful',
      deliveryKey: 'xxxx',
      previewKey: 'xxxx',
      host: 'https://api.contentful.com/',
      previewHost: 'https://preview.contentful.com/',
      space: 'xxxx',

      contentTypeMap: {
        'xxxx': 'name',
        // ...
      }
    }

Developers

Install

  • git clone this repo
  • npm install
  • bower install

Running

  • ember server
  • Visit your app at http://localhost:4200.

Running Tests

  • ember test
  • ember test --server

Building

  • ember build

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