From 02f5443a3eb013282e8485a5697a5a669285d7e2 Mon Sep 17 00:00:00 2001 From: JP Hastings-Spital Date: Tue, 30 Apr 2024 11:42:39 +0100 Subject: [PATCH] Simplify books --- content/memex/art-design/_index.md | 4 ++-- content/notes/adventure.md | 2 +- content/notes/good-morning.md | 2 +- .../notes/twitter/27993779155767297/index.md | 10 ---------- .../notes/twitter/45191576900734976/index.md | 11 ----------- content/now/index.md | 2 +- .../books/alan-lightman/einsteins-dreams.md | 2 +- .../charles-stross/accelerando-singularity.md | 2 +- .../reviews/books/daniil-kharms/incidences.md | 2 +- .../ready-player-one-ready-player-one-1-.md | 2 +- .../books/iain-m-banks/consider-phlebas.md | 2 +- .../jasper-fforde/lost-in-a-good-book.md | 2 +- .../books/jasper-fforde/the-eyre-affair.md | 2 +- .../books/john-scalzi/the-consuming-fire.md | 2 +- .../books/john-scalzi/the-human-division.md | 2 +- .../reviews/books/ken-macleod/intrusion.md | 2 +- .../books/kim-stanley-robinson/2312.md | 2 +- .../books/neil-gaiman/make-good-art.md | 2 +- ...-pilgrimage-of-harold-fry-harold-fry-1-.md | 2 +- ...-the-strange-theory-of-light-and-matter.md | 2 +- .../mr-penumbras-24-hour-bookstore.md | 2 +- .../reviews/books/ryan-north/poor-yorick.md | 2 +- .../books/steven-hall/the-raw-shark-texts.md | 2 +- .../reviews/books/terry-pratchett/sourcery.md | 2 +- layouts/partials/markdown.gmi | 2 +- .../openlibrary.obj} | 19 ++++++++++++------- layouts/shortcodes/book.gmi | 8 ++++++++ layouts/{partials => shortcodes}/book.html | 6 +++++- 28 files changed, 49 insertions(+), 53 deletions(-) delete mode 100644 content/notes/twitter/27993779155767297/index.md delete mode 100644 content/notes/twitter/45191576900734976/index.md rename layouts/{shortcodes/openlibrary.html => partials/openlibrary.obj} (80%) create mode 100644 layouts/shortcodes/book.gmi rename layouts/{partials => shortcodes}/book.html (85%) diff --git a/content/memex/art-design/_index.md b/content/memex/art-design/_index.md index 69f3f95e..b161ef88 100644 --- a/content/memex/art-design/_index.md +++ b/content/memex/art-design/_index.md @@ -4,8 +4,8 @@ emoji: 🎨 summary: Making things look good for fun. --- -{{< openlibrary "9781914236105" >}} +{{< book "9781914236105" >}} -I love making things. Recently bought a mini book at the Tate in Liverpool called [Art is the thing nobody asked you to do](https://roughtradebooks.com/products/art-is-the-thing-nobody-asked-you-to-do-babak-ganjei), and without even picking it up I felt a connection with that description of art. I _do_ love creating things, but often its the unnecessary things, the expressive and intriguing ones, that I enjoy the most. +I love making things. I recently bought a mini book at the Tate in Liverpool called [Art is the thing nobody asked you to do](https://roughtradebooks.com/products/art-is-the-thing-nobody-asked-you-to-do-babak-ganjei), and without even picking it up I felt a connection with that description of art. I _do_ love creating things, but often its the unnecessary things, the expressive and intriguing ones, that I enjoy the most. I look forward to reading that book, and to this section of the memex growing quickly! diff --git a/content/notes/adventure.md b/content/notes/adventure.md index 4ba9fa2b..4e2185cd 100644 --- a/content/notes/adventure.md +++ b/content/notes/adventure.md @@ -7,4 +7,4 @@ tags: > \[They] flock, beckoned by adventure \[…] it calls to those who care more for living than for their lives. -From {{< openlibrary "9781534430990" false >}}. +From {{< book "9781534430990" false >}}. diff --git a/content/notes/good-morning.md b/content/notes/good-morning.md index 581bc77a..4eb29752 100644 --- a/content/notes/good-morning.md +++ b/content/notes/good-morning.md @@ -5,6 +5,6 @@ tags: - quote --- -What a beautiful quote from {{< openlibrary "9781786699602" false >}}: +What a beautiful quote from {{< book "9781786699602" false >}}: > \[…] greeting even our dearest with abbreviations like β€˜Good morning’ when the true thought in our breast is β€˜Every day you step into my life, you make it brighter, and if you left the world, something in me would starve for you forever, as when some barrier rises to shade a plant, which still has light enough to grow some but will never again taste the unbroken sun.’ diff --git a/content/notes/twitter/27993779155767297/index.md b/content/notes/twitter/27993779155767297/index.md deleted file mode 100644 index a4f5ac1a..00000000 --- a/content/notes/twitter/27993779155767297/index.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -date: "2011-01-20T07:40:11Z" -tags: -- imported -- from-twitter ---- - -{{< openlibrary "OL34954380W" >}} - -Marked as to-read: The Old Man and the Sea by Ernest Hemingway diff --git a/content/notes/twitter/45191576900734976/index.md b/content/notes/twitter/45191576900734976/index.md deleted file mode 100644 index 44d33657..00000000 --- a/content/notes/twitter/45191576900734976/index.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -date: "2011-03-08T18:38:06Z" -tags: -- imported -- from-twitter -- reading ---- - -{{< openlibrary "OL5703422W" >}} - -I'm [reading](/tags/reading) Jonathan Strange & Mr Norrell by Susanna Clarke diff --git a/content/now/index.md b/content/now/index.md index fbbe89ba..9fcb3406 100644 --- a/content/now/index.md +++ b/content/now/index.md @@ -30,7 +30,7 @@ sitemap: {{< emoji "πŸ“–" >}}I'm only a few pages into [Cheap Complex Devices](https://openlibrary.org/books/OL8797982M/Cheap_Complex_Devices) and already loving it. Even the foreword has me thinking meta: should I trust the editor of the book when he says "skip the rest of the foreword", given that the editor is a character?? It's definitely not a book for sleepy bedtime reading! -{{< openlibrary "OL49368138M" >}} +{{< book "/books/OL49368138M" >}} {{< emoji "🎧" >}}A few days ago I pulled out [Kitty Cat Kill Sat](https://openlibrary.org/works/OL36523390W/Kitty_Cat_Kill_Sat) on Audible as something relaxing to listen to with house chores and travel β€” what a win! It's fun, playful, _gripping_ and lighthearted without being frivolous. I'm absolutely steaming through it! diff --git a/content/posts/reviews/books/alan-lightman/einsteins-dreams.md b/content/posts/reviews/books/alan-lightman/einsteins-dreams.md index 675b0d05..34f96c7e 100644 --- a/content/posts/reviews/books/alan-lightman/einsteins-dreams.md +++ b/content/posts/reviews/books/alan-lightman/einsteins-dreams.md @@ -13,7 +13,7 @@ syndications: - https://www.goodreads.com/review/show/610034736 --- -{{< openlibrary "9781400077809" >}} +{{< book "9781400077809" >}} {{% importnote 2023-07-27 %}} Back when I wrote Goodreads reviews, I tried to keep them short & sweet β€” which makes them seem a little out of place here on this blog! diff --git a/content/posts/reviews/books/charles-stross/accelerando-singularity.md b/content/posts/reviews/books/charles-stross/accelerando-singularity.md index c99ace97..c072844d 100644 --- a/content/posts/reviews/books/charles-stross/accelerando-singularity.md +++ b/content/posts/reviews/books/charles-stross/accelerando-singularity.md @@ -13,7 +13,7 @@ syndications: - https://www.goodreads.com/review/show/604252422 --- -{{< openlibrary "9780441014156" >}} +{{< book "9780441014156" >}} {{% importnote 2023-07-27 %}} Back when I wrote Goodreads reviews, I tried to keep them short & sweet β€” which makes them seem a little out of place here on this blog! diff --git a/content/posts/reviews/books/daniil-kharms/incidences.md b/content/posts/reviews/books/daniil-kharms/incidences.md index 2c5a4e5d..15081ab4 100644 --- a/content/posts/reviews/books/daniil-kharms/incidences.md +++ b/content/posts/reviews/books/daniil-kharms/incidences.md @@ -13,7 +13,7 @@ syndications: - https://www.goodreads.com/review/show/111896935 --- -{{< openlibrary "9781852424800" >}} +{{< book "9781852424800" >}} {{% importnote 2023-07-27 %}} Back when I wrote Goodreads reviews, I tried to keep them short & sweet β€” which makes them seem a little out of place here on this blog! diff --git a/content/posts/reviews/books/ernest-cline/ready-player-one-ready-player-one-1-.md b/content/posts/reviews/books/ernest-cline/ready-player-one-ready-player-one-1-.md index f7fe2327..7e044cda 100644 --- a/content/posts/reviews/books/ernest-cline/ready-player-one-ready-player-one-1-.md +++ b/content/posts/reviews/books/ernest-cline/ready-player-one-ready-player-one-1-.md @@ -13,7 +13,7 @@ syndications: - https://www.goodreads.com/review/show/202287308 --- -{{< openlibrary "9780307887436" >}} +{{< book "9780307887436" >}} {{% importnote 2023-07-27 %}} Back when I wrote Goodreads reviews, I tried to keep them short & sweet β€” which makes them seem a little out of place here on this blog! diff --git a/content/posts/reviews/books/iain-m-banks/consider-phlebas.md b/content/posts/reviews/books/iain-m-banks/consider-phlebas.md index 7d762f43..89c62f3f 100644 --- a/content/posts/reviews/books/iain-m-banks/consider-phlebas.md +++ b/content/posts/reviews/books/iain-m-banks/consider-phlebas.md @@ -13,7 +13,7 @@ syndications: - https://www.goodreads.com/review/show/316204375 --- -{{< openlibrary "9781857231380" >}} +{{< book "9781857231380" >}} {{% importnote 2023-07-27 %}} Back when I wrote Goodreads reviews, I tried to keep them short & sweet β€” which makes them seem a little out of place here on this blog! diff --git a/content/posts/reviews/books/jasper-fforde/lost-in-a-good-book.md b/content/posts/reviews/books/jasper-fforde/lost-in-a-good-book.md index c57a37c1..513da5dc 100644 --- a/content/posts/reviews/books/jasper-fforde/lost-in-a-good-book.md +++ b/content/posts/reviews/books/jasper-fforde/lost-in-a-good-book.md @@ -13,7 +13,7 @@ syndications: - https://www.goodreads.com/review/show/695460156 --- -{{< openlibrary "9780142004036" >}} +{{< book "9780142004036" >}} {{% importnote 2023-07-27 %}} Back when I wrote Goodreads reviews, I tried to keep them short & sweet β€” which makes them seem a little out of place here on this blog! diff --git a/content/posts/reviews/books/jasper-fforde/the-eyre-affair.md b/content/posts/reviews/books/jasper-fforde/the-eyre-affair.md index bfae97e4..a6dff28b 100644 --- a/content/posts/reviews/books/jasper-fforde/the-eyre-affair.md +++ b/content/posts/reviews/books/jasper-fforde/the-eyre-affair.md @@ -13,7 +13,7 @@ syndications: - https://www.goodreads.com/review/show/687343966 --- -{{< openlibrary "9780142001806" >}} +{{< book "9780142001806" >}} {{% importnote 2023-07-27 %}} Back when I wrote Goodreads reviews, I tried to keep them short & sweet β€” which makes them seem a little out of place here on this blog! diff --git a/content/posts/reviews/books/john-scalzi/the-consuming-fire.md b/content/posts/reviews/books/john-scalzi/the-consuming-fire.md index b2bf50ed..e828af7c 100644 --- a/content/posts/reviews/books/john-scalzi/the-consuming-fire.md +++ b/content/posts/reviews/books/john-scalzi/the-consuming-fire.md @@ -13,7 +13,7 @@ syndications: - https://www.goodreads.com/review/show/2569740480 --- -{{< openlibrary "9781509835171" >}} +{{< book "9781509835171" >}} {{% importnote 2023-07-27 %}} Back when I wrote Goodreads reviews, I tried to keep them short & sweet β€” which makes them seem a little out of place here on this blog! diff --git a/content/posts/reviews/books/john-scalzi/the-human-division.md b/content/posts/reviews/books/john-scalzi/the-human-division.md index 76fb9348..4fd3c1de 100644 --- a/content/posts/reviews/books/john-scalzi/the-human-division.md +++ b/content/posts/reviews/books/john-scalzi/the-human-division.md @@ -13,7 +13,7 @@ syndications: - https://www.goodreads.com/review/show/604255023 --- -{{< openlibrary "9780765333513" >}} +{{< book "9780765333513" >}} {{% importnote 2023-07-27 %}} Back when I wrote Goodreads reviews, I tried to keep them short & sweet β€” which makes them seem a little out of place here on this blog! diff --git a/content/posts/reviews/books/ken-macleod/intrusion.md b/content/posts/reviews/books/ken-macleod/intrusion.md index f2f95a8d..b2218572 100644 --- a/content/posts/reviews/books/ken-macleod/intrusion.md +++ b/content/posts/reviews/books/ken-macleod/intrusion.md @@ -13,7 +13,7 @@ syndications: - https://www.goodreads.com/review/show/566131190 --- -{{< openlibrary "9781841499390" >}} +{{< book "9781841499390" >}} {{% importnote 2023-07-27 %}} Back when I wrote Goodreads reviews, I tried to keep them short & sweet β€” which makes them seem a little out of place here on this blog! diff --git a/content/posts/reviews/books/kim-stanley-robinson/2312.md b/content/posts/reviews/books/kim-stanley-robinson/2312.md index 5753053a..d6aa5707 100644 --- a/content/posts/reviews/books/kim-stanley-robinson/2312.md +++ b/content/posts/reviews/books/kim-stanley-robinson/2312.md @@ -13,7 +13,7 @@ syndications: - https://www.goodreads.com/review/show/604253366 --- -{{< openlibrary "9780316098120" >}} +{{< book "9780316098120" >}} {{% importnote 2023-07-27 %}} Back when I wrote Goodreads reviews, I tried to keep them short & sweet β€” which makes them seem a little out of place here on this blog! diff --git a/content/posts/reviews/books/neil-gaiman/make-good-art.md b/content/posts/reviews/books/neil-gaiman/make-good-art.md index 9d58bb54..9bf0e3b8 100644 --- a/content/posts/reviews/books/neil-gaiman/make-good-art.md +++ b/content/posts/reviews/books/neil-gaiman/make-good-art.md @@ -13,7 +13,7 @@ syndications: - https://www.goodreads.com/review/show/808658340 --- -{{< openlibrary "9780062266767" >}} +{{< book "9780062266767" >}} {{% importnote 2023-07-27 %}} Back when I wrote Goodreads reviews, I tried to keep them short & sweet β€” which makes them seem a little out of place here on this blog! diff --git a/content/posts/reviews/books/rachel-joyce/the-unlikely-pilgrimage-of-harold-fry-harold-fry-1-.md b/content/posts/reviews/books/rachel-joyce/the-unlikely-pilgrimage-of-harold-fry-harold-fry-1-.md index e46fe38b..8f3f6d87 100644 --- a/content/posts/reviews/books/rachel-joyce/the-unlikely-pilgrimage-of-harold-fry-harold-fry-1-.md +++ b/content/posts/reviews/books/rachel-joyce/the-unlikely-pilgrimage-of-harold-fry-harold-fry-1-.md @@ -13,7 +13,7 @@ syndications: - https://www.goodreads.com/review/show/687343274 --- -{{< openlibrary "9780812993295" >}} +{{< book "9780812993295" >}} {{% importnote 2023-07-27 %}} Back when I wrote Goodreads reviews, I tried to keep them short & sweet β€” which makes them seem a little out of place here on this blog! diff --git a/content/posts/reviews/books/richard-p-feynman/qed-the-strange-theory-of-light-and-matter.md b/content/posts/reviews/books/richard-p-feynman/qed-the-strange-theory-of-light-and-matter.md index f90a6d00..ed0804cf 100644 --- a/content/posts/reviews/books/richard-p-feynman/qed-the-strange-theory-of-light-and-matter.md +++ b/content/posts/reviews/books/richard-p-feynman/qed-the-strange-theory-of-light-and-matter.md @@ -13,7 +13,7 @@ syndications: - https://www.goodreads.com/review/show/224218792 --- -{{< openlibrary "9780140125054" >}} +{{< book "9780140125054" >}} {{% importnote 2023-07-27 %}} Back when I wrote Goodreads reviews, I tried to keep them short & sweet β€” which makes them seem a little out of place here on this blog! diff --git a/content/posts/reviews/books/robin-sloan/mr-penumbras-24-hour-bookstore.md b/content/posts/reviews/books/robin-sloan/mr-penumbras-24-hour-bookstore.md index 1a5f0f76..c866eb2a 100644 --- a/content/posts/reviews/books/robin-sloan/mr-penumbras-24-hour-bookstore.md +++ b/content/posts/reviews/books/robin-sloan/mr-penumbras-24-hour-bookstore.md @@ -13,7 +13,7 @@ syndications: - https://www.goodreads.com/review/show/698555776 --- -{{< openlibrary "9781782391210" >}} +{{< book "9781782391210" >}} {{% importnote 2023-07-27 %}} Back when I wrote Goodreads reviews, I tried to keep them short & sweet β€” which makes them seem a little out of place here on this blog! diff --git a/content/posts/reviews/books/ryan-north/poor-yorick.md b/content/posts/reviews/books/ryan-north/poor-yorick.md index de6a6e92..d0c4e141 100644 --- a/content/posts/reviews/books/ryan-north/poor-yorick.md +++ b/content/posts/reviews/books/ryan-north/poor-yorick.md @@ -13,7 +13,7 @@ syndications: - https://www.goodreads.com/review/show/808640102 --- -{{< openlibrary "/books/OL49208407M" >}} +{{< book "/books/OL49208407M" >}} {{% importnote 2023-07-27 %}} Back when I wrote Goodreads reviews, I tried to keep them short & sweet β€” which makes them seem a little out of place here on this blog! diff --git a/content/posts/reviews/books/steven-hall/the-raw-shark-texts.md b/content/posts/reviews/books/steven-hall/the-raw-shark-texts.md index 409efcf3..0a3f7dc7 100644 --- a/content/posts/reviews/books/steven-hall/the-raw-shark-texts.md +++ b/content/posts/reviews/books/steven-hall/the-raw-shark-texts.md @@ -13,7 +13,7 @@ syndications: - https://www.goodreads.com/review/show/879236135 --- -{{< openlibrary "9781847670243" >}} +{{< book "9781847670243" >}} {{% importnote 2023-07-27 %}} Back when I wrote Goodreads reviews, I tried to keep them short & sweet β€” which makes them seem a little out of place here on this blog! diff --git a/content/posts/reviews/books/terry-pratchett/sourcery.md b/content/posts/reviews/books/terry-pratchett/sourcery.md index 2c552c86..277fdbdf 100644 --- a/content/posts/reviews/books/terry-pratchett/sourcery.md +++ b/content/posts/reviews/books/terry-pratchett/sourcery.md @@ -13,7 +13,7 @@ syndications: - https://www.goodreads.com/review/show/111897239 --- -{{< openlibrary "9780451162335" >}} +{{< book "9780451162335" >}} {{% importnote 2023-07-27 %}} Back when I wrote Goodreads reviews, I tried to keep them short & sweet β€” which makes them seem a little out of place here on this blog! diff --git a/layouts/partials/markdown.gmi b/layouts/partials/markdown.gmi index d020eb68..eff281b9 100644 --- a/layouts/partials/markdown.gmi +++ b/layouts/partials/markdown.gmi @@ -9,7 +9,7 @@ {{/* Swap out unsupported list types */}} {{- $content := $content | replaceRE `\n- (.+?)` "\n* $1" -}} - {{- $content := $content | replaceRE `\n(\d+). (.+?)` "\n* $2" -}} + {{- $content := $content | replaceRE `\n(\d+)\. (.+?)` "\n* $2" -}} {{/* Remove footnote references */}} {{- $content := $content | replaceRE `\[\^(.+?)\]:?` "" -}} {{/* Swap out forced newlines */}} diff --git a/layouts/shortcodes/openlibrary.html b/layouts/partials/openlibrary.obj similarity index 80% rename from layouts/shortcodes/openlibrary.html rename to layouts/partials/openlibrary.obj index a82bd16e..751fcb31 100644 --- a/layouts/shortcodes/openlibrary.html +++ b/layouts/partials/openlibrary.obj @@ -1,9 +1,10 @@ -{{- $path := .Page.Path -}} +{{- $path := .path -}} {{- $isbn := "" -}} {{- $key := "" -}} -{{- $showCover := ne (.Get 1) false -}} +{{- $showCover := ne .showcover false -}} +{{- $book := dict -}} -{{- with .Get 0 -}} +{{- with .id -}} {{- if eq (len .) 13 -}} {{- $isbn = . -}} {{- else -}} @@ -23,7 +24,7 @@ {{- end -}} {{- end -}} {{- else -}} - {{- warnf "Failed to fetch ISBN data from OpenLibrary: %s" $isbn -}} + {{- errorf "Failed to fetch ISBN data from OpenLibrary: %s" $isbn -}} {{- end -}} {{- end -}} @@ -45,6 +46,8 @@ {{- $authorObj := .Content | transform.Unmarshal -}} {{- if eq $authorObj.status "ok" -}} {{- $authors = $authors | append (dict "name" $authorObj.result.name "url" (printf "https://openlibrary.org%s" $authorObj.result.key)) -}} + {{- else -}} + {{- errorf "OpenLibrary response was %s while fetching author data: %s" $authorObj.status .key -}} {{- end -}} {{- end -}} {{- else -}} @@ -69,11 +72,13 @@ {{- end -}} {{- end -}} - {{- $book := dict "title" $bookObj.result.title "authors" $authors "url" (printf "https://openlibrary.org%s" $key) "cover" $cover -}} - {{- partial "book.html" $book -}} + {{- $book = dict "title" $bookObj.result.title "authors" $authors "url" (printf "https://openlibrary.org%s" $key) "cover" $cover -}} + {{- else -}} + {{- errorf "OpenLibrary response was %s while fetching: %s" $bookObj $key -}} {{- end -}} {{- end -}} {{- else -}} - {{- warnf "Failed to fetch Book data data from OpenLibrary: %s" $key -}} + {{- errorf "Failed to fetch Book data data from OpenLibrary: %s" $key -}} {{- end -}} {{- end -}} +{{- return $book -}} diff --git a/layouts/shortcodes/book.gmi b/layouts/shortcodes/book.gmi new file mode 100644 index 00000000..bb6278f5 --- /dev/null +++ b/layouts/shortcodes/book.gmi @@ -0,0 +1,8 @@ +{{- if ne (.Get 1) false -}} +{{- $book := partial "openlibrary.obj" (dict "path" .Page.Path "id" (.Get 0)) -}} +{{- with $book -}} +{{- if .cover }} +=> {{ .cover.RelPermalink }} πŸ“– {{ .title }} +{{- end -}} +{{- end -}} +{{- end -}} diff --git a/layouts/partials/book.html b/layouts/shortcodes/book.html similarity index 85% rename from layouts/partials/book.html rename to layouts/shortcodes/book.html index 3e66cafa..89c84659 100644 --- a/layouts/partials/book.html +++ b/layouts/shortcodes/book.html @@ -12,7 +12,10 @@ {{- end -}} {{- end -}} -{{- if .cover -}} +{{- $showCover := ne (.Get 1) false -}} +{{- $book := partial "openlibrary.obj" (dict "path" .Page.Path "id" (.Get 0)) -}} +{{- with $book -}} +{{- if and $showCover .cover -}}
{{- $title := .title -}} @@ -30,3 +33,4 @@ {{ .title }} {{- partial "partials/author-list.html" .authors -}} {{- end -}} +{{- end -}}