Merge pull request #6550 from handlers/edit-this-page-better

Safer way to build 'edit this page' link
This commit is contained in:
Seth Vargo 2015-11-19 08:34:17 -08:00
commit 3227589c12
2 changed files with 9 additions and 3 deletions

View File

@ -328,7 +328,10 @@
<li><a href="https://docs.vagrantup.com/">Documentation</a></li> <li><a href="https://docs.vagrantup.com/">Documentation</a></li>
<li><a href="https://www.vagrantup.com/about">About</a></li> <li><a href="https://www.vagrantup.com/about">About</a></li>
<li><a href="https://www.vagrantup.com/support">Support</a></li> <li><a href="https://www.vagrantup.com/support">Support</a></li>
<% github_link = 'https://github.com/mitchellh/vagrant/blob/master/' + current_page.source_file.match(/website.*/)[0] %> <% relative_path = current_page.path.match(/.*\//).to_s
file = current_page.source_file.split("/").last
github_link = "https://github.com/mitchellh/vagrant/blob/master/website/docs/source/#{relative_path}#{file}"
%>
<li class="li-under"><a href="<%= github_link %>">Edit this page</a></li> <li class="li-under"><a href="<%= github_link %>">Edit this page</a></li>
<a href="https://www.vagrantup.com/downloads"> <a href="https://www.vagrantup.com/downloads">
<li class="button inline-button">Download</li> <li class="button inline-button">Download</li>

View File

@ -61,8 +61,11 @@
<li><a href="/about.html">About</a></li> <li><a href="/about.html">About</a></li>
<li><a href="/support.html">Support</a></li> <li><a href="/support.html">Support</a></li>
<% if current_page.url != "/" %> <% if current_page.url != "/" %>
<% github_link = 'https://github.com/mitchellh/vagrant/blob/master/' + current_page.source_file.match(/website.*/)[0] %> <% relative_path = current_page.path.match(/.*\//).to_s
<li class="li-under"><a href="<%= github_link %>">Edit this page</a></li> file = current_page.source_file.split("/").last
github_link = "https://github.com/mitchellh/vagrant/blob/master/website/www/source/#{relative_path}#{file}"
%>
<li class="li-under"><a href="<%= github_link %>">Edit this page</a></li>
<% end %> <% end %>
<a href="/downloads.html"> <a href="/downloads.html">
<li class="button inline-button">Download</li> <li class="button inline-button">Download</li>