forked from danburzo/percollate
-
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.
Merge branch 'feature/blueprint' into develop
- Loading branch information
Showing
10 changed files
with
155 additions
and
50 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 |
---|---|---|
|
@@ -64,3 +64,4 @@ typings/ | |
.idea | ||
.project | ||
.settings | ||
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,84 @@ | ||
const fs = require('fs'); | ||
|
||
function defaultBlueprint() { | ||
return { | ||
cover: _defaultCover(), | ||
toc: _defaultToc(), | ||
document: _defaultDocument(), | ||
options: _defaultOptions() | ||
}; | ||
} | ||
|
||
function fromCommandLineOptions(urls, options) { | ||
let blueprint = null; | ||
if (options.blueprint) { | ||
blueprint = JSON.parse(fs.readFileSync(options.blueprint, 'utf8')); | ||
} else { | ||
blueprint = _parseCommandLineOptions(options, defaultBlueprint()); | ||
} | ||
if (urls && urls.length > 0) { | ||
blueprint.document.items = urls.map(function(url) { | ||
return { url: url }; | ||
}); | ||
} | ||
return blueprint; | ||
} | ||
|
||
function _parseCommandLineOptions(options, blueprint) { | ||
if (options.cover) { | ||
blueprint.cover['generate'] = options.cover; | ||
} | ||
if (options.toc) { | ||
blueprint.toc['generate'] = options.toc; | ||
} | ||
if (options.template) { | ||
blueprint.document['template'] = options.template; | ||
} | ||
if (options.style) { | ||
blueprint.document['css'] = options.style; | ||
} | ||
blueprint.options['sandbox'] = options.sandbox; | ||
blueprint.options['output'] = options.output; | ||
blueprint.options['individual'] = options.individual; | ||
blueprint.options['no-amp'] = options.amp; | ||
return blueprint; | ||
} | ||
|
||
function _defaultOptions() { | ||
return { | ||
output: 'percollate.pdf', | ||
individual: false, | ||
amp: true | ||
}; | ||
} | ||
|
||
function _defaultCover() { | ||
return { | ||
generate: false, | ||
template: './templates/default_cover.html', | ||
css: './templates/default_cover.css', | ||
assets: {} | ||
}; | ||
} | ||
|
||
function _defaultToc() { | ||
return { | ||
generate: false, | ||
template: './templates/default_toc.html', | ||
css: './templates/default_toc.css', | ||
assets: {} | ||
}; | ||
} | ||
|
||
function _defaultDocument() { | ||
return { | ||
template: './templates/default.html', | ||
css: './templates/default.css', | ||
assets: {}, | ||
items: [] | ||
}; | ||
} | ||
|
||
module.exports = { | ||
fromCommandLineOptions | ||
}; |
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
Empty file.
Empty file.
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,3 @@ | ||
nav.toc { | ||
page-break-after: always; | ||
} |
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,8 @@ | ||
<nav class="toc"> | ||
<h1>Items</h1> | ||
<ol> | ||
{% for item in items %} | ||
<li class="toc__line"><a href="#{{ item._id }}">{{ item.title }}</a></li> | ||
{% endfor %} | ||
</ol> | ||
</nav> |