metalsmith-youtube
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -9,42 +9,7 @@ 'use strict'; | ||
var _fs = require('fs'); | ||
var _fs2 = _interopRequireDefault(_fs); | ||
var _path = require('path'); | ||
var _path2 = _interopRequireDefault(_path); | ||
var _debug = require('debug'); | ||
var _debug2 = _interopRequireDefault(_debug); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
(0, _debug2.default)('metalsmith-youtube'); | ||
/** | ||
* Metalsmith plugin to render Youtube Video | ||
* @param {Object} options (optional) | ||
* @return {Function} | ||
* Youtube iframe generator | ||
*/ | ||
function plugin(_options) { | ||
var options = _options || {}; | ||
return function (files, metalsmith, done) { | ||
var metadata = metalsmith.metadata(); | ||
var collections = metadata.collections; | ||
var colName = void 0, | ||
file = void 0, | ||
filePath = void 0; | ||
var app = new Youtube(options, files); | ||
app.parse(function () { | ||
done(); | ||
}); | ||
}; | ||
}; | ||
var Youtube = function () { | ||
@@ -66,2 +31,8 @@ function Youtube(options, files) { | ||
/** | ||
* Parse the content | ||
* @param cb callback {Function} | ||
*/ | ||
_createClass(Youtube, [{ | ||
@@ -72,11 +43,9 @@ key: 'parse', | ||
var self = this; | ||
Object.keys(this.files).forEach(function (file) { | ||
var article_text = _this.files[file].contents.toString(); | ||
var matches = _this._getYoutubes(article_text); | ||
var matches = _this._getYoutubes(_this.files[file].contents.toString()); | ||
if (matches !== null) { | ||
matches.forEach(function (element, index) { | ||
matches.forEach(function (element) { | ||
var id = element.split('|')[1]; | ||
var iframe = _this._createIframeBody(id, _this.options.width, _this.options.height); | ||
_this.files[file].contents = article_text.replace(element, iframe); | ||
_this.files[file].contents = _this.files[file].contents.toString().replace(element, iframe); | ||
}); | ||
@@ -87,2 +56,10 @@ } | ||
} | ||
/** | ||
* Return all youtube definitions within the body content | ||
* @param content | ||
* @returns {Array|{index: number, input: string}|*} | ||
* @private | ||
*/ | ||
}, { | ||
@@ -93,2 +70,12 @@ key: '_getYoutubes', | ||
} | ||
/** | ||
* Create a YouTube iframe | ||
* @param id the YouTube id | ||
* @param width iframe width | ||
* @param height iframe height | ||
* @returns {string} iframe as string | ||
* @private | ||
*/ | ||
}, { | ||
@@ -106,3 +93,3 @@ key: '_createIframeBody', | ||
url += this.options.controls ? '&controls=0' : ''; | ||
var iframe = '<iframe width="' + width + '" height="' + height + '" src="' + url + '" frameborder="0" allowfullscreen></iframe>'; | ||
var iframe = '<iframe width=\'' + width + '\' height=\'' + height + '\' src=\'' + url + '\' frameborder=\'0\' allowfullscreen></iframe>'; | ||
return iframe; | ||
@@ -116,6 +103,21 @@ } | ||
/** | ||
* Metalsmith plugin to render Youtube Video | ||
* @param {Object} options (optional) | ||
* @return {Function} | ||
*/ | ||
function plugin(_options) { | ||
var options = _options || {}; | ||
return function (files, metalsmith, done) { | ||
var app = new Youtube(options, files); | ||
app.parse(function () { | ||
done(); | ||
}); | ||
}; | ||
} | ||
/** | ||
* Expose `plugin`. | ||
*/ | ||
exports = module.exports = plugin; |
{ | ||
"name": "metalsmith-youtube", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A Metalsmith plugin that lets you get embed Youtube Videos", | ||
@@ -10,3 +10,4 @@ "main": "lib/index.js", | ||
"prepublish": "npm run build", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"lint": "eslint --ext .js -c .eslintrc --quiet src/* ", | ||
"test": "npm run lint && npm run build && mocha" | ||
}, | ||
@@ -18,2 +19,6 @@ "keywords": [ | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/juanpicado/metalsmith-youtube.git" | ||
}, | ||
"author": "Juan Picado <juanpicado19@gmail.com> (https://www.jotadeveloper.com/)", | ||
@@ -31,4 +36,8 @@ "license": "MIT", | ||
"babel-plugin-transform-object-assign": "^6.8.0", | ||
"babel-preset-es2015": "^6.16.0" | ||
"babel-preset-es2015": "^6.16.0", | ||
"chai": "^3.5.0", | ||
"eslint": "^0.23.0", | ||
"metalsmith": "^1.7.0", | ||
"mocha": "^2.2.5" | ||
} | ||
} |
@@ -5,2 +5,4 @@ # metalsmith-youtube | ||
[![Build Status](https://travis-ci.org/juanpicado/metalsmith-youtube.svg?branch=master)](https://travis-ci.org/juanpicado/metalsmith-youtube) | ||
## Installation | ||
@@ -7,0 +9,0 @@ |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
6996
4
97
1
61
0
7