-
Notifications
You must be signed in to change notification settings - Fork 0
/
NewBookTasks.yml
216 lines (183 loc) · 6.56 KB
/
NewBookTasks.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
version: '3'
tasks:
completed.de:
desc: Add new german book to booklist 'completed'.
summary: |
Add new german book to booklist 'completed'.
Required variables:
-------------------
* ID: Either a ISBN 13 or an IDN of the Deutsche National Bibliothek of the book to be added.
Examples:
---------
> ID=978-3-641-26688-2 task {{.TASK}}
> ID=740105604 task {{.TASK}}
cmds:
- task: _completed-book
vars:
LANGUAGE: '{{ last (splitList "." .TASK) }}'
- task: _new-book-content-management
completed.en:
desc: Add new english book to booklist 'completed'.
summary: |
Add new english book to booklist 'completed'.
Required variables:
-------------------
* ID: ISBN 13 of the book to add.
Example:
--------
> ID=978-1-80336-191-3 task {{.TASK}}
cmds:
- task: _completed-book
vars:
LANGUAGE: '{{ last (splitList "." .TASK) }}'
- task: _new-book-content-management
crawl-synopsis:
desc: Crawl synopsis for a book from external website.
summary: |
Crawl synopsis for a book from external website.
The book's 'params.references[rel="synopsis"]' front matter attribute needs to point to the external website.
Required variables:
-------------------
* BOOK: Path to content file of a book.
* SELECTOR: CSS selector of the website's section containing the book synopsis.
Example:
--------
> BOOK=./content/books/978-3-641-26688-2.md SELECTOR='p#description' task {{.TASK}}
vars:
SOURCE:
sh: yq --front-matter='extract' '.params.references.[] | select (.rel == "synopsis") | .uri' {{.BOOK}} | tr -d '\n'
cmds:
- curl --silent {{.SOURCE}} | htmlq --text '{{.SELECTOR}}' | fold -w 80 -s | xargs -0 printf "\n\n%s" >> {{.BOOK}}
download-cover:
desc: Download book cover.
summary: |
Download book cover.
The book's 'params.references[rel="cover"]' front matter attribute needs to point to the cover.
Note: The file is saved under the name specified by the server. Please check whether and which file name extension needs to be added.
This can be achieved, for example, by using the command `file <path-to-cover-file` on *nix systems.
Required variables:
-------------------
* BOOK: Path to content file of a book.
Example:
--------
> BOOK=./content/books/978-3-641-26688-2.md task {{.TASK}}
vars:
SOURCE:
sh: yq --front-matter='extract' '.params.references.[] | select (.rel == "cover") | .uri' {{.BOOK}} | tr -d '\n'
cmds:
- curl --silent {{.SOURCE}} -O --output-dir $(dirname {{.BOOK}})
unread.de:
desc: Add new german book to booklist 'unread'.
summary: |
Add new german book to booklist 'unread'.
Required variables:
-------------------
* ID: Either a ISBN 13 or an IDN of the Deutsche National Bibliothek of the book to be added.
Examples:
---------
> ID=978-3-641-26688-2 task {{.TASK}}
> ID=740105604 task {{.TASK}}
cmds:
- task: _unread-book
vars:
BOOKLIST: 'unread'
LANGUAGE: '{{ last (splitList "." .TASK) }}'
- task: _new-book-content-management
unread.en:
desc: Add new english book to booklist 'unread'.
summary: |
Add new english book to booklist 'unread'.
Required variables:
-------------------
* ID: ISBN 13 of the book to add.
Example:
--------
> ID=978-1-80336-191-3 task {{.TASK}}
cmds:
- task: _unread-book
vars:
BOOKLIST: 'unread'
LANGUAGE: '{{ last (splitList "." .TASK) }}'
- task: _new-book-content-management
wishlist.de:
desc: Add new german book to booklist 'wishlist'.
summary: |
Add new german book to booklist 'wishlist'.
Required variables:
-------------------
* ID: Either a ISBN 13 or an IDN of the Deutsche National Bibliothek of the book to be added.
Examples:
---------
> ID=978-3-641-26688-2 task {{.TASK}}
> ID=740105604 task {{.TASK}}
cmds:
- task: _unread-book
vars:
BOOKLIST: 'wishlist'
LANGUAGE: '{{ last (splitList "." .TASK) }}'
- task: _new-book-content-management
wishlist.en:
desc: Add new english book to booklist 'wishlist'.
summary: |
Add new english book to booklist 'wishlist'.
Required variables:
-------------------
* ID: ISBN 13 of the book to add.
Example:
--------
> ID=978-1-80336-191-3 task {{.TASK}}
cmds:
- task: _unread-book
vars:
LANGUAGE: '{{ last (splitList "." .TASK) }}'
BOOKLIST: 'wishlist'
- task: _new-book-content-management
_add-to-vcs:
internal: true
cmds:
- git add {{.REF}}
_completed-book:
internal: true
vars:
FORMATTED_ID:
sh: jbang --quiet ./script/isbn13.java '{{.ID}}' 2>/dev/null || echo '{{.ID}}'
TARGET: 'books/{{.FORMATTED_ID}}'
cmds:
- echo "Create completed book for ID {{.FORMATTED_ID}}"
- hugo new content --kind books.{{.LANGUAGE}} {{.TARGET}}/index.md
- task: _update-booklist
vars:
BOOKLIST: 'completed'
TARGET: 'content/{{.TARGET}}/index.md'
- cp ./archetypes/review.md.dist content/{{.TARGET}}/review.md
- task: _add-to-vcs
vars:
REF: 'content/{{.TARGET}}/'
_new-book-content-management:
internal: true
cmds:
- echo "1. Open the newly generated file."
- echo "2. Adjust the front matter field 'topics'."
- echo "3. To fulfill the obligation to indicate the source of supply, e.g. the publisher's landing page of the book, adjust the front matter field 'params.references[rel="synopsis"]' accordingly."
- echo "4. Discover the book synopsis' CSS selector path"
- echo "5. Crawl the synopsis of the book."
_unread-book:
internal: true
vars:
FORMATTED_ID:
sh: jbang --quiet ./script/isbn13.java '{{.ID}}' 2>/dev/null || echo '{{.ID}}'
TARGET: 'books/{{.FORMATTED_ID}}/index.md'
cmds:
- echo "Create {{.BOOKLIST}} book for ID {{.FORMATTED_ID}}"
- hugo new content --kind books.{{.LANGUAGE}} {{.TARGET}}
- task: _update-booklist
vars:
BOOKLIST: '{{.BOOKLIST}}'
TARGET: 'content/{{.TARGET}}'
- task: _add-to-vcs
vars:
REF: 'content/{{.TARGET}}'
_update-booklist:
internal: true
cmds:
- yq --front-matter=process -i '.booklists = ["{{.BOOKLIST}}"]' {{.TARGET}}