asciibook 0.0.2 → 0.0.3

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: 4ae7901e0269a4751c07d64a9ba27e0f2cca49e2b19614e846b683c12fedd0e5
4
- data.tar.gz: 07d770921a2684ff557fa6c6add31b9bd0744a4b4b264bb7796ea2affeadfc4e
3
+ metadata.gz: ac1b2f6cc55318830a04ebb0c2051e075ead0a2cd24a66ae9b77a97f04e8727e
4
+ data.tar.gz: af327832e1592d2b99f455e41f4d3c32370988d20adc3b6c05b54146e3416343
5
5
  SHA512:
6
- metadata.gz: 26a0d7fae1562efe4afee1c4f7cac18bbf94364da4ef8b4a98298f682bfa5387560d6cb8bcd468fc5427559bd9970429d7e70bb8ccfe55089894de38e9ec09af
7
- data.tar.gz: 10199b8d5b7443564bdb8de86953211623713970ea092ef0cc633ef4d5d32d97d2c51643029511779a43aa0c9ae5a016e0fe6b2d5098869d1b3cf91e83faa1b6
6
+ metadata.gz: c7a0ea1bd7f7e059f26f339083d11bea1795defd89e8ab06401deb3e0708abdc78a51b87712d45d1e23848d98b7a68311bcbef0fb6f3abfeca85f345182551a2
7
+ data.tar.gz: 811f7da4d3876bd5a76ceb5f63ccb61bbc31e13baaeaf6bcfde1177ef435487ea897c9c879451cd027821a9c90f60fe633d3c5b774f844b9fdc9fdc2d1d84e78
@@ -5,88 +5,58 @@ Asciibook is an Ebook generator for converting AsciiDoc to HTML, PDF, EPUB and M
5
5
 
6
6
  == Installation
7
7
 
8
- If you are familiar with Ruby, you can use <<manual-installation>>.
8
+ Asciibook uses docker as distribution tool. Docker helps deal with dependencies, keeps the local environment clean, and works well with CI / CD tools.
9
9
 
10
- If your are familiar with Docker, you can use <<docker-installation>>.
10
+ You can download and install docker in https://www.docker.com/products/docker-desktop .
11
11
 
12
- [[manual-installation]]
13
- === Manual installation
14
-
15
- Install by rubygems:
16
-
17
- [source, console]
18
- ----
19
- $ gem install asciibook
20
- ----
21
-
22
- For PDF generate, download and install wkhtmltopdf in https://wkhtmltopdf.org/downloads.html .
23
-
24
- For Mobi generate, download and install kindlegen in https://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211 .
25
-
26
-
27
- [[docker-installation]]
28
- === Docker Installation
29
-
30
- Pull docker image:
12
+ After installed docker, Pull the docker image:
31
13
 
32
14
  [source, consle]
33
15
  ----
34
16
  $ docker pull asciibook/asciibook
35
17
  ----
36
18
 
37
- Then use asciibook CLI in this way:
38
-
39
- [source, console]
40
- ----
41
- $ docker run -v $(pwd):/asciibook asciibook/asciibook asciibook build mybook.adoc
42
- ----
43
-
44
- Or enter the container environment to avoid repeating lengthy commands:
45
-
46
- [source, console]
47
- ----
48
- $ docker run -v $(pwd):/asciibook asciibook/asciibook bash
49
- /asciibook $ asciibook build mybook.adoc
50
- ----
51
-
52
19
  == Usage
53
20
 
54
- For a existing AsciiDoc file, run this command to build all format books:
21
+ First, enter container enviroment in your AsciiDoc file diretory:
55
22
 
56
23
  [source, console]
57
24
  ----
58
- $ ascibook build mybook.adoc
25
+ $ docker run -it -v $(pwd):/asciibook asciibook/asciibook bash
26
+ /asciibook #
59
27
  ----
60
28
 
61
- Generated books will put in `build` directory.
29
+ Following command is executed inside the container environment.
62
30
 
63
- Or generate only partial format:
31
+ For a existing AsciiDoc file, run this command to build all formats:
64
32
 
65
33
  [source, console]
66
34
  ----
67
- $ asciibook build mybook.adoc --format html
68
- $ asciibook build mybook.adoc --format pdf,mobi
35
+ /asciibook # ascibook build mybook.adoc
69
36
  ----
70
37
 
71
- If you don't want to enter the parameters repeatedly, you can create a configuration file for the document:
38
+ Generated results will be placed in the `build` folder.
39
+
40
+ Or generate partial formats:
72
41
 
73
42
  [source, console]
74
43
  ----
