mirror of
https://github.com/by-jp/www.byjp.me.git
synced 2025-08-09 18:06:07 +01:00
Remove unnecessary spaces
This commit is contained in:
parent
679aa7890f
commit
72eed38a3c
3 changed files with 80 additions and 83 deletions
|
@ -136,16 +136,15 @@ I’ve been (ha!) pleasantly surprised by how this article pulls lots of differe
|
|||
|
||||
From the associated tweet:
|
||||
|
||||
Stories have a 4 part structure that teaches us an essential lesson.
|
||||
|
||||
- Characters (are they like me)
|
||||
- Conflict (what issue they faced)
|
||||
- Struggle (what did they do)
|
||||
- Resolution (did they solve it)
|
||||
|
||||
We _tell_ stories because it's the way we share
|
||||
how to solve problems.
|
||||
We _listen_ to stories because they're the best way to learn how somebody else solved a problem.
|
||||
> Stories have a 4 part structure that teaches us an essential lesson.
|
||||
>
|
||||
> - Characters (are they like me)
|
||||
> - Conflict (what issue they faced)
|
||||
> - Struggle (what did they do)
|
||||
> - Resolution (did they solve it)
|
||||
>
|
||||
> We _tell_ stories because it's the way we share how to solve problems.
|
||||
> We _listen_ to stories because they're the best way to learn how somebody else solved a problem.
|
||||
|
||||
I’m not sure I agree that this is _all_ that stories are, but to the extent that it can be fun and engaging to connect with a story, I think these are the angles that make sense.
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{{- $authors := . -}}
|
||||
{{- if and (ne $authors nil) (gt (len $authors) 0) -}}
|
||||
<span class="authors list">
|
||||
{{ " by " }}
|
||||
{{- " by " -}}
|
||||
{{- range $i, $a := $authors -}}
|
||||
{{- if and (ne $i 0) (eq (add $i 1) (len $authors)) -}}and {{ end -}}
|
||||
<a href="{{ $a.url }}" target="_blank">{{ $a.name }}</a>
|
||||
|
|
|
@ -1,81 +1,79 @@
|
|||
{{ $path := .Page.Path }}
|
||||
{{ $isbn := "" }}
|
||||
{{ $key := "" }}
|
||||
{{ $showCover := ne (.Get 1) false }}
|
||||
{{- $path := .Page.Path -}}
|
||||
{{- $isbn := "" -}}
|
||||
{{- $key := "" -}}
|
||||
{{- $showCover := ne (.Get 1) false -}}
|
||||
|
||||
{{ with .Get 0 }}
|
||||
{{ if eq (len .) 13 }}
|
||||
{{ $isbn = . }}
|
||||
{{ else }}
|
||||
{{ $key = . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{- with .Get 0 -}}
|
||||
{{- if eq (len .) 13 -}}
|
||||
{{- $isbn = . -}}
|
||||
{{- else -}}
|
||||
{{- $key = . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{ $isbn := .Get 0 }}
|
||||
{{- if not $key -}}
|
||||
{{- $query := (dict "type" "/type/edition" "isbn_13" $isbn) | jsonify -}}
|
||||
{{- with resources.GetRemote (printf "https://openlibrary.org/api/things?query=%s" ($query)) -}}
|
||||
{{- with .Err -}}
|
||||
{{- errorf "Error grabbing Thing from OpenLibrary: %v" . -}}
|
||||
{{- else -}}
|
||||
{{- $thing := .Content | transform.Unmarshal -}}
|
||||
{{- if and (eq $thing.status "ok") (ge (len $thing.result) 1) -}}
|
||||
{{- $key = index $thing.result 0 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- warnf "Failed to fetch ISBN data from OpenLibrary: %s" $isbn -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{ if not $key }}
|
||||
{{ $query := (dict "type" "/type/edition" "isbn_13" $isbn) | jsonify }}
|
||||
{{ with resources.GetRemote (printf "https://openlibrary.org/api/things?query=%s" ($query)) }}
|
||||
{{ with .Err }}
|
||||
{{ errorf "Error grabbing Thing from OpenLibrary: %v" . }}
|
||||
{{ else }}
|
||||
{{ $thing := .Content | transform.Unmarshal }}
|
||||
{{ if and (eq $thing.status "ok") (ge (len $thing.result) 1) }}
|
||||
{{ $key = index $thing.result 0 }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ warnf "Failed to fetch ISBN data from OpenLibrary: %s" $isbn }}
|
||||
{{ end }}
|
||||
{{ end}}
|
||||
{{- if $key -}}
|
||||
{{- with resources.GetRemote (printf "https://openlibrary.org/api/get?key=%s" $key) -}}
|
||||
{{- with .Err -}}
|
||||
{{- errorf "Error grabbing Book data from OpenLibrary: %v" . -}}
|
||||
{{- else -}}
|
||||
{{- $bookObj := .Content | transform.Unmarshal -}}
|
||||
{{- if eq $bookObj.status "ok" -}}
|
||||
{{- $isbn = index $bookObj.result.isbn_13 0 -}}
|
||||
|
||||
{{ if $key }}
|
||||
{{ with resources.GetRemote (printf "https://openlibrary.org/api/get?key=%s" $key) }}
|
||||
{{ with .Err }}
|
||||
{{ errorf "Error grabbing Book data from OpenLibrary: %v" . }}
|
||||
{{ else }}
|
||||
{{ $bookObj := .Content | transform.Unmarshal }}
|
||||
{{ if eq $bookObj.status "ok" }}
|
||||
{{ $isbn = index $bookObj.result.isbn_13 0 }}
|
||||
{{- $authors := slice -}}
|
||||
{{- range $bookObj.result.authors -}}
|
||||
{{- with resources.GetRemote (printf "https://openlibrary.org/api/get?key=%s" .key) -}}
|
||||
{{- with .Err -}}
|
||||
{{- errorf "Error grabbing Author data from OpenLibrary: %v" . -}}
|
||||
{{- else -}}
|
||||
{{- $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)) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- warnf "Failed to fetch Author data from OpenLibrary: %s" .key -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{ $authors := slice }}
|
||||
{{ range $bookObj.result.authors }}
|
||||
{{ with resources.GetRemote (printf "https://openlibrary.org/api/get?key=%s" .key) }}
|
||||
{{ with .Err }}
|
||||
{{ errorf "Error grabbing Author data from OpenLibrary: %v" . }}
|
||||
{{ else }}
|
||||
{{ $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)) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ warnf "Failed to fetch Author data from OpenLibrary: %s" .key }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ $cover := "" }}
|
||||
{{ if $showCover }}
|
||||
{{ $coverURL := (printf "https://covers.openlibrary.org/b/isbn/%s-M.jpg" $isbn)}}
|
||||
{{ if not $isbn }}
|
||||
{{ $coverURL = printf "https://covers.openlibrary.org/b/id/%.0f-M.jpg" (index $bookObj.result.covers 0) }}
|
||||
{{ end }}
|
||||
{{- $cover := "" -}}
|
||||
{{- if $showCover -}}
|
||||
{{- $coverURL := (printf "https://covers.openlibrary.org/b/isbn/%s-M.jpg" $isbn) -}}
|
||||
{{- if not $isbn -}}
|
||||
{{- $coverURL = printf "https://covers.openlibrary.org/b/id/%.0f-M.jpg" (index $bookObj.result.covers 0) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $bookFilename := replaceRE `[^a-z]+` "-" (lower $bookObj.result.title) -}}
|
||||
{{- $coverPath := replaceRE `(\.md)?$` (printf "/%s.jpg" $bookFilename) $path -}}
|
||||
{{ with resources.GetRemote $coverURL }}
|
||||
{{ with .Err }}
|
||||
{{ else }}
|
||||
{{ $cover = .Content | resources.FromString $coverPath }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{- with resources.GetRemote $coverURL -}}
|
||||
{{- with .Err -}}
|
||||
{{- else -}}
|
||||
{{- $cover = .Content | resources.FromString $coverPath -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{ $book := dict "title" $bookObj.result.title "authors" $authors "url" (printf "https://openlibrary.org%s" $key) "cover" $cover }}
|
||||
{{ partial "book.html" $book }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ warnf "Failed to fetch Book data data from OpenLibrary: %s" $key }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{- $book := dict "title" $bookObj.result.title "authors" $authors "url" (printf "https://openlibrary.org%s" $key) "cover" $cover -}}
|
||||
{{- partial "book.html" $book -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- warnf "Failed to fetch Book data data from OpenLibrary: %s" $key -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
|
Loading…
Reference in a new issue