discourse/lib/oneboxer/apple_app_onebox.rb

38 lines
645 B
Ruby
Raw Normal View History

2013-02-06 03:16:51 +08:00
require_dependency 'oneboxer/handlebars_onebox'
module Oneboxer
class AppleAppOnebox < HandlebarsOnebox
matcher /^https?:\/\/itunes\.apple\.com\/.+$/
favicon 'apple.png'
# Don't masquerade as mobile
def http_params
{}
end
def template
template_path('simple_onebox')
end
def parse(data)
hp = Hpricot(data)
result = {}
m = hp.at("h1")
result[:title] = m.inner_text if m
m = hp.at("h4 ~ p")
result[:text] = m.inner_text[0..MAX_TEXT] if m
m = hp.at(".product img.artwork")
result[:image] = m['src'] if m
result
end
end
end