New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cleaver

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cleaver - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

118

lib/cleaver.js

@@ -37,5 +37,7 @@ var fs = require('fs');

/**
* Renders the document
* Loads the document and required templates.
*
* @return {Promise}
*/
Cleaver.prototype._parseDocument = function () {
Cleaver.prototype._loadDocument = function () {
var self = this;

@@ -47,48 +49,52 @@

])
.then(function (data) {
var slices = self._slice(self.external.loaded.document);
self.metadata = yaml.safeLoad(slices[0]);
}
for (var i = 1; i < slices.length; i++) {
self.slides.push(md(slices[i]));
}
// insert an author slide (if necessary) at the end
if (self.metadata.author) {
self.slides.push(self._renderAuthorSlide(self.metadata.author));
}
/**
* Parses the metadata and renders the slides.
*
* @return {Promise}
*/
Cleaver.prototype._renderSlides = function () {
var self = this;
var slices = this._slice(self.external.loaded.document);
this.metadata = yaml.safeLoad(slices[0]);
// insert an agenda slide (if necessary) as our second slide
if (self.metadata.agenda) {
self.slides.splice(1, 0, self._renderAgendaSlide(slices));
}
for (var i = 1; i < slices.length; i++)
this.slides.push(md(slices[i]));
var promises = [];
// insert an author slide (if necessary) at the end
if (this.metadata.author)
this.slides.push(this._renderAuthorSlide(this.metadata.author));
// maybe load an external stylesheet
if (self.metadata.style) {
promises.push(helper.loadSingle(self.metadata.style)
.then(function (data) {
self.external.loaded.style = data;
}));
}
// insert an agenda slide (if necessary) as our second slide
if (this.metadata.agenda)
this.slides.splice(1, 0, this._renderAgendaSlide(slices));
// maybe load an external template
if (self.metadata.template) {
promises.push(helper.loadSingle(self.metadata.template)
.then(function (data) {
self.templates.loaded.slides = data;
}));
}
return Q.resolve(true);
}
// maybe load an external layout
if (self.metadata.layout) {
promises.push(helper.loadSingle(self.metadata.layout)
.then(function (data) {
self.templates.loaded.layout = data;
}));
}
return Q.all(promises);
});
/**
* Populates `slides` and some extra loaded content, based on the metadata
* listed in the document.
*
* @return {Promise}
*/
Cleaver.prototype._populateResources = function () {
var promises = [];
// maybe load an external stylesheet
if (this.metadata.style)
promises.push(helper.populateSingle(this.metadata.style, this.external, 'style'));
// maybe load an external template
if (this.metadata.template)
promises.push(helper.populateSingle(this.metadata.template, this.templates, 'slides'));
// maybe load an external layout
if (this.metadata.layout)
promises.push(helper.populateSingle(this.metadata.layout, this.templates, 'layout'));
return Q.all(promises);
}

@@ -100,5 +106,6 @@

* as defined by the user.
*
* @return {Promise.<Array.<Object>>}
*/
Cleaver.prototype._loadAssets = function () {
Cleaver.prototype._loadStaticAssets = function () {
return Q.all([

@@ -111,3 +118,5 @@ helper.load(this.resources, 'resources')

/**
* Renders the slideshow
* Renders the slideshow.
*
* @return {Promise}
*/

@@ -146,3 +155,4 @@ Cleaver.prototype._renderSlideshow = function () {

/**
* Renders the author slide
* Renders the author slide.
*
* @param {string} authorData The author field of the slideshow metadata

@@ -156,3 +166,4 @@ * @return {string} The formatted author slide

/*
* Renders the agenda slide
* Renders the agenda slide.
*
* @param {string} slices The set of slices that had been loaded from the input file

@@ -182,3 +193,4 @@ * @return {string} The formatted agenda slide

/**
* Returns a chopped up document that's easy to parse
* Returns a chopped up document that's easy to parse.
*
* @param {string} The full document

@@ -200,3 +212,5 @@ * @return {Array.<string>} A list of all slides

/**
* Method to run the whole show
* Method to run the whole show.
*
* @return {Promise}
*/

@@ -206,3 +220,11 @@ Cleaver.prototype.run = function () {

Q.all([this._parseDocument(), this._loadAssets()])
// Load document -> Parse Metadata / Render Slides -> Populate Resources
var documentChain = this._loadDocument()
.then(self._renderSlides.bind(self))
.then(self._populateResources.bind(self));
// Load static assets
var assetChain = this._loadStaticAssets();
return Q.all([documentChain, assetChain])
.then(self._renderSlideshow.bind(self))

@@ -215,3 +237,3 @@ .fail(function (err) {

/* exports */
module.exports = Cleaver;

@@ -24,2 +24,22 @@ var Q = require('q');

/**
* Loads a single asset and sets the returned data to the `loaded` subobject
* of a given resource map.
*
* Usage: helper.populateSingle(this.metadata.template, this.templates, 'slides')
* helper.populateSingle(this.metadata.layout, this.templates, 'layout')
*
* @param {string} filename The name and location of the file to load
* @param {Object} destination The destination map to store the loaded data
* @param {string} key The key to use for storing the loaded data in destination
* @return {Promise}
*/
function populateSingle(filename, destination, key) {
return loadSingle(filename)
.then(function (data) {
destination.loaded[key] = data;
});
}
/**
* Loads files from a given map and places them in that map's `loaded` field

@@ -62,5 +82,6 @@ * @param {Object} map The map of labels to filenames

/* exports */
exports.loadSingle = loadSingle;
exports.populateSingle = populateSingle;
exports.load = load;
exports.save = save;
{
"name": "cleaver",
"preferGlobal": true,
"version": "0.3.0",
"version": "0.3.1",
"author": "Jordan Scales <scalesjordan@gmail.com>",

@@ -6,0 +6,0 @@ "description": "30-second slideshows for hackers",

@@ -95,3 +95,3 @@ # Cleaver

* **encoding**: A specified content encoding (default: *utf-8*)
* **progress*: Option whether or not to display a small progress bar at the top of the page
* **progress**: Option whether or not to display a small progress bar at the top of the page
(default: *true*)

@@ -98,0 +98,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc