ampize 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ampize.rb +24 -1
  3. data/lib/ampize/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39dc5d847b6f466e3839497b44b8a6d0a6912f58
4
- data.tar.gz: b3ad78083a1090b6337793b2573baabc5f533605
3
+ metadata.gz: d78fa02c77595aa578a6e136df7913ebdb603a7f
4
+ data.tar.gz: f6589ad34edb17076fa4676c9d2293113537711a
5
5
  SHA512:
6
- metadata.gz: cd224ade044102450374940a186d22fb3463beb99015521bc884219ce436a82cdb39990aeb5bc2095d721f64fd479eb00d0623f8a83637d56239e86e8546c741
7
- data.tar.gz: 2e01cde238ff8887591ffb2c7e7a7c4a03eec3a70a896d55825f4c0f7e759a0e87754a3a167007ff255dae6295c50152728197ed47cc0449a0149fa0c2fd9463
6
+ metadata.gz: 226283dc64db161b903fa1bb972fc2e2ff19492ccbe7bb34b0aa6a7ae2124f928cf1b83480c1c2309f9c24eaf5a5e7b65aa70148421c016f960594ba56b7b471
7
+ data.tar.gz: 081308bc38555d0b0ff90c69221ddb5ec4f080e4bdbedd01e640067dfc644ad9879b62849762271eb41c8dc6415126ec9c2f1088d76806fca170ce2593bc24e4
data/lib/ampize.rb CHANGED
@@ -12,7 +12,8 @@ module Ampize
12
12
  end
13
13
  @options = {
14
14
  image_layout: 'responsive',
15
- image_fetch_error_callback: default_error_callback
15
+ image_fetch_error_callback: default_error_callback,
16
+ iframe_layout: 'responsive'
16
17
  }
17
18
  @options.merge!(options)
18
19
  end
@@ -26,6 +27,7 @@ module Ampize
26
27
  process_anchor doc
27
28
  process_style doc
28
29
  process_img doc
30
+ process_iframe doc
29
31
  process_event doc
30
32
  doc.at('body').children.to_s
31
33
  end
@@ -77,6 +79,27 @@ module Ampize
77
79
  end
78
80
  end
79
81
  end
82
+
83
+ def process_iframe(doc)
84
+ doc.search('//iframe').each do |tag|
85
+ src = tag.attributes['src'].value
86
+ width = tag.attributes['width']
87
+ height = tag.attributes['height']
88
+ if !width || !height
89
+ width = 400
90
+ height = 300
91
+ else
92
+ width = width.value.to_s
93
+ height = height.value.to_s
94
+ end
95
+ if width && height
96
+ aiframe = %Q|<amp-iframe src="#{src}" width="#{width}" height="#{height}" layout="#{@options[:iframe_layout]}"></amp-layout>|
97
+ tag.replace(aiframe)
98
+ else
99
+ tag.replace(@options[:image_fetch_error_callback].call(src))
100
+ end
101
+ end
102
+ end
80
103
 
81
104
  def process_event(doc)
82
105
  %W|onload onerror onblur onchange onclick ondblclick onfocus
@@ -1,3 +1,3 @@
1
1
  module Ampize
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ampize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - devneko