From c551c81e28418c67fb398d6efb2183588c09f862 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 22 Sep 2015 18:26:41 -0400 Subject: Fix "User permissions" help page path --- doc/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/README.md b/doc/README.md index 5f38086b8e3..a0ff856ebb6 100644 --- a/doc/README.md +++ b/doc/README.md @@ -51,7 +51,7 @@ ### Administrator documentation -+ [User permissions](permissions/README.md) ++ [User permissions](permissions/permissions.md) + [API](api/README.md) ## Contributor documentation -- cgit v1.2.1 From 64e0dfa5306aebdedeb65f2a6db95f4d2314f143 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 22 Sep 2015 18:26:51 -0400 Subject: Prevent double-prefixing of help page paths Prior, because the link "api/README.md" was matched twice, the first link became "help/help/api/README.md". Now we do a negative lookahead to make sure the link doesn't start with `help/`. This fix is still not ideal, see TODO note. --- app/controllers/help_controller.rb | 18 ++++++++++++++++++ app/views/help/index.html.haml | 6 +----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index ad00948da51..7283c4f4a4c 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -4,6 +4,8 @@ class HelpController < ApplicationController layout 'help' def index + @help_index = File.read(Rails.root.join('doc', 'README.md')) + prefix_help_links!(@help_index) end def show @@ -57,6 +59,22 @@ class HelpController < ApplicationController params end + # Prefix links in a Markdown document with `help/` unless they already have + # been + # + # TODO (rspeicher): This should be a pipeline filter that only gets included + # for help pages, and it should operate on the Nokogiri doc to be more robust. + # + # text - Markdown String + # + # Modifies `text` in-place + def prefix_help_links!(text) + # Match text inside a Markdown link unless it already starts with `help/` + # + # See http://rubular.com/r/nwwhzH6Z8X + text.gsub!(%r{(\]\()(?!help\/)([^\)\(]+)(\))}x, '\1help/\2\3') + end + PATH_SEPS = Regexp.union(*[::File::SEPARATOR, ::File::ALT_SEPARATOR].compact) # Taken from ActionDispatch::FileHandler diff --git a/app/views/help/index.html.haml b/app/views/help/index.html.haml index f492aaf4c0a..ab7ed1b5d95 100644 --- a/app/views/help/index.html.haml +++ b/app/views/help/index.html.haml @@ -27,11 +27,7 @@ .col-md-8 .documentation-index = preserve do - - readme_text = File.read(Rails.root.join("doc", "README.md")) - - text = readme_text.dup - - readme_text.scan(/\]\(([^(]+)\)/) { |match| text.gsub!(match.first, "help/#{match.first}") } - = markdown text - + = markdown(@help_index) .col-md-4 .panel.panel-default .panel-heading -- cgit v1.2.1 From 95f73a68fa3ff235c35217b1c72666c5bad6ce03 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 23 Sep 2015 00:24:17 -0400 Subject: Simplify help path prefixing --- app/controllers/help_controller.rb | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index 7283c4f4a4c..55050615473 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -5,7 +5,10 @@ class HelpController < ApplicationController def index @help_index = File.read(Rails.root.join('doc', 'README.md')) - prefix_help_links!(@help_index) + + # Prefix Markdown links with `help/` unless they already have been + # See http://rubular.com/r/nwwhzH6Z8X + @help_index.gsub!(/(\]\()(?!help\/)([^\)\(]+)(\))/, '\1help/\2\3') end def show @@ -59,22 +62,6 @@ class HelpController < ApplicationController params end - # Prefix links in a Markdown document with `help/` unless they already have - # been - # - # TODO (rspeicher): This should be a pipeline filter that only gets included - # for help pages, and it should operate on the Nokogiri doc to be more robust. - # - # text - Markdown String - # - # Modifies `text` in-place - def prefix_help_links!(text) - # Match text inside a Markdown link unless it already starts with `help/` - # - # See http://rubular.com/r/nwwhzH6Z8X - text.gsub!(%r{(\]\()(?!help\/)([^\)\(]+)(\))}x, '\1help/\2\3') - end - PATH_SEPS = Regexp.union(*[::File::SEPARATOR, ::File::ALT_SEPARATOR].compact) # Taken from ActionDispatch::FileHandler -- cgit v1.2.1