metanorma 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/appveyor.yml +29 -0
- data/bin/rasterize.js +49 -0
- data/lib/metanorma/output/pdf.rb +5 -3
- data/lib/metanorma/version.rb +1 -1
- data/metanorma.gemspec +0 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81a9d0206754ec2f1d456dc7812e54b05b5f74055025e723ba003af362d78380
|
4
|
+
data.tar.gz: 3b306cb4f28c937b46ebb2308f7fcf546c89493ee9eff2aad29140b6a5c3e583
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c173af8b2eff9547b2c7d17a54426f89dee53a030e717866f40ab5c5b2cf35092988a65a1df7681636897d2d07e5291ec7717a8d72bd4b4b2daac796970767b6
|
7
|
+
data.tar.gz: b71ac8b84f2de84828530e89d9df566ed0e2bc111b9254de3fb223b65573e495ae0f814d247fa17083d8861de4105b5cc2ce05c4b7b1ff0d57433131fc509ca5
|
data/Gemfile.lock
CHANGED
data/appveyor.yml
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
version: '{build}'
|
2
|
+
|
3
|
+
environment:
|
4
|
+
matrix:
|
5
|
+
- RUBY_VERSION: 25
|
6
|
+
- RUBY_VERSION: 24
|
7
|
+
- RUBY_VERSION: 23
|
8
|
+
- RUBY_VERSION: _trunk
|
9
|
+
|
10
|
+
matrix:
|
11
|
+
allow_failures:
|
12
|
+
- RUBY_VERSION: _trunk
|
13
|
+
|
14
|
+
install:
|
15
|
+
- set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
|
16
|
+
- gem install bundler -v 1.16.1
|
17
|
+
- npm install -g puppeteer
|
18
|
+
- npm install
|
19
|
+
- bundle install
|
20
|
+
|
21
|
+
build: off
|
22
|
+
|
23
|
+
before_test:
|
24
|
+
- ruby -v
|
25
|
+
- gem -v
|
26
|
+
- bundle -v
|
27
|
+
|
28
|
+
test_script:
|
29
|
+
- bundle exec rake
|
data/bin/rasterize.js
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
"use strict";
|
2
|
+
var page = require('webpage').create(),
|
3
|
+
system = require('system'),
|
4
|
+
address, output, size, pageWidth, pageHeight;
|
5
|
+
|
6
|
+
if (system.args.length < 3 || system.args.length > 5) {
|
7
|
+
console.log('Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat] [zoom]');
|
8
|
+
console.log(' paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"');
|
9
|
+
console.log(' image (png/jpg output) examples: "1920px" entire page, window width 1920px');
|
10
|
+
console.log(' "800px*600px" window, clipped to 800x600');
|
11
|
+
phantom.exit(1);
|
12
|
+
} else {
|
13
|
+
address = system.args[1];
|
14
|
+
output = system.args[2];
|
15
|
+
page.viewportSize = { width: 600, height: 600 };
|
16
|
+
if (system.args.length > 3 && system.args[2].substr(-4) === ".pdf") {
|
17
|
+
size = system.args[3].split('*');
|
18
|
+
page.paperSize = size.length === 2 ? { width: size[0], height: size[1], margin: '0px' }
|
19
|
+
: { format: system.args[3], orientation: 'portrait', margin: '1cm' };
|
20
|
+
} else if (system.args.length > 3 && system.args[3].substr(-2) === "px") {
|
21
|
+
size = system.args[3].split('*');
|
22
|
+
if (size.length === 2) {
|
23
|
+
pageWidth = parseInt(size[0], 10);
|
24
|
+
pageHeight = parseInt(size[1], 10);
|
25
|
+
page.viewportSize = { width: pageWidth, height: pageHeight };
|
26
|
+
page.clipRect = { top: 0, left: 0, width: pageWidth, height: pageHeight };
|
27
|
+
} else {
|
28
|
+
console.log("size:", system.args[3]);
|
29
|
+
pageWidth = parseInt(system.args[3], 10);
|
30
|
+
pageHeight = parseInt(pageWidth * 3/4, 10); // it's as good an assumption as any
|
31
|
+
console.log ("pageHeight:",pageHeight);
|
32
|
+
page.viewportSize = { width: pageWidth, height: pageHeight };
|
33
|
+
}
|
34
|
+
}
|
35
|
+
if (system.args.length > 4) {
|
36
|
+
page.zoomFactor = system.args[4];
|
37
|
+
}
|
38
|
+
page.open(address, function (status) {
|
39
|
+
if (status !== 'success') {
|
40
|
+
console.log('Unable to load the address!');
|
41
|
+
phantom.exit(1);
|
42
|
+
} else {
|
43
|
+
window.setTimeout(function () {
|
44
|
+
page.render(output);
|
45
|
+
phantom.exit();
|
46
|
+
}, 200);
|
47
|
+
}
|
48
|
+
});
|
49
|
+
}
|
data/lib/metanorma/output/pdf.rb
CHANGED
@@ -5,10 +5,12 @@ module Metanorma
|
|
5
5
|
def convert(url_path, output_path)
|
6
6
|
file_url = "file://#{Dir.pwd}/#{url_path}"
|
7
7
|
pdfjs = File.join(File.dirname(__FILE__), '../../../bin/metanorma-pdf.js')
|
8
|
-
|
9
|
-
|
8
|
+
ENV['NODE_PATH'] = `npm root --quiet -g`.strip
|
9
|
+
system "node #{pdfjs} #{file_url} #{output_path}"
|
10
|
+
#Phantomjs.path
|
11
|
+
#pdfjs = File.join(File.dirname(__FILE__), "../../../bin/rasterize.js")
|
12
|
+
#Phantomjs.run(pdfjs, file_url, output_path, "A4")
|
10
13
|
end
|
11
|
-
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
data/lib/metanorma/version.rb
CHANGED
data/metanorma.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -116,8 +116,10 @@ files:
|
|
116
116
|
- LICENSE.txt
|
117
117
|
- README.adoc
|
118
118
|
- Rakefile
|
119
|
+
- appveyor.yml
|
119
120
|
- bin/console
|
120
121
|
- bin/metanorma-pdf.js
|
122
|
+
- bin/rasterize.js
|
121
123
|
- bin/setup
|
122
124
|
- lib/metanorma.rb
|
123
125
|
- lib/metanorma/document.rb
|