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.
- checksums.yaml +4 -4
- data/lib/jekyll-pdf-embed.rb +25 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 888469f8bfacc1099507591ff273cd4232a1bf1839933ddcc9cfc5f643a83df0
|
4
|
+
data.tar.gz: 83c548429ed46cbc2b751b337aaa411f930b6708e5495d96b8effd980571959c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35a245969599306c9c7852f92acd808d874771c8f3899416aa59bbaf2fb0c37db5cf80e860ba352d749bd8378bcbbcc2d52f36fb5dd8c28dae6a78872a9c0252
|
7
|
+
data.tar.gz: f6b09be69b53dae11b5af3fa0ef1a95e2466e8edff20f08546a4b3a759dae116a9fe32a2841e26be4349a7c1e4a71b0da90c940ba3f9486b6cf45ca2911139ce
|
data/lib/jekyll-pdf-embed.rb
CHANGED
@@ -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
|
15
|
-
|
16
|
-
|
17
|
-
|
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.
|
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:
|
11
|
+
date: 2020-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|