Giter Club home page Giter Club logo

ink-oembed's Introduction

ink-oembed

ink-oembed is currently a work in progress.

Ink plugin to embed stuff using the oembed spec.

Install

bower install ink-oembed

Usage

Simple Example

Markup

<div id="container" data-url="http://videos.sapo.pt/vz0UeKVkl92vQ2bDhIYl" data-with="640" data-height="480"></div>

Javascript

Ink.requireModules(['Ink.Ext.OEmbed_1'], function (OEmbed) {
    new OEmbed(document.getElementById('container'));
});

Advanced Examples

You can pass custom OEmbed endpoint to avoid using the embed.ly service. Here's an example using the twitter OEmbed API:

Ink.requireModules(['Ink.Ext.OEmbed_1'], function (OEmbed) {
    new OEmbed(document.getElementById('container'), {
        endpoint: 'https://api.twitter.com/1/statuses/oembed.json'
    });
});

And the markup:

<div id="container" data-url="https://twitter.com/#!/twitter/status/99530515043983360"></div>

You can even pass a callback to get all the data returned by the OEmbed response:

Ink.requireModules(['Ink.Ext.OEmbed_1'], function (OEmbed) {
    new OEmbed(document.getElementById('container'), {
        callback: function (data) { alert(data); }
    });
});

And here's a JSBin example for you to play: http://jsbin.com/jakanodo/3/edit

API

OEmbed(element, opts)

  • element the container element where the resource will be emebeded
  • opts (hash)
    • endpoint (string) the OEmbed provider endpoint
    • callback (function) a callback to get the OEmbed response data

If no opts is passed, ink-oembed will try to match the data-url with Sapo Videos. If it does not match it will use the http://embed.ly service.

ink-oembed's People

Contributors

rogeriopvl avatar

Stargazers

Angus H. avatar Jonatas Miguel avatar Celso Martinho avatar

Watchers

 avatar James Cloos avatar

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.