diff options
Diffstat (limited to 'railties/guides/rails_guides/generator.rb')
-rw-r--r-- | railties/guides/rails_guides/generator.rb | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/railties/guides/rails_guides/generator.rb b/railties/guides/rails_guides/generator.rb index bd25111405..7c8d26a1ea 100644 --- a/railties/guides/rails_guides/generator.rb +++ b/railties/guides/rails_guides/generator.rb @@ -1,10 +1,5 @@ require 'set' - -class String - def html_safe! - self - end unless "post 9415935902f120a9bac0bfce7129725a0db38ed3".respond_to?(:html_safe!) -end +require 'fileutils' module RailsGuides class Generator @@ -17,7 +12,7 @@ module RailsGuides unless ENV["ONLY"] FileUtils.rm_r(@output) if File.directory?(@output) - FileUtils.mkdir(@output) + FileUtils.mkdir_p(@output) end @view_path = File.join(@guides_dir, "source") @@ -55,16 +50,19 @@ module RailsGuides if guide =~ /\.textile\.erb$/ # Generate the erb pages with textile formatting - e.g. index/authors result = view.render(:layout => 'layout', :file => guide) - f.write textile(result) + result = textile(result) else body = File.read(File.join(view_path, guide)) body = set_header_section(body, @view) body = set_index(body, @view) - result = view.render(:layout => 'layout', :text => textile(body).html_safe!) - f.write result + result = view.render(:layout => 'layout', :text => textile(body).html_safe) + warn_about_broken_links(result) if ENV.key?("WARN_BROKEN_LINKS") end + + result = insert_edge_badge(result) if ENV.key?('INSERT_EDGE_BADGE') + f.write result end end @@ -77,8 +75,8 @@ module RailsGuides header = textile(header) - view.content_for(:page_title) { page_title.html_safe! } - view.content_for(:header_section) { header.html_safe! } + view.content_for(:page_title) { page_title.html_safe } + view.content_for(:header_section) { header.html_safe } new_body end @@ -109,7 +107,7 @@ module RailsGuides index << '</ol>' index << '</div>' - view.content_for(:index_section) { index.html_safe! } + view.content_for(:index_section) { index.html_safe } i.result end @@ -174,5 +172,9 @@ module RailsGuides end end end + + def insert_edge_badge(html) + html.sub(/<body[^>]*>/, '\&<img src="images/edge_badge.png" style="position:fixed; right:0px; top:0px; border:none; z-index:100"/>') + end end end |