jekyll-epub 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +101 -0
- data/Rakefile +57 -0
- data/VERSION +1 -0
- data/bin/jekyll_epub +175 -0
- data/jekyll-epub.gemspec +78 -0
- data/lib/jekyll/epub.rb +242 -0
- data/lib/jekyll/epub/dtd/xhtml-lat1.ent +196 -0
- data/lib/jekyll/epub/dtd/xhtml-special.ent +80 -0
- data/lib/jekyll/epub/dtd/xhtml-symbol.ent +237 -0
- data/lib/jekyll/epub/dtd/xhtml1-strict.dtd +978 -0
- data/lib/jekyll/epub/tasks.rb +71 -0
- data/lib/jekyll/epub/templates/META-INF/container.xml +6 -0
- data/lib/jekyll/epub/templates/content.opf +59 -0
- data/lib/jekyll/epub/templates/cover.xhtml +15 -0
- data/lib/jekyll/epub/templates/mimetype +1 -0
- data/lib/jekyll/epub/templates/page-template.xpgt +49 -0
- data/lib/jekyll/epub/templates/toc.ncx +29 -0
- data/lib/jekyll/tags/epub.rb +36 -0
- data/test/helper.rb +10 -0
- data/test/test_jekyll-epub.rb +7 -0
- metadata +133 -0
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
require 'jekyll/epub'
|
4
|
+
|
5
|
+
module Jekyll
|
6
|
+
class Epub
|
7
|
+
class Tasks < ::Rake::TaskLib
|
8
|
+
def initialize( &block )
|
9
|
+
@_web = { "port" => 4000 }
|
10
|
+
@_epub = {}
|
11
|
+
|
12
|
+
instance_eval( &block ) if block
|
13
|
+
|
14
|
+
@web_override = Jekyll.configuration( @_web )
|
15
|
+
@epub_override = @_epub
|
16
|
+
|
17
|
+
define_tasks
|
18
|
+
end
|
19
|
+
|
20
|
+
def epub( key, value )
|
21
|
+
@_epub["epub"][key.to_s] = value
|
22
|
+
end
|
23
|
+
|
24
|
+
def web( key, value )
|
25
|
+
@_web[key.to_s] = value
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def define_tasks
|
31
|
+
desc "Build epub"
|
32
|
+
task :epub do
|
33
|
+
Jekyll::Epub.new().create( @epub_override )
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Build site"
|
37
|
+
task :site do
|
38
|
+
source = @web_override['source']
|
39
|
+
destination = @web_override['destination']
|
40
|
+
site = Jekyll::Site.new(@web_override)
|
41
|
+
|
42
|
+
puts "Building site: #{source} -> #{destination}"
|
43
|
+
site.process
|
44
|
+
puts "Successfully generated site: #{source} -> #{destination}"
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "Serve site on localhost with port #{@web_override["serve_port"]}"
|
48
|
+
task :serve do
|
49
|
+
require 'webrick'
|
50
|
+
|
51
|
+
FileUtils.mkdir_p( @web_override['destination'] )
|
52
|
+
|
53
|
+
mime_types = WEBrick::HTTPUtils::DefaultMimeTypes
|
54
|
+
mime_types.store 'js', 'application/javascript'
|
55
|
+
|
56
|
+
s = WEBrick::HTTPServer.new(
|
57
|
+
:Port => @web_override['server_port'],
|
58
|
+
:DocumentRoot => @web_override['destination'],
|
59
|
+
:MimeTypes => mime_types
|
60
|
+
)
|
61
|
+
t = Thread.new {
|
62
|
+
s.start
|
63
|
+
}
|
64
|
+
|
65
|
+
trap("INT") { s.shutdown }
|
66
|
+
t.join()
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<package xmlns="http://www.idpf.org/2007/opf" unique-identifier="dcidid" version="2.0">
|
3
|
+
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/"
|
4
|
+
xmlns:dcterms="http://purl.org/dc/terms/"
|
5
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
6
|
+
xmlns:opf="http://www.idpf.org/2007/opf">
|
7
|
+
|
8
|
+
<!-- required -->
|
9
|
+
<dc:title>{{epub.title}}</dc:title>
|
10
|
+
<dc:language xsi:type="dcterms:RFC3066">{{epub.lang}}</dc:language>
|
11
|
+
<dc:identifier id="dcidid" opf:scheme="URI">{{epub.identifier}}</dc:identifier>
|
12
|
+
|
13
|
+
<!-- optionals -->
|
14
|
+
<dc:subject>{{epub.subject}}</dc:subject>
|
15
|
+
<dc:description>{{epub.description}}</dc:description>
|
16
|
+
<dc:relation>{{epub.relation}}</dc:relation>
|
17
|
+
<dc:creator>{{epub.creator}}</dc:creator>
|
18
|
+
<dc:contributor>{{epub.contributor}}</dc:contributor>
|
19
|
+
<dc:publisher>{{epub.publisher}}</dc:publisher>
|
20
|
+
<dc:date xsi:type="dcterms:W3CDTF">{{epub.date}}</dc:date>
|
21
|
+
<dc:rights>{{epub.rights}}</dc:rights>
|
22
|
+
<dc:type>{{epub.type}}</dc:type>
|
23
|
+
<dc:format>{{epub.format}}</dc:format>
|
24
|
+
<dc:source>{{epub.source}}</dc:source>
|
25
|
+
<dc:coverage>{{epub.coverage}}</dc:coverage>
|
26
|
+
|
27
|
+
<!-- Cover -->
|
28
|
+
{% if epub.cover %}
|
29
|
+
<meta name="cover" content="cover-image"/>
|
30
|
+
{% endif %}
|
31
|
+
</metadata>
|
32
|
+
|
33
|
+
<manifest>
|
34
|
+
<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" />
|
35
|
+
<item id="pt" href="page-template.xpgt" media-type="application/vnd.adobe-page-template+xml" />
|
36
|
+
{% if epub.cover %}
|
37
|
+
<item id="cover" href="cover.xhtml" media-type="application/xhtml+xml"/>
|
38
|
+
<item id="cover-image" href="{{epub.cover.image}}" media-type="{{epub.cover.mime}}"/>
|
39
|
+
{% endif %}
|
40
|
+
{% for file in files %}
|
41
|
+
<item id="{{file.id}}" href="{{file.url}}" media-type="{{file.mime}}" />
|
42
|
+
{% endfor %}
|
43
|
+
</manifest>
|
44
|
+
|
45
|
+
<spine toc="ncx">
|
46
|
+
{% if epub.cover %}
|
47
|
+
<itemref idref="cover" linear="no"/>
|
48
|
+
{% endif %}
|
49
|
+
{% for file in files %}{% if file.mime == "application/xhtml+xml" %}
|
50
|
+
<itemref idref="{{file.id}}" />
|
51
|
+
{% endif %}{% endfor %}
|
52
|
+
</spine>
|
53
|
+
|
54
|
+
{% if epub.cover %}
|
55
|
+
<guide>
|
56
|
+
<reference type="cover" title="Cover" href="cover.xhtml"/>
|
57
|
+
</guide>
|
58
|
+
{% endif %}
|
59
|
+
</package>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
+
<!DOCTYPE html PUBLIC
|
3
|
+
"-//W3C//DTD XHTML 1.1//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
6
|
+
<head>
|
7
|
+
<title>{{epub.title}}</title>
|
8
|
+
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div>
|
12
|
+
<img src="{{epub.cover.image}}" alt="Jekyll-epub/Cover" title="Jekyll-epub/Cover" />
|
13
|
+
</div>
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
application/epub+zip
|
@@ -0,0 +1,49 @@
|
|
1
|
+
<ade:template xmlns="http://www.w3.org/1999/xhtml" xmlns:ade="http://ns.adobe.com/2006/ade"
|
2
|
+
xmlns:fo="http://www.w3.org/1999/XSL/Format">
|
3
|
+
|
4
|
+
<fo:layout-master-set>
|
5
|
+
<fo:simple-page-master master-name="single_column">
|
6
|
+
<fo:region-body margin-bottom="3pt" margin-top="0.5em" margin-left="3pt" margin-right="3pt"/>
|
7
|
+
</fo:simple-page-master>
|
8
|
+
|
9
|
+
<fo:simple-page-master master-name="single_column_head">
|
10
|
+
<fo:region-before extent="8.3em"/>
|
11
|
+
<fo:region-body margin-bottom="3pt" margin-top="6em" margin-left="3pt" margin-right="3pt"/>
|
12
|
+
</fo:simple-page-master>
|
13
|
+
|
14
|
+
<fo:simple-page-master master-name="two_column" margin-bottom="0.5em" margin-top="0.5em" margin-left="0.5em" margin-right="0.5em">
|
15
|
+
<fo:region-body column-count="2" column-gap="10pt"/>
|
16
|
+
</fo:simple-page-master>
|
17
|
+
|
18
|
+
<fo:simple-page-master master-name="two_column_head" margin-bottom="0.5em" margin-left="0.5em" margin-right="0.5em">
|
19
|
+
<fo:region-before extent="8.3em"/>
|
20
|
+
<fo:region-body column-count="2" margin-top="6em" column-gap="10pt"/>
|
21
|
+
</fo:simple-page-master>
|
22
|
+
|
23
|
+
<fo:simple-page-master master-name="three_column" margin-bottom="0.5em" margin-top="0.5em" margin-left="0.5em" margin-right="0.5em">
|
24
|
+
<fo:region-body column-count="3" column-gap="10pt"/>
|
25
|
+
</fo:simple-page-master>
|
26
|
+
|
27
|
+
<fo:simple-page-master master-name="three_column_head" margin-bottom="0.5em" margin-top="0.5em" margin-left="0.5em" margin-right="0.5em">
|
28
|
+
<fo:region-before extent="8.3em"/>
|
29
|
+
<fo:region-body column-count="3" margin-top="6em" column-gap="10pt"/>
|
30
|
+
</fo:simple-page-master>
|
31
|
+
|
32
|
+
<fo:page-sequence-master>
|
33
|
+
<fo:repeatable-page-master-alternatives>
|
34
|
+
<fo:conditional-page-master-reference master-reference="three_column_head" page-position="first" ade:min-page-width="80em"/>
|
35
|
+
<fo:conditional-page-master-reference master-reference="three_column" ade:min-page-width="80em"/>
|
36
|
+
<fo:conditional-page-master-reference master-reference="two_column_head" page-position="first" ade:min-page-width="50em"/>
|
37
|
+
<fo:conditional-page-master-reference master-reference="two_column" ade:min-page-width="50em"/>
|
38
|
+
<fo:conditional-page-master-reference master-reference="single_column_head" page-position="first" />
|
39
|
+
<fo:conditional-page-master-reference master-reference="single_column"/>
|
40
|
+
</fo:repeatable-page-master-alternatives>
|
41
|
+
</fo:page-sequence-master>
|
42
|
+
|
43
|
+
</fo:layout-master-set>
|
44
|
+
|
45
|
+
<ade:style>
|
46
|
+
<ade:styling-rule selector=".title_box" display="adobe-other-region" adobe-region="xsl-region-before"/>
|
47
|
+
</ade:style>
|
48
|
+
|
49
|
+
</ade:template>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN"
|
3
|
+
"http://www.daisy.org/z3986/2005/ncx-2005-1.dtd">
|
4
|
+
|
5
|
+
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
|
6
|
+
|
7
|
+
<head>
|
8
|
+
<meta name="dtb:uid" content="{{epub.identifier}}"/>
|
9
|
+
<meta name="dtb:depth" content="1"/>
|
10
|
+
<meta name="dtb:totalPageCount" content="0"/>
|
11
|
+
<meta name="dtb:maxPageNumber" content="0"/>
|
12
|
+
</head>
|
13
|
+
|
14
|
+
<docTitle>
|
15
|
+
<text>Epub Format Construction Guide</text>
|
16
|
+
</docTitle>
|
17
|
+
|
18
|
+
<navMap>
|
19
|
+
{% for file in files %}{% if file.mime == "application/xhtml+xml" %}
|
20
|
+
<navPoint id="navPoint-{{file.order}}" playOrder="{{file.order}}">
|
21
|
+
<navLabel>
|
22
|
+
<text>{{file.title}}</text>
|
23
|
+
</navLabel>
|
24
|
+
<content src="{{file.url}}"/>
|
25
|
+
</navPoint>
|
26
|
+
{% endif %}{% endfor %}
|
27
|
+
</navMap>
|
28
|
+
|
29
|
+
</ncx>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Jekyll
|
2
|
+
class EpubBlock < Liquid::Block
|
3
|
+
include Liquid::StandardFilters
|
4
|
+
|
5
|
+
def initialize(tag_name, markup, tokens)
|
6
|
+
super
|
7
|
+
end
|
8
|
+
|
9
|
+
def render(context)
|
10
|
+
if context.registers[:site].config["epub"]
|
11
|
+
super
|
12
|
+
else
|
13
|
+
""
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class NoEpubBlock < Liquid::Block
|
19
|
+
include Liquid::StandardFilters
|
20
|
+
|
21
|
+
def initialize(tag_name, markup, tokens)
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
def render(context)
|
26
|
+
if context.registers[:site].config["epub"]
|
27
|
+
""
|
28
|
+
else
|
29
|
+
super
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Liquid::Template.register_tag('epub', Jekyll::EpubBlock)
|
36
|
+
Liquid::Template.register_tag('noepub', Jekyll::NoEpubBlock)
|
data/test/helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-epub
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Gregoire Lejeune
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-04-27 00:00:00 +02:00
|
18
|
+
default_executable: jekyll_epub
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: mime-types
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: uuid
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
41
|
+
version: "0"
|
42
|
+
type: :runtime
|
43
|
+
version_requirements: *id002
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: jekyll
|
46
|
+
prerelease: false
|
47
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
version: "0"
|
54
|
+
type: :runtime
|
55
|
+
version_requirements: *id003
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: shoulda
|
58
|
+
prerelease: false
|
59
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
version: "0"
|
66
|
+
type: :development
|
67
|
+
version_requirements: *id004
|
68
|
+
description: Create an eBook (epub) of your Jekyll blog
|
69
|
+
email: gregoire.lejeune@free.fr
|
70
|
+
executables:
|
71
|
+
- jekyll_epub
|
72
|
+
extensions: []
|
73
|
+
|
74
|
+
extra_rdoc_files:
|
75
|
+
- LICENSE
|
76
|
+
- README.rdoc
|
77
|
+
files:
|
78
|
+
- .document
|
79
|
+
- .gitignore
|
80
|
+
- LICENSE
|
81
|
+
- README.rdoc
|
82
|
+
- Rakefile
|
83
|
+
- VERSION
|
84
|
+
- bin/jekyll_epub
|
85
|
+
- jekyll-epub.gemspec
|
86
|
+
- lib/jekyll/epub.rb
|
87
|
+
- lib/jekyll/epub/dtd/xhtml-lat1.ent
|
88
|
+
- lib/jekyll/epub/dtd/xhtml-special.ent
|
89
|
+
- lib/jekyll/epub/dtd/xhtml-symbol.ent
|
90
|
+
- lib/jekyll/epub/dtd/xhtml1-strict.dtd
|
91
|
+
- lib/jekyll/epub/tasks.rb
|
92
|
+
- lib/jekyll/epub/templates/META-INF/container.xml
|
93
|
+
- lib/jekyll/epub/templates/content.opf
|
94
|
+
- lib/jekyll/epub/templates/cover.xhtml
|
95
|
+
- lib/jekyll/epub/templates/mimetype
|
96
|
+
- lib/jekyll/epub/templates/page-template.xpgt
|
97
|
+
- lib/jekyll/epub/templates/toc.ncx
|
98
|
+
- lib/jekyll/tags/epub.rb
|
99
|
+
- test/helper.rb
|
100
|
+
- test/test_jekyll-epub.rb
|
101
|
+
has_rdoc: true
|
102
|
+
homepage: http://github.com/glejeune/jekyll-epub
|
103
|
+
licenses: []
|
104
|
+
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options:
|
107
|
+
- --charset=UTF-8
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
segments:
|
115
|
+
- 0
|
116
|
+
version: "0"
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
segments:
|
122
|
+
- 0
|
123
|
+
version: "0"
|
124
|
+
requirements: []
|
125
|
+
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 1.3.6
|
128
|
+
signing_key:
|
129
|
+
specification_version: 3
|
130
|
+
summary: Create an eBook (epub) of your Jekyll blog
|
131
|
+
test_files:
|
132
|
+
- test/helper.rb
|
133
|
+
- test/test_jekyll-epub.rb
|