Skip to content
This repository has been archived by the owner on Feb 24, 2022. It is now read-only.

adobe/helix-embed

Helix Embedding Microservice

This is a simple microservice (to be used in conjunction with Project Helix) that turns URLs into HTML-previews of the web page behind it. It uses HTML Meta Tags, Twitter Cards, Open Graph Protocol and OEmbed to generate a rich preview and can be configured to use 3rd-party embed providers like Embdely or Iframely.

Status

codecov CircleCI GitHub license GitHub issues LGTM Code Quality Grade: JavaScript

Usage

Run the following command to get a preview of http://www.adobe.com

$ curl https://adobeioruntime.net/api/v1/web/helix/default/embed/http://www.adobe.com
<div class="embed embed-has-url embed-has-title embed-has-image embed-has-description">
  <a href="https://www.adobe.com/">
    <span class="title">Adobe: Creative, marketing and document management solutions</span>
  </a>
  <img src="https://www.adobe.com/homepage/index/index.thumb.800.480.png?ck=1540830329" alt="Adobe: Creative, marketing and document management solutions" class="image">
    <p class="description">Adobe is changing the world through digital experiences. We help our customers create, deliver and optimize content and applications.</p>
<div>

While the above is simple to type, it is more safe to escape the url and optionally pass it as src query parameter:

curl https://adobeioruntime.net/api/v1/web/helix/default/embed/http%3A%2F%2Fwww.adobe.com

or

curl https://adobeioruntime.net/api/v1/web/helix/default/embed?src=http%3A%2F%2Fwww.adobe.com

Deployment

The default deployment can be started with npm run deploy.

Options

In order to use a third-party embedding service, make sure the api property is set at deployment time, e.g.

$ npm run zip && wsk action update embed embed.zip --kind nodejs:8 --web raw --web-secure false -p api https://my-embed-provider.com

All additional default parameters will be used as URL parameters when making the request to the URL specified in api. This allows you to create services that proxy another OEmbed-compatible provider:

Iframely uses the api_key parameter for API keys.

npm run zip && wsk action update embed embed.zip --kind nodejs:8 --web raw --web-secure false -p api http://iframe.ly/api/oembed -p api_key insert-here

Embedly, on the other hand, uses key

npm run zip && wsk action update embed embed.zip --kind nodejs:8 --web raw --web-secure false -p api https://api.embedly.com/1/oembed -p key insert-here

Development

Use the standard trifecta of npm install, npm lint, and npm test.

Build

npm install

Test

npm test

Lint

npm run lint