bookify 2.5.0 → 2.9.0

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
  SHA256:
3
- metadata.gz: 8e07bd5f6f7148fa8711de2c1cf860236e3e3da1dd4fd411246c11b15958ac49
4
- data.tar.gz: 2995c7ec5a3fef4fee1d8a837d77d253b99998d7bfb2e6a2465e067b142e9da1
3
+ metadata.gz: e7cb3fcf20cf4c0d52a7db2745e1c060fc112aff2e7602cc2dce29c9323d1e97
4
+ data.tar.gz: 4b853cfb351be5194482a3b3dd9ce8301c320bd947b85e3c0b7296e56fc302dc
5
5
  SHA512:
6
- metadata.gz: 44b913b44ff68a55071a0fbe5f88f7d8195872b6bc0deb39382d9b095b3a767d8c0b4cc183b80a9e32e001845bb421f5004b63a7189380981a8244ce8b07debe
7
- data.tar.gz: ecb58a77471a62ad08a749bef069ae9642b9b318bcd2bb0c232326ec352d33bec34a952abfba672304fc712f0c6a41c27c506caa6cc40e898440892d086c7f81
6
+ metadata.gz: 86cb9d453def89f8471704d3d540a297a034ddcf9d23fbae9ed290cd30c6a29ed9c40333e25ba6332ae0f1b80c3208f33777b53f5c4dd9fdc86ee497fdf647cb
7
+ data.tar.gz: '08455d449f42a2f3df014b8e411f5024b4f93528a4ddd44192db5634273520d2f315697524a0ec3d6e748368995ab794a2a657b549aab877cbfcaea4586d7e51'
@@ -3,10 +3,10 @@ module Bookify::Node
3
3
  attr_accessor :node, :pdf
4
4
 
5
5
  FONTS = {
6
- h1: ["Book Antiqua", size: 16, style: :bold],
7
- h2: ["Book Antiqua", size: 12, style: :bold],
8
- h3: ["Book Antiqua", size: 11, style: :bold],
9
- h4: ["Book Antiqua", size: 10, style: :bold],
6
+ h1: ["Book Antiqua", size: 18, style: :bold],
7
+ h2: ["Book Antiqua", size: 13, style: :bold],
8
+ h3: ["Book Antiqua", size: 12, style: :bold],
9
+ h4: ["Book Antiqua", size: 11, style: :bold],
10
10
  primary: ["Book Antiqua", size: 10]
11
11
  }
12
12
 
@@ -42,5 +42,9 @@ module Bookify::Node
42
42
  def break_if_close_to_bottom(tolerance = 125)
43
43
  bounds.move_past_bottom if pdf.y <= tolerance
44
44
  end
45
+
46
+ def page_top
47
+ pdf.bounds.parent.height + 50
48
+ end
45
49
  end
46
50
  end
@@ -4,7 +4,7 @@ module Bookify::Node
4
4
  class H1 < Base
5
5
  def render
6
6
  break_if_close_to_bottom(250)
7
- move_down 20 unless pdf.y == page_top
7
+ move_down 30 unless pdf.y == page_top
8
8
 
9
9
  html = decode_html(node.inner_html.strip)
10
10
  dest = dest_xyz(0, pdf.y, nil, pdf.page)
@@ -16,11 +16,7 @@ module Bookify::Node
16
16
  text html, align: :center
17
17
  end
18
18
 
19
- move_down 10
20
- end
21
-
22
- def page_top
23
- pdf.bounds.parent.height + 50
19
+ move_down 30
24
20
  end
25
21
  end
26
22
  end
@@ -3,7 +3,7 @@ require_relative "base"
3
3
  module Bookify::Node
4
4
  class H2 < Base
5
5
  def render
6
- move_down 5
6
+ move_down 15 unless pdf.y == page_top
7
7
  break_if_close_to_bottom
8
8
 
9
9
  html = decode_html(node.inner_html.strip)
@@ -14,8 +14,9 @@ module Bookify::Node
14
14
  add_dest(html, dest)
15
15
  add_dest("#{parent_h1}/#{html}", dest) if parent_h1
16
16
 
17
- font :h2
18
- text html
17
+ font :h2 do
18
+ text html
19
+ end
19
20
 
20
21
  move_down 1
21
22
  stroke { horizontal_rule }
@@ -3,11 +3,14 @@ require_relative "base"
3
3
  module Bookify::Node
4
4
  class H3 < Base
5
5
  def render
6
- font :h3
7
- move_down 5
6
+ move_down 10 unless pdf.y == page_top
8
7
  break_if_close_to_bottom
9
- text decode_html(node.inner_html.strip)
10
- move_down 2
8
+
9
+ font :h3 do
10
+ text decode_html(node.inner_html.strip)
11
+ end
12
+
13
+ move_down 5
11
14
  end
12
15
  end
13
16
  end
@@ -3,11 +3,14 @@ require_relative "base"
3
3
  module Bookify::Node
4
4
  class H4 < Base
5
5
  def render
6
- move_down 5
6
+ move_down 10 unless pdf.y == page_top
7
7
  break_if_close_to_bottom
8
- font :h4
9
- text decode_html(node.inner_html.strip)
10
- move_down 2
8
+
9
+ font :h4 do
10
+ text decode_html(node.inner_html.strip)
11
+ end
12
+
13
+ move_down 5
11
14
  end
12
15
  end
13
16
  end
@@ -1,15 +1,23 @@
1
1
  require_relative "base"
2
+ require "open-uri"
2
3
 
3
4
  module Bookify::Node
4
5
  class Image < Base
5
6
  def render
6
7
  options = {
7
8
  position: html_classes.include?("center") ? :center : :left,
8
- fit: [bounds.width, -1],
9
+ fit: [bounds.width, -1]
9
10
  }
10
11
 
11
- image node.attr(:src), options
12
+ image image_from_node(node), options
12
13
  move_down 15
13
14
  end
15
+
16
+ private
17
+
18
+ def image_from_node(node)
19
+ src = node.attr(:src)
20
+ /^https?\:\/\//.match?(src) ? URI.open(src) : src
21
+ end
14
22
  end
15
23
  end
@@ -5,19 +5,20 @@ module Bookify::Node
5
5
  def render
6
6
  font :primary
7
7
 
8
- table table_data, header: true, width: bounds.width do
8
+ options = {
9
+ header: true,
10
+ width: bounds.width,
11
+ row_colors: ["FFFFFF", "EEEEEE"]
12
+ }
13
+
14
+ table table_data, options do
9
15
  cells.borders = []
10
16
 
11
- row(0).borders = [:top, :bottom]
12
- row(0).border_top_width = 0.5
17
+ row(0).borders = [:bottom]
13
18
  row(0).border_bottom_width = 0.5
14
19
  row(0).font_style = :bold
15
20
 
16
- row(-1).borders = [:bottom]
17
- row(-1).border_bottom_width = 0.5
18
-
19
- cells.columns(0).padding = [5, 5, 5, 0]
20
- cells.columns(-1).padding = [5, 0, 5, 5]
21
+ cells.padding = 5
21
22
  end
22
23
 
23
24
  move_down 15
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookify
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joey Schoblaska
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-14 00:00:00.000000000 Z
11
+ date: 2020-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake