bookshop 0.0.21 → 0.0.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. data/README.rdoc +17 -51
  2. data/lib/bookshop/commands/build.rb +5 -10
  3. data/lib/bookshop/commands/epub/epub_build.rb +61 -37
  4. data/lib/bookshop/commands/epub/templates/OEBPS/.empty_directory +0 -0
  5. data/lib/bookshop/commands/epub/templates/OEBPS/{content.opf.erb → content.opf.tt} +0 -0
  6. data/lib/bookshop/commands/epub/templates/OEBPS/{toc.opf.erb → toc.opf.tt} +0 -0
  7. data/lib/bookshop/generators/bookshop/app/templates/README.rdoc +17 -51
  8. data/lib/bookshop/{commands/epub/templates/OEBPS → generators/bookshop/app/templates/book/assets/css}/page-template.xpgt +0 -0
  9. data/lib/bookshop/generators/bookshop/app/templates/book/{css/stylesheet.css → assets/css/stylesheet.epub.css} +0 -0
  10. data/lib/bookshop/generators/bookshop/app/templates/book/assets/css/stylesheet.html.css +451 -0
  11. data/lib/bookshop/generators/bookshop/app/templates/book/assets/css/stylesheet.mobi.css +451 -0
  12. data/lib/bookshop/generators/bookshop/app/templates/book/assets/css/stylesheet.pdf.css +451 -0
  13. data/lib/bookshop/generators/bookshop/app/templates/book/{images → assets/images}/canvas.jpg +0 -0
  14. data/lib/bookshop/generators/bookshop/app/templates/book/{images → assets/images}/draft.png +0 -0
  15. data/lib/bookshop/generators/bookshop/app/templates/book/{images → assets/images}/html-18.png +0 -0
  16. data/lib/bookshop/generators/bookshop/app/templates/book/assets/js/.empty_directory +0 -0
  17. data/lib/bookshop/generators/bookshop/app/templates/book/book.html.erb +13 -6
  18. data/lib/bookshop/generators/bookshop/app/templates/book/ch01/adding_images.html.erb +1 -1
  19. data/lib/bookshop/generators/bookshop/app/templates/book/cover.html.erb +1 -1
  20. data/lib/bookshop/generators/bookshop/app/templates/builds/epub/META-INF/.empty_directory +0 -0
  21. data/lib/bookshop/generators/bookshop/app/templates/builds/epub/META-INF/container.xml +6 -0
  22. data/lib/bookshop/generators/bookshop/app/templates/builds/epub/OEBPS/.empty_directory +0 -0
  23. data/lib/bookshop/generators/bookshop/app/templates/builds/epub/mimetype +1 -0
  24. data/lib/bookshop/generators/bookshop/app/templates/config/book.yml +2 -2
  25. data/lib/bookshop/generators/bookshop/app/templates/script/bookshop +1 -0
  26. data/lib/bookshop/version.rb +1 -1
  27. metadata +44 -26
data/README.rdoc CHANGED
@@ -2,13 +2,9 @@
2
2
 
3
3
  "a book publishing framework for today's publishing world"
4
4
 
5
- bookshop is a book publishing framework for publishers, editors, and coders in today's publishing industry. bookshop provides a framework for developing books using well-known/standard web languages like HTML/CSS, which are then converted into pdf and other (e)book formats. The framework is optimized to help developers quickly ramp-up, allowing them to jump in and develop their html-to-pdf/(e)book flows, by favoring convention over configuration, setting them up with best-practices, standards and tools from the start.
5
+ bookshop is a book publishing framework for building pdf/(e)books based on HTML, CSS, and JavaScript. The framework is optimized to help publishers, editors, and authors quickly ramp-up, allowing them to jump in and develop their html-to-pdf/(e)book flows by favoring convention over configuration, setting them up with best-practices, standards and tools from the start.
6
6
 
7
7
  bookshop hopes to simplify the process by:
