Comparing version 2.4.0 to 2.5.0
@@ -7,5 +7,5 @@ 'use strict'; | ||
var _virtualElement = require('virtual-element'); | ||
var _magicVirtualElement = require('magic-virtual-element'); | ||
var _virtualElement2 = _interopRequireDefault(_virtualElement); | ||
var _magicVirtualElement2 = _interopRequireDefault(_magicVirtualElement); | ||
@@ -19,3 +19,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var allowFullscreen = _ref.allowFullscreen; | ||
return (0, _virtualElement2.default)('iframe', { | ||
return (0, _magicVirtualElement2.default)('iframe', { | ||
src: src, | ||
@@ -22,0 +22,0 @@ width: width, |
@@ -7,5 +7,5 @@ 'use strict'; | ||
var _virtualElement = require('virtual-element'); | ||
var _magicVirtualElement = require('magic-virtual-element'); | ||
var _virtualElement2 = _interopRequireDefault(_virtualElement); | ||
var _magicVirtualElement2 = _interopRequireDefault(_magicVirtualElement); | ||
@@ -18,3 +18,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var href = _ref.href; | ||
return href ? (0, _virtualElement2.default)( | ||
return href ? (0, _magicVirtualElement2.default)( | ||
'a', | ||
@@ -21,0 +21,0 @@ { href: href }, |
@@ -8,5 +8,5 @@ 'use strict'; | ||
var _virtualElement = require('virtual-element'); | ||
var _magicVirtualElement = require('magic-virtual-element'); | ||
var _virtualElement2 = _interopRequireDefault(_virtualElement); | ||
var _magicVirtualElement2 = _interopRequireDefault(_magicVirtualElement); | ||
@@ -87,12 +87,12 @@ var _parseText = require('../parse-text'); | ||
var date = _ref.date; | ||
return (0, _virtualElement2.default)( | ||
return (0, _magicVirtualElement2.default)( | ||
'div', | ||
{ 'class': 'fb-video', 'data-allowfullscreen': '1', 'data-href': url }, | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'div', | ||
{ 'class': 'fb-xfbml-parse-ignore' }, | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'blockquote', | ||
{ cite: url }, | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'a', | ||
@@ -102,3 +102,3 @@ { href: url }, | ||
), | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'p', | ||
@@ -109,3 +109,3 @@ null, | ||
'Posted by ', | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'a', | ||
@@ -127,12 +127,12 @@ { href: user.url }, | ||
var text = _ref2.text; | ||
return (0, _virtualElement2.default)( | ||
return (0, _magicVirtualElement2.default)( | ||
'div', | ||
{ 'class': 'fb-post', 'data-href': url, 'data-width': '500' }, | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'div', | ||
{ 'class': 'fb-xfbml-parse-ignore' }, | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'blockquote', | ||
{ cite: url }, | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'p', | ||
@@ -143,3 +143,3 @@ null, | ||
'Posted by ', | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'a', | ||
@@ -150,3 +150,3 @@ { href: '#', role: 'button' }, | ||
' on ', | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'a', | ||
@@ -153,0 +153,0 @@ { href: url }, |
@@ -14,5 +14,5 @@ 'use strict'; | ||
var _virtualElement = require('virtual-element'); | ||
var _magicVirtualElement = require('magic-virtual-element'); | ||
var _virtualElement2 = _interopRequireDefault(_virtualElement); | ||
var _magicVirtualElement2 = _interopRequireDefault(_magicVirtualElement); | ||
@@ -52,3 +52,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var height = _ref3.height; | ||
return (0, _virtualElement2.default)('img', { src: src, alt: alt, width: width, height: height }); | ||
return (0, _magicVirtualElement2.default)('img', { src: src, alt: alt, width: width, height: height }); | ||
}; |
@@ -7,5 +7,5 @@ 'use strict'; | ||
var _virtualElement = require('virtual-element'); | ||
var _magicVirtualElement = require('magic-virtual-element'); | ||
var _virtualElement2 = _interopRequireDefault(_virtualElement); | ||
var _magicVirtualElement2 = _interopRequireDefault(_magicVirtualElement); | ||
@@ -19,21 +19,21 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var date = _ref.date; | ||
return (0, _virtualElement2.default)( | ||
return (0, _magicVirtualElement2.default)( | ||
'blockquote', | ||
{ 'class': 'instagram-media', 'data-instgrm-captioned': true, 'data-instgrm-version': '6', style: ' background:#FFF; border:0; border-radius:3px; box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width:658px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);' }, | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'div', | ||
{ style: 'padding:8px;' }, | ||
' ', | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'div', | ||
{ style: ' background:#F8F8F8; line-height:0; margin-top:40px; padding:50.0% 0; text-align:center; width:100%;' }, | ||
' ', | ||
(0, _virtualElement2.default)('div', { style: ' background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAsCAMAAAApWqozAAAAGFBMVEUiIiI9PT0eHh4gIB4hIBkcHBwcHBwcHBydr+JQAAAACHRSTlMABA4YHyQsM5jtaMwAAADfSURBVDjL7ZVBEgMhCAQBAf//42xcNbpAqakcM0ftUmFAAIBE81IqBJdS3lS6zs3bIpB9WED3YYXFPmHRfT8sgyrCP1x8uEUxLMzNWElFOYCV6mHWWwMzdPEKHlhLw7NWJqkHc4uIZphavDzA2JPzUDsBZziNae2S6owH8xPmX8G7zzgKEOPUoYHvGz1TBCxMkd3kwNVbU0gKHkx+iZILf77IofhrY1nYFnB/lQPb79drWOyJVa/DAvg9B/rLB4cC+Nqgdz/TvBbBnr6GBReqn/nRmDgaQEej7WhonozjF+Y2I/fZou/qAAAAAElFTkSuQmCC); display:block; height:44px; margin:0 auto -44px; position:relative; top:-22px; width:44px;' }) | ||
(0, _magicVirtualElement2.default)('div', { style: ' background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAsCAMAAAApWqozAAAAGFBMVEUiIiI9PT0eHh4gIB4hIBkcHBwcHBwcHBydr+JQAAAACHRSTlMABA4YHyQsM5jtaMwAAADfSURBVDjL7ZVBEgMhCAQBAf//42xcNbpAqakcM0ftUmFAAIBE81IqBJdS3lS6zs3bIpB9WED3YYXFPmHRfT8sgyrCP1x8uEUxLMzNWElFOYCV6mHWWwMzdPEKHlhLw7NWJqkHc4uIZphavDzA2JPzUDsBZziNae2S6owH8xPmX8G7zzgKEOPUoYHvGz1TBCxMkd3kwNVbU0gKHkx+iZILf77IofhrY1nYFnB/lQPb79drWOyJVa/DAvg9B/rLB4cC+Nqgdz/TvBbBnr6GBReqn/nRmDgaQEej7WhonozjF+Y2I/fZou/qAAAAAElFTkSuQmCC); display:block; height:44px; margin:0 auto -44px; position:relative; top:-22px; width:44px;' }) | ||
), | ||
' ', | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'p', | ||
{ style: ' margin:8px 0 0 0; padding:0 4px;' }, | ||
' ', | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'a', | ||
@@ -45,3 +45,3 @@ { href: url, style: ' color:#000; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:normal; line-height:17px; text-decoration:none; word-wrap:break-word;', target: '_blank' }, | ||
' ', | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'p', | ||
@@ -54,3 +54,3 @@ { style: ' color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; line-height:17px; margin-bottom:0; margin-top:8px; overflow:hidden; padding:8px 0 7px; text-align:center; text-overflow:ellipsis; white-space:nowrap;' }, | ||
') on ', | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'time', | ||
@@ -71,19 +71,19 @@ { style: ' font-family:Arial,sans-serif; font-size:14px; line-height:17px;', datetime: date.utc }, | ||
var date = _ref2.date; | ||
return (0, _virtualElement2.default)( | ||
return (0, _magicVirtualElement2.default)( | ||
'blockquote', | ||
{ 'class': 'instagram-media', 'data-instgrm-version': '6', style: ' background:#FFF; border:0; border-radius:3px; box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width:658px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);' }, | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'div', | ||
{ style: 'padding:8px;' }, | ||
' ', | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'div', | ||
{ style: ' background:#F8F8F8; line-height:0; margin-top:40px; padding:50.0% 0; text-align:center; width:100%;' }, | ||
' ', | ||
(0, _virtualElement2.default)('div', { style: ' background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAsCAMAAAApWqozAAAAGFBMVEUiIiI9PT0eHh4gIB4hIBkcHBwcHBwcHBydr+JQAAAACHRSTlMABA4YHyQsM5jtaMwAAADfSURBVDjL7ZVBEgMhCAQBAf//42xcNbpAqakcM0ftUmFAAIBE81IqBJdS3lS6zs3bIpB9WED3YYXFPmHRfT8sgyrCP1x8uEUxLMzNWElFOYCV6mHWWwMzdPEKHlhLw7NWJqkHc4uIZphavDzA2JPzUDsBZziNae2S6owH8xPmX8G7zzgKEOPUoYHvGz1TBCxMkd3kwNVbU0gKHkx+iZILf77IofhrY1nYFnB/lQPb79drWOyJVa/DAvg9B/rLB4cC+Nqgdz/TvBbBnr6GBReqn/nRmDgaQEej7WhonozjF+Y2I/fZou/qAAAAAElFTkSuQmCC); display:block; height:44px; margin:0 auto -44px; position:relative; top:-22px; width:44px;' }) | ||
(0, _magicVirtualElement2.default)('div', { style: ' background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAsCAMAAAApWqozAAAAGFBMVEUiIiI9PT0eHh4gIB4hIBkcHBwcHBwcHBydr+JQAAAACHRSTlMABA4YHyQsM5jtaMwAAADfSURBVDjL7ZVBEgMhCAQBAf//42xcNbpAqakcM0ftUmFAAIBE81IqBJdS3lS6zs3bIpB9WED3YYXFPmHRfT8sgyrCP1x8uEUxLMzNWElFOYCV6mHWWwMzdPEKHlhLw7NWJqkHc4uIZphavDzA2JPzUDsBZziNae2S6owH8xPmX8G7zzgKEOPUoYHvGz1TBCxMkd3kwNVbU0gKHkx+iZILf77IofhrY1nYFnB/lQPb79drWOyJVa/DAvg9B/rLB4cC+Nqgdz/TvBbBnr6GBReqn/nRmDgaQEej7WhonozjF+Y2I/fZou/qAAAAAElFTkSuQmCC); display:block; height:44px; margin:0 auto -44px; position:relative; top:-22px; width:44px;' }) | ||
), | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'p', | ||
{ style: ' color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; line-height:17px; margin-bottom:0; margin-top:8px; overflow:hidden; padding:8px 0 7px; text-align:center; text-overflow:ellipsis; white-space:nowrap;' }, | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'a', | ||
@@ -98,3 +98,3 @@ { href: url, style: ' color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:normal; line-height:17px; text-decoration:none;', target: '_blank' }, | ||
' on ', | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'time', | ||
@@ -101,0 +101,0 @@ { style: ' font-family:Arial,sans-serif; font-size:14px; line-height:17px;', datetime: date.utc }, |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.render = exports.renderUser = exports.parse = undefined; | ||
exports.render = exports.parse = undefined; | ||
@@ -19,5 +19,5 @@ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
var _virtualElement = require('virtual-element'); | ||
var _magicVirtualElement = require('magic-virtual-element'); | ||
var _virtualElement2 = _interopRequireDefault(_virtualElement); | ||
var _magicVirtualElement2 = _interopRequireDefault(_magicVirtualElement); | ||
@@ -67,6 +67,8 @@ var _parseText = require('../parse-text'); | ||
if (!elm.classList.contains('twitter-tweet')) { | ||
if (!elm.classList.contains('twitter-tweet') && !elm.classList.contains('twitter-video')) { | ||
return null; | ||
} | ||
var embedAs = elm.classList.contains('twitter-video') ? 'video' : 'tweet'; | ||
var aElm = (0, _lodash4.default)(elm.getElementsByTagName('a')); | ||
@@ -83,10 +85,6 @@ var url = aElm.getAttribute('href'); | ||
return { user: user, date: date, text: text, id: id, url: url, type: type }; | ||
return { embedAs: embedAs, user: user, date: date, text: text, id: id, url: url, type: type }; | ||
}; | ||
var renderUser = exports.renderUser = function renderUser(user) { | ||
return user && user.name && user.slug ? '— ' + user.name + ' (@' + user.slug + ') ' : ''; | ||
}; | ||
var render = exports.render = function render(_ref3) { | ||
var renderVideo = function renderVideo(_ref3) { | ||
var text = _ref3.text; | ||
@@ -97,6 +95,6 @@ var url = _ref3.url; | ||
var id = _ref3.id; | ||
return (0, _virtualElement2.default)( | ||
return (0, _magicVirtualElement2.default)( | ||
'blockquote', | ||
{ 'class': 'twitter-tweet', lang: 'en' }, | ||
(0, _virtualElement2.default)( | ||
{ 'class': 'twitter-video', 'data-lang': 'en' }, | ||
(0, _magicVirtualElement2.default)( | ||
'p', | ||
@@ -107,3 +105,3 @@ { lang: 'en', dir: 'ltr' }, | ||
renderUser(user), | ||
(0, _virtualElement2.default)( | ||
(0, _magicVirtualElement2.default)( | ||
'a', | ||
@@ -114,2 +112,38 @@ { href: url }, | ||
); | ||
}; | ||
var renderTweet = function renderTweet(_ref4) { | ||
var text = _ref4.text; | ||
var url = _ref4.url; | ||
var date = _ref4.date; | ||
var user = _ref4.user; | ||
var id = _ref4.id; | ||
return (0, _magicVirtualElement2.default)( | ||
'blockquote', | ||
{ 'class': 'twitter-tweet', 'data-lang': 'en' }, | ||
(0, _magicVirtualElement2.default)( | ||
'p', | ||
{ lang: 'en', dir: 'ltr' }, | ||
(0, _renderText2.default)(text) | ||
), | ||
renderUser(user), | ||
(0, _magicVirtualElement2.default)( | ||
'a', | ||
{ href: url }, | ||
date | ||
) | ||
); | ||
}; | ||
var renderUser = function renderUser(user) { | ||
return user && user.name && user.slug ? '— ' + user.name + ' (@' + user.slug + ') ' : ''; | ||
}; | ||
var renderTypes = { | ||
video: renderVideo, | ||
tweet: renderTweet | ||
}; | ||
var render = exports.render = function render(opts) { | ||
return renderTypes[opts.embedAs] ? renderTypes[opts.embedAs](opts) : renderTypes.tweet(opts); | ||
}; |
@@ -18,5 +18,5 @@ 'use strict'; | ||
var _virtualElement = require('virtual-element'); | ||
var _magicVirtualElement = require('magic-virtual-element'); | ||
var _virtualElement2 = _interopRequireDefault(_virtualElement); | ||
var _magicVirtualElement2 = _interopRequireDefault(_magicVirtualElement); | ||
@@ -71,3 +71,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var type = _ref3.type; | ||
return (0, _virtualElement2.default)('source', { src: src, type: type }); | ||
return (0, _magicVirtualElement2.default)('source', { src: src, type: type }); | ||
}; | ||
@@ -79,3 +79,3 @@ | ||
var height = _ref4.height; | ||
return (0, _virtualElement2.default)( | ||
return (0, _magicVirtualElement2.default)( | ||
'video', | ||
@@ -82,0 +82,0 @@ { width: width, height: height }, |
/* eslint-disable deku/no-unknown-property */ | ||
import element from 'virtual-element'; | ||
import element from 'magic-virtual-element'; | ||
@@ -4,0 +4,0 @@ export default ({src, width, height, allowFullscreen}) => |
@@ -1,2 +0,2 @@ | ||
import element from 'virtual-element'; | ||
import element from 'magic-virtual-element'; | ||
@@ -3,0 +3,0 @@ export default text => |
const type = 'facebook'; | ||
import element from 'virtual-element'; | ||
import element from 'magic-virtual-element'; | ||
import parseText from '../parse-text'; | ||
@@ -4,0 +4,0 @@ import renderText from '../render-text'; |
import getDimensions from '../dimensions'; | ||
import element from 'virtual-element'; | ||
import element from 'magic-virtual-element'; | ||
@@ -4,0 +4,0 @@ export const parse = ([elm]) => { |
/* eslint-disable deku/no-unknown-property */ | ||
// ^^^ is needed to not get errors around datetime="" below | ||
import element from 'virtual-element'; | ||
import element from 'magic-virtual-element'; | ||
@@ -6,0 +6,0 @@ const renderWithCaption = ({url, text, user, date}) => |
import find from 'lodash.find'; | ||
import last from 'lodash.last'; | ||
import element from 'virtual-element'; | ||
import element from 'magic-virtual-element'; | ||
import parseText from '../parse-text'; | ||
@@ -34,6 +34,8 @@ import renderText from '../render-text'; | ||
export const parse = ([elm]) => { | ||
if (!elm.classList.contains('twitter-tweet')) { | ||
if (!elm.classList.contains('twitter-tweet') && !elm.classList.contains('twitter-video')) { | ||
return null; | ||
} | ||
const embedAs = elm.classList.contains('twitter-video') ? 'video' : 'tweet'; | ||
const aElm = last(elm.getElementsByTagName('a')); | ||
@@ -50,6 +52,20 @@ const url = aElm.getAttribute('href'); | ||
return {user, date, text, id, url, type}; | ||
return {embedAs, user, date, text, id, url, type}; | ||
}; | ||
export const renderUser = user => | ||
const renderVideo = ({text, url, date, user, id}) => | ||
(<blockquote class='twitter-video' data-lang='en'> | ||
<p lang='en' dir='ltr'>{renderText(text)}</p> | ||
{renderUser(user)} | ||
<a href={url}>{date}</a> | ||
</blockquote>); | ||
const renderTweet = ({text, url, date, user, id}) => | ||
(<blockquote class='twitter-tweet' data-lang='en'> | ||
<p lang='en' dir='ltr'>{renderText(text)}</p> | ||
{renderUser(user)} | ||
<a href={url}>{date}</a> | ||
</blockquote>); | ||
const renderUser = user => | ||
user && user.name && user.slug | ||
@@ -59,7 +75,7 @@ ? `— ${user.name} (@${user.slug}) ` | ||
export const render = ({text, url, date, user, id}) => | ||
<blockquote class='twitter-tweet' lang='en'> | ||
<p lang='en' dir='ltr'>{renderText(text)}</p> | ||
{renderUser(user)} | ||
<a href={url}>{date}</a> | ||
</blockquote>; | ||
const renderTypes = { | ||
video: renderVideo, | ||
tweet: renderTweet | ||
}; | ||
export const render = opts => renderTypes[opts.embedAs] ? renderTypes[opts.embedAs](opts) : renderTypes.tweet(opts); |
import getDimensions from '../dimensions'; | ||
import map from 'lodash.map'; | ||
import element from 'virtual-element'; | ||
import element from 'magic-virtual-element'; | ||
@@ -5,0 +5,0 @@ const type = 'video'; |
{ | ||
"name": "embeds", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"description": "Parse & render embeds", | ||
@@ -38,3 +38,2 @@ "main": "dist/index.js", | ||
"browserify": "^13.0.0", | ||
"deku": "^1.0.0", | ||
"electron-prebuilt": "^0.37.7", | ||
@@ -53,2 +52,3 @@ "faucet": "0.0.1", | ||
"embedly-url": "^1.0.0", | ||
"deku": "^1.0.0", | ||
"get-youtube-id": "^1.0.0", | ||
@@ -61,4 +61,4 @@ "lodash.find": "^4.2.0", | ||
"lodash.values": "^4.1.0", | ||
"virtual-element": "^1.2.0" | ||
"magic-virtual-element": "^1.0.6" | ||
} | ||
} |
@@ -11,3 +11,4 @@ const fs = require('fs'); | ||
facebookEmbedCode: fs.readFileSync(`${__dirname}/facebook-embed-code.html`, 'utf8').trim(), | ||
tweetNoUser: fs.readFileSync(`${__dirname}/tweet-no-user.html`, 'utf8').trim() | ||
tweetNoUser: fs.readFileSync(`${__dirname}/tweet-no-user.html`, 'utf8').trim(), | ||
tweetVideo: fs.readFileSync(`${__dirname}/tweet-video.html`, 'utf8').trim() | ||
}; |
@@ -175,6 +175,7 @@ import test from './tape-wrapper'; | ||
test('parse() tweet - normal', t => { | ||
const input = `<blockquote class="twitter-tweet" lang="en"><p lang="en" dir="ltr">GIF vs. JIF… This <a href="https://t.co/qFAHWgdbL6">pic.twitter.com/qFAHWgdbL6</a></p>— Matt (foo) Navarra (@MattNavarra) <a href="https://twitter.com/MattNavarra/status/684690494841028608">January 6, 2016</a></blockquote><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>`; | ||
const input = `<blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">GIF vs. JIF… This <a href="https://t.co/qFAHWgdbL6">pic.twitter.com/qFAHWgdbL6</a></p>— Matt (foo) Navarra (@MattNavarra) <a href="https://twitter.com/MattNavarra/status/684690494841028608">January 6, 2016</a></blockquote><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>`; | ||
const actual = parse(input); | ||
const expected = { | ||
type: 'twitter', | ||
embedAs: 'tweet', | ||
text: [ | ||
@@ -195,7 +196,35 @@ {content: 'GIF vs. JIF… This ', href: null}, | ||
test('parse() tweet - video', t => { | ||
const input = `<blockquote class="twitter-video" data-lang="en"><p lang="en" dir="ltr">Surfer <a href="https://twitter.com/bethanyhamilton">@bethanyhamilton</a>, who lost her arm in a 2003 shark attack, finishes 3rd in <a href="https://twitter.com/wsl">@wsl</a> Fiji. <a href="https://twitter.com/hashtag/VideoOfTheDay?src=hash">#VideoOfTheDay</a> <a href="https://t.co/elSAwTdP6L">pic.twitter.com/elSAwTdP6L</a></p>— Twitter Video (@video) <a href="https://twitter.com/video/status/737840608895762432">June 1, 2016</a></blockquote><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>`; | ||
const actual = parse(input); | ||
const expected = { | ||
type: 'twitter', | ||
embedAs: 'video', | ||
text: [ | ||
{content: 'Surfer ', href: null}, | ||
{content: '@bethanyhamilton', href: 'https://twitter.com/bethanyhamilton'}, | ||
{content: ', who lost her arm in a 2003 shark attack, finishes 3rd in ', href: null}, | ||
{content: '@wsl', href: 'https://twitter.com/wsl'}, | ||
{content: ' Fiji. ', href: null}, | ||
{content: '#VideoOfTheDay', href: 'https://twitter.com/hashtag/VideoOfTheDay?src=hash'}, | ||
{content: ' ', href: null}, | ||
{content: 'pic.twitter.com/elSAwTdP6L', href: 'https://t.co/elSAwTdP6L'} | ||
], | ||
url: 'https://twitter.com/video/status/737840608895762432', | ||
date: 'June 1, 2016', | ||
user: { | ||
slug: 'video', | ||
name: 'Twitter Video' | ||
}, | ||
id: '737840608895762432' | ||
}; | ||
t.deepEqual(actual, expected); | ||
}); | ||
test('parse() tweet - no date', t => { | ||
const input = `<blockquote class="twitter-tweet" lang="en"><p lang="en" dir="ltr">GIF vs. JIF… This <a href="https://t.co/qFAHWgdbL6">pic.twitter.com/qFAHWgdbL6</a></p>— Matt (foo) Navarra (@MattNavarra) <a href="https://twitter.com/MattNavarra/status/684690494841028608"></a></blockquote><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>`; | ||
const input = `<blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">GIF vs. JIF… This <a href="https://t.co/qFAHWgdbL6">pic.twitter.com/qFAHWgdbL6</a></p>— Matt (foo) Navarra (@MattNavarra) <a href="https://twitter.com/MattNavarra/status/684690494841028608"></a></blockquote><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>`; | ||
const actual = parse(input); | ||
const expected = { | ||
type: 'twitter', | ||
embedAs: 'tweet', | ||
text: [ | ||
@@ -217,3 +246,3 @@ {content: 'GIF vs. JIF… This ', href: null}, | ||
test('parse() tweet - weird input', t => { | ||
const input = `<blockquote class="twitter-tweet" lang="en"><p lang="en" dir="ltr">foo bar<beep>boop</beep></p>— Matt Navarra (@MattNavarra) <a href="https://twitter.com/MattNavarra/status/684690494841028608">January 6, 2016</a></blockquote><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>`; | ||
const input = `<blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">foo bar<beep>boop</beep></p>— Matt Navarra (@MattNavarra) <a href="https://twitter.com/MattNavarra/status/684690494841028608">January 6, 2016</a></blockquote><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>`; | ||
const actual = parse(input).text; | ||
@@ -227,6 +256,7 @@ const expected = [ | ||
test('parse() tweet - no paragraph, no user', t => { | ||
const input = `<blockquote class="twitter-tweet" lang="en"><a href="https://twitter.com/MattNavarra/status/684690494841028608">January 6, 2016</a></blockquote><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>`; | ||
const input = `<blockquote class="twitter-tweet" data-lang="en"><a href="https://twitter.com/MattNavarra/status/684690494841028608">January 6, 2016</a></blockquote><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>`; | ||
const actual = parse(input); | ||
const expected = { | ||
type: 'twitter', | ||
embedAs: 'tweet', | ||
text: [], | ||
@@ -245,3 +275,3 @@ url: 'https://twitter.com/MattNavarra/status/684690494841028608', | ||
test('parse() tweet - no id', t => { | ||
const input = `<blockquote class="twitter-tweet" lang="en"><p lang="en" dir="ltr">GIF vs. JIF… This <a href="https://t.co/qFAHWgdbL6">pic.twitter.com/qFAHWgdbL6</a></p>— Matt (foo) Navarra (@MattNavarra) </blockquote><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>`; | ||
const input = `<blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">GIF vs. JIF… This <a href="https://t.co/qFAHWgdbL6">pic.twitter.com/qFAHWgdbL6</a></p>— Matt (foo) Navarra (@MattNavarra) </blockquote><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>`; | ||
const actual = parse(input); | ||
@@ -248,0 +278,0 @@ const expected = null; |
@@ -33,2 +33,9 @@ import test from './tape-wrapper'; | ||
test('parse() + render() twitter - video', t => { | ||
const input = fixtures.tweetVideo; | ||
const expected = input; | ||
const actual = parseAndRender(input); | ||
t.is(actual, expected); | ||
}); | ||
test('parse() + render() instagram - with caption', t => { | ||
@@ -35,0 +42,0 @@ const input = fixtures.instagramCaption; |
@@ -102,3 +102,3 @@ import test from './tape-wrapper'; | ||
const actual = render(input); | ||
const expected = tsml`<blockquote class="twitter-tweet" lang="en"> | ||
const expected = tsml`<blockquote class="twitter-tweet" data-lang="en"> | ||
<p lang="en" dir="ltr">GIF vs. JIF… This <a href="https://t.co/qFAHWgdbL6">pic.twitter.com/qFAHWgdbL6</a></p>— Matt (foo) Navarra (@MattNavarra) <a href="https://twitter.com/MattNavarra/status/684690494841028608">January 6, 2016</a> | ||
@@ -105,0 +105,0 @@ </blockquote>`; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
121107
18
60
2954
10
+ Addeddeku@^1.0.0
+ Addedmagic-virtual-element@^1.0.6
+ Addedclassnames@2.5.1(transitive)
+ Addedcomponent-emitter@1.2.0(transitive)
+ Addedcomponent-raf@1.2.0(transitive)
+ Addedcomponent-type@1.1.01.2.0(transitive)
+ Addeddeku@1.0.0(transitive)
+ Addedfast.js@0.1.1(transitive)
+ Addedget-uid@1.0.1(transitive)
+ Addedis-dom@1.0.5(transitive)
+ Addedis-svg-attribute@1.0.2(transitive)
+ Addedis-svg-element@1.0.1(transitive)
+ Addedmagic-virtual-element@1.0.6(transitive)
+ Addedobject-defaults@0.1.0(transitive)
+ Addedobject-path@0.9.2(transitive)
+ Addedsliced@1.0.1(transitive)
+ Addedto-style@1.3.3(transitive)
- Removedvirtual-element@^1.2.0