Skip to content

Commit

Permalink
Merge branch 'release/0.6.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
nleush committed Jul 8, 2014
2 parents b6ca136 + b9a4a29 commit d963aa9
Show file tree
Hide file tree
Showing 100 changed files with 1,311 additions and 187 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,19 @@ Basically, it mimics the `<head>` of the origin page, with `<meta>` and list of
...
}]
},

-- HTML field is only available in Cloud API
"html": "<div style=\"left: 0px; width: 100%; height: 0px; position: relative; padding-bottom: 56.243%;\">
<iframe src=\"//iframe.ly/ACcM3Y\" style=\"top: 0px; left: 0px; width: 100%; height: 100%; position: absolute;\"></iframe></div>"
}


`html` field contains the responsive embed code, which is provided by Cloud API and which also resolves SSL, Flash-on-iOS and autoplay issues.
In Open-Source version, you will need to render the code yourself. [See how](http://iframely.com/docs/links).

## Or in oEmbed Format

Iframely comes with oEmbed adapter. It can return embeds as oEmbed JSON, though it is more of a fallback and is slightly less flexible than main endpoint. For example, it skips `autoplay` videos.
Iframely comes with oEmbed adapter. It can return embeds as oEmbed JSON, though it is more of a fallback and is slightly less flexible than main endpoint. For example, it skips `autoplay` videos. If you want to include those in Cloud API, add `&iframe=1` parameter to your call.

[>> Here’s the same Coub in oEmbed flavor](http://iframe.ly/ACcM3Y.oembed)

Expand All @@ -88,7 +94,7 @@ Iframely comes with oEmbed adapter. It can return embeds as oEmbed JSON, though
"canonical": "http://coub.com/view/2pc24rpb"
}

`photo` and `rich` types are supported as oEmbed output. If Iframely doesn't have any embed codes for given URL, oEmbed will return `link` type object. The additional unified semantic information as well as `thumbnail`s are returned for all URLs. See the list of meta fields below.
`photo`, `video` and `rich` types are supported as oEmbed output. If Iframely doesn't have any embed codes for given URL, oEmbed will return `link` type object. The additional unified semantic information as well as `thumbnail`s are returned for all URLs. See the list of meta fields below.


## Read Next:
Expand Down
42 changes: 42 additions & 0 deletions WHATSNEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,48 @@ This is the history of the [Iframely Gateway](http://iframely.com/gateway) chang
Stay tuned, either by watching [Iframely on GitHub](https://github.com/itteco/iframely) or following [Iframely on Twitter](https://twitter.com/iframely).


### 2014.07.08, Version 0.6.5

Domains added:

+ podbean.com
+ slide.ly
+ clip.vn
+ squareup.com
+ quizlet.com
+ video.nationalgeographic.com
+ channel9.msdn.com/Events
+ c-span.org
+ indiegogo.com
+ rapgenius.com
+ vgtv.no
+ sverigesradio.se
+ medium.com
+ mixlr.com
+ twitch.tv
+ arte.tv


Domains maintenance:

* Fixed 9gag.com to find nice source image - big image or animated gif
* Fixed pinterest.com to prevent working on non-content urls
* Fixed thumbnail for speakerdeck.com
* Added video embed for smugmug.com
+ Added html5 tag to text/html players domains that support it


General improvements:

+ Added smart cache invalidation for iframely data per domain and plugin. Now plugin results cache will be invalidated after plugin file update or whitelist domain record update.
* Better support for open graph arrays
* Added support of grouped links in iframely.js
* Improved serverside oembed html attribute generation
+ Added meta plugin to detect page media (e.g. 'player', 'reader')
* Fix detecting correct charset when response headers charset not equals to html meta tag charset. Response header has priority now.
+ Updated iconv-lite to support more encodings. Please, run `npm update`.
+ Return 403 for non indexing content, according to [How to block Iframely API](http://iframely.com/docs/block-iframely).


### 2014.05.29, Version 0.6.4

Expand Down
1 change: 1 addition & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
file: "file",
survey: "survey",
app: "app",
summary: "summary",

iframely: "iframely",
og: "og",
Expand Down
23 changes: 13 additions & 10 deletions docs/API.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Iframely API Endpoints


## For both Cloud and Open-Source version of API
## For both Cloud and Open-Source versions of API

[Iframely API can return](http://iframely.com/docs) either full JSON with the list of embed links, or a simple response as oEmbed.

Each of the JSON response formats has it’s own API Endpoint relative address and set of get parameters:

- [/iframely?url=](iframe.ly/api/iframely?url=http://iframe.ly/ACcM3Y) - for full Iframely JSON,
- [/oembed?url=](iframe.ly/api/oembed?url=http://iframe.ly/ACcM3Y) - for simple oEmbed format.
- [/iframely?url=](http://iframe.ly/api/iframely?url=http://iframe.ly/ACcM3Y) - for full Iframely JSON,
- [/oembed?url=](http://iframe.ly/api/oembed?url=http://iframe.ly/ACcM3Y) - for simple oEmbed format.

Depending on whether you use Iframely Cloud API, or Open-Source API, the primary (absolute) host paths will also differ.

Expand All @@ -21,17 +21,20 @@ Depending on whether you use Iframely Cloud API, or Open-Source API, the primary

The API host for Iframely Cloud is at `http://iframe.ly/api`

### Shorten and get ID
### Shorten and get ID or HTML

Iframely Cloud acts as the database for links and URL shortener. Each endpoint is treated as the way for you to shorten URLs and add it to your database. Iframely cloud will add `id` value to the root of API JSON. Repeat requests will return the same ID.

- [http://iframe.ly/api/iframely?url={URL}&api_key={KEY}&origin={hashtag}](iframe.ly/api/iframely?url=http://iframe.ly/ACcM3Y) <br<- for full Iframely JSON,
- [http://iframe.ly/api/oembed?url={URL}&api_key={KEY}&origin={hashtag}](iframe.ly/api/oembed?url=http://iframe.ly/ACcM3Y) <br>- for simple oEmbed format.
- [http://iframe.ly/api/iframely?url={URL}&api_key={KEY}&origin={hashtag}](http://iframe.ly/api/iframely?url=http://iframe.ly/ACcM3Y) <br>- for full Iframely JSON,
- [http://iframe.ly/api/oembed?url={URL}&api_key={KEY}&origin={hashtag}](http://iframe.ly/api/oembed?url=http://iframe.ly/ACcM3Y) <br>- for simple oEmbed format.

`api_key` is required, unless URL is from iframe.ly domain itself, like `?url=http://iframe.ly/ACcM3Y`. ([Get your FREE one here](http://iframe.ly))

`origin` parameter is optional. You can filter URLs on your dashboard using origin as #hashtag.

The response will contain embed links and other meta right away, along with the short `id` for future reference. If you're using [Cloud API](http://iframe.ly), the response will also contain `html` of a hosted widget so that you don't need to render the embed code yourself.


### Get URL data by ID

When you shorten a URL, you’ll get `id` in the response. This is the short ID of the URL in Iframely DB, unique to your account.
Expand All @@ -52,13 +55,13 @@ The exact path to your Open Source API host depends on your config and setup you

Basically, it is:

- [{YOURHOST.HERE}/iframely?url=](iframe.ly/api/iframely?url=http://iframe.ly/ACcM3Y) - for full Iframely JSON,
- [{YOURHOST.HERE}/oembed?url=](iframe.ly/api/oembed?url=http://iframe.ly/ACcM3Y) - for simple oEmbed format.
- [{YOURHOST.HERE}/iframely?url=](http://iframe.ly/api/iframely?url=http://iframe.ly/ACcM3Y) - for full Iframely JSON,
- [{YOURHOST.HERE}/oembed?url=](http://iframe.ly/api/oembed?url=http://iframe.ly/ACcM3Y) - for simple oEmbed format.

The only differences in JSON format with Cloud API is the absence of `id` value and also the fact that full Iframely JSON is not grouped by `rel` in Open-Source API. To get it grouped, just add `&group=true` to the response.
The only differences in JSON format with Cloud API is the absence of `id` value and also the fact that full Iframely JSON is not grouped by `rel` in Open-Source API. To get it grouped, just add `&group=true` to the response. The open-source API also does not have `html` field, so you'd need to generate the embed codes yourself, depending on your app needs. [See how](http://iframely.com/docs/links).


See [how to install & configure](http://iframely.com/docs/host) your Open-Source host.
Also, see [how to install & configure](http://iframely.com/docs/host) your Open-Source host.

## Read Next:

Expand Down
21 changes: 21 additions & 0 deletions docs/HOW-TO-BLOCK.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# How to block Iframely API

If you are a content publisher, and do not wish your embeds be available via Iframely open-source or Cloud API (as weird as it sounds), here’s some information for you.


Iframely APIs use the following user agent:

Iframely/0.6.4 (+http://iframely.com/;)

where `0.6.4` is the version of the API, and can change.

You may opt to block this user agent completely or to allow it to certain sections of your site only.

Please, note, that users of Iframely’s open-source package may configure the user-agent to be anything else.

In this case, Iframely still will follow `robots.txt` file directive. As well as `noindex` value of `robots` attribute in page’s meta:

<meta name="robots" content="noindex">


To give specific directives to Iframely API in your robots config, use `iframely` as robot name.
4 changes: 3 additions & 1 deletion docs/IFRAMELY.JS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Iframely JS Client Lib

[Iframely Open-Source](https://github.com/itteco/iframely) package includes the client javascript wrapper of the API, so you don't need to spend time on it yourself. If you'd prefer to render a widget from the data yourself, please refer to [How to Render a Widget](http://iframely.com/docs/links).
[Iframely Open-Source](https://github.com/itteco/iframely) package includes the client javascript wrapper of the API, so you don't need to spend time on it yourself. If you'd prefer to render a widget from the data yourself, please refer to [How to Render a Widget](http://iframely.com/docs/links).

If you are using [Cloud API](http://iframe.ly), you don't need iframely.js as the embed code will be provided to you by API as the `html` field of JSON response.

You may find `iframely.js` lib in `/static/js/iframely.js` folder.

Expand Down
21 changes: 16 additions & 5 deletions docs/LINKS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Link Attributes in Iframely JSON

`links` in [Iframely API](http://iframely.com/docs) is the list of objects with fields `rel`, `href`, `type` and `media`.
`links` in [Iframely API](http://iframely.com/docs) is the list of objects with fields `rel`, `href`, `type` and `media`. Just like you would expect a `<link>` in `<html>` `<head>` of the page to be.

Just like you would expect a `<link>` in `<html>` `<head>` of the page to be.
Links are used as the raw data which you can use to render a responsive widget.

Example of a link object:

Expand All @@ -17,6 +17,14 @@ Example of a link object:

At times, Iframely will return `html` attribute instead of `href`. For example, for Twitter and Facebook Statuses, or elsewhere with very specific embed codes.

## Hosted widgets

A foreword before we go further with `links`: if you are using [Cloud API](http://iframe.ly), Iframely will also give you a simple `html` field to use as embed code in API response.

It is possible to do so in Cloud API, as we also offer hosted wigets there, and may proxy each frame view. It is helpful if you want to quickly handle SSL, iOS-Flash and autoplay issues.

If you opt to rely on our `html` field, we suggest you check the functional `rels` before using the code to see if the use cases fit your app.

## Functional Rels

`rel` object contains an array of functional and technical use cases. You’ll need to decide which link with `rel` which better works for the functionality of your app.
Expand All @@ -39,7 +47,7 @@ Iframely also uses supplementary `rels` as the way to suggest technical aspects

- `autoplay` - if player starts media playback on its load;
- `html5` - if player is capable of HTML5 playback and will render ok on devices without Flash installed (for example, iOS);
- `inline` - for `app` indicates that embed widgets can be dynamically added to the page via JavaScript (e.g. doesn’t use `document.write`). Usually goes along with `html` field instead of `href` and indicates that html should be used as `srcset`of an `<iframe>` (as substitute to `href` as `src`).
- `inline` - for `app` indicates that embed widgets can be dynamically added to the page via JavaScript (e.g. doesn’t use `document.write`). Usually goes along with `html` field instead of `href` and indicates that html should be used as `srcdoc` of an `<iframe>` (as substitute to `href` as `src`).

Usually these technical rels are available through our [Domains QA DB whitelist](http://iframely.com/qa). For example, GitHub Gists were not `inline` the last time we checked :\

Expand Down Expand Up @@ -74,12 +82,15 @@ For example, for `image` rel, Iframely will output exact sizes as `width` and `h

## How to render Responsive Widget

You can use [iframely.js](http://iframely.com/docs/iframelyjs) lib that goes with our open-source page to both communicate with Iframely and render responsive widgets.
You can use [iframely.js](http://iframely.com/docs/iframelyjs) lib that goes with our open-source page to both communicate with Iframely and render responsive widgets.

Cloud API response will also contain `HTML` field with generated embed code. This code is almost identical to the one which `iframely.js` generates, however all sources of the widgets are from the cloud. It helps with load times, SSL, iOS-Flash and autoplay issues.

[API’s oEmbed format](http://iframely.com/docs/api) will provide `HTML` field for you with the code already generated by the server.
[API’s oEmbed format](http://iframely.com/docs/api) will always provide `HTML` field for you with the code already generated by the server. It maybe hosted widgets in Cloud API or a native embed codes, depending on your call.

If you’d like to generate a responsive embed code yourself, please refer to

- ["Responsive embeds"](http://amobil.se/2011/11/responsive-embeds/) by [Anders M. Andersen](https://twitter.com/andmag) / 2011
- [Creating Intrinsic Ratios for Video](http://alistapart.com/article/creating-intrinsic-ratios-for-video) by [Thierry Koblentz](https://twitter.com/thierrykoblentz) / 2009
- [How to Generate Responsive Embed Codes](http://iframely.com/oembed2/types) from Iframely Protocol

78 changes: 77 additions & 1 deletion lib/loader/pluginLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
templates = pluginLoader._templates = {},
metaMappings = {},
pluginsList = pluginLoader._pluginsList = [],
postPluginsList = pluginLoader._postPluginsList = [];
postPluginsList = pluginLoader._postPluginsList = [],
pluginsByDomain = {};

/*
* ===================
Expand Down Expand Up @@ -219,6 +220,8 @@
var domain = bits[domainBitIdx + 1].replace(/^www\./i, "");
// Remove .js extension if not folder.
pluginDeclaration.domain = getFileName(domain);
// Store in pluginsByDomain dict to fast search by domain.
pluginsByDomain[pluginDeclaration.domain] = pluginDeclaration;
} else {
if (plugin.re) {
console.warn("re in generic plugin (will never be called)", pluginPath)
Expand Down Expand Up @@ -247,6 +250,7 @@

var stat = fs.statSync(pluginPath);
pluginDeclaration.modified = new Date(stat.mtime);
pluginDeclaration.getPluginLastModifiedDate = getPluginLastModifiedDate;

// Store plugin.
plugins[pluginDeclaration.id] = pluginDeclaration;
Expand All @@ -264,6 +268,31 @@
}
}

// Plugin method. Finds modified date, including mixins.
function getPluginLastModifiedDate() {

var plugin = this;

var modified = plugin.modified;

var mixins = plugin.module.mixins;

if (mixins) {
for(var i = 0; i < mixins.length; i++) {

var mixin = mixins[i];

var m = plugins[mixin].getPluginLastModifiedDate();

if (m > modified) {
modified = m;
}
}
}

return modified;
}

function loadPluginDir(pluginPath) {

// Scan plugin dir.
Expand Down Expand Up @@ -296,6 +325,53 @@
});
}

function extractDomain(uri) {
var m = uri.match(/^(?:https?:\/\/)?([^/]+)/i);
if (m) {
return m[1];
} else {
return null;
}
}

function extractDomainPatterns(uri) {

var patterns = [];

var domain = extractDomain(uri);
if (!domain) {
return patterns;
}

// Only full domain exact match.
patterns.push(domain);

// 'www' workaround.
var bits = domain.split('.');
if (bits[0] != 'www') {
patterns.push('www.' + domain);
} else {
// Remove www.
bits.splice(0, 1);
domain = bits.join('.');
patterns.push(domain);
}

return patterns;
}

pluginLoader.findDomainPlugin = function(uri) {
var patterns = extractDomainPatterns(uri);

var record, i = 0;
while(!record && i < patterns.length) {
record = pluginsByDomain[patterns[i]];
i++;
}

return record;
};

function scanModulesForPlugins() {

// Scan node_modules dir.
Expand Down
Loading

0 comments on commit d963aa9

Please sign in to comment.