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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ember-tarteaucitron

v1.1.0

Published

Ember integration of tarteaucitron.js, a RGPD friendly cookie manager.

Downloads

5

Readme

ember-tarteaucitron

CI Ember Observer Score License: MIT Liberapay

Ember integration of tarteaucitron.js, a RGPD friendly cookie manager.

Compatibility

  • Ember.js v3.24 or above
  • Ember CLI v3.24 or above
  • Node.js v12 or above

Installation

ember install ember-tarteaucitron

Usage

All your tarteaucitron configuration is stored inside your config/environement.js as follow:

module.exports = function (environment) {
  let ENV = {

    [...]

    tarteaucitron: {
      customServices: [], // You can define your own services directly here, see https://github.com/AmauriC/tarteaucitron.js#create-custom-service
      preInit: { // Change some settings before the initialization of tarteaucitron.js
        tarteaucitronForceCDN: "https://...", // Define where the tarteaucitron assets are available, default to <your-app>/assets/tarteaucitron/
        tarteaucitronForceLanguage: 'en', // Force the display language (default to the current browser language)
        tarteaucitronForceExpire: 365 * 10, // Force the expire cookie time (default to 365)
        tarteaucitronCustomText: { // Change a translation, see https://github.com/AmauriC/tarteaucitron.js#customize-text
          'support': {
            'title': 'Support client',
          },
          'close': 'Enregistrer et fermer',
          'engage-twitter': 'Suivez-nous sur Twitter !',
        },
      },
      config: {}, // tarteaucitron init configuration, see https://github.com/AmauriC/tarteaucitron.js#how-to-use
      jobs: ['googlefonts'], // Services name to activate
      user: { // Configuration used by services
        googleFonts: ['Tangerine'], // Configuration for googlefonts
      },
    },
  }

  [...]

  return ENV
}

If you need to deactivate ember-tarteaucitron, you can configure on your ember-cli-build.js file as follow:

const EmberAddon = require('ember-cli/lib/broccoli/ember-addon')

module.exports = function (defaults) {
  let app = new EmberAddon(defaults, {
    'ember-tarteaucitron': {
      enabled: false, // Enabled by default
    },
  })

  [...]
}

CDN

Here is the configuration if you want to use CDN for tarteaucitron assets:

module.exports = function (environment) {
  let ENV = {

    [...]

    tarteaucitron: {
      preInit: {
        tarteaucitronForceCDN: 'https://cdn.jsdelivr.net/npm/tarteaucitronjs@latest/',
      },
      [...]
    },
  }

  [...]

  return ENV
}

And you can avoid to import tarteaucitron assets:

const EmberAddon = require('ember-cli/lib/broccoli/ember-addon')

module.exports = function (defaults) {
  let app = new EmberAddon(defaults, {
    'ember-tarteaucitron': {
      importAssets: false,
    },
  })

  [...]
}

API

The tarteaucitron service exposes functions in order to add new jobs programmatically and listen to events.

Setup a new job

  • addJob(name, config): Add a new job with configuration

Service events

  • addServiceAddedListener(name, callback): listener called when a service is added
  • removeServiceAddedListener(name, callback): remove the listener when a service is added
  • addServiceLoadedListener(name, callback): listener called when a service is loaded
  • removeServiceLoadedListener(name, callback): remove the listener when a service is loaded

The service names are defined in tarteaucitron: https://github.com/AmauriC/tarteaucitron.js/blob/master/tarteaucitron.services.js

Tarteaucitron events

  • addTACListener(name, callback): listener when an event occurred
  • removeTACListener(name, callback): remove listener when an event occurred

The following events are available:

  • tac.root_available: the root element with panel has been created, services will be loaded
  • tac.open_alert: the alert is opened
  • tac.close_alert: the alert is closed
  • tac.open_panel: the panel is opened
  • tac.close_panel: the panel is closed
Code example
import Controller from '@ember/controller'
import { service } from '@ember/service'
import { tracked } from '@glimmer/tracking'

export default class ApplicationController extends Controller {
  @service tarteaucitron

  @tracked googlefontsLoaded = false
  @tracked facebookpixelLoaded = false

  constructor() {
    super(...arguments)
    this.tarteaucitron.addServiceLoadedListener('googlefonts', () => {
      this.googlefontsLoaded = true
      this.tarteaucitron.removeServiceLoadedListener('googlefonts')
    })
    this.tarteaucitron.addServiceLoadedListener('facebookpixel', () => {
      this.facebookpixelLoaded = true
      this.tarteaucitron.removeServiceLoadedListener('facebookpixel')
    })
    setTimeout(() => {
      this.tarteaucitron.addJob('facebookpixel', { facebookpixelId: 'YOUR-ID' })
    }, 5000)
  }
}

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.