jekyll-epub 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Gregoire Lejeune
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,101 @@
1
+ = jekyll-epub
2
+
3
+ Create an eBook (epub) of your Jekyll blog
4
+
5
+ == How To
6
+
7
+ === Create your blog ;)
8
+
9
+ First, you need to create your own Jekyll Blog ;) Please, refer to the {Jekyll documentation}[http://wiki.github.com/mojombo/jekyll/].
10
+
11
+ === Configuration
12
+
13
+ Then, you must add a configuration file : <tt>_epub.yml</tt>. This file is pretty similar to the Jekyll configuration file (<tt>_config.yml</tt>) except that's you must add in some specifics entries. This entries are in the mapping <tt>epub</tt>:
14
+
15
+ <tt>_epub.yml</tt> :
16
+
17
+ epub:
18
+ name: "My Jekyll Blog"
19
+ lang: en
20
+ identifier: my_blog.example.com-123456
21
+
22
+ Note that's in the file, you can also use all the {Jekyll configuration options}[http://wiki.github.com/mojombo/jekyll/configuration]. However, it is prudent not to change the <tt>permalink</tt> option, or you may spend a lot of time to set the proper access to resources (images, CSS, ...). You have been warned;)
23
+
24
+ Here is the list of options :
25
+
26
+ * <tt>name:</tt> <tt>String</tt> : The name of your book. This is a mandatory option.
27
+ * <tt>title:</tt> <tt>String</tt> : The title of your book. This is a mandatory option.
28
+ * <tt>identifier:</tt> <tt>String</tt> : A unique identifier for your book. If you have one, you can use an ISBN. If not given, Jekyll-epub will generate an UUID for you.
29
+ * <tt>subject:</tt> <tt>String</tt> : The subject of the book.
30
+ * <tt>description:</tt> <tt>String</tt> : An abstract of your book.
31
+ * <tt>relation:</tt> <tt>String</tt> :
32
+ * <tt>creator:</tt> <tt>String</tt> : The identity of the creator of the book.
33
+ * <tt>contributor:</tt> <tt>String</tt> : The identity of the contributor of the book.
34
+ * <tt>publisher:</tt> <tt>String</tt> : The identity of the publisher.
35
+ * <tt>date:</tt> <tt>Date</tt> : You really want to know ;)
36
+ * <tt>rights:</tt> <tt>String</tt> : The copyright of your book.
37
+ * <tt>type:</tt> <tt>String</tt> : The type of the book (I mean the kind)
38
+ * <tt>format:</tt> <tt>String</tt> : Some informations about the book format (The physical format)
39
+ * <tt>source:</tt> <tt>String</tt> : Information about the source of the book.
40
+ * <tt>coverage:</tt> <tt>String</tt> : Provides information on the spatial and/or time relevance of the book.
41
+ * <tt>cover-image:</tt> <tt>String</tt> : The image to use for the cover of the book (i use a 540 × 648 pixels image)
42
+ * <tt>pages-order:</tt> <tt>[page | post]</tt> : A list of pages and/or posts you want to order at the begenning of the book. If you don't specify any order, Jekyll-epub will generate the book with the posts first (from the older to the newer), then the pages.
43
+
44
+ === Layout
45
+
46
+ If you want to use a special layout for your book, you can use the <tt>epub:</tt> mapping in the header of your pages, posts, layouts. This mapping is similar to the <tt>layout:</tt> mapping except that's it is specific for the epub generation. In this example :
47
+
48
+ ---
49
+ epub: my_ebook
50
+ layout: post
51
+ ---
52
+ <p>This is the content of my post...</p>
53
+
54
+ When we generate the epub, Jekyll-epub will use the layout <tt>my_ebook</tt>.
55
+
56
+ === Liquid extension
57
+
58
+ You can also use two Liquid extensions :
59
+
60
+ {% epub %}
61
+ ... This will only be display in the epub ...
62
+ {% endepub %}
63
+
64
+ {% noepub %}
65
+ ... This will not be display in the epub ...
66
+ {% endnoepub %}
67
+
68
+ Since I have add those two extensions, if you want to use them, you also need to use one of the two following solution
69
+
70
+ ==== Use <tt>jekyll_epub</tt>
71
+
72
+ 1. Run <tt>jekyll_epub</tt> instead of <tt>jekyll</tt> to generate you site and eBook.
73
+
74
+ Otherwise, you will not be able to generate your (web) site.
75
+
76
+ ==== Use Rack tasks
77
+
78
+ 1. Create a Rakefile in your root's Jekyll blog directory
79
+ 2. Add the following code in your Rakefile
80
+
81
+ require 'jekyll/epub/tasks'
82
+ Jekyll::Epub::Tasks do
83
+ web :serve_port, 4000
84
+ epub :destination, "_epub"
85
+ end
86
+
87
+ 3. Use <tt>rake epub</tt> to generate the epub, use <tt>rake site</tt> to generate the website, use <tt>rake serve</tt> to serve the website.
88
+
89
+ == Note on Patches/Pull Requests
90
+
91
+ * Fork the project.
92
+ * Make your feature addition or bug fix.
93
+ * Add tests for it. This is important so I don't break it in a
94
+ future version unintentionally.
95
+ * Commit, do not mess with rakefile, version, or history.
96
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
97
+ * Send me a pull request. Bonus points for topic branches.
98
+
99
+ == Copyright
100
+
101
+ Copyright (c) 2010 Gregoire Lejeune. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,57 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "jekyll-epub"
8
+ gem.summary = %Q{Create an eBook (epub) of your Jekyll blog}
9
+ gem.description = %Q{Create an eBook (epub) of your Jekyll blog}
10
+ gem.email = "gregoire.lejeune@free.fr"
11
+ gem.homepage = "http://github.com/glejeune/jekyll-epub"
12
+ gem.authors = ["Gregoire Lejeune"]
13
+
14
+ gem.add_dependency 'mime-types', ">= 0"
15
+ gem.add_dependency 'uuid', ">= 0"
16
+ gem.add_dependency 'jekyll', ">= 0"
17
+
18
+ gem.add_development_dependency "shoulda", ">= 0"
19
+ end
20
+ Jeweler::GemcutterTasks.new
21
+ rescue LoadError
22
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
23
+ end
24
+
25
+ require 'rake/testtask'
26
+ Rake::TestTask.new(:test) do |test|
27
+ test.libs << 'lib' << 'test'
28
+ test.pattern = 'test/**/test_*.rb'
29
+ test.verbose = true
30
+ end
31
+
32
+ begin
33
+ require 'rcov/rcovtask'
34
+ Rcov::RcovTask.new do |test|
35
+ test.libs << 'test'
36
+ test.pattern = 'test/**/test_*.rb'
37
+ test.verbose = true
38
+ end
39
+ rescue LoadError
40
+ task :rcov do
41
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
42
+ end
43
+ end
44
+
45
+ task :test => :check_dependencies
46
+
47
+ task :default => :test
48
+
49
+ require 'rake/rdoctask'
50
+ Rake::RDocTask.new do |rdoc|
51
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
52
+
53
+ rdoc.rdoc_dir = 'rdoc'
54
+ rdoc.title = "jekyll-epub #{version}"
55
+ rdoc.rdoc_files.include('README*')
56
+ rdoc.rdoc_files.include('lib/**/*.rb')
57
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/bin/jekyll_epub ADDED
@@ -0,0 +1,175 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
4
+
5
+ help = <<HELP
6
+ Jekyll is a blog-aware, static site generator.
7
+
8
+ Basic Command Line Usage:
9
+ # Site # ePub
10
+ --------------------------------------------------------------#------------------#-----------------
11
+ jekyll_epub # . -> ./_site # . -> ./_epub
12
+ jekyll_epub <path to write generated site> # . -> <path> # . -> <path>
13
+ jekyll_epub <path to source> <path to write generated site> # <path> -> <path> # <path> -> <path>
14
+
15
+ ePub configuration is read from '<source>/_epub.yml'
16
+
17
+ Site configuration is read from '<source>/_config.yml' but can be overriden
18
+ using the following options:
19
+
20
+ HELP
21
+
22
+ require 'optparse'
23
+ require 'jekyll/epub'
24
+
25
+ exec = {}
26
+ options = {
27
+ 'gen_epub' => true,
28
+ 'gen_site' => true
29
+ }
30
+ opts = OptionParser.new do |opts|
31
+ opts.banner = help
32
+
33
+ opts.on("--auto", "Auto-regenerate") do
34
+ options['auto'] = true
35
+ end
36
+
37
+ opts.on("--no-auto", "No auto-regenerate") do
38
+ options['auto'] = false
39
+ end
40
+
41
+ opts.on("--no-epub", "Do not generate epub") do
42
+ options['gen_epub'] = false
43
+ end
44
+
45
+ opts.on("--no-site", "Do not generate site") do
46
+ options['gen_site'] = false
47
+ end
48
+
49
+ opts.on("--server [PORT]", "Start web server (default port 4000)") do |port|
50
+ options['server'] = true
51
+ options['server_port'] = port unless port.nil?
52
+ end
53
+
54
+ opts.on("--lsi", "Use LSI for better related posts") do
55
+ options['lsi'] = true
56
+ end
57
+
58
+ opts.on("--pygments", "Use pygments to highlight code") do
59
+ options['pygments'] = true
60
+ end
61
+
62
+ opts.on("--rdiscount", "Use rdiscount gem for Markdown") do
63
+ options['markdown'] = 'rdiscount'
64
+ end
65
+
66
+ opts.on("--permalink [TYPE]", "Use 'date' (default) for YYYY/MM/DD") do |style|
67
+ options['permalink'] = style unless style.nil?
68
+ end
69
+
70
+ opts.on("--paginate [POSTS_PER_PAGE]", "Paginate a blog's posts") do |per_page|
71
+ begin
72
+ options['paginate'] = per_page.to_i
73
+ raise ArgumentError if options['paginate'] == 0
74
+ rescue
75
+ puts 'you must specify a number of posts by page bigger than 0'
76
+ exit 0
77
+ end
78
+ end
79
+
80
+ opts.on("--version", "Display current version") do
81
+ puts "Jekyll (epub) " + Jekyll.version
82
+ exit 0
83
+ end
84
+ end
85
+
86
+ # Read command line options into `options` hash
87
+ opts.parse!
88
+
89
+ # Get source and destintation from command line
90
+ case ARGV.size
91
+ when 0
92
+ when 1
93
+ options['destination'] = ARGV[0]
94
+ when 2
95
+ options['source'] = ARGV[0]
96
+ options['destination'] = ARGV[1]
97
+ else
98
+ puts "Invalid options. Run `jekyll_epub --help` for assistance."
99
+ exit(1)
100
+ end
101
+
102
+ if options['gen_epub']
103
+ Jekyll::Epub.new().create( options )
104
+ end
105
+
106
+ if options['gen_site']
107
+ options = Jekyll.configuration(options)
108
+
109
+ # Get source and destination directories (possibly set by config file)
110
+ source = options['source']
111
+ destination = options['destination']
112
+
113
+ # Files to watch
114
+ def globs(source)
115
+ Dir.chdir(source) do
116
+ dirs = Dir['*'].select { |x| File.directory?(x) }
117
+ dirs -= ['_site']
118
+ dirs = dirs.map { |x| "#{x}/**/*" }
119
+ dirs += ['*']
120
+ end
121
+ end
122
+
123
+ # Create the Site
124
+ site = Jekyll::Site.new(options)
125
+
126
+ # Run the directory watcher for auto-generation, if required
127
+ if options['auto']
128
+ require 'directory_watcher'
129
+
130
+ puts "Auto-regenerating enabled: #{source} -> #{destination}"
131
+
132
+ dw = DirectoryWatcher.new(source)
133
+ dw.interval = 1
134
+ dw.glob = globs(source)
135
+
136
+ dw.add_observer do |*args|
137
+ t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
138
+ puts "[#{t}] regeneration: #{args.size} files changed"
139
+ site.process
140
+ end
141
+
142
+ dw.start
143
+
144
+ unless options['server']
145
+ loop { sleep 1000 }
146
+ end
147
+ else
148
+ puts "Building site: #{source} -> #{destination}"
149
+ site.process
150
+ puts "Successfully generated site: #{source} -> #{destination}"
151
+ end
152
+
153
+ # Run the server on the specified port, if required
154
+ if options['server']
155
+ require 'webrick'
156
+ include WEBrick
157
+
158
+ FileUtils.mkdir_p(destination)
159
+
160
+ mime_types = WEBrick::HTTPUtils::DefaultMimeTypes
161
+ mime_types.store 'js', 'application/javascript'
162
+
163
+ s = HTTPServer.new(
164
+ :Port => options['server_port'],
165
+ :DocumentRoot => destination,
166
+ :MimeTypes => mime_types
167
+ )
168
+ t = Thread.new {
169
+ s.start
170
+ }
171
+
172
+ trap("INT") { s.shutdown }
173
+ t.join()
174
+ end
175
+ end
@@ -0,0 +1,78 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{jekyll-epub}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Gregoire Lejeune"]
12
+ s.date = %q{2010-04-27}
13
+ s.default_executable = %q{jekyll_epub}
14
+ s.description = %q{Create an eBook (epub) of your Jekyll blog}
15
+ s.email = %q{gregoire.lejeune@free.fr}
16
+ s.executables = ["jekyll_epub"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".gitignore",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/jekyll_epub",
29
+ "jekyll-epub.gemspec",
30
+ "lib/jekyll/epub.rb",
31
+ "lib/jekyll/epub/dtd/xhtml-lat1.ent",
32
+ "lib/jekyll/epub/dtd/xhtml-special.ent",
33
+ "lib/jekyll/epub/dtd/xhtml-symbol.ent",
34
+ "lib/jekyll/epub/dtd/xhtml1-strict.dtd",
35
+ "lib/jekyll/epub/tasks.rb",
36
+ "lib/jekyll/epub/templates/META-INF/container.xml",
37
+ "lib/jekyll/epub/templates/content.opf",
38
+ "lib/jekyll/epub/templates/cover.xhtml",
39
+ "lib/jekyll/epub/templates/mimetype",
40
+ "lib/jekyll/epub/templates/page-template.xpgt",
41
+ "lib/jekyll/epub/templates/toc.ncx",
42
+ "lib/jekyll/tags/epub.rb",
43
+ "test/helper.rb",
44
+ "test/test_jekyll-epub.rb"
45
+ ]
46
+ s.homepage = %q{http://github.com/glejeune/jekyll-epub}
47
+ s.rdoc_options = ["--charset=UTF-8"]
48
+ s.require_paths = ["lib"]
49
+ s.rubygems_version = %q{1.3.6}
50
+ s.summary = %q{Create an eBook (epub) of your Jekyll blog}
51
+ s.test_files = [
52
+ "test/helper.rb",
53
+ "test/test_jekyll-epub.rb"
54
+ ]
55
+
56
+ if s.respond_to? :specification_version then
57
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
58
+ s.specification_version = 3
59
+
60
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
61
+ s.add_runtime_dependency(%q<mime-types>, [">= 0"])
62
+ s.add_runtime_dependency(%q<uuid>, [">= 0"])
63
+ s.add_runtime_dependency(%q<jekyll>, [">= 0"])
64
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
65
+ else
66
+ s.add_dependency(%q<mime-types>, [">= 0"])
67
+ s.add_dependency(%q<uuid>, [">= 0"])
68
+ s.add_dependency(%q<jekyll>, [">= 0"])
69
+ s.add_dependency(%q<shoulda>, [">= 0"])
70
+ end
71
+ else
72
+ s.add_dependency(%q<mime-types>, [">= 0"])
73
+ s.add_dependency(%q<uuid>, [">= 0"])
74
+ s.add_dependency(%q<jekyll>, [">= 0"])
75
+ s.add_dependency(%q<shoulda>, [">= 0"])
76
+ end
77
+ end
78
+