Skip to content
This repository has been archived by the owner on Jan 3, 2018. It is now read-only.

Add EPUB version of lessons (build with pandoc) #435

Merged
merged 7 commits into from
Jun 29, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,12 @@ BOOK_MD = ./book.md
# Build the temporary input for the book by concatenating relevant
# sections of Markdown files and then patching glossary references and
# image paths.
#
# Need to fix anchors to glossary references since it now will be in the same
# file as the lessons.
$(BOOK_MD) : $(MOST_SRC) bin/make-book.py
python bin/make-book.py $(MOST_SRC) > $@
python bin/make-book.py $(MOST_SRC) > $@
sed -i 's/\.\.\/\.\.\/gloss.html#/#g:/g' $@

$(BOOK_HTML): $(BOOK_MD)
make -B site
Expand All @@ -111,7 +115,7 @@ $(BOOK_HTML): $(BOOK_MD)

## commands : show all commands.
commands :
@grep -E '^##' Makefile | sed -e 's/##//g'
@grep -E '^##' Makefile | sed -e 's/##//g'

## ---------------------------------------

Expand All @@ -133,6 +137,10 @@ clean : tidy
# with Jekyll as usual.
book : $(BOOK_HTML)

## epub : build epub version of lessons (this is experimental)
epub : book
make -f epub.mk epub

## install : install on the server.
install : $(INDEX)
rm -rf $(INSTALL)
Expand Down
32 changes: 32 additions & 0 deletions README-EPUB.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# EPUB Version of Software Carpentry Lessons

This document explains how to build the `epub` version of Software Carpentry
lessons and others ebook formats (e.g. `mobi` and `azw`).

## Dependencies

