Skip to content

Commit f3dd858

Browse files
committed
To read -> Reading list
1 parent 6c40d8e commit f3dd858

File tree

6 files changed

+29
-29
lines changed

6 files changed

+29
-29
lines changed

Diff for: .github/workflows/cron-wishlist.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414

1515
env:
1616
DENO_VERSION: v1.40.3
17-
TO_READ_PATH: 'src/_data/toread.yml'
17+
READING_LIST_PATH: 'src/_data/reading_list.yml'
1818

1919
permissions:
2020
contents: write # to checkout repo and write back log file
@@ -32,14 +32,14 @@ jobs:
3232
with:
3333
deno-version: ${{ env.DENO_VERSION }}
3434

35-
- name: Fetch and sync into toread.yml
35+
- name: Fetch and sync into reading list
3636
run: |
3737
output=$(deno run --allow-net --allow-read --allow-env ./script/fetch-kobo-wishlist.ts)
3838
ec=$?
3939
[[ $ec -eq 0 && -n "$output" ]] && \
40-
echo "$output" >> "$to_read" || ([[ $ec -eq 10 ]] && echo "$output")
40+
echo "$output" >> "$reading_list" || ([[ $ec -eq 10 ]] && echo "$output")
4141
env:
42-
to_read: ${{ env.TO_READ_PATH }}
42+
reading_list: ${{ env.READING_LIST_PATH }}
4343
KOBO_ACCESS_TOKEN: ${{ secrets.KOBO_ACCESS_TOKEN }}
4444
KOBO_REFRESH_TOKEN: ${{ secrets.KOBO_REFRESH_TOKEN }}
4545

@@ -49,8 +49,8 @@ jobs:
4949
git pull
5050
git config user.name "Automated"
5151
git config user.email "[email protected]"
52-
git add "$to_read"
53-
git commit -m "Update 'To Read' from Johan's Kobo wishlist" || exit 0
52+
git add "$reading_list"
53+
git commit -m "Update reading list from Johan's Kobo wishlist" || exit 0
5454
git push
5555
env:
56-
to_read: ${{ env.TO_READ_PATH }}
56+
reading_list: ${{ env.READING_LIST_PATH }}

Diff for: api/model/to-read.ts renamed to api/model/reading-list.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ import * as Yaml from 'jsr:@std/yaml';
44
import { slug } from 'slug';
55
import { join } from 'std/path/mod.ts';
66

7-
const TO_READ_PATH = 'src/_data/toread.yml';
7+
const READING_LIST_PATH = 'src/_data/reading_list.yml';
88

