mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
adds support for an edge badge in guides
This commit is contained in:
parent
b6935e5179
commit
f3eab8e663
2 changed files with 9 additions and 2 deletions
BIN
railties/guides/images/edge_badge.png
Normal file
BIN
railties/guides/images/edge_badge.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.9 KiB |
|
@ -49,16 +49,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
|
||||
|
||||
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
|
||||
|
||||
|
@ -168,5 +171,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
|
||||
|
|
Loading…
Reference in a new issue