Class: Onebox::Engine::GithubBlobOnebox
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
#github_auth_header
Class Method Details
.git_regexp ⇒ Object
11
12
13
|
# File 'lib/onebox/engine/github_blob_onebox.rb', line 11
def self.git_regexp
%r{^https?://(www\.)?github\.com.*/blob/}
end
|
.onebox_name ⇒ Object
15
16
17
|
# File 'lib/onebox/engine/github_blob_onebox.rb', line 15
def self.onebox_name
"githubblob"
end
|
Instance Method Details
42
43
44
|
# File 'lib/onebox/engine/github_blob_onebox.rb', line 42
def (match)
(match[:org])
end
|
#i18n ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/onebox/engine/github_blob_onebox.rb', line 21
def i18n
{
binary_file: I18n.t("onebox.github.binary_file"),
truncated_file: I18n.t("onebox.github.truncated_file"),
show_original: I18n.t("onebox.github.show_original"),
requires_iframe: I18n.t("onebox.github.requires_iframe"),
}
end
|
#raw_regexp ⇒ Object
30
31
32
|
# File 'lib/onebox/engine/github_blob_onebox.rb', line 30
def raw_regexp
%r{github\.com/(?<org>[^/]+)/(?<repo>[^/]+)/blob/(?<sha1>[^/]+)/(?<file>[^#]+)(#(L(?<from>[^-]*)(-L(?<to>.*))?))?}mi
end
|
#raw_template(match) ⇒ Object
34
35
36
|
# File 'lib/onebox/engine/github_blob_onebox.rb', line 34
def raw_template(match)
"https://raw.githubusercontent.com/#{match[:org]}/#{match[:repo]}/#{match[:sha1]}/#{match[:file]}"
end
|
#title ⇒ Object
38
39
40
|
# File 'lib/onebox/engine/github_blob_onebox.rb', line 38
def title
Sanitize.fragment(Onebox::Helpers.uri_unencode(link).sub(%r{^https?\://github\.com/}, ""))
end
|