-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from dysania/create-soundcloud-onebox
Create soundcloud onebox
- Loading branch information
Showing
4 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |