html-pipeline-flickr 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/html/pipeline/flickr/flickr_filter.rb +17 -13
- data/lib/html/pipeline/flickr/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd6ab85adf85ca0170f5537a26ce5e192538730b
|
4
|
+
data.tar.gz: 0c02869288fd089040bbd42b1068c5879da58add
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a03d2a6079e28a1306fb858f489704b425e238ec2b1c945cc924674a75b18c74dd32da7798e800e364b4906fb49113ddded32e1aff677a1644b0e41ffd47711
|
7
|
+
data.tar.gz: 54652b2a3f5e0ea1867598fdbd25c80b257afee874cf28b464c12c983830b923a25af075af350916dca59481e523339b80df31f4a6c4a65d638c852850091b1b
|
data/.gitignore
CHANGED
@@ -13,24 +13,28 @@ module HTML
|
|
13
13
|
|
14
14
|
class FlickrFilter < TextFilter
|
15
15
|
def call
|
16
|
-
regex = %r{https
|
16
|
+
regex = %r{(=")*(https?:\/\/(www\.)?flickr\.com\/photos\/[^\s<]*)}
|
17
17
|
uri = URI("https://www.flickr.com/services/oembed")
|
18
18
|
|
19
19
|
link_attr = context[:flickr_link_attr] || ""
|
20
20
|
|
21
21
|
@text.gsub(regex) do |match|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
22
|
+
if $1.nil?
|
23
|
+
params = {
|
24
|
+
url: match,
|
25
|
+
format: :json,
|
26
|
+
maxwidth: max_value(:width),
|
27
|
+
maxheight: max_value(:height)
|
28
|
+
}
|
29
|
+
|
30
|
+
uri.query = URI.encode_www_form(params)
|
31
|
+
|
32
|
+
response = JSON.parse(Net::HTTP.get(uri))
|
33
|
+
|
34
|
+
%{<a href="#{match}" #{link_attr}><img src="#{response["url"]}" alt="#{response["title"]}" title="#{response["title"]}" /></a>}
|
35
|
+
else
|
36
|
+
match
|
37
|
+
end
|
34
38
|
end
|
35
39
|
end
|
36
40
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html-pipeline-flickr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stan Luo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: html-pipeline
|
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
79
|
rubyforge_project:
|
80
|
-
rubygems_version: 2.
|
80
|
+
rubygems_version: 2.5.1
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: Flickr filter for html-pipeline
|