blob: 1f5ab0645fea23b99b1b46721ba1861d42298ee7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# frozen_string_literal: true
module Banzai
module Filter
module References
# HTML filter that replaces snippet references with links. References to
# snippets that do not exist are ignored.
#
# This filter supports cross-project references.
class SnippetReferenceFilter < AbstractReferenceFilter
self.reference_type = :snippet
self.object_class = Snippet
def parent_records(project, ids)
return unless project.is_a?(Project)
project.snippets.where(id: ids.to_a)
end
def find_object(project, id)
reference_cache.records_per_parent[project][id]
end
def url_for_object(snippet, project)
h = Gitlab::Routing.url_helpers
h.project_snippet_url(project, snippet, only_path: context[:only_path])
end
end
end
end
end
|