prophecy 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/Overview.md +44 -0
  6. data/README.md +35 -0
  7. data/Rakefile +1 -0
  8. data/bin/kindlegen +18 -0
  9. data/bin/kindlegen.exe +0 -0
  10. data/bin/kindlegen_linux +0 -0
  11. data/bin/kindlegen_mac +0 -0
  12. data/bin/prophecy +4 -0
  13. data/docs/licenses/kindlegen/.empty_directory +0 -0
  14. data/docs/licenses/kindlegen/EULA.txt +61 -0
  15. data/docs/licenses/kindlegen/KindleGen Legal Notices 2009-11-10 Linux.txt +21 -0
  16. data/docs/licenses/kindlegen/KindleGen Legal Notices 2009-11-10 Mac.txt +21 -0
  17. data/docs/licenses/kindlegen/KindleGen OSS Notices 2009-07-29-Windows.txt +19 -0
  18. data/features/assets.feature +14 -0
  19. data/features/book.feature +10 -0
  20. data/features/generator.feature +15 -0
  21. data/features/support/hooks.rb +5 -0
  22. data/features/support/setup.rb +3 -0
  23. data/lib/prophecy/assets/.gitignore +2 -0
  24. data/lib/prophecy/assets/config.rb +20 -0
  25. data/lib/prophecy/assets/epub_template/META-INF/com.apple.ibooks.display-options.xml +6 -0
  26. data/lib/prophecy/assets/epub_template/META-INF/container.xml +6 -0
  27. data/lib/prophecy/assets/epub_template/OEBPS/.gitkeep +0 -0
  28. data/lib/prophecy/assets/epub_template/OEBPS/chapters/.gitkeep +0 -0
  29. data/lib/prophecy/assets/epub_template/OEBPS/content.opf.erb +114 -0
  30. data/lib/prophecy/assets/epub_template/OEBPS/toc.ncx.erb +18 -0
  31. data/lib/prophecy/assets/epub_template/mimetype +1 -0
  32. data/lib/prophecy/assets/fonts/Crimson-Bold.otf +0 -0
  33. data/lib/prophecy/assets/fonts/Crimson-BoldItalic.otf +0 -0
  34. data/lib/prophecy/assets/fonts/Crimson-Italic.otf +0 -0
  35. data/lib/prophecy/assets/fonts/Crimson-Roman.otf +0 -0
  36. data/lib/prophecy/assets/fonts/Crimson-Semibold.otf +0 -0
  37. data/lib/prophecy/assets/fonts/Crimson-SemiboldItalic.otf +0 -0
  38. data/lib/prophecy/assets/fonts/GenBasB.ttf +0 -0
  39. data/lib/prophecy/assets/fonts/GenBasBI.ttf +0 -0
  40. data/lib/prophecy/assets/fonts/GenBasI.ttf +0 -0
  41. data/lib/prophecy/assets/fonts/GenBasR.ttf +0 -0
  42. data/lib/prophecy/assets/fonts/GenBkBasB.ttf +0 -0
  43. data/lib/prophecy/assets/fonts/GenBkBasBI.ttf +0 -0
  44. data/lib/prophecy/assets/fonts/GenBkBasI.ttf +0 -0
  45. data/lib/prophecy/assets/fonts/GenBkBasR.ttf +0 -0
  46. data/lib/prophecy/assets/fonts/GentiumPlus-I.ttf +0 -0
  47. data/lib/prophecy/assets/fonts/GentiumPlus-R.ttf +0 -0
  48. data/lib/prophecy/assets/helpers/check_typos.sh +27 -0
  49. data/lib/prophecy/assets/helpers/helpers.rb +0 -0
  50. data/lib/prophecy/assets/helpers/pali_typos +2 -0
  51. data/lib/prophecy/assets/helpers/sed_chars +5 -0
  52. data/lib/prophecy/assets/helpers/sed_dumb_ebook +18 -0
  53. data/lib/prophecy/assets/helpers/sed_tex2uni +62 -0
  54. data/lib/prophecy/assets/helpers/tex2html.sh +112 -0
  55. data/lib/prophecy/assets/helpers/tex2md.sh +10 -0
  56. data/lib/prophecy/assets/helpers/tidy_quotes +1 -0
  57. data/lib/prophecy/assets/helpers/tidy_quotes.sh +8 -0
  58. data/lib/prophecy/assets/helpers/to-html.sh +9 -0
  59. data/lib/prophecy/assets/latex_template/Makefile +37 -0
  60. data/lib/prophecy/assets/latex_template/anecdote.cls +163 -0
  61. data/lib/prophecy/assets/latex_template/book-core-first.sty +673 -0
  62. data/lib/prophecy/assets/latex_template/book-core-last.sty +40 -0
  63. data/lib/prophecy/assets/latex_template/book_main.tex.erb +31 -0
  64. data/lib/prophecy/assets/latex_template/booklet_main.tex +15 -0
  65. data/lib/prophecy/assets/latex_template/chapters/.gitkeep +0 -0
  66. data/lib/prophecy/assets/latex_template/cover_main.tex +48 -0
  67. data/lib/prophecy/assets/latex_template/mylayout.sty +2 -0
  68. data/lib/prophecy/assets/layouts/page.xhtml.erb +20 -0
  69. data/lib/prophecy/assets/sass/_booktheme.sass +3 -0
  70. data/lib/prophecy/assets/sass/_byronic.sass +263 -0
  71. data/lib/prophecy/assets/sass/_colors.sass +7 -0
  72. data/lib/prophecy/assets/sass/_epub-css-starter-kit.sass +734 -0
  73. data/lib/prophecy/assets/sass/_font-existence.scss +12 -0
  74. data/lib/prophecy/assets/sass/_font-source-sans-pro.scss +75 -0
  75. data/lib/prophecy/assets/sass/_fontfaces.scss +11 -0
  76. data/lib/prophecy/assets/sass/_mixins.sass +4 -0
  77. data/lib/prophecy/assets/sass/print.sass +6 -0
  78. data/lib/prophecy/assets/sass/style-epub.sass +7 -0
  79. data/lib/prophecy/assets/sass/style-mobi-kf8.sass +7 -0
  80. data/lib/prophecy/assets/sass/style-mobi.sass +9 -0
  81. data/lib/prophecy/assets/stylesheets/print.css +3 -0
  82. data/lib/prophecy/assets/stylesheets/style-epub.css +401 -0
  83. data/lib/prophecy/assets/stylesheets/style-mobi-kf8.css +401 -0
  84. data/lib/prophecy/assets/stylesheets/style-mobi.css +317 -0
  85. data/lib/prophecy/assets/webfonts/existence-light.ttf +0 -0
  86. data/lib/prophecy/assets/webfonts/sourcesanspro-bold.ttf +0 -0
  87. data/lib/prophecy/assets/webfonts/sourcesanspro-extralight.ttf +0 -0
  88. data/lib/prophecy/assets/webfonts/sourcesanspro-italic.ttf +0 -0
  89. data/lib/prophecy/assets/webfonts/sourcesanspro-light.ttf +0 -0
  90. data/lib/prophecy/assets/webfonts/sourcesanspro-lightitalic.ttf +0 -0
  91. data/lib/prophecy/assets/webfonts/sourcesanspro-regular.ttf +0 -0
  92. data/lib/prophecy/assets/webfonts-extra/sourcesanspro-bolditalic.ttf +0 -0
  93. data/lib/prophecy/assets/webfonts-extra/sourcesanspro-extralightitalic.ttf +0 -0
  94. data/lib/prophecy/assets/webfonts-extra/sourcesanspro-semibold.ttf +0 -0
  95. data/lib/prophecy/assets/webfonts-extra/sourcesanspro-semibolditalic.ttf +0 -0
  96. data/lib/prophecy/book.rb +281 -0
  97. data/lib/prophecy/chapter.rb +359 -0
  98. data/lib/prophecy/cli.rb +144 -0
  99. data/lib/prophecy/generators/assets.rb +29 -0
  100. data/lib/prophecy/generators/book/.gitignore +7 -0
  101. data/lib/prophecy/generators/book/LICENSE.txt +5 -0
  102. data/lib/prophecy/generators/book/README.md.tt +4 -0
  103. data/lib/prophecy/generators/book/book.yml.tt +55 -0
  104. data/lib/prophecy/generators/book/build/epub/.empty_directory +0 -0
  105. data/lib/prophecy/generators/book/build/latex/.empty_directory +0 -0
  106. data/lib/prophecy/generators/book/build/mobi/.empty_directory +0 -0
  107. data/lib/prophecy/generators/book/epub_mobi.yml +26 -0
  108. data/lib/prophecy/generators/book/example-book.yml +78 -0
  109. data/lib/prophecy/generators/book/images/cover.jpg +0 -0
  110. data/lib/prophecy/generators/book/images/cover.xcf +0 -0
  111. data/lib/prophecy/generators/book/images/publisher-logo.jpg +0 -0
  112. data/lib/prophecy/generators/book/manuscript/glossary.md +7 -0
  113. data/lib/prophecy/generators/book/manuscript/nameless-labyrinth.markdown +34 -0
  114. data/lib/prophecy/generators/book/manuscript/preface.md +5 -0
  115. data/lib/prophecy/generators/book/manuscript/the-sway-of-reason.markdown +22 -0
  116. data/lib/prophecy/generators/book/manuscript/unhuman-massiveness.markdown +27 -0
  117. data/lib/prophecy/generators/book/manuscript/xhtml/.gitkeep +0 -0
  118. data/lib/prophecy/generators/book/manuscript/xhtml/cover.xhtml.erb +21 -0
  119. data/lib/prophecy/generators/book/manuscript/xhtml/titlepage.xhtml.erb +31 -0
  120. data/lib/prophecy/generators/book/manuscript/xhtml/toc.xhtml.erb +16 -0
  121. data/lib/prophecy/generators/new.rb +22 -0
  122. data/lib/prophecy/manifest.rb +72 -0
  123. data/lib/prophecy/version.rb +3 -0
  124. data/lib/prophecy.rb +18 -0
  125. data/prophecy.gemspec +36 -0
  126. data/spec/book_spec.rb +9 -0
  127. data/spec/chapter_spec.rb +0 -0
  128. data/spec/manifest_spec.rb +0 -0
  129. metadata +366 -0
