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
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-10-14 22:29:35 +0300
committerDouwe Maan <douwe@gitlab.com>2015-10-14 22:29:35 +0300
commit925dc5925b672718ea1f0f08c5bdd492b5ab3e5d (patch)
tree22a58bbe8f2beba9d501667fc0ea274072741788 /lib/gitlab
parent539de0dd81ea0d831031c06da502254952d87676 (diff)
Cache rendered contents of issues, MRs and notes
Diffstat (limited to 'lib/gitlab')
-rw-r--r--lib/gitlab/markdown.rb12
-rw-r--r--lib/gitlab/reference_extractor.rb20
2 files changed, 21 insertions, 11 deletions
diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb
index d1f22070cba..b9615f95012 100644
--- a/lib/gitlab/markdown.rb
+++ b/lib/gitlab/markdown.rb
@@ -20,6 +20,8 @@ module Gitlab
#
# Returns an HTML-safe String
def self.render(text, context = {})
+ context[:pipeline] ||= :full
+
cache_key = context.delete(:cache_key)
cache_key = full_cache_key(cache_key, context[:pipeline])
@@ -33,7 +35,7 @@ module Gitlab
end
def self.render_result(text, context = {})
- pipeline = context[:pipeline] || :full
+ pipeline = context[:pipeline] ||= :full
html_pipeline = html_pipelines[pipeline]
@@ -129,6 +131,7 @@ module Gitlab
atom: :full,
email: :full,
description: :full,
+ note: :full,
single_line: :gfm,
asciidoc: [
@@ -170,6 +173,13 @@ module Gitlab
only_path: false
}
],
+ note: [
+ :full,
+ {
+ # TableOfContentsFilter
+ no_header_anchors: true
+ }
+ ],
description: [
:full,
{
diff --git a/lib/gitlab/reference_extractor.rb b/lib/gitlab/reference_extractor.rb
index f34bf7d1d0e..37141efb4c3 100644
--- a/lib/gitlab/reference_extractor.rb
+++ b/lib/gitlab/reference_extractor.rb
@@ -9,13 +9,12 @@ module Gitlab
@project = project
@current_user = current_user
@load_lazy_references = load_lazy_references
- end
- def analyze(text, cache_key: nil)
- references.clear
+ @texts = []
+ end
- @pipeline = Gitlab::Markdown.cached?(cache_key, pipeline: :full) ? :full : :plain_markdown
- @html = Gitlab::Markdown.render(text, project: project, cache_key: cache_key, pipeline: @pipeline)
+ def analyze(text, options = {})
+ @texts << Gitlab::Markdown.render(text, options.merge(project: project))
end
%i(user label issue merge_request snippet commit commit_range).each do |type|
@@ -46,7 +45,7 @@ module Gitlab
filter = Gitlab::Markdown.const_get(klass)
context = {
- pipeline: [:reference_extraction],
+ pipeline: :reference_extraction,
project: project,
current_user: current_user,
@@ -56,10 +55,11 @@ module Gitlab
reference_filter: filter
}
- context[:pipeline].unshift(filter) unless @pipeline == :full
-
- result = Gitlab::Markdown.render_result(@html, context)
- values = result[:references][filter_type].uniq
+ values = @texts.flat_map do |html|
+ text_context = context.dup
+ result = Gitlab::Markdown.render_result(html, text_context)
+ result[:references][filter_type]
+ end.uniq
if @load_lazy_references
values = Gitlab::Markdown::ReferenceFilter::LazyReference.load(values).uniq