From a242a5a050b03628f55face469baea8b21281b29 Mon Sep 17 00:00:00 2001 From: Student Date: Thu, 2 Jul 2020 12:48:40 +0100 Subject: [PATCH 01/28] Removed symlink, needs work to make contributing link work in windows friendly manner --- docs/contributing.md | 1 - 1 file changed, 1 deletion(-) delete mode 120000 docs/contributing.md diff --git a/docs/contributing.md b/docs/contributing.md deleted file mode 120000 index 44fcc63439..0000000000 --- a/docs/contributing.md +++ /dev/null @@ -1 +0,0 @@ -../CONTRIBUTING.md \ No newline at end of file From 8f8431c1043ad17e722054230ff55b3b222e3237 Mon Sep 17 00:00:00 2001 From: Student Date: Fri, 3 Jul 2020 15:23:52 +0100 Subject: [PATCH 02/28] Hardcoded contributing link --- .../app/controllers/docs_controller.rb | 18 +++++++++++++++++- spec/features/documentation_spec.rb | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index f551a24fab..86c4f7a090 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -1,4 +1,15 @@ class DocsController < ApplicationController + + SPECIAL_FILES = [ + { + file: "CONTRIBUTING.md", + name: "Contributing", + path: "Contributing", + page: "CONTRIBUTING", + }.freeze + + ] + REDCARPET_CONFIG = { fenced_code_blocks: true, autolink: true, @@ -9,7 +20,12 @@ def index end def show - render_page "docs/#{params[:page]}" + # First check if page in special files, if so + if (params[:page] == "contributing") + render_page "CONTRIBUTING" + else + render_page "docs/#{params[:page]}" + end end private diff --git a/spec/features/documentation_spec.rb b/spec/features/documentation_spec.rb index b4fc2ebcda..25be3a6f32 100644 --- a/spec/features/documentation_spec.rb +++ b/spec/features/documentation_spec.rb @@ -37,4 +37,5 @@ def internal_documentation_links map { |anchor| anchor[:href] }. select { |href| URI.parse(href).relative? } end + end From d3419efdbb937b04eedc0ebad2a794db72beb7ad Mon Sep 17 00:00:00 2001 From: Student Date: Fri, 3 Jul 2020 15:36:32 +0100 Subject: [PATCH 03/28] Removing hardcoding for special files Co-Authored by: Kehinde Olofinmoyin --- spec/example_app/app/controllers/docs_controller.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index 86c4f7a090..29094631f6 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -2,10 +2,8 @@ class DocsController < ApplicationController SPECIAL_FILES = [ { - file: "CONTRIBUTING.md", - name: "Contributing", - path: "Contributing", - page: "CONTRIBUTING", + file: "CONTRIBUTING", + page: "contributing", }.freeze ] @@ -21,8 +19,8 @@ def index def show # First check if page in special files, if so - if (params[:page] == "contributing") - render_page "CONTRIBUTING" + if (params[:page] == SPECIAL_FILES[0][:page]) + render_page SPECIAL_FILES[0][:file] else render_page "docs/#{params[:page]}" end From 6f71bb26a5a7ed76ae246ababeb3fe9035def766 Mon Sep 17 00:00:00 2001 From: Student Date: Fri, 3 Jul 2020 16:09:43 +0100 Subject: [PATCH 04/28] Removed all hardcoding for special files in case of future additions - requires refactoring --- spec/example_app/app/controllers/docs_controller.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index 29094631f6..e2687ce50e 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -4,7 +4,10 @@ class DocsController < ApplicationController { file: "CONTRIBUTING", page: "contributing", - }.freeze + }, { + file: "djsfhkjdh", + page: "ksfhalk", + } ] @@ -18,9 +21,11 @@ def index end def show - # First check if page in special files, if so - if (params[:page] == SPECIAL_FILES[0][:page]) - render_page SPECIAL_FILES[0][:file] + + p SPECIAL_FILES.select { |page| page[:page] == params[:page]} + + if SPECIAL_FILES.select { |page| page[:page] == params[:page]}.length > 0 + render_page SPECIAL_FILES.select { |page| page[:page] == params[:page]}[0][:file] else render_page "docs/#{params[:page]}" end From d9ca5d5df6a6060c5326819aa782f0ecd0d132dd Mon Sep 17 00:00:00 2001 From: Student Date: Fri, 3 Jul 2020 16:17:30 +0100 Subject: [PATCH 05/28] Minor refactor Co-Authored by: Kehinde P. Olofinmoyin --- spec/example_app/app/controllers/docs_controller.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index e2687ce50e..940639f15b 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -4,11 +4,7 @@ class DocsController < ApplicationController { file: "CONTRIBUTING", page: "contributing", - }, { - file: "djsfhkjdh", - page: "ksfhalk", } - ] REDCARPET_CONFIG = { @@ -22,8 +18,6 @@ def index def show - p SPECIAL_FILES.select { |page| page[:page] == params[:page]} - if SPECIAL_FILES.select { |page| page[:page] == params[:page]}.length > 0 render_page SPECIAL_FILES.select { |page| page[:page] == params[:page]}[0][:file] else From 39da36d5fa0c51b49f16e6b0aa641a77a57fbb15 Mon Sep 17 00:00:00 2001 From: Student Date: Mon, 6 Jul 2020 09:42:47 +0100 Subject: [PATCH 06/28] Refactor --- spec/example_app/app/controllers/docs_controller.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index 940639f15b..92c7dd6148 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -17,14 +17,17 @@ def index end def show - - if SPECIAL_FILES.select { |page| page[:page] == params[:page]}.length > 0 - render_page SPECIAL_FILES.select { |page| page[:page] == params[:page]}[0][:file] + if check_special_file.length > 0 + render_page check_special_file[0][:file] else render_page "docs/#{params[:page]}" end end + def check_special_file + SPECIAL_FILES.select { |page| page[:page] == params[:page]} + end + private def render_page(name) From 23ca18ad8a2791c11f837eda7e8d800b128905e3 Mon Sep 17 00:00:00 2001 From: Student Date: Mon, 6 Jul 2020 09:45:36 +0100 Subject: [PATCH 07/28] Refactor houndbot lint warnings --- spec/example_app/app/controllers/docs_controller.rb | 2 +- spec/features/documentation_spec.rb | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index 92c7dd6148..1a338c911b 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -25,7 +25,7 @@ def show end def check_special_file - SPECIAL_FILES.select { |page| page[:page] == params[:page]} + SPECIAL_FILES.select { |page| page[:page] == params[:page] } end private diff --git a/spec/features/documentation_spec.rb b/spec/features/documentation_spec.rb index 25be3a6f32..b4fc2ebcda 100644 --- a/spec/features/documentation_spec.rb +++ b/spec/features/documentation_spec.rb @@ -37,5 +37,4 @@ def internal_documentation_links map { |anchor| anchor[:href] }. select { |href| URI.parse(href).relative? } end - end From 6a25b06d48dd2081ecf1640510979e56215ef8c3 Mon Sep 17 00:00:00 2001 From: Student Date: Mon, 6 Jul 2020 09:46:33 +0100 Subject: [PATCH 08/28] Refactor lint houndbot warnings --- spec/example_app/app/controllers/docs_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index 1a338c911b..f56c66fdea 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -2,8 +2,8 @@ class DocsController < ApplicationController SPECIAL_FILES = [ { - file: "CONTRIBUTING", - page: "contributing", + file: 'CONTRIBUTING', + page: 'contributing' } ] From 52b315de8f2cfd3bfd25b52fefa9f93f809303ee Mon Sep 17 00:00:00 2001 From: Student Date: Mon, 6 Jul 2020 09:47:42 +0100 Subject: [PATCH 09/28] Refactor lint houndbot warnings again --- spec/example_app/app/controllers/docs_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index f56c66fdea..147cb36f67 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -1,11 +1,10 @@ class DocsController < ApplicationController - SPECIAL_FILES = [ { file: 'CONTRIBUTING', page: 'contributing' } - ] + ].freeze REDCARPET_CONFIG = { fenced_code_blocks: true, From c40b69714e2273a4c0e4e57d4f873dd902984648 Mon Sep 17 00:00:00 2001 From: Student Date: Wed, 8 Jul 2020 10:22:17 +0100 Subject: [PATCH 10/28] Update to ruby naming convention --- spec/example_app/app/controllers/docs_controller.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index 147cb36f67..31f83ca838 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -4,6 +4,9 @@ class DocsController < ApplicationController file: 'CONTRIBUTING', page: 'contributing' } + { + + } ].freeze REDCARPET_CONFIG = { @@ -23,7 +26,7 @@ def show end end - def check_special_file + def find_special_file SPECIAL_FILES.select { |page| page[:page] == params[:page] } end From e5877918d437527010fed1f0dcf5a6ec3fc24b13 Mon Sep 17 00:00:00 2001 From: Student Date: Wed, 8 Jul 2020 10:25:50 +0100 Subject: [PATCH 11/28] Change all instances of check special file to find special file --- spec/example_app/app/controllers/docs_controller.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index 31f83ca838..7a04b473f5 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -4,9 +4,6 @@ class DocsController < ApplicationController file: 'CONTRIBUTING', page: 'contributing' } - { - - } ].freeze REDCARPET_CONFIG = { @@ -19,8 +16,8 @@ def index end def show - if check_special_file.length > 0 - render_page check_special_file[0][:file] + if find_special_file.length > 0 + render_page find_special_file[0][:file] else render_page "docs/#{params[:page]}" end From dc2d271c1e72b0edcc09642d2d32f6f7abce49c4 Mon Sep 17 00:00:00 2001 From: Student Date: Wed, 8 Jul 2020 10:31:26 +0100 Subject: [PATCH 12/28] find special file returns only one item instead of array --- spec/example_app/app/controllers/docs_controller.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index 7a04b473f5..8bd5d1597c 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -16,15 +16,16 @@ def index end def show - if find_special_file.length > 0 - render_page find_special_file[0][:file] + p find_special_file + if find_special_file != nil + render_page find_special_file[:file] else render_page "docs/#{params[:page]}" end end def find_special_file - SPECIAL_FILES.select { |page| page[:page] == params[:page] } + SPECIAL_FILES.select { |page| page[:page] == params[:page] }.first end private From f548edd717c9c54bd55cef7835e1367385724b86 Mon Sep 17 00:00:00 2001 From: Student Date: Wed, 8 Jul 2020 10:31:44 +0100 Subject: [PATCH 13/28] Remove p --- spec/example_app/app/controllers/docs_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index 8bd5d1597c..7862062310 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -16,7 +16,6 @@ def index end def show - p find_special_file if find_special_file != nil render_page find_special_file[:file] else From 5a8cd6d969f09613ba9308c9f8f8b31639327f91 Mon Sep 17 00:00:00 2001 From: Student Date: Wed, 8 Jul 2020 10:35:30 +0100 Subject: [PATCH 14/28] Refactor fix houndbot warnings --- spec/example_app/app/controllers/docs_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index 7862062310..f7e1d589c8 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -16,7 +16,7 @@ def index end def show - if find_special_file != nil + if !find_special_file.nil? render_page find_special_file[:file] else render_page "docs/#{params[:page]}" From a5f58a81c379deef8999ec45c06aafd3328edf55 Mon Sep 17 00:00:00 2001 From: Student Date: Wed, 8 Jul 2020 10:59:43 +0100 Subject: [PATCH 15/28] Logic in show method moved to private method --- .../example_app/app/controllers/docs_controller.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index f7e1d589c8..3ce440ca06 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -16,11 +16,7 @@ def index end def show - if !find_special_file.nil? - render_page find_special_file[:file] - else - render_page "docs/#{params[:page]}" - end + render_correct_page end def find_special_file @@ -29,6 +25,14 @@ def find_special_file private + def render_correct_page + if !find_special_file.nil? + render_page find_special_file[:file] + else + render_page "docs/#{params[:page]}" + end + end + def render_page(name) path = full_page_path(name) From 1ed08042063f3134f0d208e3de29bb02945123b0 Mon Sep 17 00:00:00 2001 From: Student Date: Wed, 8 Jul 2020 12:12:16 +0100 Subject: [PATCH 16/28] Remove index method from docs controller but hardcoded --- spec/example_app/app/controllers/docs_controller.rb | 10 +++++++--- spec/example_app/config/routes.rb | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index 3ce440ca06..5c6f34e33f 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -11,9 +11,9 @@ class DocsController < ApplicationController autolink: true, }.freeze - def index - render_page "README" - end + # def index + # render_page "README" + # end def show render_correct_page @@ -28,7 +28,11 @@ def find_special_file def render_correct_page if !find_special_file.nil? render_page find_special_file[:file] + elsif params[:page] == nil + render_page "README" else + p "here" + p params render_page "docs/#{params[:page]}" end end diff --git a/spec/example_app/config/routes.rb b/spec/example_app/config/routes.rb index 98123b7953..a0acd5082f 100644 --- a/spec/example_app/config/routes.rb +++ b/spec/example_app/config/routes.rb @@ -19,5 +19,5 @@ end get "/:page", to: "docs#show" - root to: "docs#index" + root to: "docs#show" end From 610241297f6b32d1d79ec8e940a401dfe5c6b789 Mon Sep 17 00:00:00 2001 From: Student Date: Wed, 8 Jul 2020 15:47:32 +0100 Subject: [PATCH 17/28] index page included in finding special files --- .../app/controllers/docs_controller.rb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index 5c6f34e33f..1458f5589b 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -3,6 +3,10 @@ class DocsController < ApplicationController { file: 'CONTRIBUTING', page: 'contributing' + }, + { + file: "README", + page: "index" } ].freeze @@ -20,16 +24,22 @@ def show end def find_special_file - SPECIAL_FILES.select { |page| page[:page] == params[:page] }.first + if params[:page] == nil + SPECIAL_FILES.select { |page| page[:page] == "index" }.first + else + SPECIAL_FILES.select { |page| page[:page] == params[:page] }.first + end end private def render_correct_page if !find_special_file.nil? + p find_special_file render_page find_special_file[:file] - elsif params[:page] == nil - render_page "README" + # elsif params[:page] == nil + # p params + # render_page "README" else p "here" p params From b2ebae7e068cc0d3001b33f0cb2c6f2f600e6774 Mon Sep 17 00:00:00 2001 From: Student Date: Wed, 8 Jul 2020 15:48:21 +0100 Subject: [PATCH 18/28] Refactor and remove ps --- spec/example_app/app/controllers/docs_controller.rb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index 1458f5589b..9b5d34fe5a 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -15,10 +15,6 @@ class DocsController < ApplicationController autolink: true, }.freeze - # def index - # render_page "README" - # end - def show render_correct_page end @@ -35,14 +31,8 @@ def find_special_file def render_correct_page if !find_special_file.nil? - p find_special_file render_page find_special_file[:file] - # elsif params[:page] == nil - # p params - # render_page "README" else - p "here" - p params render_page "docs/#{params[:page]}" end end From 7b1ea40f6f6ede25a90562cbe9012def88c33404 Mon Sep 17 00:00:00 2001 From: Student Date: Wed, 8 Jul 2020 15:56:05 +0100 Subject: [PATCH 19/28] Update for Nick's comments - Refactor --- spec/example_app/app/controllers/docs_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index 9b5d34fe5a..83f82cf317 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -21,16 +21,16 @@ def show def find_special_file if params[:page] == nil - SPECIAL_FILES.select { |page| page[:page] == "index" }.first + SPECIAL_FILES.find { |page| page[:page] == "index" } else - SPECIAL_FILES.select { |page| page[:page] == params[:page] }.first + SPECIAL_FILES.find { |page| page[:page] == params[:page] } end end private def render_correct_page - if !find_special_file.nil? + if find_special_file render_page find_special_file[:file] else render_page "docs/#{params[:page]}" From 824fa19ae44acacef93a6e3dd6aacedb0ab1c431 Mon Sep 17 00:00:00 2001 From: Student Date: Wed, 8 Jul 2020 16:10:41 +0100 Subject: [PATCH 20/28] Refactor - houndbot warnings --- spec/example_app/config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/example_app/config/routes.rb b/spec/example_app/config/routes.rb index a0acd5082f..04a2bac3c5 100644 --- a/spec/example_app/config/routes.rb +++ b/spec/example_app/config/routes.rb @@ -19,5 +19,5 @@ end get "/:page", to: "docs#show" - root to: "docs#show" + root to: 'docs#show' end From 0e8ba212c0d1548ef01fa679c976c49473611ca8 Mon Sep 17 00:00:00 2001 From: Student Date: Wed, 8 Jul 2020 16:11:15 +0100 Subject: [PATCH 21/28] Refactor - houndbot warnings --- spec/example_app/app/controllers/docs_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index 83f82cf317..ada03e81c2 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -5,8 +5,8 @@ class DocsController < ApplicationController page: 'contributing' }, { - file: "README", - page: "index" + file: 'README', + page: 'index' } ].freeze @@ -20,8 +20,8 @@ def show end def find_special_file - if params[:page] == nil - SPECIAL_FILES.find { |page| page[:page] == "index" } + if params[:page].nil? + SPECIAL_FILES.find { |page| page[:page] == 'index' } else SPECIAL_FILES.find { |page| page[:page] == params[:page] } end From 63378153d6009ce85def89e182df154f2f5b2658 Mon Sep 17 00:00:00 2001 From: Student Date: Wed, 8 Jul 2020 16:56:50 +0100 Subject: [PATCH 22/28] if statement to ternary --- spec/example_app/app/controllers/docs_controller.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index ada03e81c2..e2cc57490c 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -20,11 +20,7 @@ def show end def find_special_file - if params[:page].nil? - SPECIAL_FILES.find { |page| page[:page] == 'index' } - else - SPECIAL_FILES.find { |page| page[:page] == params[:page] } - end + params[:page].nil? ? SPECIAL_FILES.find { |page| page[:page] == 'index' } : SPECIAL_FILES.find { |page| page[:page] == params[:page] } end private From 27564b0faabc6c866460f0b666486a95a9b5d546 Mon Sep 17 00:00:00 2001 From: Student Date: Wed, 8 Jul 2020 17:14:01 +0100 Subject: [PATCH 23/28] separated content returned on finding special files Co-authored by: Kehinde Olofinmoyin --- spec/example_app/app/controllers/docs_controller.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index e2cc57490c..5f1fc76468 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -20,7 +20,15 @@ def show end def find_special_file - params[:page].nil? ? SPECIAL_FILES.find { |page| page[:page] == 'index' } : SPECIAL_FILES.find { |page| page[:page] == params[:page] } + params[:page].nil? ? retrieve_index_content : retrieve_everypage_content + end + + def retrieve_index_content + SPECIAL_FILES.find { |page| page[:page] == 'index' } + end + + def retrieve_everypage_content + SPECIAL_FILES.find { |page| page[:page] == params[:page] } end private From 2e7179a939c94c3ed28396a80da688b9b29c10e7 Mon Sep 17 00:00:00 2001 From: Student Date: Wed, 8 Jul 2020 18:00:45 +0100 Subject: [PATCH 24/28] Refactor - make methods private --- spec/example_app/app/controllers/docs_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index 5f1fc76468..7bce0db011 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -23,6 +23,8 @@ def find_special_file params[:page].nil? ? retrieve_index_content : retrieve_everypage_content end + private + def retrieve_index_content SPECIAL_FILES.find { |page| page[:page] == 'index' } end @@ -31,8 +33,6 @@ def retrieve_everypage_content SPECIAL_FILES.find { |page| page[:page] == params[:page] } end - private - def render_correct_page if find_special_file render_page find_special_file[:file] From 3ae7eacc08fd37e2540edc79b73aae665bfb372c Mon Sep 17 00:00:00 2001 From: Student Date: Thu, 9 Jul 2020 14:21:16 +0100 Subject: [PATCH 25/28] Revert "Remove index method from docs controller but hardcoded" This reverts commit 1ed08042063f3134f0d208e3de29bb02945123b0. Removed commits that make README a special file, as they belong in their own pull request. Fixed issue where symlink doesn't work on Windows machines. Removed symlink, instead load the Contributing.md doc via a Special File hash in the Docs Controller Class. Co-author: Kehinde Olofinmoyin " --- .../app/controllers/docs_controller.rb | 20 ++++++------------- spec/example_app/config/routes.rb | 2 +- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index 7bce0db011..3ce440ca06 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -3,10 +3,6 @@ class DocsController < ApplicationController { file: 'CONTRIBUTING', page: 'contributing' - }, - { - file: 'README', - page: 'index' } ].freeze @@ -15,26 +11,22 @@ class DocsController < ApplicationController autolink: true, }.freeze + def index + render_page "README" + end + def show render_correct_page end def find_special_file - params[:page].nil? ? retrieve_index_content : retrieve_everypage_content + SPECIAL_FILES.select { |page| page[:page] == params[:page] }.first end private - def retrieve_index_content - SPECIAL_FILES.find { |page| page[:page] == 'index' } - end - - def retrieve_everypage_content - SPECIAL_FILES.find { |page| page[:page] == params[:page] } - end - def render_correct_page - if find_special_file + if !find_special_file.nil? render_page find_special_file[:file] else render_page "docs/#{params[:page]}" diff --git a/spec/example_app/config/routes.rb b/spec/example_app/config/routes.rb index 04a2bac3c5..98123b7953 100644 --- a/spec/example_app/config/routes.rb +++ b/spec/example_app/config/routes.rb @@ -19,5 +19,5 @@ end get "/:page", to: "docs#show" - root to: 'docs#show' + root to: "docs#index" end From 57e92a3c3204d6da66d9e046637c45759d6fbb99 Mon Sep 17 00:00:00 2001 From: Student Date: Thu, 9 Jul 2020 14:29:59 +0100 Subject: [PATCH 26/28] Refactor - move find_special_file method to private --- spec/example_app/app/controllers/docs_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index 3ce440ca06..4fc85bdc23 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -19,12 +19,12 @@ def show render_correct_page end + private + def find_special_file SPECIAL_FILES.select { |page| page[:page] == params[:page] }.first end - private - def render_correct_page if !find_special_file.nil? render_page find_special_file[:file] From fcc1acd1f116e5546386dfdbcfd791d04289d238 Mon Sep 17 00:00:00 2001 From: Emily Wright <56832601+EWright212@users.noreply.github.com> Date: Fri, 31 Jul 2020 11:06:40 +0100 Subject: [PATCH 27/28] Update spec/example_app/app/controllers/docs_controller.rb Co-authored-by: Nick Charlton --- spec/example_app/app/controllers/docs_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index 4fc85bdc23..6936c6d334 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -27,7 +27,7 @@ def find_special_file def render_correct_page if !find_special_file.nil? - render_page find_special_file[:file] + render_page(find_special_file[:file]) else render_page "docs/#{params[:page]}" end From 60fefb1ebfaf56bcb9b3c281768a0d1ea875a2cc Mon Sep 17 00:00:00 2001 From: Emily Wright <56832601+EWright212@users.noreply.github.com> Date: Fri, 31 Jul 2020 11:06:52 +0100 Subject: [PATCH 28/28] Update spec/example_app/app/controllers/docs_controller.rb Co-authored-by: Nick Charlton --- spec/example_app/app/controllers/docs_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/example_app/app/controllers/docs_controller.rb b/spec/example_app/app/controllers/docs_controller.rb index 6936c6d334..bdea74c234 100644 --- a/spec/example_app/app/controllers/docs_controller.rb +++ b/spec/example_app/app/controllers/docs_controller.rb @@ -29,7 +29,7 @@ def render_correct_page if !find_special_file.nil? render_page(find_special_file[:file]) else - render_page "docs/#{params[:page]}" + render_page("docs/#{params[:page]}") end end