Skip to content

Commit

Permalink
localized covers_dir and better error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
fauno committed Feb 21, 2018
1 parent e03735a commit 79b577b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ regular jekyll site build.
* `sheetsize` is the page size for ready the print PDF. You can also
use this option on the front matter.

* `covers_dir` the directory where covers are stored
* `covers_dir` the directory where covers are stored. If you have a
`lang` defined, it will append the language to the `covers_dir` when
looking for a category/full site cover, so you can have localized
covers.

* `signature` is the amount of pages per fold on the imposition version.
Specify `0` for a single fold of all the pages. You can also use this
Expand Down
23 changes: 18 additions & 5 deletions lib/jekyll-pandoc-multiple-formats/pandoc_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ def write
# Move to the source dir since everything will be relative to that
Dir::chdir(@site.config['source']) do
# Do the stuff
puts command
Open3::popen3(command) do |stdin, stdout, stderr, thread|
Jekyll.logger.debug command
e = Open3::popen3(command) do |stdin, stdout, stderr, thread|
stdin.puts yaml_metadata
stdin.puts content
stdin.close
Expand All @@ -196,6 +196,8 @@ def write
# Wait for the process to finish
thread.value
end

Jekyll.logger.warn 'Pandoc:', "Failed generating #{path}" if e.to_i > 0
end

File.exists?(path)
Expand All @@ -205,11 +207,19 @@ def write
#
# It assumes covers are in PNG format
def cover
cover_path = [ @site.config['source'] ]
if single_post? && single_post.data['cover']
File.join(@site.config['source'], single_post.data['cover'])
cover_path << single_post.data['cover']
elsif site_lang?
cover_path << @config['covers_dir']
cover_path << site_lang
cover_path << "#{@slug}.png"
else
File.join(@site.config['source'], @config['covers_dir'], "#{@slug}.png")
cover_path << @config['covers_dir']
cover_path << "#{@slug}.png"
end

File.join(cover_path)
end

# Returns a PDF cover
Expand Down Expand Up @@ -296,7 +306,10 @@ def single_post?
end

def has_cover?
File.exists? cover
e = File.exists? cover
Jekyll.logger.warn "Cover:", "#{cover} missing for #{relative_path}" unless e

e
end

def papersize
Expand Down

0 comments on commit 79b577b

Please sign in to comment.