Skip to content

Commit

Permalink
updating pagify bookify with appropriate bindings to whitelisted tags
Browse files Browse the repository at this point in the history
  • Loading branch information
marvindanig committed Mar 26, 2019
1 parent cda44e4 commit ef82432
Show file tree
Hide file tree
Showing 12 changed files with 1,689 additions and 940 deletions.
55 changes: 55 additions & 0 deletions LICENSE.md
@@ -0,0 +1,55 @@
# Blue Oak Model License

Version 1.0.0

## Purpose

This license gives everyone as much permission to work with
this software as possible, while protecting contributors
from liability.

## Acceptance

In order to receive this license, you must agree to its
rules. The rules of this license are both obligations
under that agreement and conditions to your license.
You must not do anything with this software that triggers
a rule that you cannot or will not follow.

## Copyright

Each contributor licenses you to do everything with this
software that would otherwise infringe that contributor's
copyright in it.

## Notices

You must ensure that everyone who gets a copy of
any part of this software from you, with or without
changes, also gets the text of this license or a link to
<https://blueoakcouncil.org/license/1.0.0>.

## Excuse

If anyone notifies you in writing that you have not
complied with [Notices](#notices), you can keep your
license by taking all practical steps to comply within 30
days after the notice. If you do not do so, your license
ends immediately.

## Patent

Each contributor licenses you to do everything with this
software that would otherwise infringe any patent claims
they can license or become able to license.

## Reliability

No contributor can revoke this license.

## No Liability

***As far as the law allows, this software comes as is,
without any warranty or condition, and no contributor
will be liable to anyone for any damages related to this
software or this license, under any kind of legal claim.***
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -11,7 +11,7 @@ Commands:
fetch|f [options] Fetch single markdown long-scroll (.md, .markdown or .txt )
sanitize|s Sanitize your HTML inline with Bookiza requirements
objectify|o Objectify into a Array-like Json
pagify|p Pagination with formatting!
pagify|p Pagination with line-tracking!
bookify|b Apply templates to form actual pages


Expand Down
394 changes: 263 additions & 131 deletions interim/tmp/.book

Large diffs are not rendered by default.

18 changes: 13 additions & 5 deletions interim/tmp/.index
@@ -1,7 +1,15 @@
{
"0": "<li><a class = \"page\" href=\"9\"> Franz Kafka </a> <span class=\"flex\">9</span> </li>",
"1": "<li><a class = \"page\" href=\"10\"> Translated by David Wyllie </a> <span class=\"flex\">10</span> </li>",
"2": "<li><a class = \"page\" href=\"11\"> PART I </a> <span class=\"flex\">11</span> </li>",
"3": "<li><a class = \"page\" href=\"52\"> Part II </a> <span class=\"flex\">52</span> </li>",
"4": "<li><a class = \"page\" href=\"95\"> PART III </a> <span class=\"flex\">95</span> </li>"
"0": "<li><a class = \"page\" href=\"42\"> Book I. </a> <span class=\"flex\">42</span> </li>",
"1": "<li><a class = \"page\" href=\"60\"> Book II. </a> <span class=\"flex\">60</span> </li>",
"2": "<li><a class = \"page\" href=\"74\"> Book III. </a> <span class=\"flex\">74</span> </li>",
"3": "<li><a class = \"page\" href=\"90\"> Book IV. </a> <span class=\"flex\">90</span> </li>",
"4": "<li><a class = \"page\" href=\"115\"> Book V. </a> <span class=\"flex\">115</span> </li>",
"5": "<li><a class = \"page\" href=\"140\"> Book VI. </a> <span class=\"flex\">140</span> </li>",
"6": "<li><a class = \"page\" href=\"165\"> Book VII. </a> <span class=\"flex\">165</span> </li>",
"7": "<li><a class = \"page\" href=\"191\"> Book VIII. </a> <span class=\"flex\">191</span> </li>",
"8": "<li><a class = \"page\" href=\"217\"> Book IX. </a> <span class=\"flex\">217</span> </li>",
"9": "<li><a class = \"page\" href=\"241\"> Book X. </a> <span class=\"flex\">241</span> </li>",
"10": "<li><a class = \"page\" href=\"265\"> Book XI. </a> <span class=\"flex\">265</span> </li>",
"11": "<li><a class = \"page\" href=\"286\"> Book XII. </a> <span class=\"flex\">286</span> </li>",
"12": "<li><a class = \"page\" href=\"304\"> THE END. </a> <span class=\"flex\">304</span> </li>"
}
26 changes: 11 additions & 15 deletions lib/bookify.js
Expand Up @@ -11,21 +11,21 @@ function bookify() {

let promises = []

// if (bookLength % 2 === 0) { /* Insert Back Cover and a few empty pages on the book after the manuscript */
// promises.push(fse.copy(path.join(__dirname, '..', 'last', 'page-2n-1'), path.join('.', 'manuscript', `page-${bookLength + 1}`)).catch(err => console.log(err)))
// promises.push(fse.copy(path.join(__dirname, '..', 'last', 'page-2n'), path.join('.', 'manuscript', `page-${bookLength + 2}`)).catch(err => console.log(err)))
// } else {
// promises.push(fse.copy(path.join(__dirname, '..', 'last', 'page-2n-1'), path.join('.', 'manuscript', `page-${bookLength + 1}`)).catch(err => console.log(err)))
// promises.push(fse.copy(path.join(__dirname, '..', 'last', 'page-2n-1'), path.join('.', 'manuscript', `page-${bookLength + 2}`)).catch(err => console.log(err)))
// promises.push(fse.copy(path.join(__dirname, '..', 'last', 'page-2n'), path.join('.', 'manuscript', `page-${bookLength + 3}`)).catch(err => console.log(err)))
// }

for (const page in book) {
if (book.hasOwnProperty(page)) {
const TEMPLATE_START = '<div class="leaf flex"><div class="inner justify">'
const PAGE_TEMPLATE_START = '<div class="leaf flex"><div class="inner justify">'
const HEADING_TEMPLATE_START = '<div class="leaf flex"><div class="justify">'
const TEMPLATE_END = '</div> </div>';

let page_html = TEMPLATE_START + book[page] + TEMPLATE_END;
let page_html = '';

if (book[page].startsWith('<h')) {
page_html = HEADING_TEMPLATE_START + book[page] + TEMPLATE_END;

} else {
page_html = PAGE_TEMPLATE_START + book[page] + TEMPLATE_END;

}

let htmlFile = path.join('.', 'manuscript', page, 'body.html')

Expand All @@ -45,14 +45,10 @@ function bookify() {

fse.readdir(path.join('.', 'manuscript')).then((files) => {
let bookLength = files.length
console.log(bookLength)
if (bookLength % 2 === 0) { /* Insert Back Cover and a few empty pages on the book after the manuscript */

console.log('Here A')
promises.push(fse.copy(path.join(__dirname, '..', 'last', 'page-2n-1'), path.join('.', 'manuscript', `page-${bookLength + 1}`)).catch(err => console.log(err)))
promises.push(fse.copy(path.join(__dirname, '..', 'last', 'page-2n'), path.join('.', 'manuscript', `page-${bookLength + 2}`)).catch(err => console.log(err)))
} else {
console.log('B')
promises.push(fse.copy(path.join(__dirname, '..', 'last', 'page-2n-1'), path.join('.', 'manuscript', `page-${bookLength + 1}`)).catch(err => console.log(err)))
promises.push(fse.copy(path.join(__dirname, '..', 'last', 'page-2n-1'), path.join('.', 'manuscript', `page-${bookLength + 2}`)).catch(err => console.log(err)))
promises.push(fse.copy(path.join(__dirname, '..', 'last', 'page-2n'), path.join('.', 'manuscript', `page-${bookLength + 3}`)).catch(err => console.log(err)))
Expand Down

0 comments on commit ef82432

Please sign in to comment.