Hello,
I had an attempt to create a plugin which increases the unfurled image size within a discourse post for our domain (count.co). This is a link example:
https://count.co/stackoverflow/share/hnT-t1UMfSLTSscX46p9k
This is my onebox plugin attempt:
This is my onebox plugin attempt
Although the plugin does unfurl the image fine, I am struggling to get the og
metatags from the website displayed.
register_css <<CSS
.reference {
position: relative;
height: 100%;
width: 100%;
}
.count-embed {
position: relative;
height: 400px;
border: 1px solid #ddd;
border-radius: 3px;
}
.count-container {
position: absolute;
top: 33px;
bottom: 1px;
left: 1px;
right: 1px;
}
CSS
Onebox = Onebox
class Onebox::Engine::CountOnebox
include Onebox::Engine
# include Onebox::Engine::StandardEmbed
def self.priority
0
end
REGEX = /^https:\/\/count.co\/(\w+)\/share\/(.+)/
matches_regexp REGEX
def id
@url.match(REGEX)[2]
end
def url
return @url
end
def get_opengraph
@opengraph ||= ::Onebox::OpenGraph.new(html_doc)
end
def html_doc
return @html_doc if @html_doc
headers = nil
headers = { 'Cookie' => options[:cookie] } if options[:cookie]
@html_doc = Onebox::Helpers.fetch_html_doc(url, headers)
end
def og
@og = get_opengraph
end
def to_html
<<HTML
<div class= "count-embed">
<p> "Explore this data with Count"</p>
<h3><a href='#{og[:url]}' target="_blank">'#{og[:title]}'</a></h3>
<div class= "count-container">
<img src="https://storage.googleapis.com/count-data/shared-visuals/#{id}.png" width="500" height="300" frameborder="0" >
<p>'#{og[:description]}'</p>
</div>
</div>
HTML
end
end
Thanks in advance
Nicolas