-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
5,696 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/node_modules | ||
*.DS_Store | ||
test/fixtures/_build | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
var cheerio = require('cheerio'); | ||
var Inky = require('../lib/inky'); | ||
|
||
var inky; | ||
|
||
window.setupInky = function(opts, cb) { | ||
opts = opts || {}; | ||
opts.cheerio = Inky.mergeCheerioOpts(opts.cheerio); | ||
if (typeof inky === 'undefined') { | ||
inky = new Inky(opts); | ||
} | ||
|
||
// This transform function takes in an element and calls a callback. | ||
function transform(html, callback) { | ||
var convertedHtml = inky.releaseTheKraken(html, opts.cheerio); | ||
callback(null, convertedHtml); | ||
} | ||
|
||
cb(transform); | ||
} | ||
|
||
if(typeof(window) !== 'undefined') { | ||
window.runInky = function(opts, elem) { | ||
if(typeof(elem) === 'undefined') { | ||
elem = opts; | ||
opts = {}; | ||
} | ||
window.setupInky(opts, function(transform) { | ||
transform(elem.outerHTML, function(err, html) { | ||
if(err === null) { | ||
elem.outerHTML = html; | ||
} else { | ||
console.log(err); | ||
} | ||
}); | ||
}); | ||
} | ||
var elems = document.body.getElementsByTagName('container') | ||
for(var i = 0; i < elems.length; i++) { | ||
window.runInky(elems[i]); | ||
} | ||
} | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
var browserify = require('browserify'); | ||
var gulp = require('gulp'); | ||
var source = require('vinyl-source-stream'); | ||
var buffer = require('vinyl-buffer'); | ||
var uglify = require('gulp-uglify'); | ||
|
||
gulp.task('browser', function() { | ||
var b = browserify({ | ||
entries: 'bin/inky-browser.js', | ||
debug: false | ||
}); | ||
|
||
return b.bundle() | ||
.pipe(source('inky-browser.js')) | ||
.pipe(buffer()) | ||
.pipe(uglify()) | ||
.pipe(gulp.dest('./dist/')); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.