Skip to content

Commit

Permalink
Allow fetching special files in the documentation (#1698)
Browse files Browse the repository at this point in the history
In #1514, we added a symlink so that the docs would show up on the demo app …but
symlinks aren't supported on Windows and was causing a problem when trying to bundle.

This instead adds a lookup table of files not in docs/ which allows us to render those.

This partially fixes #1693, in allowing Administrate itself to be bundled without a symlink but
other dependencies have the same problem.
  • Loading branch information
EWright212 committed Jul 31, 2020
1 parent 9e008a3 commit 40e0652
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
1 change: 0 additions & 1 deletion docs/contributing.md

This file was deleted.

21 changes: 20 additions & 1 deletion spec/example_app/app/controllers/docs_controller.rb
@@ -1,4 +1,11 @@
class DocsController < ApplicationController
SPECIAL_FILES = [
{
file: 'CONTRIBUTING',
page: 'contributing'
}
].freeze

REDCARPET_CONFIG = {
fenced_code_blocks: true,
autolink: true,
Expand All @@ -9,11 +16,23 @@ def index
end

def show
render_page "docs/#{params[:page]}"
render_correct_page
end

private

def find_special_file
SPECIAL_FILES.select { |page| page[:page] == params[:page] }.first
end

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)

Expand Down

0 comments on commit 40e0652

Please sign in to comment.