hpm118dwx4 0.1.0 → 0.2.0

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: 5ac5cb256952e6b8a135b09fe1bcb62cf04aebf1a70208241ba12f75aafa32e5
4
- data.tar.gz: abf11bea7925eec3ca9f66ce68b5d01e0f4ee71a9828cf9d38af8e55c572df91
3
+ metadata.gz: 1364b9b66aea61a3e3d320a2f43095d68918138ab9fb69c8fe906404eb96abaa
4
+ data.tar.gz: 383ac69890aa9d53d687444cbd6248fac66dc9c54936d7632891575a7e61f697
5
5
  SHA512:
6
- metadata.gz: 761d286669d59b560fdda3ed4de62f5cda67a9950aa3408814a76bfd60758a20a1672391668dba939c9dd43db4fbaadb1a0babf760ce6fa73fa7f973a78c938b
7
- data.tar.gz: 3434030a9134a151ea5d08745e22369511070ad5a7f8e98fd0893500e38c3c515c395d3e35bc9b1a64ef88261365ea7efdfb0d1d8bf9d179c63be504f1739997
6
+ metadata.gz: 8b3eb220493d2a69e3866445473242750aae020699db60f72f04cdaad94eaa35a5c7b84ea9bf4cb2a342c5277614b16717bd53f1ad14b397f74a905354e74387
7
+ data.tar.gz: 7decfd5f61f4109a2455d41fe09da6fa97ab3e468e4d6be722d581c240cdd02d7eb4c7a756ea292d867581f489e238c9d33091d890a3518d2cdda5a96e816c65
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/hpm118dwx4.rb CHANGED
@@ -2,155 +2,68 @@
2
2
 
3
3
  # file: hpm118dwx4.rb
4
4
 
5
- require 'rexle'
6
- require 'rexle-builder'
7
- require 'kramdown'
8
5
 
6
+ require 'htmlbook'
9
7
 
10
8
 
11
- class HpM118dwx4
9
+ class HpM118dwx4 < HtmlBook
12
10
 
13
- attr_reader :to_html
14
- attr_accessor :pages
15
11
 
12
+ def initialize(filename='page.html', pg_height: 500, debug: false)
16
13
 
17
- def initialize(filename='page.html', pages: 8, debug: false)
14
+ super(filename, pg_height: pg_height, debug: debug)
18
15
 
19
- @filename, @pages, @debug = filename, ['&nbsp;']*pages, debug
20
-
21
- end
22
-
23
- def build()
24
- @to_html = build_html @pages
25
- @doc = Rexle.new(@to_html)
26
- end
27
-
28
- def save(filename=@filename)
29
- File.write filename, @doc.xml(pretty: true)
30
- File.write filename.sub(/\.html$/, '.css'), css()
31
16
  end
32
17
 
33
18
  private
34
-
35
-
36
- def build_html(pages)
37
-
38
- n = 1
39
- xml = RexleBuilder.new
40
- a = xml.body do
41
-
42
- collate(pages.length).each_slice(4).each do |x|
43
-
44
- puts 'x: ' + x.inspect if @debug
45
-
46
- x.each.with_index do |y,i|
47
-
48
- xml.div({class: 'page ' + (97+i).chr}) do
49
- xml.article Kramdown::Document.new(pages[y-1]).to_html
50
- xml.footer do
51
- xml.p({class: 'n'+ (y.odd? ? 'odd' : 'even')}, 'pg ' + (y).to_s)
52
- end
53
- end
54
-
55
- n+=1
56
-
57
- end
58
- end
19
+
20
+ def build_html(doc, pages)
21
+
22
+ doc = super(doc, pages)
23
+
24
+ # add the a, b, c, and d to each page
25
+ a = %w(a b c d).cycle
26
+
27
+ puts 'doc.xml: ' + doc.xml.inspect if @debug
28
+
29
+ doc.root.xpath('//body/div').each do |e|
30
+ e.attributes[:class] = ['page', a.next]
59
31
  end
60
-
61
- html=<<EOF
62
- <!DOCTYPE html>
63
- <html lang="en">
64
- <head>
65
- <title>Untitled Book</title>
66
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
67
- <link rel="stylesheet" type="text/css" href="page.css" media="screen, projection, tv, print" />
68
- </head>
69
- #{Rexle.new(a).xml(declaration: false)}
70
- </html>
71
- EOF
72
-
73
- Rexle.new(html).xml pretty: true
74
-
32
+
33
+ return doc
75
34
  end
76
35
 
77
36
  def css()
