Skip to content

Commit

Permalink
Restore epub target
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed Feb 25, 2018
1 parent 2bc453e commit ac25fd1
Show file tree
Hide file tree
Showing 24 changed files with 461 additions and 31 deletions.
19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CHAPTERS := $(basename $(shell ls [0-9][0-9]_*.md) .md)

SVGS := $(wildcard img/*.svg)

all: html book.pdf book_mobile.pdf
all: html book.pdf book_mobile.pdf book.epub

html: $(foreach CHAP,$(CHAPTERS),html/$(CHAP).html) html/js/acorn_codemirror.js \
code/skillsharing.zip code/solutions/20_3_a_public_space_on_the_web.zip html/js/chapter_info.js
Expand Down Expand Up @@ -58,3 +58,20 @@ img/generated/%.pdf: img/%.svg

pdf/%.tex: %.md
node src/render_latex.js $< > $@

book.epub: epub/titlepage.xhtml epub/toc.xhtml epub/hints.xhtml $(foreach CHAP,$(CHAPTERS),epub/$(CHAP).xhtml) \
epub/content.opf.src epub/style.css src/add_images_to_epub.js
rm -f $@
grep '<img' epub/*.xhtml | sed -e 's/.*src="\([^"]*\)".*/\1/' | xargs -I{} cp --parents "{}" epub
node src/add_images_to_epub.js
cd epub; zip -X ../$@ mimetype
cd epub; zip -X ../$@ -r * -x mimetype -x content.opf.src

epub/%.xhtml: %.md src/render_html.js
node src/render_html.js --epub $< > $@

epub/hints.xhtml: $(foreach CHAP,$(CHAPTERS),$(CHAP).md) src/extract_hints.js src/render_html.js
node src/extract_hints.js | node src/render_html.js --epub - > $@

epubcheck: book.epub
epubcheck book.epub 2>&1 | grep -v 'img/.*\.svg'
6 changes: 6 additions & 0 deletions epub/META-INF/container.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
<rootfiles>
<rootfile full-path="content.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
76 changes: 76 additions & 0 deletions epub/content.opf.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="pub-id" prefix="cc: http://creativecommons.org/ns#">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title id="title">Eloquent JavaScript</dc:title>
<meta refines="#title" property="title-type">main</meta>
<dc:creator id="creator">Marijn Haverbeke</dc:creator>
<meta refines="#creator" property="file-as">HAVERBEKE, MARIJN</meta>
<meta refines="#creator" property="role" scheme="marc:relators">aut</meta>
<dc:identifier id="pub-id">net.eloquentjavascript</dc:identifier>
<dc:language>en-US</dc:language>
<dc:rights>This work is shared with the public using the Attribution-NonCommercial 3.0 Unported (CC BY-NC 3.0) license.</dc:rights>
<link rel="cc:license" href="http://creativecommons.org/licenses/by-nc/3.0/"/>
<meta property="cc:attributionURL">http://eloquentjavascript.net/</meta>
<meta property="dcterms:modified">2018-02-25T22:07:00Z</meta>
</metadata>
<manifest>
<item id="titlepage" href="titlepage.xhtml" media-type="application/xhtml+xml"/>
<item id="frontmatter" href="frontmatter.xhtml" media-type="application/xhtml+xml"/>
<item id="toc" properties="nav" href="toc.xhtml" media-type="application/xhtml+xml"/>
<item id="c00_intro" href="00_intro.xhtml" media-type="application/xhtml+xml"/>
<item id="c01_values" href="01_values.xhtml" media-type="application/xhtml+xml"/>
<item id="c02_program_structure" href="02_program_structure.xhtml" media-type="application/xhtml+xml" properties="svg"/>
<item id="c03_functions" href="03_functions.xhtml" media-type="application/xhtml+xml"/>
<item id="c04_data" href="04_data.xhtml" media-type="application/xhtml+xml" properties="svg"/>
<item id="c05_higher_order" href="05_higher_order.xhtml" media-type="application/xhtml+xml"/>
<item id="c06_object" href="06_object.xhtml" media-type="application/xhtml+xml" properties="svg"/>
<item id="c07_robot" href="07_robot.xhtml" media-type="application/xhtml+xml"/>
<item id="c08_error" href="08_error.xhtml" media-type="application/xhtml+xml"/>
<item id="c09_regexp" href="09_regexp.xhtml" media-type="application/xhtml+xml" properties="svg"/>
<item id="c10_modules" href="10_modules.xhtml" media-type="application/xhtml+xml"/>
<item id="c11_async" href="11_async.xhtml" media-type="application/xhtml+xml" properties="svg"/>
<item id="c12_language" href="12_language.xhtml" media-type="application/xhtml+xml" properties="svg"/>
<item id="c13_browser" href="13_browser.xhtml" media-type="application/xhtml+xml"/>
<item id="c14_dom" href="14_dom.xhtml" media-type="application/xhtml+xml" properties="svg"/>
<item id="c15_event" href="15_event.xhtml" media-type="application/xhtml+xml"/>
<item id="c16_game" href="16_game.xhtml" media-type="application/xhtml+xml" properties="svg"/>
<item id="c17_canvas" href="17_canvas.xhtml" media-type="application/xhtml+xml" properties="svg"/>
<item id="c18_http" href="18_http.xhtml" media-type="application/xhtml+xml"/>
<item id="c19_paint" href="19_paint.xhtml" media-type="application/xhtml+xml" properties="svg"/>
<item id="c20_node" href="20_node.xhtml" media-type="application/xhtml+xml"/>
<item id="c21_skillsharing" href="21_skillsharing.xhtml" media-type="application/xhtml+xml"/>
<item id="c_hints" href="hints.xhtml" media-type="application/xhtml+xml"/>
<item id="style" href="style.css" media-type="text/css"/>
<item id="font.cinzel.bold" href="font/cinzel_bold.otf" media-type="application/vnd.ms-opentype"/>
<item id="font.pt.regular" href="font/pt_mono.otf" media-type="application/vnd.ms-opentype"/>
{{images}}
</manifest>
<spine>
<itemref idref="titlepage" linear="yes"/>
<itemref idref="frontmatter" linear="yes"/>
<itemref idref="toc" linear="yes"/>
<itemref idref="c00_intro" linear="yes"/>
<itemref idref="c01_values" linear="yes"/>
<itemref idref="c02_program_structure" linear="yes"/>
<itemref idref="c03_functions" linear="yes"/>
<itemref idref="c04_data" linear="yes"/>
<itemref idref="c05_higher_order" linear="yes"/>
<itemref idref="c06_object" linear="yes"/>
<itemref idref="c07_robot" linear="yes"/>
<itemref idref="c08_error" linear="yes"/>
<itemref idref="c09_regexp" linear="yes"/>
<itemref idref="c10_modules" linear="yes"/>
<itemref idref="c11_async" linear="yes"/>
<itemref idref="c12_language" linear="yes"/>
<itemref idref="c13_browser" linear="yes"/>
<itemref idref="c14_dom" linear="yes"/>
<itemref idref="c15_event" linear="yes"/>
<itemref idref="c16_game" linear="yes"/>
<itemref idref="c17_canvas" linear="yes"/>
<itemref idref="c18_http" linear="yes"/>
<itemref idref="c19_paint" linear="yes"/>
<itemref idref="c20_node" linear="yes"/>
<itemref idref="c21_skillsharing" linear="yes"/>
<itemref idref="c_hints" linear="yes"/>
</spine>
</package>
Binary file added epub/font/cinzel_bold.otf
Binary file not shown.
Binary file added epub/font/pt_mono.otf
Binary file not shown.
51 changes: 51 additions & 0 deletions epub/frontmatter.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<link rel="stylesheet" href="style.css"/>
<title>Eloquent JavaScript</title>
<style>
img.logo { vertical-align: text-top; padding: 0px 4px; border: 0; }
</style>
</head>
<body>
<h1>Eloquent JavaScript</h1>
<p>Written by Marijn Haverbeke.</p>

<p>Licensed under
a <a href="http://creativecommons.org/licenses/by-nc/3.0/">Creative
Commons attribution-noncommercial license</a>. All code in this book
may also be considered licensed under
an <a href="http://opensource.org/licenses/MIT">MIT license</a>.</p>

<p style="font-size: 80%">Illustrations by various artists: Cover
and chapter illustrations by Madalina Tantareanu. Pixel art in
Chapters 7 and 16 by Antonio Perdomo Pastor. Regular expression
diagrams in Chapter 9 generated
with <a href="http://regexper.com">regexper.com</a> by Jeff
Avallone. Village photograph in Chapter 11 by Fabrice Creuzot.
Game concept for Chapter 15
by <a href="http://lessmilk.com">Thomas Palef</a>.</p>

<p style="font-size: 80%">The third edition was made possible
by <a href="https://eloquentjavascript.net/backers3.html">325 financial backers</a>, most
notably <a href="https://nextjournal.com/"><img src="img/nextjournal.png"
alt="Nextjournal" class="logo"/></a>
and <a href="https://www.holbertonschool.com/"><img src="img/holberton.png"
alt="Holberton School" class="logo"/></a>. The second edition was
supported by <a href="https://eloquentjavascript.net/backers.html">454 backers</a>, with
significant contributions
from <a href="http://www.mozilla.org/en-US/"><img src="img/mozilla_mini.png"
alt="Mozilla" class="logo"/></a>,
<a href="http://www.hackreactor.com/"><img src="img/hack_reactor_mini.png"
alt="Hack Reactor" class="logo"/></a>,
and <a href="http://www.ghostery.com/"><img src="img/ghostery_mini.png"
alt="Ghostery" class="logo"/></a>.</p>

<p>A <a href="https://www.amazon.com/Eloquent-JavaScript-2nd-Ed-Introduction/dp/1593275846">paper
version</a> of Eloquent JavaScript, including a bonus chapter, is
being brought out by <a href="http://www.nostarch.com/">No Starch
Press</a>. They also sell a more polished EPUB version that
includes the bonus chapter.</p>

</body>
</html>
1 change: 1 addition & 0 deletions epub/mimetype
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
application/epub+zip
144 changes: 144 additions & 0 deletions epub/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
@font-face {
font-family: 'Cinzel';
font-style: normal;
font-weight: 700;
src: url(font/cinzel_bold.otf);
}

@font-face {
font-family: 'PT Mono';
font-style: normal;
font-weight: 400;
src: url(font/pt_mono.otf);
}

body {
font-family: Georgia, 'Nimbus Roman No9 L', 'Century Schoolbook L', serif;
font-size: 20px;
line-height: 1.45;
color: black;
background: white;
text-align: left;
}

article {
padding: 2em 0 5em 0;
}

pre {
padding: 5px 0 5px 15px;
line-height: 1.35;
margin: 1rem 0;
position: relative;
font-size: 16px;
}

code, pre {
font-family: 'PT Mono', monospace;
}

code {
font-size: 18px;
padding: 0 2px;
}

h1, h2, h3 {
font-family: 'Cinzel', Georgia, serif;
font-weight: 700;
margin: 1rem 0;
letter-spacing: 2px;
}

h1 {
font-size: 130%;
}
h2 {
font-size: 115%;
}
h3 {
font-size: 100%;
}

span.chap_num {
display: block;
font-size: 60%;
color: #aaa;
margin-top: -.7em;
}

blockquote {
margin: 0 0 0 3em;
padding: 0;
font-size: 85%;
}

blockquote p {
color: #333;
}

blockquote p:first-of-type:before {
content: '“';
}

blockquote p:last-of-type:after {
content: '”';
}

p + footer {
margin-top: -.5em;
}

blockquote footer cite {
font-style: italic;
}

blockquote footer:before {
content: '—';
}

figure img {
max-width: 80%;
margin-left: 30px;
}

figure.chapter {
text-align: center;
margin: 3em 0 2em;
}

figure.chapter img {
max-width: 75%;
}

figure.framed img {
border-radius: 50%;
border: 2px solid black;
}

td {
vertical-align: top;
}

td + td {
padding-left: 1em;
}

table {
margin-left: 15px;
}

/* Syntax highlighting */
.cm-keyword {color: #506;}
.cm-atom {color: #106;}
.cm-number {color: #042;}
.cm-def {color: #009;}
.cm-variable-2, .cm-attribute {color: #027;}
.cm-variable-3 {color: #072;}
.cm-comment {color: #740;}
.cm-string {color: #700;}
.cm-string-2 {color: #740;}
.cm-tag {color: #170;}
.cm-keyword {color: #708;}
.cm-atom {color: #219;}
.cm-number {color: #164;}
.cm-def {color: #00f;}
16 changes: 16 additions & 0 deletions epub/titlepage.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<title>Cover</title>
<link rel="stylesheet" href="style.css"/>
<style type="text/css" title="override_css">
@page {padding: 0pt; margin:0pt}
body { text-align: center; padding:0pt; margin: 0pt; }
</style>
</head>
<body>
<div>
<img src="img/cover.jpg" alt="Eloquent JavaScript 3rd edition"/>
</div>
</body>
</html>
66 changes: 66 additions & 0 deletions epub/toc.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<title>Table of Contents</title>
<link rel="stylesheet" href="style.css"/>
<style type="text/css">
ol.toc {
margin: 1em 0;
padding: 0;
}
ol.toc li {
margin: 0 0 0 40px;
padding: 0;
list-style: none;
}
ol.toc span.parttitle {
display: block;
float: right;
margin: -2px 0;
font-weight: normal;
font-size: 90%;
}
span.hidden { visibility: hidden; }
</style>
</head>

<body>
<h1>Table of Contents</h1>
<nav xmlns:epub="http://www.idpf.org/2007/ops" epub:type="toc" id="toc">
<ol class="toc">
<li><span class="hidden">00. </span><a href="00_intro.xhtml">Introduction</a></li>
<li>
<span class="parttitle">(Part 1: Language)</span>
<span class="hidden">0</span>1. <a href="01_values.xhtml">Values, Types, and Operators</a>
</li>
<li><span class="hidden">0</span>2. <a href="02_program_structure.xhtml">Program Structure</a></li>
<li><span class="hidden">0</span>3. <a href="03_functions.xhtml">Functions</a></li>
<li><span class="hidden">0</span>4. <a href="04_data.xhtml">Data Structures: Objects and Arrays</a></li>
<li><span class="hidden">0</span>5. <a href="05_higher_order.xhtml">Higher-order Functions</a></li>
<li><span class="hidden">0</span>6. <a href="06_object.xhtml">The Secret Life of Objects</a></li>
<li><span class="hidden">0</span>7. <a href="07_robot.xhtml">Project: A Robot</a></li>
<li><span class="hidden">0</span>8. <a href="08_error.xhtml">Bugs and Errors</a></li>
<li><span class="hidden">0</span>9. <a href="09_regexp.xhtml">Regular Expressions</a></li>
<li>10. <a href="10_modules.xhtml">Modules</a></li>
<li>11. <a href="11_async.xhtml">Asynchronous Programming</a></li>
<li>12. <a href="12_language.xhtml">Project: A Programming Language</a></li>
<li style="position: relative">
<span class="parttitle">(Part 2: Browser)</span>
13. <a href="13_browser.xhtml">JavaScript and the Browser<span class="parttitle">(Part 2: Browser)</span></a>
</li>
<li>14. <a href="14_dom.xhtml">The Document Object Model</a></li>
<li>15. <a href="15_event.xhtml">Handling Events</a></li>
<li>16. <a href="16_game.xhtml">Project: A Platform Game</a></li>
<li>17. <a href="17_canvas.xhtml">Drawing on Canvas</a></li>
<li>18. <a href="18_http.xhtml">HTTP and Forms</a></li>
<li>19. <a href="19_paint.xhtml">Project: A Pixel Art Editor</a></li>
<li style="position: relative">
<span class="parttitle">(Part 3: Node)</span>
20. <a href="20_node.xhtml">Node.js</a>
</li>
<li>21. <a href="21_skillsharing.xhtml">Project: Skill-Sharing Website</a></li>
<li><span class="hidden">00.</span> <a href="hints.xhtml">Hints to the exercises</a></li>
</ol>
</nav>
</body>
</html>
Loading

0 comments on commit ac25fd1

Please sign in to comment.