embedrb 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/embedrb.gemspec +3 -3
- data/lib/embedrb/audio/embed_audio.rb +1 -0
- data/lib/embedrb/base.rb +1 -1
- data/lib/embedrb/embed.rb +4 -2
- data/lib/embedrb/embed_open_graph.rb +1 -1
- data/lib/embedrb/image/embed_flickr.rb +1 -0
- data/lib/embedrb/image/embed_images.rb +1 -0
- data/lib/embedrb/image/embed_instagram.rb +1 -0
- data/lib/embedrb/utils.rb +8 -0
- data/lib/embedrb/version.rb +1 -1
- data/lib/embedrb/video/embed_ted.rb +1 -0
- data/lib/embedrb/video/embed_ustream.rb +1 -0
- data/lib/embedrb/video/embed_video.rb +1 -0
- data/lib/embedrb/video/embed_youtube.rb +3 -2
- data/lib/embedrb.rb +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29a1c1027ae50d6fb90093dc118e01fb4c6a8930
|
4
|
+
data.tar.gz: d59b3a1453772ac11d5e4dc4efe6e647b03b2ef9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 323db49baac4ffd1bb6dd04f537d5342ec35880014095b7cadfafe1e84596e15990fe5459b14c59051e0bbfefb148d646552c01b575e30cabeccde870f540ae1
|
7
|
+
data.tar.gz: 2cbe816d5f8777ff7e10fd8ea7bf020fac78999a5b11903dec77c43669d0a5153ca58174fc0b1cd8c682d266552bcc51d70a50db528747d0056212ab3f5388cd
|
data/embedrb.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: embedrb 0.2.
|
5
|
+
# stub: embedrb 0.2.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "embedrb"
|
9
|
-
s.version = "0.2.
|
9
|
+
s.version = "0.2.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["liris"]
|
14
|
-
s.date = "2016-02-
|
14
|
+
s.date = "2016-02-22"
|
15
15
|
s.description = "a ruby port of Embed.js"
|
16
16
|
s.email = "liris.pp@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
data/lib/embedrb/base.rb
CHANGED
@@ -9,7 +9,7 @@ module EmbedRb
|
|
9
9
|
def embed()
|
10
10
|
@input.scan(@regex) {|match|
|
11
11
|
url = match[0]
|
12
|
-
if !@options[:served].include? url
|
12
|
+
if !@options[:served].include? url && EmbedRb.process_more?(@options, @service, @embeds)
|
13
13
|
text = url_to_text match
|
14
14
|
if text
|
15
15
|
@options[:served] << url
|
data/lib/embedrb/embed.rb
CHANGED
@@ -26,6 +26,8 @@ PROCESSORS = {
|
|
26
26
|
}
|
27
27
|
|
28
28
|
DEFAULT_OPTIONS = {
|
29
|
+
:maxEmbed => 0,
|
30
|
+
:maxEmbedExcludes => [],
|
29
31
|
:link => true,
|
30
32
|
:linkOptions => {
|
31
33
|
:target => 'self',
|
@@ -76,8 +78,8 @@ module EmbedRb
|
|
76
78
|
output = ''
|
77
79
|
|
78
80
|
PROCESSORS.each {|key, klass|
|
79
|
-
if @options[key]
|
80
|
-
output = klass.new(input, output, @options, embeds).process
|
81
|
+
if @options[key] && EmbedRb.process_more?(@options, key, embeds)
|
82
|
+
output = klass.new(input, output, @options, embeds).process
|
81
83
|
end
|
82
84
|
}
|
83
85
|
|
@@ -25,7 +25,7 @@ module EmbedRb
|
|
25
25
|
@input.scan(@url_regex) {|match|
|
26
26
|
url = match[2]
|
27
27
|
short_url = shorten(url)
|
28
|
-
if !exclude?(url) && !@options[:served].include?(short_url)
|
28
|
+
if !exclude?(url) && !@options[:served].include?(short_url) && EmbedRb.process_more?(@options, :openGraphEndpoint, @embeds)
|
29
29
|
p short_url
|
30
30
|
data = fetch(url)
|
31
31
|
if data
|
data/lib/embedrb/utils.rb
CHANGED
@@ -28,6 +28,14 @@ module EmbedRb
|
|
28
28
|
options[key] ? options[key] : {}
|
29
29
|
end
|
30
30
|
|
31
|
+
def process_more?(options, key, embeds)
|
32
|
+
max_num = options[:maxEmbed]
|
33
|
+
if max_num == 0
|
34
|
+
return true
|
35
|
+
end
|
36
|
+
embeds.length < max_num || options[:maxEmbedExcludes].include?(key)
|
37
|
+
end
|
38
|
+
|
31
39
|
def create_text(str, embeds)
|
32
40
|
# TODO: sort embeds
|
33
41
|
embeds_str = embeds.map {|embed|
|
data/lib/embedrb/version.rb
CHANGED
@@ -11,6 +11,7 @@ module EmbedRb
|
|
11
11
|
@embeds = embeds
|
12
12
|
@options = options
|
13
13
|
@regex = /(https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))([\w\-]{11})[?=&+%\w-]*)/mi
|
14
|
+
@service = :youtube
|
14
15
|
end
|
15
16
|
|
16
17
|
private
|
@@ -22,8 +23,8 @@ module EmbedRb
|
|
22
23
|
def render(url)
|
23
24
|
dims = EmbedRb.get_dimensions(@options)
|
24
25
|
return <<EOF
|
25
|
-
<div class="ejs-video-player ejs-embed">
|
26
|
-
<iframe src="#{url}" frameBorder="0" width="#{dims[:width]}" height="#{dims[:height]}" ></iframe>
|
26
|
+
<div class="ejs-video-player ejs-embed" style="width: #{dims[:width]}px; height: #{dims[:height]}px;">
|
27
|
+
<iframe src="#{url}" frameBorder="0" width="#{dims[:width]}px" height="#{dims[:height]}px" ></iframe>
|
27
28
|
</div>
|
28
29
|
EOF
|
29
30
|
end
|
data/lib/embedrb.rb
CHANGED
@@ -7,6 +7,7 @@ if $0 == __FILE__
|
|
7
7
|
http://www.google.com/
|
8
8
|
the following is geocode
|
9
9
|
@(東京駅)
|
10
|
+
@(東京駅)
|
10
11
|
http://hoge.fuga.com/xxx/yyy.png
|
11
12
|
https://www.flickr.com/photos/parismadrid/5573484679/in/photolist-9uvyPr-7TD5uZ-jYwbo8-qeZLRe-odzeYC-n8x6Xn-dzq2Ws-oRNMGp-68DxGi-c4DxV7-bnmwjN-nqZDVD-kF39se-rXJWT4-nTTR4S-7YLgdX-apPuvi-q1DhYc-kFWFjG-a2c9kr-aPGmhK-oqB5cQ-ziBGRr-oBkGxp-pEFgd8-jY9diK-mDTbpD-jzSaXQ-cuCWwN-pzK88U-9HvHVt-dBPTZV-nKdYRM-oEDGkL-bTygzn-o3CxjL-rhtanH-oXpW1i-s4Jdat-p8N1RJ-fhpghZ-dX2tPC-v8R2LX-x7M7j1-xFACNe-cAWLSf-A6FvqE-adcNyU-t2N6Hh-j1TaxV
|
12
13
|
|
@@ -23,6 +24,8 @@ if $0 == __FILE__
|
|
23
24
|
EOF
|
24
25
|
|
25
26
|
opts = {
|
27
|
+
:maxEmbed => 0,
|
28
|
+
:maxEmbedExcludes => [ :youtube ],
|
26
29
|
:openGraphEndpoint => 'http://opengraph.io/api/1.0/site/',
|
27
30
|
:gmap => true,
|
28
31
|
:gmapOptions => {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embedrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- liris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shoulda
|