- [lxml](http://lxml.de/)
- [Jekyll](http://jekyllrb.com/)
- [Pandoc](http://johnmacfarlane.net/pandoc/)

We recommend use pandoc >= 1.13 due a [issue with
tables](https://github.com/jgm/pandoc/issues/1341). The build process won't
fail if you use an older version but will hard to read tables.
- [Calibre](http://calibre-ebook.com/)

Only need to build the `mobi` and `azw` formats.

## Build Steps

To build `epub`:

~~~
$ make epub
~~~

After build `epub` you can build `mobi` and/or `azw`:

~~~
$ make -f epub.mk mobi
$ make -f epub.mk azw
~~~
15 changes: 15 additions & 0 deletions _epub/metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<metadata
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title>Software Carpentry - Volume 1: Basics</dc:title>
<dc:creator>Greg Wilson (editor)</dc:creator>
<dc:subject>Programming</dc:subject>
<dc:description>Basic lab skills for scientific computing: the tools and techniques that will help them get more done in less time, and with less pain.</dc:description>
<dc:publisher>Software Carpentry</dc:publisher>
<dc:date>2014-04-11</dc:date>
<dc:type>Text</dc:type>
<dc:format>EPUB</dc:format>
<dc:language>English</dc:language>
<dc:rights>CC-BY</dc:rights>
<dc:identifier id="BookId">daad3330da93f8fcce22751285014e7144555209</dc:identifier>
</metadata>
258 changes: 258 additions & 0 deletions _epub/stylesheet.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
/* Main body of pages. */
body {
font-family: "Open Sans", Helvetica, Arial, sans-serif;
color: rgb(03, 03, 03);
}

/* Styling for editorial stylesheet */
body.stylesheet {
background: #ffffff;
width: 60em;
margin: 20 auto;
}

/* Top banner of every page. */
div.banner {
background-color: #FFFFFF;
width: 100%;
height: 90px;
margin: 0px;
padding: 0;
border-bottom: 1px solid #A6A6A6;
}

/* Padding around image in top banner. */
div.banner a img {
padding: 20px 25px;
}

@media (max-width: 700px) {
div.banner a img {
padding: 20px 0px;
}
}

/* Explanatory call-out boxes. */
div.box {
background-color: mistyrose;
display: block;
margin-left: auto;
margin-right: auto;
padding-top: 1px;
padding-bottom: 1px;
padding-left: 10px;
padding-right: 10px;
outline-color: gray;
outline-width: 1px;
outline-style: solid;
}
@media (max-width: 700px) {
div.box {
width: 80%;
}
}
@media (min-width: 700px) {
div.box {
width: 54em;
max-width: 80%;
}
}

/* Level 2 headings inside pages. */
div.content div h3 {
border-bottom: 1px solid #CCCCCC;
display: block;
font-family: Verdana,"BitStream vera Sans";
margin-top: 10px;
padding: 0 5px 3px;
}

/* PDF and slide files referenced from lectures. */
div.files {
padding: 10px;
}

/* Footer of every page. */
div.footer {
clear: both;
background: url("/img/main_shadow.png") repeat-x scroll center top #FFFFFF;
padding: 4px 10px 7px 10px;
border-top: 1px solid #A6A6A6;
text-align: right;
}

/* Chapter titles. */
div.chapter h2 {
text-align: center;
font-style: italic;
}

/* Objectives and key points */
.objectives, .keypoints {
background-color: azure;
}

/* Things to fix. */
.fixme {
text-decoration: underline;
color: darkred;
background-color: lightgray;
}

/* Putting shadows around things. */
.shadow {
-moz-box-shadow: 0 0 30px 5px #999;
-webkit-box-shadow: 0 0 30px 5px #999;
box-shadow: 0 0 30px 5px #999;
}

/* Things to understand (lead-in to sections in book). */
.understand {
background-color: lightyellow;
}

/* Block quotations. */
blockquote {
margin: 1em;
padding: 1em 1em .5em 1em;
width: 90%;
}

/* Citation for testimonial quote. */
blockquote.testimonial cite {
font-style: italic;
}

/* Table of contents. */
div.toc {
/* No special styling yet. */
}

.transcript {
display: table;
}

.transcript .media img {
border: 1px solid grey;
}

/* Title styling */
h1.title {
margin:40px 0px;
border-bottom:1px solid #515151;
}

/* YouTube video embed. */
div.youtube {
text-align: center;
padding: 10px;
}

/* Glossary description lists. */
dl.gloss {
/* Empty for now. */
}

/* FIXME: shouldn't be using iframe's directly (EventBrite and YouTube should be via macro expansion). */
iframe.youtube_player {
border : 0;
text-align : center;
width : 640px;
height : 500px;
}

/* pre blocks inherit color from parent */
pre {
color: inherit;
}

/* Work around to issue when create EPUB with pandoc for IPython Notebook
* template.
*/
div.out {
display: block;
padding: 9.5px;
margin-bottom: 10px;
font-size: 13px;
line-height: 20px;
word-break: break-all;
word-wrap: break-word;
background-color: #f5f5f5;
border: 1px solid #ccc;
border: 1px solid rgba(0, 0, 0, 0.15);
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}

div.out pre {
padding: 0px;
margin: 0px;
border: 0px;
}

/* Comments in code. */
.comment {
color: purple;
}

/* Highlighted changes in code. */
.highlight {
background-color: mistyrose;
}

/* Manual input. */
.in {
color: darkgreen;
margin-left: 20px;
}

/* Program output. */
.out {
color: darkblue;
margin-left: 20px;
}

/* Error output. */
.err {
color: darkred;
margin-left: 20px;
font-style: italic;
font-weight: bold;
}

/* Files. */
.file {
margin-left: 20px;
}

/* Explanatory call-out boxes. */
div.box {
background-color: lightgray;
}

/* Challenge questions. */
div.challenge {
background-color: lightblue;
}

/* Key points in summary. */
div.keypoints {}

/* Learning objectives. */
div.objectives {}
span.subtitle {
color: #030303;
display: block;
font-family: inherit;
font-size: 31.5px;
font-weight: bold;
line-height: 40px;
margin: 40px 0px 10px 0px;
text-rendering: optimizelegibility;
}

img {
max-width: 90%;
max-height: 90%;
}
14 changes: 5 additions & 9 deletions _templates/ipynb.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,18 @@ root: ../..
{% extends 'markdown.tpl' %}

{% block input %}
<div class="in">
<pre>{{ cell.input | escape }}</pre>
</div>
<pre class="in"><code>{{ cell.input | escape }}</code></pre>
{% endblock input %}

{% block output_group %}
<div class="out">
<pre>{{- super() -}}</pre>
</div>
<div class="out">{{- super() -}}</div>
{% endblock output_group %}

{%- block stream -%}{{- output.text | escape -}}{%- endblock stream -%}
{%- block stream -%}<pre class='out'><code>{{- output.text | escape -}}</code></pre>{%- endblock stream -%}

{%- block pyout -%}{{- output.text | escape -}}{%- endblock pyout -%}
{%- block pyout -%}<pre class='out'><code>{{- output.text | escape -}}</code></pre>{%- endblock pyout -%}

{%- block pyerr -%}{{- output.traceback | join('\n') | strip_ansi | escape -}}{%- endblock pyerr -%}
{%- block pyerr -%}<pre class='err'><code>{{- output.traceback | join('\n') | strip_ansi | escape -}}</code></pre>{%- endblock pyerr -%}

{%- block data_svg -%}<img src="../../{{ output.svg_filename | path2url }}">{%- endblock data_svg -%}

Expand Down
Loading