forked from critcola/discourse-clyp-onebox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.rb
More file actions
25 lines (21 loc) · 851 Bytes
/
plugin.rb
File metadata and controls
25 lines (21 loc) · 851 Bytes
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
# name: quantafrontier-onebox
# about: onebox
# version: 1.0
# authors: Quoc Le
class Onebox::Engine::QuantaFrontierOnebox
include Onebox::Engine
REGEX = /^https?:\/\/quantafrontier\.com\/research\/algorithm\/(\w+)(\?version=)?(\d+)?/
matches_regexp REGEX
def id
@url.match(REGEX)[1]
end
def to_html
matches = @url.match(REGEX)
puts "onebox %s %d" % [@url, matches.length]
if matches.length > 3
return "<iframe width=\"100%\" height=\"600\" src=\"//quantafrontier.com/research/iframe?id=#{id}&version=#{matches[3]}\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"></iframe>"
else
return "<iframe width=\"100%\" height=\"600\" src=\"//quantafrontier.com/research/iframe?id=#{id}\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"></iframe>"
end
end
end