reddavis-embedit 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +22 -0
- data/lib/embedit/media.rb +43 -0
- data/lib/embedit/providers.rb +21 -0
- data/lib/embedit.rb +31 -0
- data/lib/providers.yaml +13 -0
- metadata +57 -0
data/README
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Embedit
|
|
2
|
+
-------
|
|
3
|
+
|
|
4
|
+
Embedit is an embedding tool written in Ruby.
|
|
5
|
+
|
|
6
|
+
We are currently re-writing dothegreenthing.com and allow users to add media from pretty much anywhere. Handling all the different embed codes/api's validations and everything else that comes with this functionality can be/is a pain.
|
|
7
|
+
|
|
8
|
+
Embedit is extremely simple to use. You have the url? Just plonk it in here =>
|
|
9
|
+
|
|
10
|
+
media = Embedit::Media.new('here')
|
|
11
|
+
|
|
12
|
+
Thats it!
|
|
13
|
+
|
|
14
|
+
At the time of writing, you now have the ability to call:
|
|
15
|
+
media.title => Shows the title of whatever was uploaded
|
|
16
|
+
media.format => The format of the file
|
|
17
|
+
media.url => The url to the media
|
|
18
|
+
media.html => The embed code, whether this is a generic flash player, a company player (Vimeo, Youtube), image tag and more to come
|
|
19
|
+
|
|
20
|
+
You also specify media sizes => media.html(:width => 200, :height => 700)
|
|
21
|
+
|
|
22
|
+
At the moment Embedit supports the oEmbed family (http://www.oembed.com/) and YouTube.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module Embedit
|
|
2
|
+
|
|
3
|
+
class Media
|
|
4
|
+
|
|
5
|
+
attr_accessor :title, :url, :format, :html
|
|
6
|
+
|
|
7
|
+
def initialize(url)
|
|
8
|
+
@oembed_providers = Providers.new.sites
|
|
9
|
+
find_provider(url)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def title
|
|
13
|
+
@media_data.title
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def html(size = {})
|
|
17
|
+
@media_data.html(size)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def format
|
|
21
|
+
@media_data.format
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def url
|
|
25
|
+
@media_data.url
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
#Find a provider
|
|
31
|
+
def find_provider(url)
|
|
32
|
+
@oembed_providers.keys.each do |key| #First search oembed providers for a match
|
|
33
|
+
if url.match(/#{key}/)
|
|
34
|
+
return @media_data = Oembed.new(url)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
if url.match(/youtube/) #Next up is YouTube
|
|
38
|
+
return @media_data = YouTube.new(url)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Embedit
|
|
2
|
+
class Providers
|
|
3
|
+
|
|
4
|
+
attr_accessor :sites
|
|
5
|
+
|
|
6
|
+
def initialize
|
|
7
|
+
@sites = {}
|
|
8
|
+
add_default_providers
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
def add_default_providers
|
|
13
|
+
load_providers
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def load_providers
|
|
17
|
+
providers = YAML.load_file("#{File.dirname(__FILE__)}/../providers.yaml")
|
|
18
|
+
providers.each {|d| @sites.merge!(d[0] => d[1])}
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
data/lib/embedit.rb
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'json'
|
|
3
|
+
require 'rexml/document'
|
|
4
|
+
require 'net/http'
|
|
5
|
+
require 'open-uri'
|
|
6
|
+
require 'yaml'
|
|
7
|
+
|
|
8
|
+
#Files
|
|
9
|
+
require 'embedit/providers'
|
|
10
|
+
require 'embedit/media'
|
|
11
|
+
require 'embedit/oembed'
|
|
12
|
+
require 'embedit/youtube'
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
#puts a = Embedit::Media.new('http://www.vimeo.com/1263763').format
|
|
16
|
+
|
|
17
|
+
#puts b = Embedit::Media.new('http://www.flickr.com/photos/davidgutierrez/2135724493/').html(:height => 200)
|
|
18
|
+
|
|
19
|
+
#puts c = Embedit::Media.new('http://www.viddler.com/explore/winelibrarytv/videos/142/').html(:height => 200, :width => 500)
|
|
20
|
+
|
|
21
|
+
#puts d = Embedit::Media.new('http://qik.com/video/141977').html(:height => 50)
|
|
22
|
+
|
|
23
|
+
#puts e = Embedit::Media.new('http://pownce.com/dburka/notes/2951118/').html(:height => 200)
|
|
24
|
+
|
|
25
|
+
#puts f = Embedit::Media.new('http://revision3.com/trs/blockoland/').html(:height => 500)
|
|
26
|
+
|
|
27
|
+
#YouTUBE
|
|
28
|
+
|
|
29
|
+
#puts g = Embedit::Media.new("http://www.youtube.com/watch?v=j3TOT1lnVTA")
|
|
30
|
+
|
|
31
|
+
#puts Embedit::Media.new("http://www.youtube.com/watch?v=j3TOT1lnVTA")
|
data/lib/providers.yaml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
flickr: http://www.flickr.com/services/oembed
|
|
2
|
+
|
|
3
|
+
vimeo: http://www.vimeo.com/api/oembed.{format}
|
|
4
|
+
|
|
5
|
+
viddler: http://lab.viddler.com/services/oembed/
|
|
6
|
+
|
|
7
|
+
qik: http://qik.com/api/oembed.{format}
|
|
8
|
+
|
|
9
|
+
pownce: http://api.pownce.com/2.1/oembed.{format}
|
|
10
|
+
|
|
11
|
+
revision3: http://revision3.com/api/oembed/
|
|
12
|
+
|
|
13
|
+
# hulu: http://www.hulu.com/api/oembed.{format} - No UK service
|
metadata
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: reddavis-embedit
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Red Davis
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2008-08-26 08:04:36 -07:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies: []
|
|
15
|
+
|
|
16
|
+
description:
|
|
17
|
+
email: reddavis@gmail.com
|
|
18
|
+
executables: []
|
|
19
|
+
|
|
20
|
+
extensions: []
|
|
21
|
+
|
|
22
|
+
extra_rdoc_files: []
|
|
23
|
+
|
|
24
|
+
files:
|
|
25
|
+
- README
|
|
26
|
+
- lib/embedit.rb
|
|
27
|
+
- lib/providers.yaml
|
|
28
|
+
- lib/embedit/media.rb
|
|
29
|
+
- lib/embedit/providers.rb
|
|
30
|
+
has_rdoc: false
|
|
31
|
+
homepage: http://github.com/reddavis/embedit/
|
|
32
|
+
post_install_message:
|
|
33
|
+
rdoc_options: []
|
|
34
|
+
|
|
35
|
+
require_paths:
|
|
36
|
+
- lib
|
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - ">="
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: "0"
|
|
42
|
+
version:
|
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: "0"
|
|
48
|
+
version:
|
|
49
|
+
requirements: []
|
|
50
|
+
|
|
51
|
+
rubyforge_project:
|
|
52
|
+
rubygems_version: 1.2.0
|
|
53
|
+
signing_key:
|
|
54
|
+
specification_version: 2
|
|
55
|
+
summary: Ruby interface for embedding anymedia
|
|
56
|
+
test_files: []
|
|
57
|
+
|