-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pre-rendering support using nbconvert is implemented. The only problem is the page renders a little funky with the pre-rendered html. Need to look into this more. Pre-rendering can be disabled by setting the `preRender` boolean in `./_config.js` to `false'.
- Loading branch information
Showing
11 changed files
with
417 additions
and
59 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* Created by tlyon on 5/18/17. | ||
*/ | ||
|
||
var sprintf = require('sprintf'); | ||
var exec = require('child_process').exec; | ||
var tmp = require('tmp'); | ||
var fs = require('fs'); | ||
var config = require('../_config'); | ||
|
||
function renderHTMLFromFile(file, id){ | ||
var outputDir = config.rootDirectory + config.filesDirectory | ||
var outputName = id; | ||
var templateLocation = '../assets/nbconvert/templates/notebookHTML.tpl' | ||
|
||
var command = sprintf('jupyter nbconvert %s --output=%s --output-dir=%s --template=%s', file.path, outputName, outputDir, templateLocation); | ||
|
||
exec(command, { | ||
maxBuffer: 1024*500 | ||
}, (err, stdout, stderr) => { | ||
if(err){ | ||
return {error: err} | ||
} | ||
}) | ||
} | ||
|
||
function renderHTMLFromJSON(json, id){ | ||
var outputDir = config.rootDirectory + config.filesDirectory | ||
var outputName = id; | ||
var templateLocation = config.rootDirectory + '/assets/nbconvert/templates/notebookHTML.tpl' | ||
|
||
var tmpObj = tmp.fileSync({ | ||
mode: 0644, | ||
prefix: 'prefix-', | ||
postfix: '.json' | ||
}); | ||
|
||
console.log('tmpObj: ', tmpObj); | ||
console.log('Output dir: ', outputDir); | ||
|
||
fs.writeFileSync(tmpObj.name, json); | ||
|
||
var command = sprintf('jupyter nbconvert %s --output=%s --output-dir=%s --template=%s', tmpObj.name, outputName, outputDir, templateLocation); | ||
|
||
console.log('Execute command'); | ||
exec(command, { | ||
maxBuffer: 1024*500 | ||
}, (err, stdout, stderr) => { | ||
if(err){ | ||
console.log('Error executing command: ', err); | ||
return {error: err} | ||
} else { | ||
console.log('No error executing command'); | ||
} | ||
}) | ||
} | ||
|
||
module.exports = {renderHTMLFromFile, renderHTMLFromJSON} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.