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

angular-embed

v2.1.1

Published

This library wraps the embed services from [NoEmbed](http://noembed.com/) and [Embed.ly](http://embed.ly/).

Downloads

7

Readme

angular-embed

This library wraps the embed services from NoEmbed and Embed.ly.

How it works

NoEmbed is an open-source project which provides a lot of supported services. Because it's free and unlimited, we use this service first.
But sometimes, when the page is unknown, NoEmbed can't provide anything.
Then when we try to retrieve information on a page that NoEmbed doesn't support, we use Embed.ly. It is a lot more accommodating with random page. It use an extractor to retrieve a title, a description and an illustration if available.
Embed.ly limits the amount of requests and requires an API key so you need to register.

How to use it

  • You need to import angular-embed and angular-embedly in your page
<script src="bower/angular-embedly/em-minified/angular-embedly.min.js"></script>
<script src="bower/angular-embed/dist/angular-embed.min.js"></script>
  • And add them in your angular application
    angular.module('myApp', [
        // set `angular-embed` as a dependency of your module
        'angular-embed'
    // inject the service
    ]).controller('Ctrl', ['embedService', function(embedService) {
        // retrieve page information
        embedService.get('https://www.youtube.com/watch?v=Ksd-a9lIIDc')
    }]).config(function(embedlyServiceProvider) {
        // set your embed.ly key
        embedlyServiceProvider.setKey('your key');
    });
  • You can also use the directive instead of using the embedService with one of the following syntaxes
<ng-embed url="https://www.youtube.com/watch?v=Ksd-a9lIIDc"></ng-embed>
<div ng-embed="https://www.youtube.com/watch?v=Ksd-a9lIIDc"></div>
<div class="ng-embed:https://www.youtube.com/watch?v=Ksd-a9lIIDc;"></div>

Special Handlers

angular-embed comes with some custom handlers

| Name | Description | |:----------------------- |:---------------------------------------------------------------------------| | ngEmbedFacebookHandler | Add a width parameter to the facebook embed code and an App id (see below) | | ngEmbedInstagramHandler | Use embed.ly for instagram | | ngEmbedTwitterHandler | Construct a custom <blockquote> element from embed.ly's metadata | | ngEmbedYoutubeHandler | Use embed.ly for youtube |

To use a special handler, register them in the run block.

angular.module('myApp')
    .run(['embedService', 'ngEmbedTwitterHandler', 'ngEmbedFacebookHandler',
        function(embedService, ngEmbedTwitterHandler, ngEmbedFacebookHandler) {
            embedService.registerHandler(ngEmbedFacebookHandler);
            embedService.setConfig('facebookAppId', 'xxxxxxxxxxxxxxx');
            embedService.registerHandler(ngEmbedTwitterHandler);
            // optional: if true, prevent to use noembed as first choice (default: false)
            embedService.setConfig('useOnlyFallback', true);
        }
    ]);

Custom Handler

You can register all the handlers you want. An handler must match this structure and must return a promise of a valid oembed code.

{
    name: 'Twitter',
    patterns: [
        'https?://(?:www|mobile\\.)?twitter\\.com/(?:#!/)?[^/]+/status(?:es)?/(\\d+)/?$',
        'https?://t\\.co/[a-zA-Z0-9]+'
    ],
    embed: function(url, max_width) {
        var deferred = $q.defer();
        ...
        return deferred.promise;
    }
}