diff options
Diffstat (limited to 'railties/guides/rails_guides')
-rw-r--r-- | railties/guides/rails_guides/generator.rb | 22 | ||||
-rw-r--r-- | railties/guides/rails_guides/indexer.rb | 4 |
2 files changed, 16 insertions, 10 deletions
diff --git a/railties/guides/rails_guides/generator.rb b/railties/guides/rails_guides/generator.rb index 2a4714b13a..bd25111405 100644 --- a/railties/guides/rails_guides/generator.rb +++ b/railties/guides/rails_guides/generator.rb @@ -1,5 +1,11 @@ require 'set' +class String + def html_safe! + self + end unless "post 9415935902f120a9bac0bfce7129725a0db38ed3".respond_to?(:html_safe!) +end + module RailsGuides class Generator attr_reader :output, :view_path, :view, :guides_dir @@ -18,7 +24,7 @@ module RailsGuides end def generate - guides = Dir.entries(view_path).find_all {|g| g =~ /textile$/ } + guides = Dir.entries(view_path).find_all {|g| g =~ /\.textile(?:\.erb)?$/ } if ENV["ONLY"] only = ENV["ONLY"].split(",").map{|x| x.strip }.map {|o| "#{o}.textile" } @@ -36,7 +42,7 @@ module RailsGuides end def generate_guide(guide) - guide =~ /(.*?)(\.erb)?\.textile/ + guide =~ /(.*?)\.textile(?:\.erb)?$/ name = $1 puts "Generating #{name}" @@ -46,7 +52,7 @@ module RailsGuides @view = ActionView::Base.new(view_path) @view.extend(Helpers) - if guide =~ /\.erb\.textile/ + 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) @@ -55,7 +61,7 @@ module RailsGuides body = set_header_section(body, @view) body = set_index(body, @view) - result = view.render(:layout => 'layout', :text => textile(body)) + result = view.render(:layout => 'layout', :text => textile(body).html_safe!) f.write result warn_about_broken_links(result) if ENV.key?("WARN_BROKEN_LINKS") end @@ -71,8 +77,8 @@ module RailsGuides header = textile(header) - view.content_for(:page_title) { page_title } - view.content_for(:header_section) { header } + view.content_for(:page_title) { page_title.html_safe! } + view.content_for(:header_section) { header.html_safe! } new_body end @@ -95,7 +101,7 @@ module RailsGuides view.content_tag(:li, l) end - children_ul = view.content_tag(:ul, children) + children_ul = view.content_tag(:ul, children.join(" ")) index << view.content_tag(:li, link + children_ul) end @@ -103,7 +109,7 @@ module RailsGuides index << '</ol>' index << '</div>' - view.content_for(:index_section) { index } + view.content_for(:index_section) { index.html_safe! } i.result end diff --git a/railties/guides/rails_guides/indexer.rb b/railties/guides/rails_guides/indexer.rb index 5b5ad3fee1..939404c85f 100644 --- a/railties/guides/rails_guides/indexer.rb +++ b/railties/guides/rails_guides/indexer.rb @@ -19,9 +19,9 @@ module RailsGuides level_hash = ActiveSupport::OrderedHash.new while !s.eos? - s.match?(/\h[0-9]\..*$/) + s.match?(/h[0-9]\..*$/) if matched = s.matched - matched =~ /\h([0-9])\.(.*)$/ + matched =~ /h([0-9])\.(.*)$/ level, title = $1.to_i, $2 if level < current_level |