8
- * separating the book into layers
9
- * *Content*: the book's source - <i>writings, images, videos, copy</i>
10
- * *Structure*: using div/css microformat to describe the book's structure - <i>chapter, section, etc.</i>
11
- * *Style*: stylesheets to create the book's layout - <i>fonts, margins, color, etc.</i>
12
8
  * using common tools like HTML/CSS to make the creation of your book comfortable and familiar, greatly reducing the learning curve for your developers, authors, agents, and other team members
13
9
  * providing a Ruby Gem to make building a book in HTML as easy as 'gem install bookshop'
14
10
  * pulling all the html-to-pdf/(e)book tools together into one place (wkhtmltopdf, kindlegen, epubcheck)
@@ -262,9 +258,10 @@ The default directory structure of a generated bookshop project:
262
258
 
263
259
  |-- book/ # Source files for your book
264
260
  |--book.html.erb # The master file
265
- |--css/
266
- |--stylesheet.css
267
- |--images/
261
+ |--assets/
262
+ |--css/
263
+ |--stylesheet.css
264
+ |--images/
268
265
 
269
266
  |-- builds/ # All the builds are created here
270
267
  |--epub/
@@ -302,45 +299,9 @@ config
302
299
  6. Let us know about your code and we'll review/merge it into the master.
303
300
  7. And pat yourself on the back for contributing to an open source project!!
304
301
 
305
- == Copyright (LICENSE)
306
-
307
- BookShop is available under *either* the terms of the modified BSD license *or* the
308
- MIT License (2008). As a recipient of BookShop, you may choose which
309
- license to receive this code under (except as noted in per-module LICENSE
310
- files). Some modules may not be the copyright of BlueHead Publishing. These
311
- modules contain explicit declarations of copyright in both the LICENSE files in
312
- the directories in which they reside and in the code itself. No external
313
- contributions are allowed under licenses which are fundamentally incompatible
314
- with the MIT or BSD licenses that BookShop is distributed under.
315
-
316
- The text of the MIT and BSD licenses is reproduced below.
317
-
318
- === The "New" BSD License
319
-
320
- Copyright (c) 2010-2011, BlueHead Publishing
321
- All rights reserved.
302
+ == Copyright (MIT-LICENSE)
322
303
 
