dragonfly_phantomjs 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f10f860936a87eb0db8c933b363f6533e6d79b88
4
- data.tar.gz: f13237acf25cdbae2095a4c73e5440dc36318e3e
3
+ metadata.gz: 517e2acf740e3d393aacdb34d4930412a009d969
4
+ data.tar.gz: 843e4fae60ba187c24cd0c9c6ad89f9ca04cb8e8
5
5
  SHA512:
6
- metadata.gz: 48ee7327877f0704ffc7fac84b15907c90629a0d061275416ac162464439b60f080d9eca5720d9198f6f53477cf6eda97dd4ff405d6a771c832245e32be5b7b8
7
- data.tar.gz: abf665d554a9e35117384565891402b783f088408ecdaede38fc3552c51b82f43600e787ae98432d216cf240eb0d5c9720100173c48d4a7815d9818bbdcfab39
6
+ metadata.gz: a8af26375c693c651df8584ae5d46704714eb5a06df11dc4a90c9070b0bc1185d4982dfcd994af5e6ccde13c02806e9be8a097cb86853c3d698b24af5d40935d
7
+ data.tar.gz: 83d3516e87291bc0f8c9e8800102694040a2f62fbedcee7eafbbe5785fd6453c5ac295425870d6f08c48f7904458e792ececd525f22fa1cbf0d67420c4abe737
data/README.md CHANGED
@@ -48,11 +48,11 @@ Options:
48
48
  :paper_size - {string}, 'width*height', '300mm*300mm', supported units are 'mm', 'cm', 'in', 'px'
49
49
  :viewport_size - {string}, 'width*height', '1440*900'
50
50
  :zoom_factor - {number}, defaults to 1
51
- :header - {hash}, {height: '10mm', content: 'Header content'}
52
- :footer - {hash}, {height: '10mm', content: 'Footer content'}
51
+ :header - {hash}, {height: '10mm', content: 'Header content', hide_on: [1]}
52
+ :footer - {hash}, {height: '10mm', content: 'Footer content', hide_on: [1]}
53
53
  ```
54
54
 
55
- For now refer to the phantomjs [api](http://phantomjs.org/api/webpage/property/paper-size.html) for more details on how to construct the string for the header/footer. You can use `pageNum` and `numPages` as variables.
55
+ For now refer to the phantomjs [api](http://phantomjs.org/api/webpage/property/paper-size.html) for more details on how to construct the string for the header/footer. You can use `pageNum` and `numPages` as variables. The `hide_on` option takes an array of page numbers where the header and/or footer will be hidden.
56
56
 
57
57
  ## Contributing
58
58
 
@@ -22,8 +22,8 @@ module DragonflyPhantomjs
22
22
  # :paper_size - {string}, 'width*height', '300mm*300mm', supported units are 'mm', 'cm', 'in', 'px'
23
23
  # :viewport_size - {string}, 'width*height', '1440*900'
24
24
  # :zoom_factor - {number}, defaults to 1
25
- # :header - {hash}, {height: '10mm', contents: 'foo'}
26
- # :footer - {hash}, {height: '10mm', contents: 'foo'}
25
+ # :header - {hash}, {height: '10mm', contents: 'foo', hide_on: [1] }
26
+ # :footer - {hash}, {height: '10mm', contents: 'foo', hide_on: [1] }
27
27
 
28
28
  def call content, format=:pdf, options={}
29
29
  raise UnsupportedFormat unless %w(gif jpeg pdf png).include?(format.to_s)
@@ -1,3 +1,3 @@
1
1
  module DragonflyPhantomjs
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -33,11 +33,14 @@ zoom_factor = options['zoom_factor'] || 1
33
33
  user_agent = options['user_agent']
34
34
  referer = options['referer']
35
35
  element_id = options['element_id']
36
+ hide_header_on_pages = options['header']['hide_on'] || []
37
+ hide_footer_on_pages = options['footer']['hide_on'] || []
36
38
 
37
39
  header =
38
40
  if options['header']
39
41
  height: options['header']['height']
40
42
  contents: phantom.callback((pageNum, numPages) ->
43
+ return "" if hide_header_on_pages.indexOf(pageNum) > -1
41
44
  eval options['header']['content']
42
45
  )
43
46
  else
@@ -47,6 +50,7 @@ footer =
47
50
  if options['footer']
48
51
  height: options['footer']['height']
49
52
  contents: phantom.callback((pageNum, numPages) ->
53
+ return "" if hide_footer_on_pages.indexOf(pageNum) > -1
50
54
  eval options['footer']['content']
51
55
  )
52
56
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dragonfly_phantomjs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Celizna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-12 00:00:00.000000000 Z
11
+ date: 2014-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dragonfly