Skip to content

Commit 7bba694

Browse files
committed
work on epub transformation
1 parent 9aeb8f4 commit 7bba694

File tree

5 files changed

+56
-4
lines changed

5 files changed

+56
-4
lines changed

Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ pdf: bookbuild
2626
cd generated/book; prince pdf-book.html -o full_stack_python.pdf
2727

2828

29+
epub: bookbuild
30+
sed -i '' 's/\(^.*~~.*$$\)/<\/pre><pre class="highlight-line">\1<\/pre><pre>/g' generated/book/epub-book.html
31+
sed -i '' 's/~~//g' generated/book/epub-book.html
32+
cd generated/book; pandoc -f html epub-book.html -t epub3 --epub-metadata=epub-metadata.xml --epub-cover-image=img/book/cover-a4.jpg --toc-depth=2 --epub-stylesheet=theme/css/epub.css -o full_stack_python.epub
33+
34+
35+
mobi: epub
36+
cd generated/book; kindlegen full_stack_python.epub -o full_stack_python.mobi
37+
38+
2939
update:
3040
python update_s3.py
3141
rm -rf generated/current_site

book_settings.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# -*- coding: utf-8 -*-
2-
AUTHOR = u'Matt Makai'
2+
AUTHOR = u'Matthew Makai'
33
SITENAME = u'Full Stack Python'
44
SITEURL = 'https://www.fullstackpython.com'
55
TIMEZONE = 'America/New_York'
66

77
GITHUB_URL = 'https://github.com/mattmakai/fullstackpython.com'
88
PDF_GENERATOR = False
9-
DIRECT_TEMPLATES = ('pdf-book', )#'epub-book')
9+
DIRECT_TEMPLATES = ('pdf-book', 'epub-book')
1010
PLUGINS = ['plugins.pelican-toc',]
1111

1212
ARTICLE_SAVE_AS = 'blog/{slug}.html'

static-html/epub-metadata.xml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<dc:title>Full Stack Python</dc:title>
2+
<dc:language>en-US</dc:language>
3+
<dc:creator opf:file-as="Makai, Matt" opf:role="aut">Matt Makai</dc:creator>
4+
<dc:publisher>Full Stack Guides, Inc.</dc:publisher>
5+
<dc:date opf:event="publication">2018-04-20</dc:date>
6+
<dc:rights>Copyright 2012-2018 by Matt Makai</dc:rights>

static-html/title.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
% Full Stack Python
2+
% Matthew Makai

theme/templates/epub-book.html

+36-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
<!DOCTYPE html>
33
<html lang="en">
44
<head>
5-
<link href="theme/css/epub-book.css" rel="stylesheet">
5+
<link href="theme/css/base.css" rel="stylesheet">
6+
<link href="theme/css/epub.css" rel="stylesheet">
67
</head>
78
<body>
9+
<img src="img/book/cover-a4.jpg" width="100%">
10+
<br/>
811
{% for page in pages|sort(attribute='sortorder') %}
912
{% if page.sortorder[0:2] == "00" %}
1013
{{ page.content }}
@@ -13,11 +16,42 @@
1316
<p style="page-break-after:always;"></p>
1417

1518
<h1>Table of Contents</h1>
16-
{% include "toc.html" %}
19+
{% include "book-toc.html" %}
1720

1821
{% for page in pages|sort(attribute='sortorder') %}
1922
{% if not page.sortorder[0:2] == "00" %}
23+
{% if page.sortorder == "0100" %}
24+
<div class="chapter">
25+
<img src="img/book/01-introduction/01-cover.png" class="chapter-cover">
26+
</div>
27+
{% elif page.sortorder == "0200" %}
28+
<div class="chapter">
29+
<img src="img/book/02-dev-environments/02-cover.png" class="chapter-cover">
30+
</div>
31+
{% elif page.sortorder == "0300" %}
32+
<div class="chapter">
33+
<img src="img/book/03-data/03-cover.png" class="chapter-cover">
34+
</div>
35+
{% elif page.sortorder == "0400" %}
36+
<div class="chapter">
37+
<img src="img/book/04-web-development/04-cover.png" class="chapter-cover">
38+
</div>
39+
{% elif page.sortorder == "0500" %}
40+
<div class="chapter">
41+
<img src="img/book/05-deployments/05-cover.png" class="chapter-cover">
42+
</div>
43+
{% elif page.sortorder == "0600" %}
44+
<div class="chapter">
45+
<img src="img/book/06-devops/06-cover.png" class="chapter-cover">
46+
</div>
47+
{% elif page.sortorder == "0700" %}
48+
<div class="chapter">
49+
<img src="img/book/07-meta/07-cover.png" class="chapter-cover">
50+
</div>
51+
{% endif %}
52+
{% if page.slug != "change-log" and page.slug != "page-statuses" and page.slug != "future-directions" %}
2053
{{ page.content }}
54+
{% endif %}
2155
{% endif %}
2256
{% endfor %}
2357
</body>

0 commit comments

Comments
 (0)