move logic into legacy_render_context helper method
This commit is contained in:
parent
a963721f79
commit
589776fc2e
9 changed files with 25 additions and 16 deletions
|
@ -115,13 +115,13 @@ module MarkupHelper
|
||||||
text = wiki_page.content
|
text = wiki_page.content
|
||||||
return '' unless text.present?
|
return '' unless text.present?
|
||||||
|
|
||||||
context.merge!({
|
context.merge!(
|
||||||
pipeline: :wiki,
|
pipeline: :wiki,
|
||||||
project: @project,
|
project: @project,
|
||||||
project_wiki: @project_wiki,
|
project_wiki: @project_wiki,
|
||||||
page_slug: wiki_page.slug,
|
page_slug: wiki_page.slug,
|
||||||
issuable_state_filter_enabled: true
|
issuable_state_filter_enabled: true
|
||||||
})
|
)
|
||||||
|
|
||||||
html =
|
html =
|
||||||
case wiki_page.format
|
case wiki_page.format
|
||||||
|
|
|
@ -252,6 +252,10 @@ module ProjectsHelper
|
||||||
"xcode://clone?repo=#{CGI.escape(default_url_to_repo(project))}"
|
"xcode://clone?repo=#{CGI.escape(default_url_to_repo(project))}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def legacy_render_context(params)
|
||||||
|
params[:legacy_render] ? { markdown_engine: :redcarpet } : {}
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_project_nav_tabs(project, current_user)
|
def get_project_nav_tabs(project, current_user)
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
%div{ class: container_class }
|
%div{ class: container_class }
|
||||||
.prepend-top-default.append-bottom-default
|
.prepend-top-default.append-bottom-default
|
||||||
.wiki
|
.wiki
|
||||||
- context = params[:legacy_render] ? { markdown_engine: :redcarpet} : {}
|
= render_wiki_content(@wiki_home, legacy_render_context(params))
|
||||||
= render_wiki_content(@wiki_home, context)
|
|
||||||
- else
|
- else
|
||||||
- can_create_wiki = can?(current_user, :create_wiki, @project)
|
- 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)] }
|
.project-home-empty{ class: [('row-content-block' if can_create_wiki), ('content-block' unless can_create_wiki)] }
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
.diff-content
|
.diff-content
|
||||||
- if markup?(@blob.name)
|
- if markup?(@blob.name)
|
||||||
.file-content.wiki
|
.file-content.wiki
|
||||||
- context = params[:legacy_render] ? { markdown_engine: :redcarpet} : {}
|
= markup(@blob.name, @content, legacy_render_context(params))
|
||||||
= markup(@blob.name, @content, context)
|
|
||||||
- else
|
- else
|
||||||
.file-content.code.js-syntax-highlight
|
.file-content.code.js-syntax-highlight
|
||||||
- unless @diff_lines.empty?
|
- unless @diff_lines.empty?
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
- blob = viewer.blob
|
- blob = viewer.blob
|
||||||
- context = {}
|
- context = legacy_render_context(params)
|
||||||
- if params[:legacy_render]
|
- unless context[:markdown_engine] == :redcarpet
|
||||||
- context[:markdown_engine] = :redcarpet
|
|
||||||
- else
|
|
||||||
- context[:rendered] = blob.rendered_markup if blob.respond_to?(:rendered_markup)
|
- context[:rendered] = blob.rendered_markup if blob.respond_to?(:rendered_markup)
|
||||||
.file-content.wiki
|
.file-content.wiki
|
||||||
= markup(blob.name, blob.data, context)
|
= markup(blob.name, blob.data, context)
|
||||||
|
|
|
@ -12,8 +12,7 @@
|
||||||
.blocks-container
|
.blocks-container
|
||||||
.block.block-first
|
.block.block-first
|
||||||
- if @sidebar_page
|
- if @sidebar_page
|
||||||
- context = params[:legacy_render] ? { markdown_engine: :redcarpet} : {}
|
= render_wiki_content(@sidebar_page, legacy_render_context(params))
|
||||||
= render_wiki_content(@sidebar_page, context)
|
|
||||||
- else
|
- else
|
||||||
%ul.wiki-pages
|
%ul.wiki-pages
|
||||||
= render @sidebar_wiki_entries, context: 'sidebar'
|
= render @sidebar_wiki_entries, context: 'sidebar'
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
|
|
||||||
.prepend-top-default.append-bottom-default
|
.prepend-top-default.append-bottom-default
|
||||||
.wiki
|
.wiki
|
||||||
- context = params[:legacy_render] ? { markdown_engine: :redcarpet} : {}
|
= render_wiki_content(@page, legacy_render_context(params))
|
||||||
= render_wiki_content(@page, context)
|
|
||||||
|
|
||||||
= render 'sidebar'
|
= render 'sidebar'
|
||||||
|
|
|
@ -21,8 +21,7 @@
|
||||||
.file-content.wiki
|
.file-content.wiki
|
||||||
- snippet_chunks.each do |chunk|
|
- snippet_chunks.each do |chunk|
|
||||||
- unless chunk[:data].empty?
|
- unless chunk[:data].empty?
|
||||||
- context = params[:legacy_render] ? { markdown_engine: :redcarpet} : {}
|
= markup(snippet.file_name, chunk[:data], legacy_render_context(params))
|
||||||
= markup(snippet.file_name, chunk[:data], context)
|
|
||||||
- else
|
- else
|
||||||
.file-content.code
|
.file-content.code
|
||||||
.nothing-here-block Empty file
|
.nothing-here-block Empty file
|
||||||
|
|
|
@ -470,4 +470,16 @@ describe ProjectsHelper do
|
||||||
end
|
end
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue