Code Monkey home page Code Monkey logo

helix-embed's Introduction

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

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.