postdoc 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 992a2e72146f61bfe0312d91925d13335ec8959962c19c6427aefb8050e477ae
4
- data.tar.gz: c416947f3c790aa235f1fdc9e96f62dc6c84952c186d88e879bbacc16cf33626
3
+ metadata.gz: 66b2bf15842d2bb088526c1d00aa1680e299aa37b0431825d60d71ce84d77b6c
4
+ data.tar.gz: acc941b19fbbbddb2e0f6c84ddad1fe7576852b09eabed787063afe6b428b74c
5
5
  SHA512:
6
- metadata.gz: 0af41fee51b8552b2f8314788fb7c75898241dc1494c6772a192c249844087103dfd17fdb85ab121ad49527ef033548916790731ab501171a36694a5ec4873e8
7
- data.tar.gz: 715251ad3be74b4a8a44df09b21cbd13bd29fe523f11b7d08abdfdb81105893252034225468ad5bcbbd42e9dcf4abe311d3867a009b8b2ec6dabef4f5950c43e
6
+ metadata.gz: a3cc2d4563b3c660122817b3abd73897842baf84fa7cbecf4b054dc3758826fef359d68613fc10a60a5eecfcbc7a2841a3d6e89e45ee98bf050f2acd24f10783
7
+ data.tar.gz: 55d531eaffa08bb24545fa3e1103d4e6377bc10f63514b3baaea8254aad04a2319a90bd0dbda66b7d56027082245d23cf3fc7e3041afd2baa7ebe67687b34b68
@@ -1,15 +1,23 @@
1
1
  module PostdocViewHelper
2
- def postdoc_stylesheet_link_tag(*path)
3
- content_tag :style, File.read(
4
- Rails.root.join('app', 'assets', 'stylesheets', *path)
5
- ).html_safe,
6
- type: 'text/css'
2
+ def postdoc_stylesheet_link_tag(path)
3
+ content_tag :style, read_asset(path), type: 'text/css'
4
+ end
5
+
6
+ def postdoc_javascript_include_tag(path)
7
+ content_tag :script, read_asset(path), type: 'text/javascript'
8
+ end
9
+
10
+ def postdoc_image_tag(path, options = {})
11
+ image_tag asset_path(path), options
7
12
  end
8
13
 
9
14
  protected
10
15
 
11
- # include an assets from the gem app/assets folder
12
- def postdoc_gem_asset(*path)
13
- File.join(File.dirname(__FILE__), '..', '..', 'app', 'assets', *path)
16
+ def read_asset(path)
17
+ Rails.application.assets.find_asset(path).to_s.html_safe
18
+ end
19
+
20
+ def asset_path(path)
21
+ Rails.application.assets.find_asset(path).filename
14
22
  end
15
23
  end
data/lib/postdoc.rb CHANGED
@@ -30,11 +30,20 @@ module Postdoc
30
30
  chrome.send_cmd 'Page.navigate', url: "file://#{htmlfile.path}"
31
31
  chrome.wait_for 'Page.loadEventFired'
32
32
 
33
+ if options[:header_template].present? || options[:footer_template].present?
34
+ displayHeaderFooter = true
35
+ else
36
+ displayHeaderFooter = false
37
+ end
38
+
33
39
  response = chrome.send_cmd 'Page.printToPDF', {
34
40
  landscape: options[:landscape] || false,
35
41
  printBackground: true,
36
- headerTemplate: options[:header_template] || '',
37
- footerTemplate: options[:footer_template] || '',
42
+ marginTop: options[:margin_top] || 1,
43
+ marginBottom: options[:margin_bottom] || 1,
44
+ displayHeaderFooter: displayHeaderFooter,
45
+ headerTemplate: options[:header_template],
46
+ footerTemplate: options[:footer_template]
38
47
  }
39
48
  result = Base64.decode64 response['data']
40
49
  ensure
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postdoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Groeneveld
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-15 00:00:00.000000000 Z
11
+ date: 2019-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 4.0.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6'
22
+ version: '6.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 4.0.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6'
32
+ version: '6.1'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: chrome_remote
35
35
  requirement: !ruby/object:Gem::Requirement