Class: Onebox::Engine::GitlabBlobOnebox
- Inherits:
-
Object
- Object
- Onebox::Engine::GitlabBlobOnebox
show all
- Includes:
- Mixins::GitBlobOnebox
- Defined in:
- lib/onebox/engine/gitlab_blob_onebox.rb
Constant Summary
Mixins::GitBlobOnebox::DEFAULTS, Mixins::GitBlobOnebox::EXPAND_AFTER, Mixins::GitBlobOnebox::EXPAND_BEFORE, Mixins::GitBlobOnebox::EXPAND_NONE
Class Method Summary
collapse
Instance Method Summary
collapse
included
Class Method Details
.git_regexp ⇒ Object
8
9
10
|
# File 'lib/onebox/engine/gitlab_blob_onebox.rb', line 8
def self.git_regexp
%r{^https?://(www\.)?gitlab\.com.*/blob/}
end
|
.onebox_name ⇒ Object
12
13
14
|
# File 'lib/onebox/engine/gitlab_blob_onebox.rb', line 12
def self.onebox_name
"gitlabblob"
end
|
Instance Method Details
37
38
39
|
# File 'lib/onebox/engine/gitlab_blob_onebox.rb', line 37
def (_match)
{}
end
|
#i18n ⇒ Object
18
19
20
21
22
23
|
# File 'lib/onebox/engine/gitlab_blob_onebox.rb', line 18
def i18n
{
truncated_file: I18n.t("onebox.gitlab.truncated_file"),
show_original: I18n.t("onebox.gitlab.show_original"),
}
end
|
#raw_regexp ⇒ Object
25
26
27
|
# File 'lib/onebox/engine/gitlab_blob_onebox.rb', line 25
def raw_regexp
%r{gitlab\.com/(?<user>[^/]+)/(?<repo>[^/]+)/blob/(?<sha1>[^/]+)/(?<file>[^#]+)(#(L(?<from>[^-]*)(-L(?<to>.*))?))?}mi
end
|
#raw_template(m) ⇒ Object
29
30
31
|
# File 'lib/onebox/engine/gitlab_blob_onebox.rb', line 29
def raw_template(m)
"https://gitlab.com/#{m[:user]}/#{m[:repo]}/raw/#{m[:sha1]}/#{m[:file]}"
end
|
#title ⇒ Object
33
34
35
|
# File 'lib/onebox/engine/gitlab_blob_onebox.rb', line 33
def title
Sanitize.fragment(Onebox::Helpers.uri_unencode(link).sub(%r{^https?\://gitlab\.com/}, ""))
end
|