bookshop 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. data/README.rdoc +24 -2
  2. data/lib/bookshop/commands/build.rb +53 -1
  3. data/lib/bookshop/generators/bookshop/app/templates/README.rdoc +24 -2
  4. data/lib/bookshop/generators/bookshop/app/templates/book/assets/css/stylesheet.epub.css +17 -9
  5. data/lib/bookshop/generators/bookshop/app/templates/book/assets/css/stylesheet.html.css +16 -8
  6. data/lib/bookshop/generators/bookshop/app/templates/book/assets/css/stylesheet.mobi.css +17 -9
  7. data/lib/bookshop/generators/bookshop/app/templates/book/assets/css/stylesheet.pdf.css +16 -8
  8. data/lib/bookshop/generators/bookshop/app/templates/book/assets/images/cover.png +0 -0
  9. data/lib/bookshop/generators/bookshop/app/templates/book/backmatter/index.html.erb +2 -2
  10. data/lib/bookshop/generators/bookshop/app/templates/book/bodymatter/ch02/ch02.html.erb +1 -1
  11. data/lib/bookshop/generators/bookshop/app/templates/book/book.html.erb +11 -4
  12. data/lib/bookshop/{commands/epub/templates → generators/bookshop/app/templates/book/epub}/META-INF/container.xml +0 -0
  13. data/lib/bookshop/generators/bookshop/app/templates/book/epub/OEBPS/content.opf.erb +41 -0
  14. data/lib/bookshop/generators/bookshop/app/templates/book/epub/OEBPS/toc.ncx.erb +57 -0
  15. data/lib/bookshop/{commands/epub/templates → generators/bookshop/app/templates/book/epub}/mimetype +0 -0
  16. data/lib/bookshop/generators/bookshop/app/templates/book/frontmatter/cover.html.erb +26 -7
  17. data/lib/bookshop/generators/bookshop/app/templates/book/frontmatter/preface.html.erb +2 -2
  18. data/lib/bookshop/generators/bookshop/app/templates/book/frontmatter/title.html.erb +8 -6
  19. data/lib/bookshop/generators/bookshop/app/templates/book/frontmatter/toc.html.erb +58 -21
  20. data/lib/bookshop/generators/bookshop/app/templates/config/book.yml +18 -7
  21. data/lib/bookshop/version.rb +1 -1
  22. metadata +21 -27
  23. data/lib/bookshop/commands/epub/epub_build.rb +0 -91
  24. data/lib/bookshop/commands/epub/templates/OEBPS/.empty_directory +0 -0
  25. data/lib/bookshop/commands/epub/templates/OEBPS/content.opf.tt +0 -106
  26. data/lib/bookshop/commands/epub/templates/OEBPS/toc.opf.tt +0 -107
  27. data/lib/bookshop/commands/yaml/toc.rb +0 -46
  28. data/lib/bookshop/generators/bookshop/app/templates/builds/epub/META-INF/.empty_directory +0 -0
  29. data/lib/bookshop/generators/bookshop/app/templates/builds/epub/META-INF/container.xml +0 -6
  30. data/lib/bookshop/generators/bookshop/app/templates/builds/epub/OEBPS/.empty_directory +0 -0
  31. data/lib/bookshop/generators/bookshop/app/templates/builds/epub/mimetype +0 -1
