Skip to content

Commit

Permalink
Merge pull request #113 from dysania/create-soundcloud-onebox
Browse files Browse the repository at this point in the history
Create soundcloud onebox
  • Loading branch information
jzeta committed Sep 5, 2013
2 parents e9e29bc + 3118a41 commit fa61d5d
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/onebox/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def matches(&block)
require_relative "engine/funny_or_die_onebox"
require_relative "engine/hulu_onebox"
require_relative "engine/nfb_onebox"
require_relative "engine/sound_cloud_onebox"
require_relative "engine/qik_onebox"
require_relative "engine/revision3_onebox"
require_relative "engine/slideshare_onebox"
Expand Down
25 changes: 25 additions & 0 deletions lib/onebox/engine/sound_cloud_onebox.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module Onebox
module Engine
class SoundCloudOnebox
include Engine
include OpenGraph

matches do
# /^https?:\/\/(?:www\.)?soundcloud\.com\/.+$/
find "soundcloud.com"
end

private

def extracted_data
{
url: @url,
title: @body.title,
image: @body.images.first,
description: @body.description,
video: @body.metadata[:video][1][:_value]
}
end
end
end
end
32 changes: 32 additions & 0 deletions spec/lib/onebox/engine/sound_cloud_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require "spec_helper"

describe Onebox::Engine::SoundCloudOnebox do
let(:link) { "http://dailymotion.com" }
let(:html) { described_class.new(link).to_html }

before do
fake(link, response("soundcloud.response"))
end

it "returns video title" do
expect(html).to include("Penguin Prison - Worse It Gets (RAC Mix)")
end

it "returns video image" do
expect(html).to include("artworks-000033643332-vpuznu-t500x500.jpg")
end

it "returns video description" do
expect(html).to include("Remix by André Allen Anjos.")
end

it "returns video URL" do
expect(html).to include("Remix by André Allen Anjos.")
end

it "returns video embed code"

it "returns URL" do
expect(html).to include(link)
end
end
9 changes: 9 additions & 0 deletions templates/soundcloud.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="onebox">
<a href="{{url}}">
<h1>{{title}}</h1>
<h2 class="host">soundcloud.com</h2>
<img src="{{image}}" />
{{video}}
<p>{{description}}</p>
</a>
</div>

0 comments on commit fa61d5d

Please sign in to comment.