Comparing version 0.4.0 to 0.4.1
title: Basic Example | ||
author: | ||
name: "Jordan Scales" | ||
twitter: "@jdan" | ||
url: "http://jordanscales.com" | ||
name: Jordan Scales | ||
twitter: jdan | ||
url: http://jordanscales.com | ||
output: basic.html | ||
@@ -45,1 +45,14 @@ | ||
* currency ¤ $ ¢ € ₠ £ ¥ | ||
-- | ||
### A code example | ||
// cool looking code | ||
var func = function (arg1) { | ||
return function (arg2) { | ||
return "arg1: " + arg1 + "arg2: " + arg2; | ||
}; | ||
}; | ||
console.log(func(1)(2)); // result is three |
@@ -1,5 +0,6 @@ | ||
var fs = require('fs'); | ||
var Q = require('q'); | ||
var fs = require('fs'); | ||
var Q = require('q'); | ||
var path = require('path'); | ||
var md = require('node-markdown').Markdown; | ||
var marked = require('marked'); | ||
var hljs = require('highlight.js'); | ||
var yaml = require('js-yaml'); | ||
@@ -23,2 +24,3 @@ var mustache = require('mustache'); | ||
style: 'default.css', | ||
githubStyle: 'github.css', | ||
navigation: 'navigation.js' | ||
@@ -33,2 +35,9 @@ }; | ||
this.slides = []; | ||
marked.setOptions({ | ||
gfm: true, | ||
highlight: function (code) { | ||
return hljs.highlightAuto(code).value; | ||
} | ||
}); | ||
} | ||
@@ -42,3 +51,3 @@ | ||
*/ | ||
Cleaver.prototype._loadDocument = function () { | ||
Cleaver.prototype.loadDocument = function () { | ||
var self = this; | ||
@@ -49,3 +58,3 @@ | ||
helper.load(this.templates, 'templates') | ||
]) | ||
]); | ||
} | ||
@@ -59,17 +68,21 @@ | ||
*/ | ||
Cleaver.prototype._renderSlides = function () { | ||
Cleaver.prototype.renderSlides = function () { | ||
var self = this; | ||
var slices = this._slice(self.external.loaded.document); | ||
var slices = this.slice(self.external.loaded.document); | ||
this.metadata = yaml.safeLoad(slices[0]) || {}; | ||
for (var i = 1; i < slices.length; i++) | ||
this.slides.push(md(slices[i])); | ||
this.slides.push(this.renderSlide(slices[i])); | ||
// insert an author slide (if necessary) at the end | ||
if (this.metadata.author) | ||
this.slides.push(this._renderAuthorSlide(this.metadata.author)); | ||
if (this.metadata.author) { | ||
if (!this.metadata.author.twitter.match(/^@/)) { | ||
this.metadata.author.twitter = '@' + this.metadata.author.twitter; | ||
} | ||
this.slides.push(this.renderAuthorSlide(this.metadata.author)); | ||
} | ||
// insert an agenda slide (if necessary) as our second slide | ||
if (this.metadata.agenda) | ||
this.slides.splice(1, 0, this._renderAgendaSlide(slices)); | ||
this.slides.splice(1, 0, this.renderAgendaSlide(slices)); | ||
@@ -86,3 +99,3 @@ return Q.resolve(true); | ||
*/ | ||
Cleaver.prototype._populateResources = function () { | ||
Cleaver.prototype.populateResources = function () { | ||
var promises = [], file; | ||
@@ -92,3 +105,3 @@ | ||
if (this.metadata.style) { | ||
file = this._normalizePath(this.metadata.style); | ||
file = this.normalizePath(this.metadata.style); | ||
promises.push(helper.populateSingle(file, this.external, 'style')); | ||
@@ -99,3 +112,3 @@ } | ||
if (this.metadata.template) { | ||
file = this._normalizePath(this.metadata.template); | ||
file = this.normalizePath(this.metadata.template); | ||
promises.push(helper.populateSingle(file, this.templates, 'slides')); | ||
@@ -106,3 +119,3 @@ } | ||
if (this.metadata.layout) { | ||
file = this._normalizePath(this.metadata.layout); | ||
file = this.normalizePath(this.metadata.layout); | ||
promises.push(helper.populateSingle(file, this.templates, 'layout')); | ||
@@ -121,3 +134,3 @@ } | ||
*/ | ||
Cleaver.prototype._loadStaticAssets = function () { | ||
Cleaver.prototype.loadStaticAssets = function () { | ||
return Q.all([ | ||
@@ -134,3 +147,3 @@ helper.load(this.resources, 'resources') | ||
*/ | ||
Cleaver.prototype._renderSlideshow = function () { | ||
Cleaver.prototype.renderSlideshow = function () { | ||
var putControls = this.metadata.controls || (this.metadata.controls === undefined); | ||
@@ -151,2 +164,7 @@ var putProgress = this.metadata.progress || (this.metadata.progress === undefined); | ||
var encoding = this.metadata.encoding || 'utf-8'; | ||
var style = [ | ||
this.resources.loaded.style, | ||
this.resources.loaded.githubStyle, | ||
this.external.loaded.style | ||
].join('\n'); | ||
@@ -157,4 +175,3 @@ var layoutData = { | ||
encoding: encoding, | ||
style: this.resources.loaded.style, | ||
externalStyle: this.external.loaded.style | ||
style: style | ||
}; | ||
@@ -169,9 +186,20 @@ | ||
/** | ||
* Renders a slide. | ||
* | ||
* @param {string} content Markdown content to be rendered as a slide | ||
* @return {string} The formatted slide | ||
*/ | ||
Cleaver.prototype.renderSlide = function (content) { | ||
return marked(content); | ||
} | ||
/** | ||
* Renders the author slide. | ||
* | ||
* @param {string} authorData The author field of the slideshow metadata | ||
* @param {string} content The author field of the slideshow metadata | ||
* @return {string} The formatted author slide | ||
*/ | ||
Cleaver.prototype._renderAuthorSlide = function (authorData) { | ||
return mustache.render(this.templates.loaded.author, authorData); | ||
Cleaver.prototype.renderAuthorSlide = function (content) { | ||
return mustache.render(this.templates.loaded.author, content); | ||
} | ||
@@ -185,3 +213,3 @@ | ||
*/ | ||
Cleaver.prototype._renderAgendaSlide = function (slices) { | ||
Cleaver.prototype.renderAgendaSlide = function (slices) { | ||
var titles = []; | ||
@@ -212,3 +240,3 @@ var firstLine, lastTitle, matches; | ||
*/ | ||
Cleaver.prototype._slice = function(document) { | ||
Cleaver.prototype.slice = function(document) { | ||
var cuts = document.split(/\r?\n--\r?\n/); | ||
@@ -249,3 +277,3 @@ var slices = []; | ||
*/ | ||
Cleaver.prototype._normalizePath = function (pathname) { | ||
Cleaver.prototype.normalizePath = function (pathname) { | ||
if (pathname[0] == '/') return pathname; | ||
@@ -266,13 +294,13 @@ | ||
// Load document -> Parse Metadata / Render Slides -> Populate Resources | ||
var documentChain = this._loadDocument() | ||
.then(self._renderSlides.bind(self)) | ||
.then(self._populateResources.bind(self)); | ||
var documentChain = this.loadDocument() | ||
.then(self.renderSlides.bind(self)) | ||
.then(self.populateResources.bind(self)); | ||
// Load static assets | ||
var assetChain = this._loadStaticAssets(); | ||
var assetChain = this.loadStaticAssets(); | ||
return Q.all([documentChain, assetChain]) | ||
.then(self._renderSlideshow.bind(self)) | ||
.then(self.renderSlideshow.bind(self)) | ||
.fail(function (err) { | ||
throw err; | ||
console.log('!!', err.message); | ||
}); | ||
@@ -279,0 +307,0 @@ } |
{ | ||
"name": "cleaver", | ||
"preferGlobal": true, | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"author": "Jordan Scales <scalesjordan@gmail.com>", | ||
"description": "30-second slideshows for hackers", | ||
"keywords":[ | ||
"keywords": [ | ||
"markdown", | ||
@@ -21,10 +21,11 @@ "static", | ||
}, | ||
"dependencies" : { | ||
"dependencies": { | ||
"optimist": "0.3.5", | ||
"mustache": "0.7.0", | ||
"q": "0.9.6", | ||
"node-markdown": "0.1.1", | ||
"js-yaml": "2.1.0" | ||
"js-yaml": "2.1.0", | ||
"highlight.js": "~7.3.0", | ||
"marked": "~0.2.9" | ||
}, | ||
"license": "MIT" | ||
} |
@@ -11,5 +11,5 @@ # Cleaver | ||
author: | ||
name: "Jordan Scales" | ||
twitter: "@jdan" | ||
url: "http://jordanscales.com" | ||
name: Jordan Scales | ||
twitter: jdan | ||
url: http://jordanscales.com | ||
output: basic.html | ||
@@ -80,5 +80,5 @@ controls: true | ||
author: | ||
name: "Jordan Scales" | ||
twitter: "@jdan" | ||
url: "http://jordanscales.com" | ||
name: Jordan Scales | ||
twitter: jdan | ||
url: http://jordanscales.com | ||
output: basic.html | ||
@@ -88,3 +88,3 @@ controls: true | ||
The first section of any cleaver document is the metadata. Currently cleaver supports | ||
the following fields. | ||
the following fields. **All metadata is optional**. | ||
@@ -97,3 +97,5 @@ **Ordinary Users** | ||
* **url**: A url to your website | ||
* **twitter**: Your twitter handle | ||
* **twitter**: Your twitter handle (*please note that the character '@' | ||
must be wrapped in quotes - e.g. "@jdan" - as per the YAML specification*) | ||
* **email**: Your email address | ||
* **style**: An optional stylesheet to load | ||
@@ -100,0 +102,0 @@ * **output**: A location to save the rendered document (default: *FILENAME-cleaver.html*) |
Sorry, the diff of this file is not supported yet
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
27492
18
702
205
6
+ Addedhighlight.js@~7.3.0
+ Addedmarked@~0.2.9
+ Addedhighlight.js@7.3.0(transitive)
+ Addedmarked@0.2.10(transitive)
- Removednode-markdown@0.1.1
- Removednode-markdown@0.1.1(transitive)