diff options
author | Brett Walker <bwalker@gitlab.com> | 2018-09-04 22:21:20 +0300 |
---|---|---|
committer | Brett Walker <bwalker@gitlab.com> | 2018-09-05 17:19:16 +0300 |
commit | c4f26d4b1c9adcbfc3ad45b71534b990e2b6692b (patch) | |
tree | 4cfbc11da4275bd6a24dc65594b6998ffd076d32 /app | |
parent | 3aea946e7f590319ff7b85dbbd4eedfc20569deb (diff) |
added feature flag 'commonmark_for_repositories'
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/markup_helper.rb | 6 | ||||
-rw-r--r-- | app/models/repository.rb | 7 | ||||
-rw-r--r-- | app/views/projects/wikis/_form.html.haml | 5 |
3 files changed, 16 insertions, 2 deletions
diff --git a/app/helpers/markup_helper.rb b/app/helpers/markup_helper.rb index 6b826dac84c..3adaa1366c0 100644 --- a/app/helpers/markup_helper.rb +++ b/app/helpers/markup_helper.rb @@ -107,6 +107,7 @@ module MarkupHelper def markup(file_name, text, context = {}) context[:project] ||= @project + context[:markdown_engine] ||= :redcarpet unless commonmark_for_repositories_enabled? html = context.delete(:rendered) || markup_unsafe(file_name, text, context) prepare_for_rendering(html, context) end @@ -122,6 +123,7 @@ module MarkupHelper page_slug: wiki_page.slug, issuable_state_filter_enabled: true ) + context[:markdown_engine] ||= :redcarpet unless commonmark_for_repositories_enabled? html = case wiki_page.format @@ -176,6 +178,10 @@ module MarkupHelper end end + def commonmark_for_repositories_enabled? + Feature.enabled?(:commonmark_for_repositories, default_enabled: true) + end + private # Return +text+, truncated to +max_chars+ characters, excluding any HTML diff --git a/app/models/repository.rb b/app/models/repository.rb index 4b4d5d5f349..929d28b9d88 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -580,7 +580,12 @@ class Repository end def rendered_readme - MarkupHelper.markup_unsafe(readme.name, readme.data, project: project) if readme + return unless readme + + context = { project: project } + context[:markdown_engine] = :redcarpet unless MarkupHelper.commonmark_for_repositories_enabled? + + MarkupHelper.markup_unsafe(readme.name, readme.data, context) end cache_method :rendered_readme diff --git a/app/views/projects/wikis/_form.html.haml b/app/views/projects/wikis/_form.html.haml index 707fc1dc842..7fb80450161 100644 --- a/app/views/projects/wikis/_form.html.haml +++ b/app/views/projects/wikis/_form.html.haml @@ -1,6 +1,9 @@ - commit_message = @page.persisted? ? s_("WikiPageEdit|Update %{page_title}") : s_("WikiPageCreate|Create %{page_title}") - commit_message = commit_message % { page_title: @page.title } -- markdown_version = params[:legacy_render] ? CacheMarkdownField::CACHE_REDCARPET_VERSION : 0 +- if params[:legacy_render] || !commonmark_for_repositories_enabled? + - markdown_version = CacheMarkdownField::CACHE_REDCARPET_VERSION +- else + - markdown_version = 0 = form_for [@project.namespace.becomes(Namespace), @project, @page], method: @page.persisted? ? :put : :post, html: { class: 'wiki-form common-note-form prepend-top-default js-quick-submit' }, |