Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-10 12:08:56 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-10 12:08:56 +0300
commitb4ded0ba7b4d2cdbed5b1f331cf2083a25ee4d7c (patch)
tree6694fa9d8f3e226597cc01dfb8e3e07b50ae85b6 /lib
parent2aaef94c80937d9d188f7b9cbbad2dcd1508c3c1 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/api/keys.rb2
-rw-r--r--lib/banzai/filter/gollum_tags_filter.rb36
-rw-r--r--lib/banzai/filter/table_of_contents_tag_filter.rb45
-rw-r--r--lib/banzai/pipeline/gfm_pipeline.rb1
-rw-r--r--lib/feature/gitaly.rb1
5 files changed, 53 insertions, 32 deletions
diff --git a/lib/api/keys.rb b/lib/api/keys.rb
index bec3dc9bd97..b730e027063 100644
--- a/lib/api/keys.rb
+++ b/lib/api/keys.rb
@@ -26,7 +26,7 @@ module API
get do
authenticated_with_can_read_all_resources!
- key = KeysFinder.new(current_user, params).execute
+ key = KeysFinder.new(params).execute
not_found!('Key') unless key
diff --git a/lib/banzai/filter/gollum_tags_filter.rb b/lib/banzai/filter/gollum_tags_filter.rb
index 0c1bbd2d250..dec4ec871f1 100644
--- a/lib/banzai/filter/gollum_tags_filter.rb
+++ b/lib/banzai/filter/gollum_tags_filter.rb
@@ -25,12 +25,10 @@ module Banzai
# * [[http://example.com/images/logo.png]]
# * [[http://example.com/images/logo.png|alt=Logo]]
#
- # - Insert a Table of Contents list:
- #
- # * [[_TOC_]]
- #
# Based on Gollum::Filter::Tags
#
+ # Note: the table of contents tag is now handled by TableOfContentsTagFilter
+ #
# Context options:
# :project_wiki (required) - Current project wiki.
#
@@ -64,23 +62,11 @@ module Banzai
def call
doc.search(".//text()").each do |node|
next if has_ancestor?(node, IGNORED_ANCESTOR_TAGS)
+ next unless node.content =~ TAGS_PATTERN
- # A Gollum ToC tag is `[[_TOC_]]`, but due to MarkdownFilter running
- # before this one, it will be converted into `[[<em>TOC</em>]]`, so it
- # needs special-case handling
- if toc_tag?(node)
- process_toc_tag(node)
- else
- content = node.content
-
- next unless content =~ TAGS_PATTERN
-
- html = process_tag($1)
+ html = process_tag($1)
- if html && html != node.content
- node.replace(html)
- end
- end
+ node.replace(html) if html && html != node.content
end
doc
@@ -88,12 +74,6 @@ module Banzai
private
- # Replace an entire `[[<em>TOC</em>]]` node with the result generated by
- # TableOfContentsFilter
- def process_toc_tag(node)
- node.parent.parent.replace(result[:toc].presence || '')
- end
-
# Process a single tag into its final HTML form.
#
# tag - The String tag contents (the stuff inside the double brackets).
@@ -129,12 +109,6 @@ module Banzai
end
end
- def toc_tag?(node)
- node.content == 'TOC' &&
- node.parent.name == 'em' &&
- node.parent.parent.text == '[[TOC]]'
- end
-
def image?(path)
path =~ ALLOWED_IMAGE_EXTENSIONS
end
diff --git a/lib/banzai/filter/table_of_contents_tag_filter.rb b/lib/banzai/filter/table_of_contents_tag_filter.rb
new file mode 100644
index 00000000000..13d0a6a4cc7
--- /dev/null
+++ b/lib/banzai/filter/table_of_contents_tag_filter.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+module Banzai
+ module Filter
+ # Using `[[_TOC_]]`, inserts a Table of Contents list.
+ # This syntax is based on the Gollum syntax. This way we have
+ # some consistency between with wiki and normal markdown.
+ # If there ever emerges a markdown standard, we can implement
+ # that here.
+ #
+ # The support for this has been removed from GollumTagsFilter
+ #
+ # Based on Banzai::Filter::GollumTagsFilter
+ class TableOfContentsTagFilter < HTML::Pipeline::Filter
+ TEXT_QUERY = %q(descendant-or-self::text()[ancestor::p and contains(., 'TOC')])
+
+ def call
+ return doc if context[:no_header_anchors]
+
+ doc.xpath(TEXT_QUERY).each do |node|
+ # A Gollum ToC tag is `[[_TOC_]]`, but due to MarkdownFilter running
+ # before this one, it will be converted into `[[<em>TOC</em>]]`, so it
+ # needs special-case handling
+ process_toc_tag(node) if toc_tag?(node)
+ end
+
+ doc
+ end
+
+ private
+
+ # Replace an entire `[[<em>TOC</em>]]` node with the result generated by
+ # TableOfContentsFilter
+ def process_toc_tag(node)
+ node.parent.parent.replace(result[:toc].presence || '')
+ end
+
+ def toc_tag?(node)
+ node.content == 'TOC' &&
+ node.parent.name == 'em' &&
+ node.parent.parent.text == '[[TOC]]'
+ end
+ end
+ end
+end
diff --git a/lib/banzai/pipeline/gfm_pipeline.rb b/lib/banzai/pipeline/gfm_pipeline.rb
index f6c12cdb53b..dad0d95685e 100644
--- a/lib/banzai/pipeline/gfm_pipeline.rb
+++ b/lib/banzai/pipeline/gfm_pipeline.rb
@@ -32,6 +32,7 @@ module Banzai
Filter::InlineMetricsFilter,
Filter::InlineGrafanaMetricsFilter,
Filter::TableOfContentsFilter,
+ Filter::TableOfContentsTagFilter,
Filter::AutolinkFilter,
Filter::ExternalLinkFilter,
Filter::SuggestionFilter,
diff --git a/lib/feature/gitaly.rb b/lib/feature/gitaly.rb
index 6e27b500802..7e3b9378d10 100644
--- a/lib/feature/gitaly.rb
+++ b/lib/feature/gitaly.rb
@@ -11,6 +11,7 @@ class Feature
inforef_uploadpack_cache
commit_without_batch_check
use_core_delta_islands
+ use_git_protocol_v2
].freeze
DEFAULT_ON_FLAGS = Set.new([]).freeze