78
- <<CSS
79
- html,
80
- body {
81
- height: 100%;
82
- margin: 0;
83
- padding: 0;
84
- }
85
-
86
- .page {
87
- display: flex;
88
- flex-direction: column;
89
- min-height: 100%;
90
- }
91
-
92
- article {
93
- flex: 1;
94
- }
95
- body {
96
- font-size: 1.96em; margin: 0; padding: 0;
97
-
98
- }
99
- /*h1 {margin: 0; padding: 0}
100
- h4 {margin: 0; padding: 0}
101
- h5 {margin: 0; padding: 0}*/
102
- /*p {margin: 0; padding: 0}*/
103
- @media print {
104
- .page {page-break-after: always;}
105
- }
106
-
107
- .page {
108
-
109
- margin: 0; padding: 0;
110
- border: 1px solid black;
111
- /* height: 98vh; */
112
-
113
- display: -webkit-box;
114
- display: -ms-flexbox;
115
- display: flex;
116
- -webkit-box-orient: vertical;
117
- -webkit-box-direction: normal;
118
- -ms-flex-direction: column;
119
- flex-direction: column;
120
- min-height: 88%;
121
- }
122
- article {
123
- -webkit-box-flex: 1;
124
- -ms-flex: 1;
125
- flex: 1;
126
- }
127
-
37
+
38
+ s=<<CSS
39
+ body { font-size: 1.96em; }
128
40
  .a {background-color: #fe2;}
129
41
  .b {background-color: #ae2;}
130
42
  .c {background-color: #8d2;}
131
43
  .d {background-color: #aa2;}
132
44
  .c, .d {
133
45
  background-color: #a42; margin-top: 3.6em; padding-top: 0em;
134
- /*height: 88vh;*/
135
46
  min-height: 88%;
136
47
  }
137
48
  .b, .d {background-color: #aa2; margin-left: 2.3em;}
138
49
  .a, .c {background-color: #aa2; margin-right: 2.1em;}
139
-
140
- footer p.nodd {text-align: right;}
141
50
  CSS
51
+ super() + s
52
+
142
53
  end
143
54
 
144
- def collate(n)
55
+ def collate(pages)
145
56
 
146
57
  r = -2
147
- a = n.times.each_slice(8).flat_map do |x|
58
+ a = pages.length.times.each_slice(8).flat_map do |x|
148
59
  x.map.with_index do |y,i|
149
- puts 'r: ' + r.inspect
60
+ puts 'r: ' + r.inspect if @debug
150
61
  r+= [3, 3, 1, 3, -5, -1, 5, -1][i]
151
62
  r
152
63
  end
153
64
  end
65
+ puts 'before zip' if @debug
66
+ pages.zip(a)
154
67
  end
155
68
 
156
69
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hpm118dwx4
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,48 +35,28 @@ cert_chain:
35
35
  sNqMAscBKy6c1o1geOEoyzhNmvqOpnTx3Cq60JPxKVQVJ/t1Chk+hBsX7uWgYyx7
36
36
  TQh7cRnUlJpo8YCfgLLW8CZa
37
37
  -----END CERTIFICATE-----
38
- date: 2019-11-14 00:00:00.000000000 Z
38
+ date: 2019-11-16 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
- name: rexle
42
- requirement: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '1.5'
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: 1.5.3
50
- type: :runtime
51
- prerelease: false
52
- version_requirements: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - "~>"
55
- - !ruby/object:Gem::Version
56
- version: '1.5'
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- version: 1.5.3
60
- - !ruby/object:Gem::Dependency
61
- name: kramdown
41
+ name: htmlbook
62
42
  requirement: !ruby/object:Gem::Requirement
63
43
  requirements:
64
44
  - - ">="
65
45
  - !ruby/object:Gem::Version
66
- version: 2.1.0
46
+ version: 0.1.0
67
47
  - - "~>"
68
48
  - !ruby/object:Gem::Version
69
- version: '2.1'
49
+ version: '0.1'
70
50
  type: :runtime
71
51
  prerelease: false
72
52
  version_requirements: !ruby/object:Gem::Requirement
73
53
  requirements:
74
54
  - - ">="
75
55
  - !ruby/object:Gem::Version
76
- version: 2.1.0
56
+ version: 0.1.0
77
57
  - - "~>"
78
58
  - !ruby/object:Gem::Version
79
- version: '2.1'
59
+ version: '0.1'
80
60
  description:
81
61
  email: james@jamesrobertson.eu
82
62
  executables: []
metadata.gz.sig CHANGED
Binary file