softcover 0.9.12 → 0.9.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34addb08d23506a84eeb264921dc9696166d52be
4
- data.tar.gz: 931a45e10a105bd351d77722bab932932287f6a7
3
+ metadata.gz: a6c5968c1ee3aa5ac80ae5778c8bd261b276c06a
4
+ data.tar.gz: 616dcfa6a161311f6717d6461f1ce2a9f91fdf78
5
5
  SHA512:
6
- metadata.gz: abb6f30999c50a2557d2d46b27d924c77fad55c7c46dfde4a4bd2c6553682a296d8d572b3aca650a8cb95fe6b527b445b89d9c35c189497600ac654aa7c853ac
7
- data.tar.gz: 9529dbc87abd363e3c8c3c4e7d49dde5a5919c28c640d8aaab48ab8ef7ef9fcb011a6ede6a518009ed4e52507b03b0dba98e8a740e0571cfd1aa47a90b59a4f5
6
+ metadata.gz: 60248392104ecb71d092cb9e4241e066ee40a5ef48152d9ec8559a6a4c8fa3a56fe4c61809630710b5563abb1924481deb3b2c58bbcfdb9042170edbf7a79772
7
+ data.tar.gz: 01e5daacfbc9c515083ec92b6b75b78d9bc113695d964025c979290010fa72adaf21d18bdfb66b8ff576f26e7f080cf0be13d5694bb3dfc3a4e0934a4ef3afa0
@@ -57,7 +57,7 @@ class Softcover::Book
57
57
 
58
58
  # get array of paths and checksums
59
59
  def files
60
- paths = %w{html/*_fragment.html images/**/* config/*}
60
+ paths = %W{html/#{slug}.html html/*_fragment.html images/**/* config/*}
61
61
  Dir[*paths].map do |path|
62
62
  BookFile.new(path) unless File.directory?(path)
63
63
  end.compact
@@ -70,12 +70,11 @@ module Softcover
70
70
  # Included is a math detector that processes the page with MathJax
71
71
  # (via page.js) so that math can be included in EPUB (and thence MOBI).
72
72
  def write_html(options={})
73
- images_dir = File.join('epub', 'OEBPS', 'images')
74
73
  texmath_dir = File.join(images_dir, 'texmath')
75
74
  mkdir images_dir
76
75
  mkdir texmath_dir
77
76
 
78
- File.write(path('epub/OEBPS/cover.html'), cover_page)
77
+ File.write(path('epub/OEBPS/cover.html'), cover_page) if cover?
79
78
 
80
79
  pngs = []
81
80
  chapters.each_with_index do |chapter, i|
@@ -113,6 +112,10 @@ module Softcover
113
112
  end
114
113
  end
115
114
 
115
+ def images_dir
116
+ File.join('epub', 'OEBPS', 'images')
117
+ end
118
+
116
119
  # Returns HTML for HTML source that includes math.
117
120
  # As a side-effect, html_with_math creates PNGs corresponding to any
118
121
  # math in the given source. The technique involves using PhantomJS to
@@ -316,6 +319,7 @@ module Softcover
316
319
  image_files = Dir['epub/OEBPS/images/**/*'].select { |f| File.file?(f) }
317
320
  images = image_files.map do |image|
318
321
  ext = File.extname(image).sub('.', '') # e.g., 'png'
322
+ ext = 'jpeg' if ext == 'jpg'
319
323
  # Strip off the leading 'epub/OEBPS'.
320
324
  sep = File::SEPARATOR
321
325
  href = image.split(sep)[2..-1].join(sep)
@@ -337,7 +341,7 @@ module Softcover
337
341
  <dc:publisher>Softcover</dc:publisher>
338
342
  <dc:identifier id="BookID">urn:uuid:#{uuid}</dc:identifier>
339
343
  <meta property="dcterms:modified">#{Time.now.strftime('%Y-%m-%dT%H:%M:%S')}Z</meta>
340
- <meta name="cover" content="img-cover-png"/>
344
+ <meta name="cover" content="cover-image"/>
341
345
  </metadata>
342
346
  <manifest>
343
347
  <item href="nav.html" id="nav" media-type="application/xhtml+xml" properties="nav"/>
@@ -369,13 +373,28 @@ module Softcover
369
373
  </head>
370
374
  <body>
371
375
  <div id="cover">
372
- <img width="573" height="800" src="images/cover.png" alt="cover image" />
376
+ <img width="573" height="800" src="images/#{cover_img}" alt="cover" />
373
377
  </div>
374
378
  </body>
375
379
  </html>
376
380
  )