75
- $ asciibook init mybook.adoc
44
+ /asciibook # asciibook build mybook.adoc --format html
45
+ /asciibook # asciibook build mybook.adoc --format pdf,mobi
76
46
  ----
77
47
 
78
- It will create a config file `asciibook.yml` in the same directory, edit config for your need, then use this command to build next time:
48
+ If you don't want to type the parameters repeatedly, you can create a configuration file for the document:
79
49
 
80
50
  [source, console]
81
51
  ----
82
- $ asciibook build
52
+ /asciibook # asciibook init mybook.adoc
83
53
  ----
84
54
 
85
- Use this command to create a empty AsciiDoc and config file:
55
+ It will create a config file named `asciibook.yml` in the same directory, edit config for your need, then use this command to build next time:
86
56
 
87
57
  [source, console]
88
58
  ----
89
- $ asciibook new mybook
59
+ /asciibook # asciibook build
90
60
  ----
91
61
 
92
62
  == Development
@@ -46,21 +46,24 @@ module Asciibook
46
46
  doc.attributes['cover-image']
47
47
  end
48
48
 
49
- def toc
50
- @toc ||= outline(doc)
49
+ def outline
50
+ outline_node(doc)
51
51
  end
52
52
 
53
- def outline(node)
53
+ # book outline only list sections that split as page
54
+ def outline_node(node)
54
55
  data = []
55
56
  node.sections.each do |section|
56
- section_data = {
57
- 'title' => section.xreftext,
58
- 'path' => section.page ? section.page.path : "#{find_page_node(section).page.path}##{section.id}"
59
- }
60
- if section.sections.count > 0 and section.level < (doc.attributes['toclevels'] || 2).to_i
61
- section_data['items'] = outline(section)
57
+ if section.page
58
+ section_data = {
59
+ 'title' => section.xreftext,
60
+ 'path' => section.page.path
61
+ }
62
+ if section.sections.count > 0 and section.level < @page_level
63
+ section_data['items'] = outline_node(section)
64
+ end
65
+ data << section_data
62
66
  end
63
- data << section_data
64
67
  end
65
68
  data
66
69
  end
@@ -79,7 +82,7 @@ module Asciibook
79
82
  {
80
83
  'title' => doc.attributes['doctitle'],
81
84
  'attributes' => doc.attributes,
82
- 'toc' => toc
85
+ 'outline' => outline
83
86
  }
84
87
  end
85
88
 
@@ -14,7 +14,41 @@ module Asciibook
14
14
  end
15
15
 
16
16
  def content
17
- node.convert
17
+ @content ||= node.convert
18
+ end
19
+
20
+ def doc
21
+ @doc ||= Nokogiri::HTML.fragment(content)
22
+ end
23
+
24
+ def image_url
25
+ doc.css('img').first&.attr('src')
26
+ end
27
+
28
+ def description
29
+ doc.css('p').first&.text
30
+ end
31
+
32
+ def outline
33
+ outline_node(@node)
34
+ end
35
+
36
+ # page outline only list sections that not split as page
37
+ def outline_node(node)
38
+ data = []
39
+ node.sections.each do |section|
40
+ if !section.page
41
+ section_data = {
42
+ 'title' => section.xreftext,
43
+ 'path' => "##{section.id}"
44
+ }
45
+ if section.sections.count > 0
46
+ section_data['items'] = outline_node(section)
47
+ end
48
+ data << section_data
49
+ end
50
+ end
51
+ data
18
52
  end
19
53
 
20
54
  def to_hash
@@ -22,6 +56,9 @@ module Asciibook
22
56
  'path' => path,
23
57
  'title' => title,
24
58
  'content' => content,
59
+ 'image_url' => image_url,
60
+ 'description' => description,
61
+ 'outline' => outline,
25
62
  'prev_page' => prev_page && { 'path' => prev_page.path, 'title' => prev_page.title },
26
63
  'next_page' => next_page && { 'path' => next_page.path, 'title' => next_page.title }
27
64
  }
@@ -1,3 +1,3 @@
1
1
  module Asciibook
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,5 +1,6 @@
1
1
  <div class="admonition admonition-{{ node.attributes.name }}" {% if node.id %}id="{{ node.id }}"{% endif %}>
2
2
  <div class="admonition-icon">
3
+ <b>{{ node.attributes.name | upcase }}</b>
3
4
  </div>
4
5
  <div class="admonition-content">
5
6
  {% if node.title %}<h5>{{ node.title }}</h5>{% endif %}
@@ -0,0 +1 @@
1
+ {{ node.text }}<br/>
@@ -1,16 +1,97 @@
1
- .toolbar {
2
- position: fixed;
1
+ html,
2
+ body {
3
+ height: 100%;
4
+ }
5
+
6
+ .preload * {
7
+ -webkit-transition: none !important;
8
+ -moz-transition: none !important;
9
+ -ms-transition: none !important;
10
+ -o-transition: none !important;
11
+ }
12
+
13
+ .drawer .drawer-content {
14
+ width: 240px;
15
+ position: absolute;
3
16
  top: 0;
17
+ left: -240px;
18
+ bottom: 0;
19
+ overflow-y: auto;
20
+ transition: left 0.15s;
21
+ background: #fafafa;
22
+ border-right: 1px solid #eee;
23
+ box-sizing: border-box;
24
+ }
25
+
26
+ .drawer.open .drawer-content {
4
27
  left: 0;
28
+ }
29
+
30
+ .drawer-menu ol {
31
+ list-style: none;
32
+ padding: 0;
33
+ margin: 0;
34
+ }
35
+
36
+ .drawer-menu-item {
37
+ padding: 10px 16px;
38
+ display: block;
39
+ text-decoration: none;
40
+ color: #555;
41
+ font-size: 14px;
42
+ line-height: 20px;
43
+ }
44
+
45
+ .drawer-menu-item:hover {
46
+ background: rgba(0, 0, 0, 0.05);
47
+ color: #333;
48
+ }
49
+
50
+ .drawer-menu-item.active {
51
+ background: rgba(0, 0, 0, 0.05);
52
+ color: #3f51b5;
53
+ }
54
+
55
+ .drawer-menu ol ol .drawer-menu-item {
56
+ padding-left: 32px;
57
+ }
58
+
59
+ .main {
60
+ position: absolute;
61
+ top: 0;
5
62
  right: 0;
6
- padding: 0.25em 1.25em;
63
+ left: 0;
64
+ bottom: 0;
65
+ transition: left 0.15s;
66
+ }
67
+
68
+ .drawer.open + .main {
69
+ left: 240px;
70
+ }
71
+
72
+ .main-content {
73
+ position: absolute;
74
+ top: 56px;
75
+ left: 0;
76
+ right: 0;
77
+ bottom: 0;
78
+ overflow-y: auto;
79
+ padding: 32px;
80
+ outline: 0;
81
+ }
82
+
83
+ .container {
84
+ max-width: 768px;
85
+ margin: 0 auto;
86
+ }
87
+
88
+ .toolbar {
89
+ padding: 4px;
7
90
  display: flex;
8
- background: white;
9
- z-index: 100;
10
91
  }
11
92
 
12
93
  .toolbar-title {
13
- padding: 0.75em;
94
+ padding: 12px;
14
95
  flex-grow: 1;
15
96
  font-weight: bold;
16
97
  }
@@ -25,7 +106,7 @@
25
106
  }
26
107
 
27
108
  .toolbar-action {
28
- padding: 0.25em;
109
+ padding: 4px;
29
110
  }
30
111
 
31
112
  .button {
@@ -41,24 +122,44 @@
41
122
  line-height: 1;
42
123
  border: none;
43
124
  padding: 0;
125
+ color: #999;
126
+ }
127
+
128
+ .button:hover {
129
+ color: #555;
130
+ }
131
+
132
+ .button:active,
133
+ .button.active {
134
+ color: #333;
135
+ }
136
+
137
+ .button:disabled,
138
+ .button.disabled {
139
+ pointer-events: none;
140
+ opacity: 0.5;
141
+ }
142
+
143
+ .button-text {
144
+ padding: 8px 16px;
44
145
  }
45
146
 
46
147
  .button-icon {
47
- padding: 0.5em;
148
+ padding: 8px;
149
+ border-radius: 50%;
48
150
  }
49
151
 
50
152
  .button-icon {
51
- color: #999;
153
+ fill: #999;
52
154
  }
53
155
 
54
156
  .button-icon:hover {
55
- color: #555;
157
+ fill: #555;
56
158
  }
57
159
 
