jekyll-pdf_generator 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +86 -0
- data/README.md +36 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/jekyll-pdf_generator.gemspec +24 -0
- data/lib/jekyll-pdf_generator.rb +2 -0
- data/lib/jekyll-pdf_generator/hook.rb +41 -0
- data/lib/jekyll-pdf_generator/version.rb +5 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 709867a07998e36de8b32ece3843515a16d77c5e3a401bd14c47312fe6a5717e
|
4
|
+
data.tar.gz: 5d9b27a342bb479335b1f2e8025414bc307f0b8ddcfa326632707188377f7bc7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4df31466efddf160fd8f7e2bd08eca2d63266e781c07fe9c39d20dd388fc0e28456226bdcc1d2ae290e421b8d7f5493b6143f064892c5ba011f4d550a70c55fc
|
7
|
+
data.tar.gz: 30e5c17126eeadeb696c2ccb6943311694e16355f766f967d7893fcefd3c790fa8196444d1cf43f85ee308687d5fc35a0f4551c66899f86062f82f192db2725c
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jekyll-pdf_generator (0.1.0)
|
5
|
+
jekyll (~> 4.1)
|
6
|
+
puppeteer-ruby (~> 0.31.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.7.0)
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
13
|
+
colorator (1.1.0)
|
14
|
+
concurrent-ruby (1.1.8)
|
15
|
+
em-websocket (0.5.2)
|
16
|
+
eventmachine (>= 0.12.9)
|
17
|
+
http_parser.rb (~> 0.6.0)
|
18
|
+
eventmachine (1.2.7-x64-mingw32)
|
19
|
+
ffi (1.14.2-x64-mingw32)
|
20
|
+
forwardable-extended (2.6.0)
|
21
|
+
http_parser.rb (0.6.0)
|
22
|
+
i18n (1.8.9)
|
23
|
+
concurrent-ruby (~> 1.0)
|
24
|
+
jekyll (4.2.0)
|
25
|
+
addressable (~> 2.4)
|
26
|
+
colorator (~> 1.0)
|
27
|
+
em-websocket (~> 0.5)
|
28
|
+
i18n (~> 1.0)
|
29
|
+
jekyll-sass-converter (~> 2.0)
|
30
|
+
jekyll-watch (~> 2.0)
|
31
|
+
kramdown (~> 2.3)
|
32
|
+
kramdown-parser-gfm (~> 1.0)
|
33
|
+
liquid (~> 4.0)
|
34
|
+
mercenary (~> 0.4.0)
|
35
|
+
pathutil (~> 0.9)
|
36
|
+
rouge (~> 3.0)
|
37
|
+
safe_yaml (~> 1.0)
|
38
|
+
terminal-table (~> 2.0)
|
39
|
+
jekyll-sass-converter (2.1.0)
|
40
|
+
sassc (> 2.0.1, < 3.0)
|
41
|
+
jekyll-watch (2.2.1)
|
42
|
+
listen (~> 3.0)
|
43
|
+
kramdown (2.3.0)
|
44
|
+
rexml
|
45
|
+
kramdown-parser-gfm (1.1.0)
|
46
|
+
kramdown (~> 2.0)
|
47
|
+
liquid (4.0.3)
|
48
|
+
listen (3.4.1)
|
49
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
50
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
51
|
+
mercenary (0.4.0)
|
52
|
+
mime-types (3.3.1)
|
53
|
+
mime-types-data (~> 3.2015)
|
54
|
+
mime-types-data (3.2021.0225)
|
55
|
+
pathutil (0.16.2)
|
56
|
+
forwardable-extended (~> 2.6)
|
57
|
+
public_suffix (4.0.6)
|
58
|
+
puppeteer-ruby (0.31.1)
|
59
|
+
concurrent-ruby (~> 1.1.0)
|
60
|
+
mime-types (>= 3.0)
|
61
|
+
websocket-driver (>= 0.6.0)
|
62
|
+
rake (12.3.3)
|
63
|
+
rb-fsevent (0.10.4)
|
64
|
+
rb-inotify (0.10.1)
|
65
|
+
ffi (~> 1.0)
|
66
|
+
rexml (3.2.4)
|
67
|
+
rouge (3.26.0)
|
68
|
+
safe_yaml (1.0.5)
|
69
|
+
sassc (2.4.0-x64-mingw32)
|
70
|
+
ffi (~> 1.9)
|
71
|
+
terminal-table (2.0.0)
|
72
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
73
|
+
unicode-display_width (1.7.0)
|
74
|
+
websocket-driver (0.7.3)
|
75
|
+
websocket-extensions (>= 0.1.0)
|
76
|
+
websocket-extensions (0.1.5)
|
77
|
+
|
78
|
+
PLATFORMS
|
79
|
+
x64-mingw32
|
80
|
+
|
81
|
+
DEPENDENCIES
|
82
|
+
jekyll-pdf_generator!
|
83
|
+
rake (~> 12.0)
|
84
|
+
|
85
|
+
BUNDLED WITH
|
86
|
+
2.2.7
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Jekyll::PdfGenerator
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/jekyll/pdf_generator`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'jekyll-pdf_generator'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install jekyll-pdf_generator
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jekyll-pdf_generator.
|
36
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "jekyll/pdf_generator"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative 'lib/jekyll-pdf_generator/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "jekyll-pdf_generator"
|
5
|
+
spec.version = Jekyll::PdfGenerator::VERSION
|
6
|
+
spec.authors = ["Jwiggiff"]
|
7
|
+
spec.email = ["friedman.josh03@gmail.com"]
|
8
|
+
|
9
|
+
spec.summary = "A Jekyll plugin to generate pdfs."
|
10
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
11
|
+
|
12
|
+
|
13
|
+
# Specify which files should be added to the gem when it is released.
|
14
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
15
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
16
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
end
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "jekyll", "~> 4.1"
|
23
|
+
spec.add_dependency "puppeteer-ruby", "~> 0.31.5"
|
24
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'puppeteer'
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class PDF < Jekyll::StaticFile
|
5
|
+
def initialize(site, base, dir, name)
|
6
|
+
super
|
7
|
+
end
|
8
|
+
|
9
|
+
def write(dest)
|
10
|
+
super
|
11
|
+
trigger_hooks(:post_write)
|
12
|
+
end
|
13
|
+
|
14
|
+
def trigger_hooks(hook_name, *args)
|
15
|
+
Jekyll::Hooks.trigger :pdfs, hook_name, self, *args
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
Jekyll::Hooks.register :pages, :post_render do |page|
|
21
|
+
if page.data["pdf"] == true
|
22
|
+
path = File.expand_path __dir__
|
23
|
+
|
24
|
+
Puppeteer.launch() do |browser|
|
25
|
+
browser_page = browser.pages.first || browser.new_page
|
26
|
+
browser_page.set_content(page.output, wait_until: "networkidle0")
|
27
|
+
browser_page.pdf(
|
28
|
+
path: "#{path}/generated_files/#{page.basename}.pdf",
|
29
|
+
format: "letter",
|
30
|
+
margin: { top: "1cm", left: "1cm", right: "1cm", bottom: "1cm" },
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
page.site.static_files << Jekyll::PDF.new(page.site, "#{path}/generated_files/", page.dir, "#{page.basename}.pdf")
|
35
|
+
page.site.pages.delete(page)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Jekyll::Hooks.register :pdfs, :post_write do |pdf|
|
40
|
+
File.delete(__dir__+"/generated_files/#{pdf.name}") if File.exist?(__dir__+"/generated_files/#{pdf.name}")
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-pdf_generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jwiggiff
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-03-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: puppeteer-ruby
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.31.5
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.31.5
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- friedman.josh03@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- bin/console
|
54
|
+
- bin/setup
|
55
|
+
- jekyll-pdf_generator.gemspec
|
56
|
+
- lib/jekyll-pdf_generator.rb
|
57
|
+
- lib/jekyll-pdf_generator/hook.rb
|
58
|
+
- lib/jekyll-pdf_generator/version.rb
|
59
|
+
homepage:
|
60
|
+
licenses: []
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 2.3.0
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubygems_version: 3.1.4
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: A Jekyll plugin to generate pdfs.
|
81
|
+
test_files: []
|