blob: bf7e0f78609cfeba5db7729c021ba3259da5c31a (
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
def self.object_class
Snippet
end
def find_object(project, id)
return unless project.is_a?(Project)
project.snippets.find_by(id: 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
|