58
- .button-icon .fas {
59
- font-size: 1.25em;
60
- width: 1.2em;
61
- line-height: 1.2em;
160
+ .button-icon {
161
+ width: 40px;
162
+ height: 40px;
62
163
  text-align: center;
63
164
  }
64
165
 
@@ -69,7 +170,7 @@
69
170
  .dropdown-menu {
70
171
  display: none;
71
172
  position: absolute;
72
- min-width: 320px;
173
+ min-width: 240px;
73
174
  max-width: 90%;
74
175
  max-height: 480px;
75
176
  top: 100%;
@@ -79,6 +180,7 @@
79
180
  z-index: 10;
80
181
  overflow-y: auto;
81
182
  background: white;
183
+ font-size: 14px;
82
184
  }
83
185
 
84
186
  .dropdown.open .dropdown-menu {
@@ -93,9 +195,10 @@
93
195
 
94
196
  .dropdown-menu-item {
95
197
  display: block;
96
- padding: 12px;
198
+ padding: 10px 12px;
97
199
  text-decoration: none;
98
200
  color: #555;
201
+ line-height: 20px;
99
202
  }
100
203
 
101
204
  .dropdown-menu-item:hover {
@@ -111,10 +214,54 @@
111
214
  padding-left: 24px;
112
215
  }
113
216
 
114
- .content {
115
- padding: 2em;
116
- max-width: 768px;
117
- margin: 0 auto;
217
+ .dropdown-group {
218
+ margin: 16px;
219
+ }
220
+
221
+ .dropdown-group label {
222
+ display: block;
223
+ margin-bottom: 8px;
224
+ font-weight: bold;
225
+ color: #777;
226
+ }
227
+
228
+ .dropdown-options {
229
+ display: flex;
230
+ justify-content: space-between;
231
+ align-items: center;
232
+ }
233
+
234
+ .font-family-options .button {
235
+ justify-content: center;
236
+ flex-grow: 1;
237
+ }
238
+
239
+ .background-options .button {
240
+ border: 1px solid #ccc;
241
+ }
242
+
243
+ .background-options .button svg {
244
+ display: none;
245
+ }
246
+
247
+ .background-options .button.active svg {
248
+ display: block;
249
+ }
250
+
251
+ .background-options .button[data-value="white"] {
252
+ background: white;
253
+ }
254
+
255
+ .background-options .button[data-value="warm"] {
256
+ background: #fff8e1;
257
+ }
258
+
259
+ .background-options .button[data-value="dim"] {
260
+ background: #424242;
261
+ }
262
+
263
+ .background-options .button[data-value="black"] {
264
+ background: black;
118
265
  }
119
266
 
120
267
  .paginator {
@@ -122,19 +269,15 @@
122
269
 
123
270
  .paginator a {
124
271
  padding: 32px;
125
- color: #999;
272
+ fill: #999;
126
273
  text-decoration: none;
127
274
  }
128
275
 
129
- .paginator a .fas {
130
- font-size: 1.25em;
131
- width: 1.2em;
132
- line-height: 1.2em;
133
- text-align: center;
276
+ .paginator a svg {
134
277
  }
135
278
 
136
279
  .paginator a:hover {
137
- color: #555;
280
+ fill: #555;
138
281
  }
139
282
 
140
283
  .paginator a.disabled {
@@ -145,8 +288,9 @@
145
288
  display: flex;
146
289
  flex-direction: column;
147
290
  justify-content: center;
148
- position: fixed;
149
- top: 48px;
291
+ align-items: center;
292
+ position: absolute;
293
+ top: 56px;
150
294
  bottom: 0;
151
295
  left: 0;
152
296
  }
@@ -155,23 +299,188 @@
155
299
  display: flex;
156
300
  flex-direction: column;
157
301
  justify-content: center;
158
- position: fixed;
159
- top: 48px;
302
+ align-items: center;
303
+ position: absolute;
304
+ top: 56px;
160
305
  bottom: 0;
161
306
  right: 0;
162
307
  }
163
308
 
164
- .main {
165
- margin-top: 56px;
309
+ /* Theme */
310
+
311
+ body[data-font-size="50"] .main-content {
312
+ font-size: 50%;
313
+ }
314
+
315
+ body[data-font-size="67"] .main-content {
316
+ font-size: 67%;
317
+ }
318
+
319
+ body[data-font-size="75"] .main-content {
320
+ font-size: 75%;
321
+ }
322
+
323
+ body[data-font-size="80"] .main-content {
324
+ font-size: 80%;
325
+ }
326
+
327
+ body[data-font-size="90"] .main-content {
328
+ font-size: 90%;
329
+ }
330
+
331
+ body[data-font-size="100"] .main-content {
332
+ font-size: 100%;
333
+ }
334
+
335
+ body[data-font-size="110"] .main-content {
336
+ font-size: 110%;
337
+ }
338
+
339
+ body[data-font-size="125"] .main-content {
340
+ font-size: 125%;
341
+ }
342
+
343
+ body[data-font-size="150"] .main-content {
344
+ font-size: 150%;
345
+ }
346
+
347
+ body[data-font-size="175"] .main-content {
348
+ font-size: 175%;
349
+ }
350
+
351
+ body[data-font-size="200"] .main-content {
352
+ font-size: 200%;
353
+ }
354
+
355
+ body[data-font-family="serif"] .main-content {
356
+ font-family: serif;
357
+ }
358
+
359
+ body[data-font-family="sans-serif"] .main-content {
360
+ font-family: sans-serif;
361
+ }
362
+
363
+ body[data-background="white"] {
364
+ background: white;
365
+ }
366
+
367
+ body[data-background="warm"] {
368
+ background: #fff8e1;
369
+ }
370
+
371
+ body[data-background="dim"] {
372
+ background: #424242;
373
+ }
374
+
375
+ body[data-background="dim"] .main-content,
376
+ body[data-background="dim"] .main-content h1,
377
+ body[data-background="dim"] .main-content h2,
378
+ body[data-background="dim"] .main-content h3,
379
+ body[data-background="dim"] .main-content h4,
380
+ body[data-background="dim"] .main-content h5,
381
+ body[data-background="dim"] .main-content h6 {
382
+ color: #ddd;
383
+ }
384
+
385
+ body[data-background="dim"] .main-content pre,
386
+ body[data-background="dim"] .main-content *:not(pre) code,
387
+ body[data-background="dim"] .main-content .example,
388
+ body[data-background="dim"] .main-content .sidebar,
389
+ body[data-background="dim"] .main-content blockquote {
390
+ background: transparent;
391
+ }
392
+
393
+ body[data-background="dim"] .main-content pre span {
394
+ color: #ddd;
395
+ }
396
+
397
+ body[data-background="dim"] .main-content a {
398
+ color: #81d4fa;
399
+ }
400
+
401
+ body[data-background="dim"] .main-content a.callout {
402
+ color: #ddd;
403
+ }
404
+
405
+ body[data-background="black"] {
406
+ background: black;
407
+ }
408
+
409
+ body[data-background="black"] .main-content,
410
+ body[data-background="black"] .main-content h1,
411
+ body[data-background="black"] .main-content h2,
412
+ body[data-background="black"] .main-content h3,
413
+ body[data-background="black"] .main-content h4,
414
+ body[data-background="black"] .main-content h5,
415
+ body[data-background="black"] .main-content h6 {
416
+ color: #ddd;
417
+ }
418
+
419
+ body[data-background="black"] .main-content pre,
420
+ body[data-background="black"] .main-content *:not(pre) code,
421
+ body[data-background="black"] .main-content .example,
422
+ body[data-background="black"] .main-content .sidebar,
423
+ body[data-background="black"] .main-content blockquote {
424
+ background: transparent;
166
425
  }
167
426
 
168
- @media (max-width: 992px) {
427
+ body[data-background="black"] .main-content pre span {
428
+ color: #ddd;
429
+ }
430
+
431
+ body[data-background="black"] .main-content a {
432
+ color: #81d4fa;
433
+ }
434
+
435
+ body[data-background="black"] .main-content a.callout {
436
+ color: #ddd;
437
+ }
438
+ /* responsive */
439
+
440
+ @media (max-width: 1280px) {
441
+ .drawer.open .drawer-content {
442
+ z-index: 20;
443
+ background: white;
444
+ }
445
+
446
+ .drawer .drawer-backdrop {
447
+ display: none;
448
+ }
449
+
450
+ .drawer.open .drawer-backdrop {
451
+ display: block;
452
+ position: absolute;
453
+ top: 0;
454
+ left: 0;
455
+ right: 0;
456
+ bottom: 0;
457
+ z-index: 10;
458
+ background: rgba(0, 0, 0, 0.15);
459
+ }
460
+
461
+ .drawer.open + .main {
462
+ left: 0;
463
+ }
464
+
465
+ .drawer.open .drawer-content {
466
+ border: none;
467
+ box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
468
+ }
469
+
470
+ .main-content {
471
+ bottom: 56px;
472
+ }
473
+
169
474
  .paginator {
170
475
  display: flex;
476
+ position: absolute;
477
+ bottom: 0;
478
+ left: 0;
479
+ right: 0;
171
480
  }
172
481
 
173
482
  .paginator a {
174
- padding: 1em;
483
+ padding: 16px;
175
484
  }
176
485
 
177
486
  .paginator-prev {
@@ -188,15 +497,7 @@
188
497
  }
189
498
 
190
499
  @media (max-width: 480px) {
191
- .toolbar {
192
- padding: 0.25em;
193
- }
194
-
195
- .content {
196
- padding: 1em;
197
- }
198
-
199
- .paginator a {
200
- padding: 0.25em;
500
+ .main-content {
501
+ padding: 16px;
201
502
  }
202
503
  }