323
- Redistribution and use in source and binary forms, with or without
324
- modification, are permitted provided that the following conditions are met:
325
-
326
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
327
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
328
- * Neither the name of Bookshop/BlueHead/BlueHead Publishing nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
329
-
330
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
331
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
332
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
333
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
334
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
335
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
336
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
337
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
338
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
339
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
340
-
341
- === The MIT License
342
-
343
- Copyright (c) 2010, 2011 BlueHead Publishing, et. al.,
304
+ Copyright (C) 2010, 2011 by BlueHead Publishing, Inc (http://blueheadpublishing.com)
344
305
 
345
306
  Permission is hereby granted, free of charge, to any person obtaining a copy
346
307
  of this software and associated documentation files (the "Software"), to deal
@@ -360,11 +321,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
360
321
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
361
322
  THE SOFTWARE.
362
323
 
363
- == The Boom Microformat License (as listed in the boom.css)
324
+ == The Boom Microformat License - boom.css (from which the css microformat was based)
325
+
326
+ http://www.alistapart.com/articles/boom
364
327
 
365
- Sample style sheet for boom!, the book microformat
366
- written by Hakon Wium Lie and Bert Bos, November 2005
367
- You may reuse this style sheet for any purpose without any fees
328
+ Sample style sheet for boom!, the book microformat
329
+ written by Hakon Wium Lie and Bert Bos, November 2005
330
+ You may reuse this style sheet for any purpose without any fees
368
331
 
369
332
  == Thanks
370
333
 
@@ -373,4 +336,7 @@ We would like to thank:
373
336
  * The Ruby/Rubygems Team www.ruby-lang.org/
374
337
  * The Thor Team - https://github.com/wycats/thor
375
338
  * Hakon Wium Lie and Bert Bos for developing the book microformat http://www.alistapart.com/articles/boom
376
- * The WKHTMLTOPDF team http://code.google.com/p/wkhtmltopdf/
339
+ * The WKHTMLTOPDF team http://code.google.com/p/wkhtmltopdf/
340
+
341
+ A List of Our Contributors:
342
+ https://github.com/blueheadpublishing/bookshop/blob/master/CONTRIBUTORS.md
@@ -5,8 +5,6 @@ require 'yaml'
5
5
  require 'PDFKit'
6
6
 
7
7
  require 'bookshop/commands/yaml/book'
8
-
9
- # require 'bookshop/commands/yaml/toc'
10
8
  # require 'bookshop/commands/epub/epub_build'
11
9
 
12
10
  module Bookshop
@@ -76,8 +74,7 @@ module Bookshop
76
74
  f << erb
77
75
  end
78
76
 
79
- FileUtils.cp_r('book/css/', 'builds/html/', :verbose => true)
80
- FileUtils.cp_r('book/images/', 'builds/html/', :verbose => true)
77
+ FileUtils.cp_r('book/assets/', 'builds/html/', :verbose => true)
81
78
 
82
79
  # 'build pdf' generates a pdf version of the book from the builds/html/book.html
83
80
  # which is generated from the book/book.html.erb source file
@@ -97,8 +94,7 @@ module Bookshop
97
94
  end
98
95
 
99
96
  # Copy over html assets
100
- FileUtils.cp_r('book/css/', 'builds/html/', :verbose => true)
101
- FileUtils.cp_r('book/images/', 'builds/html/', :verbose => true)
97
+ FileUtils.cp_r('book/assets/', 'builds/html/', :verbose => true)
102
98
 
103
99
 
104
100
  # PDFKit.new takes the HTML and any options for wkhtmltopdf
@@ -111,10 +107,9 @@ module Bookshop
111
107
  # Save the PDF to a file
112
108
  file = kit.to_file('builds/pdf/book.pdf')
113
109
 
114
- #when 'epub'
115
- # require 'bookshop/commands/epub/epub_build'
116
- #EpubBuild.new
117
-
110
+ # when 'epub'
111
+ # Bookshop::Commands::EpubBuild.new
112
+
118
113
  else
119
114
  puts "Error: Command not recognized" unless %w(-h --help).include?(build)
120
115
  puts <<-EOT
@@ -1,67 +1,91 @@
1
1
  require 'thor/group'
2
2
  require 'erb'
3
+ require 'fileutils'
3
4
  require 'yaml'
4
-
5
+ require 'nokogiri'
5
6
 
6
7
  require 'bookshop/commands/yaml/book'
7
8
 
8
9
  module Bookshop
9
10
  module Commands
10
11
 
11
- # Builds the EPUB version of the book
12
+ # Define build commands for bookshop command line
12
13
  class EpubBuild < Thor::Group
13
14
  include Thor::Actions
14
15
 
16
+ app_path = APP_PATH
17
+ BOOK_SOURCE = "book.html.erb"
18
+
15
19
  # Define source root of application
16
20
  def self.source_root
17
21
  File.dirname(__FILE__)
18
22
  end
19
-
20
-
21
23
 
22
- def clean_up
24
+ # Load YAML files
25
+ def self.load_yaml_files
26
+ # Load the book.yml into the Book object
27
+ @book = Book.new(YAML.load_file('config/book.yml'))
28
+ # @toc = Toc.new(YAML.load_file('config/toc.yml'))
29
+ end
30
+
31
+ # Renders <%= import(source.html.erb) %> files with ERB
32
+ #
33
+ # When a new import() is encountered within source files it is
34
+ # processed with this method and the result is added to 'erb'
35
+ def self.import(file)
36
+ load_yaml_files
37
+ # Parse the source erb file
38
+ ERB.new(File.read('book/'+file)).result(binding).gsub(/\n$/,'')
39
+ end
40
+
41
+ # Create the project from templates
42
+ def create_base_project
43
+ # Clean up any old builds
23
44
  puts "Deleting any old builds"
24
45
  FileUtils.rm_r Dir.glob('builds/epub/*')
25
- FileUtils.rm_r Dir.glob('builds/html/*')
46
+
47
+ puts "Creating epub base files"
48
+ directory "templates", "#{app_path}/builds/epub/"
26
49
  end
27
50
 
28
- def compile_erb_source
29
- @output = :epub
30
-
31
- erb = import(BOOK_SOURCE)
32
-
33
- # Generate the html from ERB
34
- puts "Building new epub at builds/epub/book.epub"
35
- File.open('builds/epub/OEBPS/book.html', 'a') do |f|
36
- f << erb
37
- end
38
- FileUtils.cp_r('book/css/', 'builds/epub/OEBPS/', :verbose => true)
39
- FileUtils.cp_r('book/images/', 'builds/epub/OEBPS/', :verbose => true)
51
+ @output = :epub
52
+ erb = import(BOOK_SOURCE)
53
+ puts "Generating new html from erb"
54
+ File.open('builds/epub/OEBPS/book.html', 'a') do |f|
55
+ f << erb
40
56
  end
41
57
 
42
- # Load the book.yml into the Book object
43
- @book = Book.new(YAML.load_file('config/book.yml'))
44
- @toc = Toc.new(TAML.load_file('config/table_of_contents.yml'))
58
+ # Copy over html assets
59
+ FileUtils.cp_r('book/assets/', 'builds/epub/OEBPS/', :verbose => true)
45
60
 
46
- def create_epub_structure
47
- directory "templates/epub", "builds/epub"
48
- end
61
+ # Generate toc source
62
+ # @output = :epub
63
+ # def create_toc
64
+ # puts "Generating new toc from toc.html.erb"
65
+ # toc_erb = import("book/toc.html.erb")
66
+ # @noko_doc = Nokogiri::HTML(toc_erb)
67
+ # File.open("builds/epub/OEBPS/toc.ncx", 'a') do |f|
68
+ # f << @noko_doc.to_xml
69
+ # end
70
+ #end
49
71
 
50
- def generate_content_opf_file
51
- template "templates/content.opf.tt" "builds/epub/OEBPS"
52
- end
53
-
54
- def generate_toc
55
- template "templates/toc.ncs.tt" "builds/epub/OEBPS"
56
- end
57
72
 
58
- def zip_epub
59
- # zip the contents into book.epub
60
- end
61
73
 
62
- def validate_epub
63
- # cmd = %x[tools/epubcheck book_#{Time.now.strftime('%m-%e-%y').epub]
64
- end
74
+
75
+ #File.open("builds/epub/OEBPS/toc.ncx", 'a') do |f|
76
+ # f << @noko_doc.to_xml
77
+ #end
78
+
79
+ #@doc = Nokogiri::HTML(f)
80
+
81
+ #f.close
82
+
83
+ # store nav structure in array tree
84
+ # build xml toc.ncx file from array
85
+
86
+ # create content.opf
87
+
88
+ # zip it up
65
89
  end
66
90
  end
67
91
  end
@@ -2,13 +2,9 @@
2
2
 
3
3
  "a book publishing framework for today's publishing world"
4
4
 
5
- bookshop is a book publishing framework for publishers, editors, and coders in today's publishing industry. bookshop provides a framework for developing books using well-known/standard web languages like HTML/CSS, which are then converted into pdf and other (e)book formats. The framework is optimized to help developers quickly ramp-up, allowing them to jump in and develop their html-to-pdf/(e)book flows, by favoring convention over configuration, setting them up with best-practices, standards and tools from the start.
5
+ bookshop is a book publishing framework for building pdf/(e)books based on HTML, CSS, and JavaScript. The framework is optimized to help publishers, editors, and authors quickly ramp-up, allowing them to jump in and develop their html-to-pdf/(e)book flows by favoring convention over configuration, setting them up with best-practices, standards and tools from the start.
6
6
 
7
7
  bookshop hopes to simplify the process by:
8
- * separating the book into layers
9
- * *Content*: the book's source - <i>writings, images, videos, copy</i>
10
- * *Structure*: using div/css microformat to describe the book's structure - <i>chapter, section, etc.</i>
11
- * *Style*: stylesheets to create the book's layout - <i>fonts, margins, color, etc.</i>
12
8
  * using common tools like HTML/CSS to make the creation of your book comfortable and familiar, greatly reducing the learning curve for your developers, authors, agents, and other team members
13
9
  * providing a Ruby Gem to make building a book in HTML as easy as 'gem install bookshop'
14
10
  * pulling all the html-to-pdf/(e)book tools together into one place (wkhtmltopdf, kindlegen, epubcheck)
@@ -262,9 +258,10 @@ The default directory structure of a generated bookshop project:
262
258
 
263
259
  |-- book/ # Source files for your book
264
260
  |--book.html.erb # The master file
265
- |--css/
266
- |--stylesheet.css
267
- |--images/
261
+ |--assets/
262
+ |--css/
263
+ |--stylesheet.css
264
+ |--images/
268
265
 
269
266
  |-- builds/ # All the builds are created here
270
267
  |--epub/
@@ -302,45 +299,9 @@ config
302
299
  6. Let us know about your code and we'll review/merge it into the master.
303
300
  7. And pat yourself on the back for contributing to an open source project!!
304
301
 
305
- == Copyright (LICENSE)
306
-
307
- BookShop is available under *either* the terms of the modified BSD license *or* the
308
- MIT License (2008). As a recipient of BookShop, you may choose which
309
- license to receive this code under (except as noted in per-module LICENSE
310
- files). Some modules may not be the copyright of BlueHead Publishing. These
311
- modules contain explicit declarations of copyright in both the LICENSE files in
312
- the directories in which they reside and in the code itself. No external
313
- contributions are allowed under licenses which are fundamentally incompatible
314
- with the MIT or BSD licenses that BookShop is distributed under.
315
-
316
- The text of the MIT and BSD licenses is reproduced below.
317
-
318
- === The "New" BSD License
319
-
320
- Copyright (c) 2010-2011, BlueHead Publishing
321
- All rights reserved.
302
+ == Copyright (MIT-LICENSE)
322
303
 
323
- Redistribution and use in source and binary forms, with or without
324
- modification, are permitted provided that the following conditions are met:
325
-
326
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
327
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
328
- * Neither the name of Bookshop/BlueHead/BlueHead Publishing nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
329
-
330
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
331
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
332
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
333
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
334
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
335
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
336
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
337
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
338
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
339
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
340
-
341
- === The MIT License
342
-
343
- Copyright (c) 2010, 2011 BlueHead Publishing, et. al.,
304
+ Copyright (C) 2010, 2011 by BlueHead Publishing, Inc (http://blueheadpublishing.com)
344
305
 
345
306
  Permission is hereby granted, free of charge, to any person obtaining a copy
346
307
  of this software and associated documentation files (the "Software"), to deal
@@ -360,11 +321,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
360
321
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
361
322
  THE SOFTWARE.
362
323
 
363
- == The Boom Microformat License (as listed in the boom.css)
324
+ == The Boom Microformat License - boom.css (from which the css microformat was based)
325
+
326
+ http://www.alistapart.com/articles/boom
364
327
 
365
- Sample style sheet for boom!, the book microformat
366
- written by Hakon Wium Lie and Bert Bos, November 2005
367
- You may reuse this style sheet for any purpose without any fees
328
+ Sample style sheet for boom!, the book microformat
329
+ written by Hakon Wium Lie and Bert Bos, November 2005
330
+ You may reuse this style sheet for any purpose without any fees
368
331
 
369
332
  == Thanks
370
333
 
@@ -373,4 +336,7 @@ We would like to thank:
373
336
  * The Ruby/Rubygems Team www.ruby-lang.org/
374
337
  * The Thor Team - https://github.com/wycats/thor
375
338
  * Hakon Wium Lie and Bert Bos for developing the book microformat http://www.alistapart.com/articles/boom
376
- * The WKHTMLTOPDF team http://code.google.com/p/wkhtmltopdf/
339
+ * The WKHTMLTOPDF team http://code.google.com/p/wkhtmltopdf/
340
+
341
+ A List of Our Contributors:
342
+ https://github.com/blueheadpublishing/bookshop/blob/master/CONTRIBUTORS.md