Code Monkey home page Code Monkey logo

embetty-vue's Introduction

embetty-vue npm

Embetty displays remote content like tweets or videos without compromising your privacy.

This is a Vue.js alternative to the original embetty implementation (which is based on Web Components). To use it, you need to have a embetty server up and running.

Usage

Setup when using a bundler (webpack, rollup, etc.)

import Vue from 'vue';
import EmbettyVue from 'embetty-vue';

const Vue = require('vue');
const { EmbettyVue } = require('embetty-vue');

Vue.use(EmbettyVue, {
  // optional, but recommended
  serverUrl: '/path/to/embetty-server', // without trailing slash

  // optional
  posterImageMode: 'cover' // or 'contain'
});

The CSS can be imported from embetty-vue/dist/embetty-vue.css.

Setup when directly linking the files

In your HTML head:

<link rel="stylesheet" type="text/css" href="dist/embetty-vue.min.css" />
<meta data-embetty-server="/path/to/embetty-server" /> <!-- without trailing slash -->
<script type="text/javascript" src="vue.js"></script>
<script type="text/javascript" src="dist/embetty-vue.browser.min.js"></script>

You can link to the files without .min for debugging.

Using the components

<embetty-tweet status="928365837123227654" />
<embetty-video type="youtube" video-id="m6UOo2YGbIE" />

If you didn't specify the server URL globally (either the options passed to Vue.use or the <meta> tag), you must specify it on every component:

<embetty-tweet server-url="/path/to/embetty-server" status="928365837123227654" />
<embetty-video server-url="/path/to/embetty-server" type="youtube" video-id="m6UOo2YGbIE" />

See src/App.vue for a lot of examples and component options.

Differences to original implementation

embetty-vue's <embetty-video> component supports type native: Provide an URL to a video file as video-id to load it on click in a <video> HTML element.

Development

Project setup

npm install

Compiles and hot-reloads for development

npm run watch

Compiles and minifies for production

npm run build

embetty-vue's People

Contributors

dependabot[bot] avatar floedelmann avatar luckyrumo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

embetty-vue's Issues

Error handling

  • Embetty server down
  • Wrong response code
  • Twitter not authorized
  • Wrong returned data format

Migrate from rollup to Vite

The rollup plugin for Vue is deprecated and it is suggested to switch to Vite instead. Since Vite is much faster and easier to work with, it makes sense anyway.

Parse '1m16s'-style strings in start-at

YouTube and vimeo allow strings like 1h23m45s as value for their time parameter in video urls (e.g. https://www.youtube.com/watch?v=_FvgGrI6pe4&t=1m5s and https://vimeo.com/283459050#t=2m15s). It would be nice if embetty-vue would also support them as possible value for start-at.

The YouTube iframe needs a single positive integer, though. Parsing could be done like this:

const timeRegex = /^(?:(\d+)h|)(?:(\d+)m|)(?:(\d+)s|)$/;
const timeMatch = query.t.match(timeRegex);

if (timeMatch) {
  // '1m16s'    -> timeMatch = ['1m16s',    undefined, '1', '16']
  // '1h23m45s' -> timeMatch = ['1h23m45s', '1',       '2', '34']
  const [hours, minutes, seconds] = timeMatch.slice(1, 4).map(val => {
    if (val === undefined) {
      return 0;
    }
    return parseInt(val);
  });

  const startAt = (hours * 3600) + (minutes * 60) + seconds;
}

Loading UI

Add progress bar / spinner. Mainly for tweets, as videos (except Facebook) are usable without loading, the poster image just enhances the experience.

GitHub Pages Demo

It would be great to have a demo page on GitHub Pages to showcase the embetty-vue look and feel.

The original implementation also has demos (with server) on GitHub pages, so this could be some inspiration.

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.