From d1233c1d078ce2062c4a42206b873ce885c5f2a5 Mon Sep 17 00:00:00 2001 From: Sam Handler Date: Thu, 19 Nov 2015 11:03:02 -0500 Subject: [PATCH] safer way to display edit this page link --- website/docs/source/layouts/layout.erb | 5 ++++- website/www/source/layouts/layout.erb | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/website/docs/source/layouts/layout.erb b/website/docs/source/layouts/layout.erb index 38a735de3..f43eb3dfa 100644 --- a/website/docs/source/layouts/layout.erb +++ b/website/docs/source/layouts/layout.erb @@ -324,7 +324,10 @@
  • Documentation
  • About
  • Support
  • - <% 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}" + %>
  • Edit this page
  • Download
  • diff --git a/website/www/source/layouts/layout.erb b/website/www/source/layouts/layout.erb index 2daba176d..6c556b6b7 100644 --- a/website/www/source/layouts/layout.erb +++ b/website/www/source/layouts/layout.erb @@ -60,8 +60,11 @@
  • About
  • Support
  • <% if current_page.url != "/" %> - <% github_link = 'https://github.com/mitchellh/vagrant/blob/master/' + current_page.source_file.match(/website.*/)[0] %> -
  • Edit this page
  • + <% 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/www/source/#{relative_path}#{file}" + %> +
  • Edit this page
  • <% end %>
  • Download