aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/rails_guides
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2011-12-25 03:18:18 -0800
committerXavier Noria <fxn@hashref.com>2011-12-25 04:08:55 -0800
commit05b8faa2040cc7062a91dfd527dd27459d01439d (patch)
tree08b80ca4d817dfce1f97cc695fb12f4db076d9ab /railties/guides/rails_guides
parent97636d95227b73e3875732fa61fa1d44157d32f1 (diff)
downloadrails-05b8faa2040cc7062a91dfd527dd27459d01439d.tar.gz
rails-05b8faa2040cc7062a91dfd527dd27459d01439d.tar.bz2
rails-05b8faa2040cc7062a91dfd527dd27459d01439d.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.rb24
1 files changed, 15 insertions, 9 deletions
diff --git a/railties/guides/rails_guides/generator.rb b/railties/guides/rails_guides/generator.rb
index 9504b6566a..71b3240585 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)