giblish 0.7.0 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -37,12 +37,13 @@ Gem::Specification.new do |spec|
37
37
  spec.add_development_dependency "minitest", "~> 5.0"
38
38
  spec.add_development_dependency "rake", "~> 11.0"
39
39
  spec.add_development_dependency "oga", "~> 2.15"
40
+ spec.add_development_dependency 'thor', '~> 0.20.3'
40
41
 
41
42
  # Usage: spec.add_runtime_dependency "[gem name]", [[version]]
42
43
  spec.add_runtime_dependency "asciidoctor", "~>2.0", ">= 2.0.10"
43
44
  spec.add_runtime_dependency "asciidoctor-diagram", ["~> 1.5"]
44
- spec.add_runtime_dependency "asciidoctor-pdf", [">= 1.5.0.rc.1"]
45
- spec.add_runtime_dependency "git", "~> 1.3"
46
- spec.add_runtime_dependency "rouge", "~> 3.3"
45
+ spec.add_runtime_dependency "asciidoctor-pdf", ["~> 1.5", ">= 1.5.3"]
46
+ spec.add_runtime_dependency "git", "~> 1.7"
47
+ spec.add_runtime_dependency "rouge", "~> 3.24"
47
48
  spec.add_runtime_dependency "prawn-svg", "~> 0.30.0"
48
49
  end
@@ -1,3 +1,3 @@
1
1
  module Giblish
2
- VERSION = "0.7.0".freeze
2
+ VERSION = "0.7.5".freeze
3
3
  end