@@ -0,0 +1,144 @@
1
+
2
+ require 'thor'
3
+ require 'prophecy'
4
+ require 'prophecy/generators/new'
5
+ require 'prophecy/generators/assets'
6
+
7
+ module Prophecy
8
+
9
+ class CLI < Thor
10
+
11
+ desc "new \"Title Of Book\"", "start a new book project"
12
+ def new(title)
13
+ Prophecy::Generators::New.start([title, ])
14
+ end
15
+
16
+ desc "assets", "get a local copy of the 'assets' folder for customization"
17
+ def assets
18
+ Prophecy::Generators::Assets.start
19
+ end
20
+
21
+ desc "epub", "generate EPUB"
22
+ def epub
23
+ @config = YAML::load(IO.read('book.yml'))
24
+ # Local assets dir in book project folder
25
+ compile_assets if Dir.exists?('./assets') && @assets_dir == File.join('.', 'assets')
26
+ @book = epub_init_book
27
+ clean_dir(@book.build_dir)
28
+ @book.generate_build
29
+
30
+ # Compile Epub with Zip
31
+ path = File.expand_path("./publish/epub/#{@book.compile_name}.epub")
32
+ system "cd #{@book.build_dir} && zip -X #{path} mimetype"
33
+ system "cd #{@book.build_dir} && zip -rg #{path} META-INF"
34
+ system "cd #{@book.build_dir} && zip -rg #{path} OEBPS"
35
+ end
36
+
37
+ desc "mobi", "generate MOBI with Kindlegen"
38
+ def mobi
39
+ @config = YAML::load(IO.read('book.yml'))
40
+ # Local assets dir in book project folder
41
+ compile_assets if Dir.exists?('./assets') && @assets_dir == File.join('.', 'assets')
42
+ @book = mobi_init_book
43
+ clean_dir(@book.build_dir)
44
+ @book.generate_build
45
+
46
+ # Compile Epub with Zip for conversion with kindlegen
47
+ path = File.expand_path("./#{@book.compile_name}.epub")
48
+ system "cd #{@book.build_dir} && zip -X #{path} mimetype"
49
+ system "cd #{@book.build_dir} && zip -rg #{path} META-INF"
50
+ system "cd #{@book.build_dir} && zip -rg #{path} OEBPS"
51
+
52
+ # Kindlegen
53
+ binpath = File.expand_path(File.join(__FILE__, '..', '..', '..', 'bin/kindlegen'))
54
+ system "#{binpath} '#{@book.compile_name}.epub'"
55
+ system "mv '#{@book.compile_name}.mobi' ./publish/mobi/"
56
+ system "rm '#{@book.compile_name}.epub'"
57
+ end
58
+
59
+ desc "pdf", "generate PDF with LaTeX"
60
+ def pdf
61
+ @config = YAML::load(IO.read('book.yml'))
62
+ @book = latex_init_book
63
+ clean_dir(@book.build_dir)
64
+ @book.generate_build
65
+ system "cd #{@book.build_dir} && make"
66
+ end
67
+
68
+ desc "to_markdown", "convert .tex files to markdown"
69
+ def to_markdown
70
+ @book = latex_init_book
71
+
72
+ Dir[File.join(@book.tex_dir, '*.tex')].each do |f|
73
+ dest = File.expand_path(File.join(@book.markdown_dir, File.basename(f).sub(/\.tex$/, '.md')))
74
+ if File.exist?(dest)
75
+ print "WARNING: destination exists: #{dest}\nOverwrite? [yN] "
76
+ a = STDIN.gets.chomp()
77
+ if a.downcase != 'y'
78
+ puts "OK, skipping file"
79
+ next
80
+ end
81
+ end
82
+ r = system "/bin/bash #{File.join(@book.assets_dir, 'helpers/tex2md.sh')} '#{File.expand_path(f)}' '#{dest}'"
83
+ warn "WARNING: tex2md.sh returned non-zero for #{f}" unless r
84
+ end
85
+ end
86
+
87
+ private
88
+
89
+ def epub_init_book
90
+ [ './epub_mobi.yml',
91
+ './epub.yml' ].each do |c|
92
+ next if !File.exists?(c)
93
+ h = YAML::load(IO.read(c))
94
+ @config.merge!(h) if h
95
+ end
96
+
97
+ @config['output_format'] ||= 'epub'
98
+ Prophecy::Book.new(@config)
99
+ end
100
+
101
+ def mobi_init_book
102
+ [ './epub_mobi.yml',
103
+ './mobi.yml' ].each do |c|
104
+ next if !File.exists?(c)
105
+ h = YAML::load(IO.read(c))
106
+ @config.merge!(h) if h
107
+ end
108
+
109
+ @config['output_format'] ||= 'mobi'
110
+ Prophecy::Book.new(@config)
111
+ end
112
+
113
+ def latex_init_book
114
+ [ './latex.yml', ].each do |c|
115
+ next if !File.exists?(c)
116
+ h = YAML::load(IO.read(c))
117
+ @config.merge!(h) if h
118
+ end
119
+
120
+ @config['output_format'] ||= 'latex'
121
+ @book = Prophecy::Book.new(@config)
122
+ end
123
+
124
+ def compile_assets
125
+ system 'cd assets && compass compile'
126
+ end
127
+
128
+ def clean_dir(dir)
129
+ if Dir[File.join(dir, '*')].empty?
130
+ puts "#{dir} is empty."
131
+ return
132
+ end
133
+ print "Delete everything in #{dir} ? [yN] "
134
+ a = STDIN.gets.chomp()
135
+ if a.downcase != 'y'
136
+ puts "Cancelled, bye!"
137
+ exit
138
+ end
139
+ system "rm -rf #{File.join(dir, '*')}"
140
+ end
141
+
142
+ end
143
+
144
+ end
@@ -0,0 +1,29 @@
1
+
2
+ require 'thor/group'
3
+
4
+ module Prophecy
5
+
6
+ module Generators
7
+ class Assets < Thor::Group
8
+ include Thor::Actions
9
+
10
+ def self.source_root
11
+ File.dirname(__FILE__)
12
+ end
13
+
14
+ def copy_assets
15
+ unless File.exists?('book.yml')
16
+ warn "Cancelled. This doesn't look like a book project folder (there's no book.yml)."
17
+ exit 2
18
+ end
19
+ if Dir.exists?('assets')
20
+ warn "Cancelled. There is already an 'assets' folder here. Move it or delete it manually if you want a new copy."
21
+ exit 2
22
+ end
23
+ directory(File.join('..', 'assets'), "assets")
24
+ end
25
+ end
26
+ end
27
+
28
+ end
29
+
@@ -0,0 +1,7 @@
1
+ *.swp
2
+ *.aux
3
+ *.log
4
+ *.toc
5
+ publish/epub
6
+ publish/mobi
7
+ publish/pdf
@@ -0,0 +1,5 @@
1
+
2
+ This work is licensed under a Creative Commons Attribution 3.0 Unported
3
+ License.
4
+
5
+ http://creativecommons.org/licenses/by/3.0/deed.en_GB
@@ -0,0 +1,4 @@
1
+
2
+ <%= title %>
3
+ ==============
4
+
@@ -0,0 +1,55 @@
1
+
2
+ # General Config
3
+ # ==============
4
+
5
+ # The data in this file is shared between output formats.
6
+ #
7
+ # Add format-specific data in the following files, which will add to
8
+ # and override the settings in this file:
9
+ # epub_mobi.yml, epub.yml, mobi.yml, latex.yml
10
+
11
+ # These are very minimal settings, for a more complete example see
12
+ # example-book.yml
13
+
14
+ title: "<%= title %>"
15
+ author: "The Author"
16
+ date: <%= Time.now.strftime("%Y-%m-%d") %>
17
+
18
+ # A general-purpose TOC. Formats will be converted, ERB templates will
19
+ # be rendered.
20
+
21
+ # The Contents page comes in a different sequence in EPUB and MOBI,
22
+ # because of the book will open on "type: text" in the Kindle, and the
23
+ # way the "Frontmatter" menu works in Kindle, that is, it includes the
24
+ # contents before the item "type: toc".
25
+
26
+ toc:
27
+ - { the_matter: frontmatter }
28
+ - { title: "Cover", src: 'cover.xhtml.erb', target: epub, layout: none, type: cover, linear: no }
29
+ - { title: "Title Page", src: 'titlepage.xhtml.erb', target: epub, type: title-page }
30
+ - { title: "Contents", src: 'toc.xhtml.erb', target: epub, type: toc }
31
+ - preface.md
32
+ - { title: "Title Page", src: 'titlepage.xhtml.erb', target: mobi, type: text, class: title-page }
33
+ - { title: "Contents", src: 'toc.xhtml.erb', target: mobi, type: toc }
34
+ - { the_matter: mainmatter, section_number: 1 }
35
+ - the-sway-of-reason.markdown
36
+ - unhuman-massiveness.markdown
37
+ - nameless-labyrinth.markdown
38
+ - { the_matter: backmatter }
39
+ - glossary.md
40
+
41
+ cover_image: "cover.jpg"
42
+
43
+ exclude_assets: [ "cover.xcf", ]
44
+
45
+ # Either an ISBN or an UUID to identify the book.
46
+ # If you don't have an ISBN, generate an UUID:
47
+ # http://www.famkruithof.net/uuid/uuidgen
48
+
49
+ # uuid: "000-000"
50
+ isbn: "000-0-0000000-0-0"
51
+ publisher: "The Publisher"
52
+ publisher_atag: "<a href='http://thepublisher.org/' target='_blank'>www.thepublisher.org</a>"
53
+ publisher_logo: "publisher-logo.jpg"
54
+ book_atag: "<a href='http://thepublisher.org/thebookurl/' target='_blank'>www.thepublisher.org/thebookurl</a>"
55
+
@@ -0,0 +1,26 @@
1
+
2
+ # Epub and Mobi
3
+ # =============
4
+
5
+ bookid: "ProphecyBookId"
6
+
7
+ # ISBN for the ebook editions
8
+ isbn: "000-0-000000-00-0"
9
+
10
+ # BISAC Subject Headings List:
11
+ # http://www.bisg.org/what-we-do-0-136-bisac-subject-headings-list-major-subjects.php
12
+
13
+ #subject: LIST / OF / SUBJECTS
14
+ #source: http://www.source.org/
15
+
16
+ # MARC Code List for Relators:
17
+ # Editor [edt], Cover designer [cov], Translator [trl],
18
+ # Book designer [bkd]
19
+ # http://www.loc.gov/marc/relators/relaterm.html
20
+
21
+ #contributors:
22
+ # - edt: Lastname, Name
23
+ # - edt: Other Lastname, Name
24
+ # - cov: Lastname, Name
25
+ # - trl: Lastname, Name
26
+
@@ -0,0 +1,78 @@
1
+
2
+ # General
3
+ # =======
4
+
5
+ # The data in this file is shared between output formats. Custom data
6
+ # and settings go in the config/*.yml files.
7
+
8
+ title: "<%= bookname %>"
9
+ subtitle: "It's a subtle difference"
10
+ author: "The Author"
11
+ creator: "The Author"
12
+ rights: "Copyright © YEAR COPYRIGHT HOLDER. This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported Licence."
13
+ version: "v0.1"
14
+ date: "2013-01-01"
15
+
16
+ # Language and region, ISO 639-1 and ISO 3166-1
17
+ # http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
18
+ # http://en.wikipedia.org/wiki/ISO_3166-1
19
+
20
+ lang: "en-GB"
21
+
22
+ # A general-purpose Table of Contents. Formats will be converted as
23
+ # necessary. A specific TOC for an output format can be given in the
24
+ # corresponding config/*.yml file.
25
+ #
26
+ # Types (roles): http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.6
27
+
28
+ # Level 1, 2, 3
29
+ section_names: [ "Part", "Chapter", "Section" ]
30
+
31
+ toc:
32
+ - { the_matter: frontmatter }
33
+ - { insert: "\\frontmatter*\n\\chapterstyle{frontmatter}", target: latex }
34
+ - { title: "Cover", src: 'cover.xhtml.erb', target: epub, layout: none, type: cover, linear: no }
35
+ - { title: "Title Page", src: 'titlepage.xhtml.erb', target: epub, type: title-page }
36
+ - { title: "Title Page", src: "titlepage.tex", target: latex }
37
+ - { title: "Contents", src: 'toc.xhtml.erb', target: epub, type: toc }
38
+ - { title: "Copyright", src: 'copyright.md', target: [ epub, mobi ], type: copyright-page }
39
+ - { title: "Copyright", src: 'copyright.tex', target: latex }
40
+ - { title: "Dedication", src: 'dedication.md', type: dedication }
41
+ - { insert: "\\cleartorecto\n\\tableofcontents*", target: latex }
42
+ - { title: "Preface", src: 'preface.tex', type: preface }
43
+ - { title: "Introduction", src: 'introduction.tex' }
44
+ - { title: "Editor's Note", src: 'editors-note.tex' }
45
+ - { title: "Title Page", src: 'titlepage.xhtml.erb', target: mobi, type: text, class: title-page }
46
+ - { title: "Contents", src: 'toc.xhtml.erb', target: mobi, type: toc }
47
+ - { the_matter: mainmatter, section_number: 3 }
48
+ - { insert: "\\mainmatter*\n\\book{\\thetitle}\n\\setcounter{chapter}{0}\n\\chapterstyle{mainmatter}", target: latex }
49
+ - { title: "Waiting for Death", src: 'book3.html', target: [ epub, mobi ], class: part-page }
50
+ - { level: 2, title: "Text Samples", src: 'text-samples.md' }
51
+ - { title: "The Dead Hand", src: 'book5.html', target: [ epub, mobi ], class: part-page }
52
+ - { level: 2, title: "The Waste Land", src: 'wasteland.xhtml', class: verse }
53
+ - { level: 3, title: "The Metamorphosis", src: 'metamorphosis.md' }
54
+ - { level: 3, title: "Nemesis, by H.P. Lovecraft", src: 'nemesis.md', class: verse }
55
+ - { insert: '\appendix', target: latex }
56
+ - { level: 1, section_name: "Appendix", section_number: 1 }
57
+ - { title: "Further Comments", src: 'further-comments.tex' }
58
+ - { the_matter: backmatter }
59
+ - { insert: "\\backmatter\n\\bookmarksetup{startatroot}\n\\chapterstyle{backmatter}", target: latex }
60
+ - { title: "Glossary", src: 'glossary.md', target: [ epub, mobi ], type: glossary }
61
+ - { title: "Glossary", src: 'glossary.tex', target: latex }
62
+ - { title: "Acknowledgements", src: 'acknowledgements.tex', type: acknowledgements }
63
+ - { title: "About the Author", src: 'about.tex' }
64
+ - { title: "Colophon", src: 'colophon.md', type: colophon }
65
+
66
+ cover_image: "cover.jpg"
67
+
68
+ # Either an ISBN or an UUID is necessary to identify the book.
69
+ # If you don't have an ISBN, generate an UUID:
70
+ # http://www.famkruithof.net/uuid/uuidgen
71
+
72
+ # uuid: "000-000"
73
+ isbn: "000-0-0000000-0-0"
74
+ publisher: "The Publisher"
75
+ publisher_atag: "<a href='http://thepublisher.org/' target='_blank'>www.thepublisher.org</a>"
76
+ publisher_logo: "publisher-logo.jpg"
77
+ book_atag: "<a href='http://thepublisher.org/thebookurl/' target='_blank'>www.thepublisher.org/thebookurl</a>"
78
+
@@ -0,0 +1,7 @@
1
+
2
+ # Glossary
3
+
4
+ * word one
5
+ * word two
6
+ * how many words do you know?
7
+
@@ -0,0 +1,34 @@
1
+
2
+ # Nameless Labyrinth
3
+
4
+ The nameless stone labyrinth consisted, for the most part, of walls from ten to
5
+ one hundred and fifty feet in ice-clear height, and of a thickness varying from
6
+ five to ten feet. It was composed mostly of prodigious blocks of dark
7
+ primordial slate, schist, and sandstone—blocks in many cases as large as 4 x 6
8
+ x 8 feet—though in several places it seemed to be carved out of a solid, uneven
9
+ bed rock of pre-Cambrian slate. The buildings were far from equal in size,
10
+ there being innumerable honeycomb arrangements of enormous extent as well as
11
+ smaller separate structures. The general shape of these things tended to be
12
+ conical, pyramidal, or terraced; though there were many perfect cylinders,
13
+ perfect cubes, clusters of cubes, and other rectangular forms, and a peculiar
14
+ sprinkling of angled edifices whose five-pointed ground plan roughly suggested
15
+ modern fortifications. The builders had made constant and expert use of the
16
+ principle of the arch, and domes had probably existed in the city's heyday.
17
+
18
+ The whole tangle was monstrously weathered, and the glacial surface from which
19
+ the towers projected was strewn with fallen blocks and immemorial debris. Where
20
+ the glaciation was transparent we could see the lower parts of the gigantic
21
+ piles, and we noticed the ice-preserved stone bridges which connected the
22
+ different towers at varying distances above the ground. On the exposed walls we
23
+ could detect the scarred places where other and higher bridges of the same sort
24
+ had existed. Closer inspection revealed countless largish windows; some of
25
+ which were closed with shutters of a petrified material originally wood, though
26
+ most gaped open in a sinister and menacing fashion. Many of the ruins, of
27
+ course, were roofless, and with uneven though wind-rounded upper edges; whilst
28
+ others, of a more sharply conical or pyramidal model or else protected by
29
+ higher surrounding structures, preserved intact outlines despite the
30
+ omnipresent crumbling and pitting. With the field glass we could barely make
31
+ out what seemed to be sculptural decorations in horizontal bands—decorations
32
+ including those curious groups of dots whose presence on the ancient soapstones
33
+ now assumed a vastly larger significance.
34
+
@@ -0,0 +1,5 @@
1
+
2
+ # Preface
3
+
4
+ Preparing your readers for the worst.
5
+
@@ -0,0 +1,22 @@
1
+
2
+ # The Sway of Reason
3
+
4
+ > "I have seen the dark universe yawning\\
5
+ > Where the black planets roll without aim,\\
6
+ > Where they roll in their horror unheeded,\\
7
+ > without knowledge or lustre or name."
8
+ >
9
+ > Nemesis, 1917
10
+ > {:.attribution}
11
+
12
+ Yet now the sway of reason seemed irrefutably shaken, for this Cyclopean maze
13
+ of squared, curved, and angled blocks had features which cut off all
14
+ comfortable refuge. It was, very clearly, the blasphemous city of the mirage in
15
+ stark, objective, and ineluctable reality. That damnable portent had had a
16
+ material basis after all—there had been some horizontal stratum of ice dust in
17
+ the upper air, and this shocking stone survival had projected its image across
18
+ the mountains according to the simple laws of reflection, Of course, the
19
+ phantom had been twisted and exaggerated, and had contained things which the
20
+ real source did not contain; yet now, as we saw that real source, we thought it
21
+ even more hideous and menacing than its distant image.
22
+
@@ -0,0 +1,27 @@
1
+
2
+ # Vast Stone Towers
3
+
4
+ Only the incredible, unhuman massiveness of these vast stone towers and
5
+ ramparts had saved the frightful things from utter annihilation in the hundreds
6
+ of thousands—perhaps millions—of years it had brooded there amidst the blasts
7
+ of a bleak upland. "Corona Mundi—Roof of the World—" All sorts of fantastic
8
+ phrases sprang to our lips as we looked dizzily down at the unbelievable
9
+ spectacle. I thought again of the eldritch primal myths that had so
10
+ persistently haunted me since my first sight of this dead antarctic world—of
11
+ the demoniac plateau of Leng, of the Mi-Go, or abominable Snow Men of the
12
+ Himalayas, of the Pnakotic Manuscripts with their prehuman implications, of the
13
+ Cthulhu cult, of the Necronomicon, and of the Hyperborean legends of formless
14
+ Tsathoggua and the worse than formless star spawn associated with that
15
+ semientity.
16
+
17
+ For boundless miles in every direction the thing stretched off with very little
18
+ thinning; indeed, as our eyes followed it to the right and left along the base
19
+ of the low, gradual foothills which separated it from the actual mountain rim,
20
+ we decided that we could see no thinning at all except for an interruption at
21
+ the left of the pass through which we had come. We had merely struck, at
22
+ random, a limited part of something of incalculable extent. The foothills were
23
+ more sparsely sprinkled with grotesque stone structures, linking the terrible
24
+ city to the already familiar cubes and ramparts which evidently formed its
25
+ mountain outposts. These latter, as well as the queer cave mouths, were as
26
+ thick on the inner as on the outer sides of the mountains.
27
+
@@ -0,0 +1,21 @@
1
+ <?xml version="1.0" encoding="utf-8" standalone="no"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
3
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4
+
5
+ <html xmlns="http://www.w3.org/1999/xhtml">
6
+ <head>
7
+ <title>Cover</title>
8
+ <style type="text/css">
9
+ /*<![CDATA[*/
10
+ <% unless book.output_format == 'mobi' %>img { max-width: 100%; }<% end %>
11
+ body { oeb-column-number: 1; }
12
+ #cover-image { text-align: center; }
13
+ /*]]>*/
14
+ </style>
15
+ </head>
16
+ <body>
17
+ <div id="cover-image">
18
+ <img alt="<%= book.title %>" src="../images/<%= book.cover_image %>" />
19
+ </div>
20
+ </body>
21
+ </html>
@@ -0,0 +1,31 @@
1
+
2
+ <h1><%= book.title %></h1>
3
+ <% unless book.subtitle.nil? %><h2><%= book.subtitle %></h2><% end %>
4
+ <h3>by <%= book.author %></h3>
5
+
6
+ <div class="title-page-rule"></div>
7
+
8
+ <table border="0" cellspacing="0" cellpadding="0" style="width: 100%; text-align: right;">
9
+ <tbody>
10
+ <tr>
11
+ <td>
12
+ <p class="footnotesize" style="font-style: italic;">
13
+ <% unless book.publisher.nil? %>
14
+ Published by <%= book.publisher %>: <%= book.publisher_atag %><br/>
15
+ <% end %>
16
+ <% unless book.book_atag.nil? %>
17
+ Find out more about this book at: <%= book.book_atag %>
18
+ <% end %>
19
+ </p>
20
+ </td>
21
+ <td>
22
+ <% unless book.publisher_logo.nil? %>
23
+ <div class="publisher-logo"><img src="../images/<%= book.publisher_logo %>" alt="logo"/></div>
24
+ <% end %>
25
+ </td>
26
+ </tr>
27
+ </tbody>
28
+ </table>
29
+
30
+
31
+
@@ -0,0 +1,16 @@
1
+
2
+ <table border="0" cellspacing="0" cellpadding="0" class="toc">
3
+ <tbody>
4
+ <tr>
5
+ <td></td>
6
+ <td></td>
7
+ <td>
8
+ <h1 style="margin-left: 0; padding-left: 0;">Contents</h1>
9
+ </td>
10
+ </tr>
11
+ <% book.chapters.each do |ch| %>
12
+ <%= ch.to_toc_tr %>
13
+ <% end %>
14
+ </tbody>
15
+ </table>
16
+
@@ -0,0 +1,22 @@
1
+
2
+ require 'thor/group'
3
+
4
+ module Prophecy
5
+
6
+ module Generators
7
+ class New < Thor::Group
8
+ include Thor::Actions
9
+
10
+ argument :title, :type => :string
11
+
12
+ def self.source_root
13
+ File.dirname(__FILE__)
14
+ end
15
+
16
+ def copy_book
17
+ directory('book', "#{title.downcase.gsub(/[^a-z0-9-]/, '')}")
18
+ end
19
+ end
20
+ end
21
+
22
+ end
@@ -0,0 +1,72 @@
1
+
2
+ module Prophecy
3
+
4
+ class Manifest
5
+
6
+ attr_accessor :items
7
+
8
+ def initialize(book)
9
+ @items = []
10
+ @dir = File.expand_path(File.join(book.build_dir, 'OEBPS'))
11
+ Dir[File.join(@dir, '**/*')].each do |f|
12
+ next if File.directory?(f)
13
+ next if File.fnmatch('content.opf*', File.basename(f))
14
+ @items << ManifestItem.new(book, @dir, f)
15
+ end
16
+ end
17
+
18
+ def find_by_filename(filename)
19
+ @items.select{|i| File.basename(i.path) == File.basename(filename) }.first.href
20
+ end
21
+
22
+ end
23
+
24
+ class ManifestItem
25
+
26
+ attr_reader :href, :id, :path, :dir
27
+
28
+ def initialize(book, dir, itempath)
29
+ @book = book
30
+ @dir = Pathname.new(File.expand_path(dir))
31
+ @path = Pathname.new(File.expand_path(itempath))
32
+
33
+ @href = @path.relative_path_from(@dir)
34
+
35
+ if File.basename(@path.to_s) == 'toc.ncx'
36
+ @id = 'ncx'
37
+ elsif !book.cover_image.nil? && File.basename(book.cover_image) == File.basename(itempath)
38
+ @id = 'cover-image'
39
+ else
40
+ @id = self.chapter_id || @href.to_s.downcase.gsub(/[^a-z0-9-]/, '-').gsub(/--+/, '-')
41
+ end
42
+ end
43
+
44
+ def chapter_id
45
+ ret = @book.chapters.select{|ch| ch.render_path == @path.to_s }.first
46
+ ret.id if ret
47
+ end
48
+
49
+ def media_type
50
+ ret = MIME::Types.type_for(File.basename(@path)).first.to_s
51
+ if ret == ""
52
+ ext = File.extname(@path)
53
+ types = {
54
+ '.ncx' => 'application/x-dtbncx+xml',
55
+ }
56
+ if types.has_key?(ext)
57
+ ret = types[ext]
58
+ else
59
+ warn "Can't determine media type for: #{@path}"
60
+ raise "Unknown Media Type"
61
+ end
62
+ end
63
+ ret
64
+ end
65
+
66
+ def to_s
67
+ @path.to_s
68
+ end
69
+
70
+ end
71
+
72
+ end
@@ -0,0 +1,3 @@
1
+ module Prophecy
2
+ VERSION = "0.0.1"
3
+ end
data/lib/prophecy.rb ADDED
@@ -0,0 +1,18 @@
1
+
2
+ #require 'pry'
3
+ #require 'pry-debugger'
4
+
5
+ require 'fileutils'
6
+ require 'pathname'
7
+ require 'yaml'
8
+ require 'erb'
9
+ require 'cgi'
10
+ require 'mime/types'
11
+ require 'kramdown'
12
+ require 'nokogiri'
13
+
14
+ require "prophecy/version"
15
+ require "prophecy/book"
16
+ require "prophecy/chapter"
17
+ require "prophecy/manifest"
18
+