@@ -1,91 +0,0 @@
1
- require 'thor/group'
2
- require 'erb'
3
- require 'fileutils'
4
- require 'yaml'
5
- require 'nokogiri'
6
-
7
- require 'bookshop/commands/yaml/book'
8
-
9
- module Bookshop
10
- module Commands
11
-
12
- # Define build commands for bookshop command line
13
- class EpubBuild < Thor::Group
14
- include Thor::Actions
15
-
16
- app_path = APP_PATH
17
- BOOK_SOURCE = "book.html.erb"
18
-
19
- # Define source root of application
20
- def self.source_root
21
- File.dirname(__FILE__)
22
- end
23
-
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
44
- puts "Deleting any old builds"
45
- FileUtils.rm_r Dir.glob('builds/epub/*')
46
-
47
- puts "Creating epub base files"
48
- directory "templates", "#{app_path}/builds/epub/"
49
- end
50
-
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
56
- end
57
-
58
- # Copy over html assets
59
- FileUtils.cp_r('book/assets/', 'builds/epub/OEBPS/', :verbose => true)
60
-
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
71
-
72
-
73
-
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
89
- end
90
- end
91
- end
@@ -1,106 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <package xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="PragmaticMagazine">
3
- <metadata xmlns:opf="http://www.idpf.org/2007/opf" xmlns:dc="http://purl.org/dc/elements/1.1/">
4
- <dc:language>en</dc:language>
5
- <dc:title>PragPub 2011-11: Issue #29</dc:title>
6
- <dc:creator opf:role="aut">The Pragmatic Bookshelf</dc:creator>
7
- <dc:date>2011-11-01</dc:date>
8
- <dc:publisher>The Pragmatic Bookshelf, LLC</dc:publisher>
9
- <dc:rights>
10
- Copyright © The Pragmatic Bookshelf, LLC
11
- </dc:rights>
12
- <dc:identifier id="PragmaticMagazine" opf:scheme="pragmatic">November 2011</dc:identifier>
13
- <dc:subject>PragPub—Monthly Magazine</dc:subject>
14
- <meta name="cover" content="cover-image"/>
15
- </metadata>
16
- <manifest>
17
- <item id="magazine-css" href="css/magazine.css" media-type="text/css"/>
18
- <item id="pt" href="page-template.xpgt" media-type="application/vnd.adobe-page-template+xml"/>
19
- <item id="cover" href="cover.xhtml" media-type="application/xhtml+xml"/>
20
- <item id="cover-image" href="images/cover.jpg" media-type="image/jpeg"/>
21
- <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>
22
- <item id="f_0000"
23
- href="f_0000.html"
24
- media-type="application/xhtml+xml" />
25
-
26
- <item id="f_0001"
27
- href="f_0001.html"
28
- media-type="application/xhtml+xml" />
29
-
30
- <item id="f_0002"
31
- href="f_0002.html"
32
- media-type="application/xhtml+xml" />
33
-
34
- <item id="f_0003"
35
- href="f_0003.html"
36
- media-type="application/xhtml+xml" />
37
-
38
- <item id="f_0004"
39
- href="f_0004.html"
40
- media-type="application/xhtml+xml" />
41
-
42
- <item id="f_0005"
43
- href="f_0005.html"
44
- media-type="application/xhtml+xml" />
45
-
46
- <item id="f_0006"
47
- href="f_0006.html"
48
- media-type="application/xhtml+xml" />
49
-
50
- <item id="f_0007"
51
- href="f_0007.html"
52
- media-type="application/xhtml+xml" />
53
-
54
- <item id="f_0008"
55
- href="f_0008.html"
56
- media-type="application/xhtml+xml" />
57
-
58
- <item id="f_0009"
59
- href="f_0009.html"
60
- media-type="application/xhtml+xml" />
61
-
62
- <item id="f_0010"
63
- href="f_0010.html"
64
- media-type="application/xhtml+xml" />
65
-
66
- <item id="f_0011"
67
- href="f_0011.html"
68
- media-type="application/xhtml+xml" />
69
-
70
- <item id="f_0012"
71
- href="f_0012.html"
72
- media-type="application/xhtml+xml" />
73
-
74
- <item id="img1" href="images/actionshot-november.jpg" media-type="image/jpeg"/>
75
- <item id="img2" href="images/XcodeSettings.jpg" media-type="image/jpeg"/>
76
- <item id="img3" href="images/RefactorToARC.jpg" media-type="image/jpeg"/>
77
- <item id="img4" href="images/ScreenShot.jpg" media-type="image/jpeg"/>
78
- <item id="img5" href="images/bigger-than-we-thought.jpg" media-type="image/jpeg"/>
79
- <item id="img6" href="images/self-infliced-scope-creep.jpg" media-type="image/jpeg"/>
80
- <item id="img7" href="images/why-is-this-going-up.jpg" media-type="image/jpeg"/>
81
- <item id="img8" href="images/Brian1.jpg" media-type="image/jpeg"/>
82
- <item id="img9" href="images/Brian2.jpg" media-type="image/jpeg"/>
83
- <item id="img10" href="images/Brian3.jpg" media-type="image/jpeg"/>
84
- <item id="img11" href="images/new-in-pragpub.jpg" media-type="image/jpeg"/>
85
- <item id="img12" href="images/new-on-bookshelf.jpg" media-type="image/jpeg"/>
86
- </manifest>
87
- <spine toc="ncx">
88
- <itemref idref="cover" linear="no"/>
89
- <itemref idref="f_0000" />
90
- <itemref idref="f_0001" />
91
- <itemref idref="f_0002" />
92
- <itemref idref="f_0003" />
93
- <itemref idref="f_0004" />
94
- <itemref idref="f_0005" />
95
- <itemref idref="f_0006" />
96
- <itemref idref="f_0007" />
97
- <itemref idref="f_0008" />
98
- <itemref idref="f_0009" />
99
- <itemref idref="f_0010" />
100
- <itemref idref="f_0011" />
101
- <itemref idref="f_0012" />
102
- </spine>
103
- <guide>
104
- <reference type="cover" title="Cover" href="cover.xhtml"/>
105
- </guide>
106
- </package>
@@ -1,107 +0,0 @@
1
- <?xml version="1.0"?>
2
- <ncx xmlns:calibre="http://calibre.kovidgoyal.net/2009/metadata" xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1" xml:lang="en">
3
- <head>
4
- <meta name="dtb:uid" content="<%= book.isbn %>"/>
5
- <meta name="dtb:depth" content="1"/>
6
- <meta name="dtb:totalPageCount" content="0"/>
7
- <meta name="dtb:maxPageNumber" content="0"/>
8
- </head>
9
- <docTitle>
10
- <text><%= book.epub.title %></text>
11
- </docTitle>
12
- <navMap>
13
- <% for toc in toc do %>
14
- <navPoint id="navPoint-0" playOrder="1">
15
- <navLabel>
16
- <text><%= toc.test %></text>
17
- </navLabel>
18
- <content src="book.html#<%= toc.name %>"/>
19
- </navPoint>
20
-
21
-
22
- <navPoint id="navPoint-1" playOrder="2">
23
- <navLabel>
24
- <text>Up Front</text>
25
- </navLabel>
26
- <content src="f_0001.html"/>
27
- </navPoint>
28
-
29
- <navPoint id="navPoint-2" playOrder="3">
30
- <navLabel>
31
- <text>Choice Bits</text>
32
- </navLabel>
33
- <content src="f_0002.html"/>
34
- </navPoint>
35
-
36
- <navPoint id="navPoint-3" playOrder="4">
37
- <navLabel>
38
- <text>Meet the Team</text>
39
- </navLabel>
40
- <content src="f_0003.html"/>
41
- </navPoint>
42
-
43
- <navPoint id="navPoint-4" playOrder="5">
44
- <navLabel>
45
- <text>Inside iOS 5</text>
46
- </navLabel>
47
- <content src="f_0004.html"/>
48
- </navPoint>
49
-
50
- <navPoint id="navPoint-5" playOrder="6">
51
- <navLabel>
52
- <text>Scala for the Intrigued</text>
53
- </navLabel>
54
- <content src="f_0005.html"/>
55
- </navPoint>
56
-
57
- <navPoint id="navPoint-6" playOrder="7">
58
- <navLabel>
59
- <text>Test-Driven Development</text>
60
- </navLabel>
61
- <content src="f_0006.html"/>
62
- </navPoint>
63
-
64
- <navPoint id="navPoint-7" playOrder="8">
65
- <navLabel>
66
- <text>Self-Inflicted Scope Creep</text>
67
- </navLabel>
68
- <content src="f_0007.html"/>
69
- </navPoint>
70
-
71
- <navPoint id="navPoint-8" playOrder="9">
72
- <navLabel>
73
- <text>Root Cause Analysis from Long Ago</text>
74
- </navLabel>
75
- <content src="f_0008.html"/>
76
- </navPoint>
77
-
78
- <navPoint id="navPoint-9" playOrder="10">
79
- <navLabel>
80
- <text>When Did That Happen?</text>
81
- </navLabel>
82
- <content src="f_0009.html"/>
83
- </navPoint>
84
-
85
- <navPoint id="navPoint-10" playOrder="11">
86
- <navLabel>
87
- <text>Calendar</text>
88
- </navLabel>
89
- <content src="f_0010.html"/>
90
- </navPoint>
91
-
92
- <navPoint id="navPoint-11" playOrder="12">
93
- <navLabel>
94
- <text>Shady Illuminations</text>
95
- </navLabel>
96
- <content src="f_0011.html"/>
97
- </navPoint>
98
-
99
- <navPoint id="navPoint-12" playOrder="13">
100
- <navLabel>
101
- <text>But Wait, There ’s More...</text>
102
- </navLabel>
103
- <content src="f_0012.html"/>
104
- </navPoint>
105
-
106
- </navMap>
107
- </ncx>
@@ -1,46 +0,0 @@
1
- # Take a YAML data structure and express it in a 'class.attribute.attribute' convention so
2
- # it can be used in the source files to call data from the toc.yml file
3
- #
4
- # # toc.yml
5
- # foo:
6
- # bar: foobar
7
- #
8
- # is referenced in the source files as <%= toc.foo.bar %> and yields in build 'foobar'
9
- module Bookshop
10
- module Commands
11
- class Toc
12
-
13
- def initialize(data={})
14
- @data = {}
15
- update!(data)
16
- end
17
-
18
- def update!(data)
19
- data.each do |key, value|
20
- self[key] = value
21
- end
22
- end
23
-
24
- def [](key)
25
- @data[key.to_sym]
26
- end
27
-
28
- def []=(key, value)
29
- if value.class == Hash
30
- @data[key.to_sym] = Book.new(value)
31
- else
32
- @data[key.to_sym] = value
33
- end
34
- end
35
-
36
- def method_missing(sym, *args)
37
- if sym.to_s =~ /(.+)=$/
38
- self[$1] = args.first
39
- else
40
- self[sym]
41
- end
42
- end
43
-
44
- end
45
- end
46
- end
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" ?>
2
- <container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
3
- <rootfiles>
4
- <rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/>
5
- </rootfiles>
6
- </container>
@@ -1 +0,0 @@
1
- application/epub+zip