Commit 589776fc authored by Brett Walker's avatar Brett Walker

move logic into legacy_render_context helper method

parent a963721f
......@@ -115,13 +115,13 @@ module MarkupHelper
text = wiki_page.content
return '' unless text.present?
context.merge!({
context.merge!(
pipeline: :wiki,
project: @project,
project_wiki: @project_wiki,
page_slug: wiki_page.slug,
issuable_state_filter_enabled: true
})
)
html =
case wiki_page.format
......
......@@ -252,6 +252,10 @@ module ProjectsHelper
"xcode://clone?repo=#{CGI.escape(default_url_to_repo(project))}"
end
def legacy_render_context(params)
params[:legacy_render] ? { markdown_engine: :redcarpet } : {}
end
private
def get_project_nav_tabs(project, current_user)
......
......@@ -2,8 +2,7 @@
%div{ class: container_class }
.prepend-top-default.append-bottom-default
.wiki
- context = params[:legacy_render] ? { markdown_engine: :redcarpet} : {}
= render_wiki_content(@wiki_home, context)
= render_wiki_content(@wiki_home, legacy_render_context(params))
- else
- can_create_wiki = can?(current_user, :create_wiki, @project)
.project-home-empty{ class: [('row-content-block' if can_create_wiki), ('content-block' unless can_create_wiki)] }
......
......@@ -2,8 +2,7 @@
.diff-content
- if markup?(@blob.name)
.file-content.wiki
- context = params[:legacy_render] ? { markdown_engine: :redcarpet} : {}
= markup(@blob.name, @content, context)
= markup(@blob.name, @content, legacy_render_context(params))
- else
.file-content.code.js-syntax-highlight
- unless @diff_lines.empty?
......
- blob = viewer.blob
- context = {}
- if params[:legacy_render]
- context[:markdown_engine] = :redcarpet
- else
- context = legacy_render_context(params)
- unless context[:markdown_engine] == :redcarpet
- context[:rendered] = blob.rendered_markup if blob.respond_to?(:rendered_markup)
.file-content.wiki
= markup(blob.name, blob.data, context)
......@@ -12,8 +12,7 @@
.blocks-container
.block.block-first
- if @sidebar_page
- context = params[:legacy_render] ? { markdown_engine: :redcarpet} : {}
= render_wiki_content(@sidebar_page, context)
= render_wiki_content(@sidebar_page, legacy_render_context(params))
- else
%ul.wiki-pages
= render @sidebar_wiki_entries, context: 'sidebar'
......
......@@ -26,7 +26,6 @@
.prepend-top-default.append-bottom-default
.wiki
- context = params[:legacy_render] ? { markdown_engine: :redcarpet} : {}
= render_wiki_content(@page, context)
= render_wiki_content(@page, legacy_render_context(params))
= render 'sidebar'
......@@ -21,8 +21,7 @@
.file-content.wiki
- snippet_chunks.each do |chunk|
- unless chunk[:data].empty?
- context = params[:legacy_render] ? { markdown_engine: :redcarpet} : {}
= markup(snippet.file_name, chunk[:data], context)
= markup(snippet.file_name, chunk[:data], legacy_render_context(params))
- else
.file-content.code
.nothing-here-block Empty file
......
......@@ -470,4 +470,16 @@ describe ProjectsHelper do
end
end
end
describe '#legacy_render_context' do
it 'returns the redcarpet engine' do
params = { legacy_render: '1' }
expect(helper.legacy_render_context(params)).to include(markdown_engine: :redcarpet)
end
it 'returns nothing' do
expect(helper.legacy_render_context({})).to be_empty
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment