diff options
author | Xavier Noria <fxn@hashref.com> | 2011-12-25 03:18:18 -0800 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2011-12-25 04:10:11 -0800 |
commit | 4ae1cdd36be6ad2998da2bb58aebba2ed77e853d (patch) | |
tree | 6d163a48b2788cff89ffd7e881a932edae3dd1da /railties/guides/rails_guides | |
parent | 0daf80a8a6d0da16d132a68226c71e7a4c59dbc5 (diff) | |
download | rails-4ae1cdd36be6ad2998da2bb58aebba2ed77e853d.tar.gz rails-4ae1cdd36be6ad2998da2bb58aebba2ed77e853d.tar.bz2 rails-4ae1cdd36be6ad2998da2bb58aebba2ed77e853d.zip |
guides generation for the Kindle looking good now [Mip Earson & Xavier Noria]
Diffstat (limited to 'railties/guides/rails_guides')
-rw-r--r-- | railties/guides/rails_guides/generator.rb | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/railties/guides/rails_guides/generator.rb b/railties/guides/rails_guides/generator.rb index f0fdaf9ac2..f138a58f16 100644 --- a/railties/guides/rails_guides/generator.rb +++ b/railties/guides/rails_guides/generator.rb @@ -95,7 +95,7 @@ module RailsGuides def register_kindle_mime_types Mime::Type.register_alias("application/xml", :opf, %w(opf)) - Mime::Type.register_alias("application/xml", :ncx ,%w(ncx)) + Mime::Type.register_alias("application/xml", :ncx, %w(ncx)) end def generate @@ -117,19 +117,25 @@ module RailsGuides end def generate_mobi - system "kindlegen #{output_dir}/rails_guides.opf -o #{kindle_output_file} > #{output_dir}/kindlegen.out 2>&1" - puts "Guides compiled as Kindle book to #{kindle_output_file}" - puts "(kindlegen log at #{output_dir}/kindlegen.out)." - end + opf = "#{output_dir}/rails_guides.opf" + mobi = "ruby_on_rails_guides_#@version%s.mobi" % (@lang.present? ? ".#@lang" : '') + out = "#{output_dir}/kindlegen.out" - def kindle_output_file - "rails_guides_#@version%s.mobi" % (@lang.present? ? ".#@lang" : '') + system "kindlegen #{opf} -o #{mobi} > #{out} 2>&1" + puts "Guides compiled as Kindle book to #{mobi}" + puts "(kindlegen log at #{out})." end def initialize_dirs(output) @guides_dir = File.join(File.dirname(__FILE__), '..') @source_dir = "#@guides_dir/source/#@lang" - @output_dir = output || "#@guides_dir/output/#@lang" + @output_dir = if output + output + elsif kindle? + "#@guides_dir/output/kindle/#@lang" + else + "#@guides_dir/output/#@lang" + end.sub(%r</$>, '') end def create_output_dir_if_needed @@ -187,7 +193,7 @@ module RailsGuides def generate_guide(guide, output_file) output_path = output_path_for(output_file) puts "Generating #{guide} as #{output_file}" - layout = guide.start_with?('kindle/') ? 'kindle/layout' : 'layout' + layout = kindle? ? 'kindle/layout' : 'layout' File.open(output_path, 'w') do |f| view = ActionView::Base.new(source_dir, :version => @version) |