diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/guides/files/stylesheets/main.css | 11 | ||||
-rw-r--r-- | railties/guides/rails_guides/generator.rb | 25 | ||||
-rw-r--r-- | railties/guides/source/layout.html.erb | 5 |
3 files changed, 28 insertions, 13 deletions
diff --git a/railties/guides/files/stylesheets/main.css b/railties/guides/files/stylesheets/main.css index d377628d73..2fd0a2f37e 100644 --- a/railties/guides/files/stylesheets/main.css +++ b/railties/guides/files/stylesheets/main.css @@ -439,3 +439,14 @@ spurious blank area below with the box background. */ div.important p, div.caution p, div.warning p, div.note p, div.info p { margin-bottom: 0px; } + +/* Edge Badge +--------------------------------------- */ + +#edge-badge { + position: fixed; + right: 0px; + top: 0px; + z-index: 100; + border: none; +} diff --git a/railties/guides/rails_guides/generator.rb b/railties/guides/rails_guides/generator.rb index c40bbc32da..d0873bfed5 100644 --- a/railties/guides/rails_guides/generator.rb +++ b/railties/guides/rails_guides/generator.rb @@ -11,13 +11,14 @@ require 'rails_guides/levenshtein' module RailsGuides class Generator - attr_reader :guides_dir, :source_dir, :output_dir + attr_reader :guides_dir, :source_dir, :output_dir, :edge GUIDES_RE = /\.(?:textile|html\.erb)$/ def initialize(output=nil) initialize_dirs(output) create_output_dir_if_needed + set_edge end def generate @@ -34,7 +35,11 @@ module RailsGuides def create_output_dir_if_needed FileUtils.mkdir_p(output_dir) - end + end + + def set_edge + @edge = ENV['EDGE_GUIDES'] == '1' + end def generate_guides guides_to_generate.each do |guide| @@ -56,8 +61,8 @@ module RailsGuides end def copy_assets - FileUtils.cp_r(File.join(guides_dir, 'images'), File.join(output_dir, 'images')) - FileUtils.cp_r(File.join(guides_dir, 'files'), File.join(output_dir, 'files')) + FileUtils.cp_r(File.join(guides_dir, 'images'), output_dir) + FileUtils.cp_r(File.join(guides_dir, 'files'), output_dir) end def output_file_for(guide) @@ -73,11 +78,11 @@ module RailsGuides def generate_guide(guide, output_file) puts "Generating #{output_file}" File.open(File.join(output_dir, output_file), 'w') do |f| - view = ActionView::Base.new(source_dir) + view = ActionView::Base.new(source_dir, :edge => edge) view.extend(Helpers) - + if guide =~ /\.html\.erb$/ - # Generate the erb pages with textile formatting - e.g. index/authors + # Generate the special pages like the home. result = view.render(:layout => 'layout', :file => guide) else body = File.read(File.join(source_dir, guide)) @@ -89,8 +94,6 @@ module RailsGuides 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 @@ -201,9 +204,5 @@ module RailsGuides end end end - - def insert_edge_badge(html) - html.sub(/<body[^>]*>/, '\&<div><img src="images/edge_badge.png" alt="edge badge" style="position:fixed; right:0px; top:0px; border:none; z-index:100"/></div>') - end end end diff --git a/railties/guides/source/layout.html.erb b/railties/guides/source/layout.html.erb index 95be1d2eab..9819db1f89 100644 --- a/railties/guides/source/layout.html.erb +++ b/railties/guides/source/layout.html.erb @@ -17,6 +17,11 @@ </head> <body class="guide"> + <% if @edge %> + <div> + <img src="images/edge_badge.png" alt="edge-badge" id="edge-badge" /> + </div> + <% end %> <div id="topNav"> <div class="wrapper"> <strong>More at <a href="http://rubyonrails.org/">rubyonrails.org:</a> </strong> |