discourse/lib/oneboxer/android_app_store_onebox.rb

36 lines
737 B
Ruby
Raw Normal View History

2013-02-05 14:16:51 -05:00
require_dependency 'oneboxer/handlebars_onebox'
module Oneboxer
class AndroidAppStoreOnebox < HandlebarsOnebox
matcher /^https?:\/\/play\.google\.com\/.+$/
favicon 'google_play.png'
def template
template_path('simple_onebox')
end
2013-02-25 11:42:20 -05:00
2013-02-05 14:16:51 -05:00
def parse(data)
2013-02-12 09:46:45 -05:00
html_doc = Nokogiri::HTML(data)
2013-02-05 14:16:51 -05:00
result = {}
2013-02-12 09:46:45 -05:00
m = html_doc.at("h1.doc-banner-title")
2013-02-05 14:16:51 -05:00
result[:title] = m.inner_text if m
2013-02-12 09:46:45 -05:00
m = html_doc.at("div#doc-original-text")
2013-02-05 14:16:51 -05:00
if m
result[:text] = BaseOnebox.replace_tags_with_spaces(m.inner_html)
result[:text] = result[:text][0..MAX_TEXT]
end
2013-02-12 09:46:45 -05:00
m = html_doc.at("div.doc-banner-icon img")
2013-02-05 14:16:51 -05:00
result[:image] = m['src'] if m
result
end
end
end