2013-02-06 03:16:51 +08: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-26 00:42:20 +08:00
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
def parse(data)
|
|
|
|
|
2013-02-12 22:46:45 +08:00
|
|
|
html_doc = Nokogiri::HTML(data)
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
result = {}
|
|
|
|
|
2013-02-12 22:46:45 +08:00
|
|
|
m = html_doc.at("h1.doc-banner-title")
|
2013-02-06 03:16:51 +08:00
|
|
|
result[:title] = m.inner_text if m
|
|
|
|
|
2013-02-12 22:46:45 +08:00
|
|
|
m = html_doc.at("div#doc-original-text")
|
2013-02-06 03:16:51 +08:00
|
|
|
if m
|
|
|
|
result[:text] = BaseOnebox.replace_tags_with_spaces(m.inner_html)
|
|
|
|
result[:text] = result[:text][0..MAX_TEXT]
|
|
|
|
end
|
|
|
|
|
2013-02-12 22:46:45 +08:00
|
|
|
m = html_doc.at("div.doc-banner-icon img")
|
2013-02-06 03:16:51 +08:00
|
|
|
result[:image] = m['src'] if m
|
|
|
|
|
|
|
|
result
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|