@@ -0,0 +1,57 @@
1
+ #!/bin/bash
2
+ #
3
+ # this hook runs the publish_html.sh script which, in turn,
4
+ # publishes html versions of adoc files to the desired
5
+ # destination.
6
+ #
7
+ #
8
+ # Adjust the WORKING_TREE_ROOT, DST_DIR and SRC_DIR below to
9
+ # locations suitable for your setup
10
+
11
+ ### config section
12
+ # set this to the repo root where the working tree exists
13
+ WORKING_TREE_ROOT="/the/path/to/the/stage/repo"
14
+
15
+ # set this to the publish root dir served by a web server
16
+ DST_DIR="/the/path/to/webserver/directory/root"
17
+
18
+ # set this to "true" if you want to force an 'rm -rf'of
19
+ # the destination dir before generating new htmls
20
+ CLEAR_DST=""
21
+
22
+ # set this to the top dir to look for docs under in the
23
+ # staging repo. This shall be given as a relative path
24
+ # from the top dir of the git repo.
25
+ SRC_DIR="."
26
+
27
+ # Make config available in subshell
28
+ export WORKING_TREE_ROOT
29
+ export DST_DIR
30
+ export SRC_DIR
31
+ export CLEAR_DST
32
+
33
+ # read the input from git...not currently used.
34
+ # it could for example be used to filter on git branches
35
+ #
36
+ # while read line
37
+ # do
38
+ # echo "git ref: $line"
39
+ # done < /dev/stdin
40
+
41
+ echo "Post update hook running..."
42
+ (
43
+ cd "${WORKING_TREE_ROOT}"
44
+
45
+ # need to unset the GIT_DIR env set by the invoking hook...
46
+ unset GIT_DIR
47
+
48
+ # Run the publish script
49
+ PUBLISH_SCRIPT="scripts/publish_html.sh"
50
+ echo "invoking publish script at ${WORKING_TREE_ROOT}/${PUBLISH_SCRIPT}"
51
+ if [[ -z "${CLEAR_DST}" ]]; then
52
+ "${PUBLISH_SCRIPT}" "${DST_DIR}" "${SRC_DIR}"
53
+ else
54
+ "${PUBLISH_SCRIPT}" -f "${DST_DIR}" "${SRC_DIR}"
55
+ fi
56
+
57
+ )
@@ -0,0 +1,99 @@
1
+ #!/bin/bash
2
+ #
3
+ # pulls the master branch from origin and then runs giblish
4
+ # on the working tree emitting the result to the given destination
5
+ # folder
6
+ #
7
+ # NOTE: This script assumes that all assets referenced from adoc files
8
+ # are located in corresponding .../<file>_assets directories
9
+ # Ex:
10
+ # adoc file .../repo_root/docs/myfile.adoc
11
+ # is expected to have an imagesdir directive in its header pointing to:
12
+ # .../repo_root/docs/myfile_assets
13
+ #
14
+ # all ..._assets directories found under SRC_TOP will be copied in full to
15
+ # DST_DIR
16
+
17
+ SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
18
+
19
+ ### config section
20
+ # set this to the 'resource' folder as expected by the giblish -r flag
21
+ RESOURCE_DIR="${SCRIPT_DIR}/resources"
22
+
23
+ # set this to the publish dir as expected by the giblish -w flag
24
+ WEB_ROOT="/giblish"
25
+
26
+ # display usage message
27
+ function usage {
28
+ echo "Usage:"
29
+ echo " publish_html.sh <dst_dir> [src_top]"
30
+ echo ""
31
+ echo "where"
32
+ echo " dst_dir the top dir to where the html will be generated"
33
+ }
34
+
35
+ # abort with non zero exit code
36
+ # @param msg the message to output to user
37
+ function die {
38
+ echo "Error! $1"
39
+ exit 1
40
+ }
41
+
42
+ ### useful variables
43
+ GIT_ROOT=$(git rev-parse --show-toplevel)
44
+ [ $? -ne 0 ] && die "You must invoke this from within a git working tree."
45
+ SRC_ROOT="${GIT_ROOT}"
46
+
47
+ # handle user flags
48
+ force_remove=''
49
+ while getopts 'f' flag; do
50
+ case "${flag}" in
51
+ f) force_remove='true'
52
+ shift;;
53
+ *) print_usage
54
+ exit 1 ;;
55
+ esac
56
+ done
57
+
58
+ # handle user args
59
+ if [[ $# < 1 || $# > 2 ]]; then
60
+ usage
61
+ die "Wrong number of input arguments."
62
+ fi
63
+ DST_HTML=$1
64
+ if [[ $# == 2 ]]; then
65
+ SRC_ROOT=$2
66
+ fi
67
+
68
+ # Make the paths absolute
69
+ DST_HTML=$(realpath "$1")
70
+ [ $? -ne 0 ] && die "Unknown path: ${DST_HTML}"
71
+ SRC_ROOT=$(realpath "${SRC_ROOT}")
72
+ [ $? -ne 0 ] && die "Unknown path: ${SRC_ROOT}"
73
+
74
+ # update working tree with latest master
75
+ echo "Cleaning git repo at..."
76
+ git clean -fdx
77
+ [ $? -ne 0 ] && die "Could not clean repo"
78
+ echo "Pulling updates from origin..."
79
+ git pull
80
+ [ $? -ne 0 ] && die "Could not pull from origin"
81
+
82
+ # generate the html from adoc files in repo
83
+ echo "Will generate html to: ${DST_HTML} from adoc files found under ${SRC_ROOT}"
84
+ if [[ "${force_remove}" ]]; then
85
+ echo "force flag enabled, remove everything under ${DST_HTML}/"
86
+ rm -rf ${DST_HTML}/*
87
+ fi
88
+
89
+ giblish -a icons=font -c -r "${RESOURCE_DIR}" -s giblish -w "${WEB_ROOT}" "${SRC_ROOT}" "${DST_HTML}"
90
+ [ $? -ne 0 ] && die
91
+
92
+ # copy assets folders
93
+ # do this within subshell so we can use find with '.' notation,
94
+ # giving relative paths back
95
+ echo "Copying asset folders to destination..."
96
+ (
97
+ cd "${SRC_ROOT}"
98
+ find . -name '*_assets' -type d -exec cp -r {} ${DST_HTML}/{} \;
99
+ )
@@ -0,0 +1,419 @@
1
+ /* Modified from https://github.com/edwardtufte/tufte-css */
2
+
3
+ @charset "UTF-8";
4
+
5
+ @font-face {
6
+ font-family: "et-book";
7
+ src: url("https://edwardtufte.github.io/tufte-css/et-book/et-book-roman-line-figures/et-book-roman-line-figures.ttf");
8
+ font-weight: normal;
9
+ font-style: normal
10
+ }
11
+
12
+ @font-face {
13
+ font-family: "et-book";
14
+ src: url("https://edwardtufte.github.io/tufte-css/et-book/et-book-display-italic-old-style-figures/et-book-display-italic-old-style-figures.ttf");
15
+ font-weight: normal;
16
+ font-style: italic
17
+ }
18
+
19
+ @font-face {
20
+ font-family: "et-book";
21
+ src: url("https://edwardtufte.github.io/tufte-css/et-book/et-book-bold-line-figures/et-book-bold-line-figures.ttf");
22
+ font-weight: bold;
23
+ font-style: normal
24
+ }
25
+
26
+ @font-face {
27
+ font-family: "et-book-roman-old-style";
28
+ src: url("https://edwardtufte.github.io/tufte-css/et-book/et-book-roman-old-style-figures/et-book-roman-old-style-figures.ttf");
29
+ font-weight: normal;
30
+ font-style: normal;
31
+ }
32
+
33
+ /* Tufte CSS styles */
34
+ html {
35
+ font-size: 15px;
36
+ }
37
+
38
+ body {
39
+ width: 90%;
40
+ margin-left: auto;
41
+ margin-right: auto;
42
+ padding-left: 12.5%;
43
+ font-family: et-book, Palatino, "Palatino Linotype", "Palatino LT STD", "Book Antiqua", Georgia, serif;
44
+ background-color: #fffff8;
45
+ color: #111;
46
+ max-width: 1400px;
47
+ counter-reset: sidenote-counter;
48
+ /* background-repeat: no-repeat; */
49
+ /* background-attachment: fixed; */
50
+ /* background-position: center top; */
51
+ }
52
+
53
+ h1 { font-weight: 400;
54
+ margin-top: 4rem;
55
+ margin-bottom: 1.5rem;
56
+ font-size: 3.2rem;
57
+ line-height: 1; }
58
+
59
+ h2 {
60
+ font-style: normal;
61
+ font-weight: 400;
62
+ margin-top: 2.1rem;
63
+ margin-bottom: 0;
64
+ font-size: 2.2rem;
65
+ line-height: 1;
66
+ }
67
+
68
+ h3 {
69
+ font-style: italic;
70
+ font-weight: 400;
71
+ font-size: 1.7rem;
72
+ margin-top: 2rem;
73
+ margin-bottom: 0;
74
+ line-height: 1;
75
+ }
76
+
77
+ hr {
78
+ display: block;
79
+ height: 1px;
80
+ width: 50%;
81
+ border: 0;
82
+ border-top: 1px solid black;
83
+ margin: 2em;
84
+ padding: 0;
85
+ }
86
+
87
+ p.subtitle {
88
+ font-style: italic;
89
+ margin-top: 1rem;
90
+ margin-bottom: 1rem;
91
+ font-size: 1.8rem;
92
+ display: block;
93
+ line-height: 1;
94
+ }
95
+
96
+ .numeral {
97
+ font-family: et-book-roman-old-style;
98
+ }
99
+
100
+ .danger {
101
+ color: red;
102
+ }
103
+
104
+ article {
105
+ position: relative;
106
+ padding: 5rem 0rem;
107
+ }
108
+
109
+ section {
110
+ padding-top: 1rem;
111
+ padding-bottom: 1rem;
112
+ }
113
+
114
+ p, ol, ul {
115
+ font-size: 1.4rem;
116
+ }
117
+
118
+ p {
119
+ line-height: 2rem;
120
+ margin-top: 1.4rem;
121
+ margin-bottom: 1.4rem;
122
+ padding-right: 0;
123
+ vertical-align: baseline;
124
+ }
125
+
126
+ /* Chapter Epigraphs */
127
+ div.epigraph { margin: 5em 0; }
128
+
129
+ div.epigraph > blockquote { margin-top: 3em;
130
+ margin-bottom: 3em; }
131
+
132
+ div.epigraph > blockquote, div.epigraph > blockquote > p { font-style: italic; }
133
+
134
+ div.epigraph > blockquote > footer { font-style: normal; }
135
+
136
+ div.epigraph > blockquote > footer > cite { font-style: italic; }
137
+
138
+ /* end chapter epigraphs styles */
139
+
140
+ blockquote { font-size: 1.4rem; }
141
+
142
+ blockquote p { width: 50%; }
143
+
144
+ blockquote footer {
145
+ width: 50%;
146
+ font-size: 1.1rem;
147
+ text-align: right;
148
+ }
149
+
150
+ ol, ul {
151
+ width: 55%;
152
+ width: 89%;
153
+ -webkit-padding-start: 5%;
154
+ -webkit-padding-end: 5%;
155
+ }
156
+
157
+ li {
158
+ /* padding: 0.5rem 0; */
159
+ }
160
+
161
+ figure {
162
+ padding: 0;
163
+ border: 0;
164
+ font-size: 100%;
165
+ font: inherit;
166
+ vertical-align: baseline;
167
+ max-width: 55%;
168
+ -webkit-margin-start: 0;
169
+ -webkit-margin-end: 0;
170
+ margin: 0 0 3em 0;
171
+ }
172
+
173
+ figcaption {
174
+ float: right;
175
+ clear: right;
176
+ margin-right: -48%;
177
+ margin-top: 0;
178
+ margin-bottom: 0;
179
+ font-size: 1.1rem;
180
+ line-height: 1.6;
181
+ vertical-align: baseline;
182
+ position: relative;
183
+ max-width: 40%;
184
+ }
185
+
186
+ figure.fullwidth figcaption { margin-right: 24%; }
187
+
188
+ /* Links: replicate underline that clears descenders */
189
+ a:link, a:visited { color: inherit; }
190
+
191
+ a:link {
192
+ text-decoration: none;
193
+ background: -webkit-linear-gradient(#fffff8, #fffff8), -webkit-linear-gradient(#fffff8, #fffff8), -webkit-linear-gradient(#333, #333);
194
+ background: linear-gradient(#fffff8, #fffff8), linear-gradient(#fffff8, #fffff8), linear-gradient(#333, #333);
195
+ -webkit-background-size: 0.05em 1px, 0.05em 1px, 1px 1px;
196
+ -moz-background-size: 0.05em 1px, 0.05em 1px, 1px 1px;
197
+ background-size: 0.05em 1px, 0.05em 1px, 1px 1px;
198
+ background-repeat: no-repeat, no-repeat, repeat-x;
199
+ text-shadow: 0.03em 0 #fffff8, -0.03em 0 #fffff8, 0 0.03em #fffff8, 0 -0.03em #fffff8, 0.06em 0 #fffff8, -0.06em 0 #fffff8, 0.09em 0 #fffff8, -0.09em 0 #fffff8, 0.12em 0 #fffff8, -0.12em 0 #fffff8, 0.15em 0 #fffff8, -0.15em 0 #fffff8;
200
+ background-position: 0% 93%, 100% 93%, 0% 93%;
201
+ }
202
+
203
+ #toc {
204
+ display: none;
205
+ }
206
+
207
+ video {
208
+ max-width: 100%;
209
+ }
210
+
211
+ @media screen and (-webkit-min-device-pixel-ratio: 0) { a:link { background-position-y: 87%, 87%, 87%; } }
212
+
213
+ a:link::selection { text-shadow: 0.03em 0 #b4d5fe, -0.03em 0 #b4d5fe, 0 0.03em #b4d5fe, 0 -0.03em #b4d5fe, 0.06em 0 #b4d5fe, -0.06em 0 #b4d5fe, 0.09em 0 #b4d5fe, -0.09em 0 #b4d5fe, 0.12em 0 #b4d5fe, -0.12em 0 #b4d5fe, 0.15em 0 #b4d5fe, -0.15em 0 #b4d5fe;
214
+ background: #b4d5fe; }
215
+
216
+ a:link::-moz-selection { text-shadow: 0.03em 0 #b4d5fe, -0.03em 0 #b4d5fe, 0 0.03em #b4d5fe, 0 -0.03em #b4d5fe, 0.06em 0 #b4d5fe, -0.06em 0 #b4d5fe, 0.09em 0 #b4d5fe, -0.09em 0 #b4d5fe, 0.12em 0 #b4d5fe, -0.12em 0 #b4d5fe, 0.15em 0 #b4d5fe, -0.15em 0 #b4d5fe;
217
+ background: #b4d5fe; }
218
+
219
+ /* Sidenotes, margin notes, figures, captions */
220
+ img {max-width: 100%;}
221
+
222
+ .image.right {
223
+ float: right;
224
+ }
225
+ .image.left {
226
+ float: left;
227
+ }
228
+
229
+ .footnote {
230
+ float: right;
231
+ clear: right;
232
+ margin-right: -60%;
233
+ width: 50%;
234
+ margin-top: 0;
235
+ margin-bottom: 0;
236
+ font-size: 1.1rem;
237
+ line-height: 1.3;
238
+ vertical-align: baseline;
239
+ position: relative;
240
+ }
241
+
242
+ .table-caption {
243
+ float:right;
244
+ clear:right;
245
+ margin-right: -60%;
246
+ width: 50%;
247
+ margin-top: 0;
248
+ margin-bottom: 0;
249
+ font-size: 1.0rem;
250
+ line-height: 1.6;
251
+ }
252
+
253
+ .footnote a:after, .footnote:before {
254
+ content: counter(sidenote-counter) " ";
255
+ font-family: et-book-roman-old-style;
256
+ position: relative;
257
+ vertical-align: baseline;
258
+ }
259
+
260
+ .footnote a:after {
261
+ content: counter(sidenote-counter);
262
+ font-size: 1rem;
263
+ top: -0.5rem;
264
+ left: 0.1rem;
265
+ }
266
+
267
+ .footnote:before {
268
+ content: counter(sidenote-counter) " ";
269
+ top: -0.5rem;
270
+ }
271
+
272
+ p, footer, table, div.table-wrapper-small, div.supertable-wrapper > p, div.booktabs-wrapper { width: 55%; }
273
+
274
+ div.fullwidth, table.fullwidth { width: 100%; }
275
+
276
+ div.table-wrapper {
277
+ overflow-x: auto;
278
+ font-family: "Trebuchet MS", "Gill Sans", "Gill Sans MT", sans-serif;
279
+ }
280
+
281
+ @media screen and (max-width: 760px) {
282
+ p, footer { width: 90%; }
283
+ pre.code { width: 87.5%; }
284
+ ul { width: 85%; }
285
+ figure { max-width: 90%; }
286
+ figcaption, figure.fullwidth figcaption {
287
+ margin-right: 0%;
288
+ max-width: none;
289
+ }
290
+ blockquote p, blockquote footer { width: 90%; }
291
+ }
292
+
293
+ .sans {
294
+ font-family: "Gill Sans", "Gill Sans MT", Calibri, sans-serif;
295
+ letter-spacing: .03em;
296
+ }
297
+
298
+ .code {
299
+ font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
300
+ font-size: 1.125rem;
301
+ line-height: 1.6;
302
+ }
303
+
304
+ h1 .code, h2 .code, h3 .code { font-size: 0.80em; }
305
+
306
+ .marginnote .code, .sidenote .code { font-size: 1rem; }
307
+
308
+ pre.code {
309
+ width: 52.5%;
310
+ padding-left: 2.5%;
311
+ overflow-x: auto;
312
+ }
313
+
314
+ .fullwidth {
315
+ max-width: 90%;
316
+ clear:both;
317
+ }
318
+
319
+ span.newthought {
320
+ font-variant: small-caps;
321
+ font-size: 1.2em;
322
+ }
323
+
324
+ input.margin-toggle { display: none; }
325
+
326
+ label.sidenote-number { display: inline; }
327
+
328
+ label.margin-toggle:not(.sidenote-number) { display: none; }
329
+
330
+ @media (max-width: 760px) {
331
+ label.margin-toggle:not(.sidenote-number) {
332
+ display: inline;
333
+ }
334
+ .footnote, .marginnote {
335
+ display: none;
336
+ }
337
+ .margin-toggle:checked + .sidenote, .margin-toggle:checked + .marginnote {
338
+ display: block;
339
+ float: left;
340
+ left: 1rem;
341
+ clear: both;
342
+ width: 95%;
343
+ margin: 1rem 2.5%;
344
+ vertical-align: baseline;
345
+ position: relative;
346
+ }
347
+ label {
348
+ cursor: pointer;
349
+ }
350
+ pre.code {
351
+ width: 90%;
352
+ padding: 0;
353
+ }
354
+ .table-caption {
355
+ display: block;
356
+ float: right;
357
+ clear: both;
358
+ width: 98%;
359
+ margin-top: 1rem;
360
+ margin-bottom: 0.5rem;
361
+ margin-left: 1%;
362
+ margin-right: 1%;
363
+ vertical-align: baseline;
364
+ position: relative;
365
+ }
366
+ div.table-wrapper, table, table.booktabs {
367
+ width: 85%;
368
+ }
369
+ div.table-wrapper {
370
+ border-right: 1px solid #efefef;
371
+ }
372
+ img {
373
+ width: 100%;
374
+ }
375
+ }
376
+ .sidenote,
377
+ .marginnote {
378
+ float: right;
379
+ clear: right;
380
+ margin-right: -60%;
381
+ width: 50%;
382
+ margin-top: 0;
383
+ margin-bottom: 0;
384
+ font-size: 1.1rem;
385
+ line-height: 1.3;
386
+ vertical-align: baseline;
387
+ position: relative;
388
+ }
389
+
390
+ .sidenote-number {
391
+ counter-increment: sidenote-counter;
392
+ }
393
+
394
+ .sidenote-number:after,
395
+ .sidenote:before {
396
+ font-family: et-book-roman-old-style;
397
+ position: relative;
398
+ vertical-align: baseline;
399
+ }
400
+
401
+ .sidenote-number:after {
402
+ content: counter(sidenote-counter);
403
+ font-size: 1rem;
404
+ top: -0.5rem;
405
+ left: 0.1rem;
406
+ }
407
+
408
+ .sidenote:before {
409
+ content: counter(sidenote-counter) " ";
410
+ font-size: 1rem;
411
+ top: -0.5rem;
412
+ }
413
+
414
+ blockquote .sidenote,
415
+ blockquote .marginnote {
416
+ margin-right: -82%;
417
+ min-width: 59%;
418
+ text-align: left;
419
+ }