hpm118dwx4 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5ac5cb256952e6b8a135b09fe1bcb62cf04aebf1a70208241ba12f75aafa32e5
4
+ data.tar.gz: abf11bea7925eec3ca9f66ce68b5d01e0f4ee71a9828cf9d38af8e55c572df91
5
+ SHA512:
6
+ metadata.gz: 761d286669d59b560fdda3ed4de62f5cda67a9950aa3408814a76bfd60758a20a1672391668dba939c9dd43db4fbaadb1a0babf760ce6fa73fa7f973a78c938b
7
+ data.tar.gz: 3434030a9134a151ea5d08745e22369511070ad5a7f8e98fd0893500e38c3c515c395d3e35bc9b1a64ef88261365ea7efdfb0d1d8bf9d179c63be504f1739997
checksums.yaml.gz.sig ADDED
Binary file
data/lib/hpm118dwx4.rb ADDED
@@ -0,0 +1,156 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: hpm118dwx4.rb
4
+
5
+ require 'rexle'
6
+ require 'rexle-builder'
7
+ require 'kramdown'
8
+
9
+
10
+
11
+ class HpM118dwx4
12
+
13
+ attr_reader :to_html
14
+ attr_accessor :pages
15
+
16
+
17
+ def initialize(filename='page.html', pages: 8, debug: false)
18
+
19
+ @filename, @pages, @debug = filename, [' ']*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
+ end
32
+
33
+ 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
59
+ 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
+
75
+ end
76
+
77
+ 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
+
128
+ .a {background-color: #fe2;}
129
+ .b {background-color: #ae2;}
130
+ .c {background-color: #8d2;}
131
+ .d {background-color: #aa2;}
132
+ .c, .d {
133
+ background-color: #a42; margin-top: 3.6em; padding-top: 0em;
134
+ /*height: 88vh;*/
135
+ min-height: 88%;
136
+ }
137
+ .b, .d {background-color: #aa2; margin-left: 2.3em;}
138
+ .a, .c {background-color: #aa2; margin-right: 2.1em;}
139
+
140
+ footer p.nodd {text-align: right;}
141
+ CSS
142
+ end
143
+
144
+ def collate(n)
145
+
146
+ r = -2
147
+ a = n.times.each_slice(8).flat_map do |x|
148
+ x.map.with_index do |y,i|
149
+ puts 'r: ' + r.inspect
150
+ r+= [3, 3, 1, 3, -5, -1, 5, -1][i]
151
+ r
152
+ end
153
+ end
154
+ end
155
+
156
+ end
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hpm118dwx4
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
+ YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTkxMTE0MDAyMzM3WhcN
15
+ MjAxMTEzMDAyMzM3WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
+ cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDlJJKe
17
+ C3wZAB5bSVQfJUSsGTNsqKsGKn4q5dKv7gZwky23+bx+TnMi/MTXUWoIuztEeUYh
18
+ Ivn4YnytW5cG16+7awfoXJX10O+Bvz3+ioPDVUng409RF9JQZR0NaV3S9FRFlaZA
19
+ aJF1BORvoDUfY/lLXLS3LRIcQi9+hJq9gFtoeN1S5pNeORnamqyYHoQUmlgpRscs
20
+ SpTr80qXoEVqZ0XIsJ5ngA/G/75NH9z0l+Vp4eVVjTvt81HJl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
36
+ TQh7cRnUlJpo8YCfgLLW8CZa
37
+ -----END CERTIFICATE-----
38
+ date: 2019-11-14 00:00:00.000000000 Z
39
+ dependencies:
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
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 2.1.0
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '2.1'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 2.1.0
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '2.1'
80
+ description:
81
+ email: james@jamesrobertson.eu
82
+ executables: []
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - lib/hpm118dwx4.rb
87
+ homepage: https://github.com/jrobertson/hpm118dwx4
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubygems_version: 3.0.3
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Experimental gem to produce an HTML printed booklet in A6 size using an HP
110
+ Laserjet Pro M118dw printer.
111
+ test_files: []
metadata.gz.sig ADDED
Binary file