9-
export interface ToReadBook {
9+
export interface ReadingListBook {
1010
title: string;
1111
author: string;
1212
notes?: string;
1313
addedAt?: Date;
1414
isbn?: string;
1515
}
1616

17-
export const findAll = async (store: FileHost): Promise<ToReadBook[]> => {
18-
const raw = await store.getFile(TO_READ_PATH);
17+
export const findAll = async (store: FileHost): Promise<ReadingListBook[]> => {
18+
const raw = await store.getFile(READING_LIST_PATH);
1919

2020
if (!raw) return [];
2121

2222
return booksArrayOf(raw);
2323
};
2424

25-
export const add = async (store: FileHost, input: ToReadBook): Promise<[ToReadBook, string]> => {
25+
export const add = async (store: FileHost, input: ReadingListBook): Promise<[ReadingListBook, string]> => {
2626
const books = await findAll(store);
2727

2828
if (books.find((b) => slug(b.title) == slug(input.title))) {
@@ -32,43 +32,43 @@ export const add = async (store: FileHost, input: ToReadBook): Promise<[ToReadBo
3232
);
3333
}
3434

35-
const raw = await store.getFile(TO_READ_PATH);
35+
const raw = await store.getFile(READING_LIST_PATH);
3636

3737
const str = Yaml.stringify([input]);
3838

3939
const final = raw + '\n' + str;
4040

4141
const fullPath = await store.putFile(
4242
final,
43-
join(TO_READ_PATH),
43+
join(READING_LIST_PATH),
4444
);
4545

4646
return [input, fullPath];
4747
};
4848

49-
export const addMany = async (store: FileHost, todo: ToReadBook[]) => {
49+
export const addMany = async (store: FileHost, todo: ReadingListBook[]) => {
5050
if (!todo.length) return 0;
5151

52-
const raw = await store.getFile(TO_READ_PATH);
52+
const raw = await store.getFile(READING_LIST_PATH);
5353

5454
const str = Yaml.stringify(todo);
5555

5656
const final = raw + '\n' + str;
5757

5858
await store.putFile(
5959
final,
60-
join(TO_READ_PATH),
60+
join(READING_LIST_PATH),
6161
);
6262

6363
return todo.length;
6464
};
6565

66-
const booksArrayOf = (raw: string): ToReadBook[] => {
66+
const booksArrayOf = (raw: string): ReadingListBook[] => {
6767
const books = Yaml.parse(raw);
6868

6969
if (!Array.isArray(books)) {
70-
throw new ProblemError(ProblemKind.InconsistentFile, `${TO_READ_PATH} isn't a YAML array`);
70+
throw new ProblemError(ProblemKind.InconsistentFile, `${READING_LIST_PATH} isn't a YAML array`);
7171
}
7272

73-
return books as ToReadBook[];
73+
return books as ReadingListBook[];
7474
};

Diff for: script/fetch-kobo-wishlist.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { encodeBase64 } from 'jsr:@std/encoding/base64';
22
import { slug } from 'slug';
33
import * as Yaml from 'jsr:@std/yaml';
44
import { join } from 'jsr:@std/path';
5-
import { type ToReadBook } from '../api/model/to-read.ts';
5+
import { type ReadingListBook } from '../api/model/reading-list.ts';
66

7-
const TO_READ_PATH = 'src/_data/toread.yml';
7+
const READING_LIST_PATH = 'src/_data/reading_list.yml';
88

99
// Rewritten from Python (https://github.com/subdavis/kobo-book-downloader/blob/main/kobodl/kobo.py) by Johan.
1010
// Huge props to the great reverse engineering by them.
@@ -52,15 +52,15 @@ interface WishlistItem {
5252
}
5353

5454
const diffOf = async (wishlist: WishlistItem[]) => {
55-
const books = wishlist.map<ToReadBook>((w) => ({
55+
const books = wishlist.map<ReadingListBook>((w) => ({
5656
title: w.ProductMetadata.Book.Title,
5757
author: w.ProductMetadata.Book.Contributors,
5858
addedAt: new Date(w.DateAdded),
5959
isbn: w.ProductMetadata.Book.ISBN,
6060
})).sort((b1, b2) => b1.addedAt!.getTime() - b2.addedAt!.getTime());
6161

62-
const yml = await Deno.readTextFile(join(Deno.cwd(), TO_READ_PATH));
63-
const all = Yaml.parse(yml) as ToReadBook[];
62+
const yml = await Deno.readTextFile(join(Deno.cwd(), READING_LIST_PATH));
63+
const all = Yaml.parse(yml) as ReadingListBook[];
6464

6565
const diff = books.filter((b1) => !all.find((b2) => slug(b1.title.trim()) == slug(b2.title.trim())));
6666

File renamed without changes.

Diff for: src/to-read.njk renamed to src/reading-list.njk

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: Want to read
2+
title: Reading list
33
layout: layouts/page.njk
4-
description: Books which are on my reading list.
4+
description: Books I want to read.
55
---
66

77
<table>
@@ -12,7 +12,7 @@ description: Books which are on my reading list.
1212
<th scope="column">Notes</th>
1313
</tr>
1414
</thead>
15-
{% for book in toread | reverse %}
15+
{% for book in reading_list | reverse %}
1616
<tr id="{{ book.slug }}">
1717
<th scope="row">
1818
{{ book.title }}

Diff for: src/reading.vto

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ menu:
2828
<h1 class="title p-name">{{ title }}</h1>
2929

3030
<p class="subhead">
31-
Non-exhaustive list of books I've read and am reading, in reverse chronological order. You can also check out what I <a href="/to-read">want to read next.</a>
31+
Non-exhaustive list of books I've read and am reading, in reverse chronological order. You can also check out what I <a href="/reading-list">want to read next.</a>
3232
</p>
3333
</header>
3434

0 commit comments

Comments
 (0)