377
381
  end
378
382
 
383
+ # Returns the name of the cover file.
384
+ # We support (in order) JPG/JPEG, PNG, and TIF.
385
+ def cover_img
386
+ extensions = %w[jpg jpeg ng tif]
387
+ extensions.each do |ext|
388
+ file = Dir[path("#{images_dir}/cover.#{ext}")].first
389
+ return File.basename(file) if file
390
+ end
391
+ return false
392
+ end
393
+
394
+ def cover?
395
+ cover_img
396
+ end
397
+
379
398
  # Returns the Table of Contents for the spine.
380
399
  def toc_ncx
381
400
  title = manifest.title
@@ -44,6 +44,8 @@ module Softcover
44
44
  basename = File.basename(manifest.filename, '.tex')
45
45
  @html = converted_html(basename)
46
46
  @title = basename
47
+ @mathjax = Softcover::Mathjax::config(chapter_number: false)
48
+ @src = Softcover::Mathjax::AMS_SVG
47
49
  erb_file = File.read(File.join(File.dirname(__FILE__),
48
50
  '..', 'server', 'views',
49
51
  'book.html.erb'))
data/lib/softcover/cli.rb CHANGED
@@ -229,6 +229,7 @@ module Softcover
229
229
  desc "config", "View local config"
230
230
  def config
231
231
  require "softcover/config"
232
+ puts "Reading contents of #{Softcover::Config.path}:"
232
233
  Softcover::Config.read
233
234
  end
234
235
 
@@ -85,7 +85,8 @@ module Softcover::Commands::Publisher
85
85
 
86
86
  def exit_with_message
87
87
  number = current_book.processed_media.size
88
- puts "Processed #{number} directory."
88
+ dir = number == 1 ? "directory" : "directories"
89
+ puts "Processed #{number} #{dir}"
89
90
  end
90
91
 
91
92
  def unpublish!(slug=nil)
@@ -41,18 +41,22 @@ module Softcover
41
41
  end
42
42
 
43
43
  def file_path
44
- File.expand_path(self::PATH).tap do |path|
45
- path.gsub!(/$/,"-test") if Softcover::test?
44
+ File.expand_path(path).tap do |full_path|
45
+ full_path.gsub!(/$/,"-test") if Softcover::test?
46
46
  end
47
47
  end
48
48
  end
49
49
  end
50
50
 
51
51
  class BookConfig < BaseConfig
52
- PATH = ".softcover-book"
52
+ def self.path
53
+ ".softcover-book"
54
+ end
53
55
  end
54
56
 
55
57
  class Config < BaseConfig
56
- PATH = "~/.softcover"
58
+ def self.path
59
+ File.exists?(".softcover") ? ".softcover" : "~/.softcover"
60
+ end
57
61
  end
58
62
  end
@@ -7,9 +7,17 @@ module Softcover
7
7
  # Call .inspect.inspect to escape the chapter number
8
8
  # code for interpolation.
9
9
  options[:chapter_number].inspect.inspect
10
- else
10
+ elsif options[:chapter_number].nil?
11
11
  '#{chapter_number}'
12
+ else # chapter_number is false, i.e., it's a single page
13
+ false
12
14
  end
15
+ fn = if chapter_number
16
+ "formatNumber: function (n) { return #{chapter_number} + '.' + n }"
17
+ else
18
+ ""
19
+ end
20
+
13
21
  <<-EOS
14
22
  MathJax.Hub.Config({
15
23
  "HTML-CSS": {
@@ -19,7 +27,7 @@ module Softcover
19
27
  extensions: ["AMSmath.js", "AMSsymbols.js"],
20
28
  equationNumbers: {
21
29
  autoNumber: "AMS",
22
- formatNumber: function (n) { return #{chapter_number} + '.' + n }
30
+ #{fn}
23
31
  },
24
32
  Macros: {
25
33
  PolyTeX: "Poly{\\\\TeX}",
@@ -19,8 +19,8 @@ epub/
19
19
  # Generated ebooks
20
20
  ebooks/
21
21
 
22
- # Screencasts (likely to be huge)
23
- screencasts/
22
+ # Media (likely to be huge)
23
+ media/
24
24
 
25
25
  # Other miscellaneous files
26
26
  log/