jekyll-pdf-embed 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll-pdf-embed.rb +25 -5
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a1810d37651040f56ddf5c3b7bd97bb06f7013bdf4ff2010e5c9584c0e44d1e
4
- data.tar.gz: 70612d1a41f465b18e6f624c76c988f25a9707d421bf643c0d62e079967c2f2f
3
+ metadata.gz: 888469f8bfacc1099507591ff273cd4232a1bf1839933ddcc9cfc5f643a83df0
4
+ data.tar.gz: 83c548429ed46cbc2b751b337aaa411f930b6708e5495d96b8effd980571959c
5
5
  SHA512:
6
- metadata.gz: 8a8d8c93bd45bc8dc4e1be55e035b19343a4405afa2e6b61c00672812da035e0771f139aa64a9bddc86dad475876e490869c0f8b8c36b6eb50aa50fc8ba20087
7
- data.tar.gz: 726883df29da44c0320e516693afe1b4a12875ef9beb8c2f22282973ae7aae100fef04d33c7f0222f9738399a39b8c3b56c0a5e344d446c3c1ad0c3f68128dce
6
+ metadata.gz: 35a245969599306c9c7852f92acd808d874771c8f3899416aa59bbaf2fb0c37db5cf80e860ba352d749bd8378bcbbcc2d52f36fb5dd8c28dae6a78872a9c0252
7
+ data.tar.gz: f6b09be69b53dae11b5af3fa0ef1a95e2466e8edff20f08546a4b3a759dae116a9fe32a2841e26be4349a7c1e4a71b0da90c940ba3f9486b6cf45ca2911139ce
@@ -4,21 +4,41 @@ class PDFEmbed < Liquid::Tag
4
4
 
5
5
  def initialize(tag_name, text, tokens)
6
6
  super
7
+ @allowed_files = [".pdf\"", ".ppt\""]
7
8
  @link = text[/".*?"/]
8
9
  @link_escaped = @link.gsub(" ", "%20")
10
+ @raw_link = @link_escaped.gsub("\"", "")
11
+ @ext = File.extname(@link_escaped)
12
+ @is_allowed = @allowed_files.include? @ext
9
13
  @text = text.gsub(@link, @link_escaped)
10
14
  *@params = @text.split(/ /)
11
15
  end
12
16
 
13
17
  def render(context)
14
- if @params.length == 1
15
- %Q{<style>.pdf-embed-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; margin-bottom: 20px; border-style: solid; } .pdf-link { background-color: white; text-align: center; border-style: solid; } .pdf-embed-container iframe, .pdf-embed-container object, .pdf-embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }</style><div class='pdf-link'><a href=#{@link_escaped} target="_blank">View PDF</a></div><div class='pdf-embed-container'><iframe title="PDF file" width="640" height="390" src=#{@link_escaped} frameborder="0" allowfullscreen></iframe></div>}
16
- elsif @params.length == 2 && @params[1] == 'no_link'
17
- %Q{<style>.pdf-embed-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; margin-bottom: 20px; } .pdf-embed-container iframe, .pdf-embed-container object, .pdf-embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }</style><div class='pdf-embed-container'><iframe title="PDF file" width="640" height="390" src=#{@link_escaped} frameborder="0" allowfullscreen></iframe></div>}
18
+ if !@is_allowed
19
+ raise ArgumentError, 'ERROR:file_not_allowed'
20
+ end
21
+
22
+ if @ext == ".pdf\""
23
+ if @params.length == 1
24
+ %Q{<style>.pdf-embed-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; margin-bottom: 20px; border-style: solid; } .pdf-link { background-color: white; text-align: center; border-style: solid; } .pdf-embed-container iframe, .pdf-embed-container object, .pdf-embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }</style><div class='pdf-link'><a href=#{@link_escaped} target="_blank">View PDF</a></div><div class='pdf-embed-container'><iframe title="PDF file" width="640" height="390" src=#{@link_escaped} frameborder="0" allowfullscreen></iframe></div>}
25
+ elsif @params.length == 2 && @params[1] == 'no_link'
26
+ %Q{<style>.pdf-embed-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; margin-bottom: 20px; } .pdf-embed-container iframe, .pdf-embed-container object, .pdf-embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }</style><div class='pdf-embed-container'><iframe title="PDF file" width="640" height="390" src=#{@link_escaped} frameborder="0" allowfullscreen></iframe></div>}
27
+ else
28
+ raise ArgumentError, 'ERROR:bad_syntax'
29
+ end
30
+ elsif @ext == ".ppt\""
31
+ if @params.length == 1
32
+ %Q{<style>.pdf-embed-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; margin-bottom: 20px; border-style: solid; } .pdf-link { background-color: white; text-align: center; border-style: solid; } .pdf-embed-container iframe, .pdf-embed-container object, .pdf-embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }</style><div class='pdf-link'><a href="https://view.officeapps.live.com/op/embed.aspx?src=#{@raw_link}" target="_blank">View presentation</a></div><div class='pdf-embed-container'><iframe title="PDF file" width="640" height="390" src="https://view.officeapps.live.com/op/embed.aspx?src=#{@raw_link}" frameborder="0" allowfullscreen></iframe></div>}
33
+ elsif @params.length == 2 && @params[1] == 'no_link'
34
+ %Q{<style>.pdf-embed-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; margin-bottom: 20px; } .pdf-embed-container iframe, .pdf-embed-container object, .pdf-embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }</style><div class='pdf-embed-container'><iframe title="PDF file" width="640" height="390" src="https://view.officeapps.live.com/op/embed.aspx?src=#{@raw_link}" frameborder="0" allowfullscreen></iframe></div>}
35
+ else
36
+ raise ArgumentError, 'ERROR:bad_syntax'
37
+ end
18
38
  else
19
39
  raise ArgumentError, 'ERROR:bad_syntax'
20
40
  end
21
41
  end
22
42
 
23
43
  Liquid::Template.register_tag('pdf', self)
24
- end
44
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-pdf-embed
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mihajlo Nesic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-26 00:00:00.000000000 Z
11
+ date: 2020-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll