Cataloguer/layouts/partials/books/table-body.html
2023-05-19 21:50:50 -06:00

159 lines
6.3 KiB
HTML

{{ if ( eq ( .Scratch.Get "listMode" ) "current" ) }}
{{ range ( sort $.Site.Data.books.current "Date Started" "desc" ) }}
<tr>
<td>{{ if index . "Date Added" }}{{ time.Format "Jan 2, 2006" ( index . "Date Added" ) }}{{ else }}n/a{{end }}</td>
<td>
<p>
{{- with ( where ( where $.Site.Pages "Section" "books" ) "Title" .Title ) -}}
{{ range . }}
<a href="{{ .RelPermalink }}">
{{ end }}
{{- end -}}
<cite class="book">{{ .Title }}</cite>{{ if .Edition }} <span class="book--edition">({{ .Edition }})</span>{{ end }}
{{- with ( where ( where $.Site.Pages "Section" "books" ) "Title" .Title ) -}}
</a>
{{- end -}}
</p>
</td>
<td>
<p class="author">{{ .Author }}</p>
{{- if ( index . "Additional Authors" ) -}}
<p class="author--additional">Additional: {{ index . "Additional Authors" }}</p>
{{- end -}}
</td>
<td>
<p class="year">{{- index . "Year Published" -}}
{{- if ( and ( ne ( index . "Original Publication Year" ) "" ) ( ne ( index . "Original Publication Year" ) ( index . "Year Published" ) ) ( ne ( index . "Original Publication Year" ) nil ) ) -}}
&nbsp;<span class="year--original">(orig.&nbsp;{{ index . "Original Publication Year" }})</span>
{{- end -}}
</td>
<td>
{{- if index . "Date Started" -}}
{{- time.Format "Jan 2, 2006" ( index . "Date Started" ) -}}
{{- end -}}&ndash;
</td>
</tr>
{{ end }}
{{ else if ( eq ( .Scratch.Get "listMode" ) "log" ) }}
<tr>
<td colspan=5><h3>Diary</h3></td>
</tr>
{{ range ( sort ( where $.Site.Data.books.log "Date Finished" "!=" "" ) "Date Finished" "desc" ) }}
<tr>
<td>{{ if index . "Date Added" }}{{ time.Format "Jan 2, 2006" ( index . "Date Added" ) }}{{ else }}n/a{{end }}</td>
<td>
<p>
{{- with ( where ( where $.Site.Pages "Section" "books" ) "Title" .Title ) -}}
{{ range . }}
<a href="{{ .RelPermalink }}">
{{ end }}
{{- end -}}
<cite class="book">{{ .Title }}</cite>{{ if .Edition }} <span class="book--edition">({{ .Edition }})</span>{{ end }}
{{- with ( where ( where $.Site.Pages "Section" "books" ) "Title" .Title ) -}}
</a>
{{- end -}}
</p>
</td>
<td>
<p class="author">{{ .Author }}</p>
{{- if ( index . "Additional Authors" ) -}}
<p class="author--additional">Additional: {{ index . "Additional Authors" }}</p>
{{- end -}}
</td>
<td>
<p class="year">{{- index . "Year Published" -}}
{{- if ( and ( ne ( index . "Original Publication Year" ) "" ) ( ne ( index . "Original Publication Year" ) ( index . "Year Published" ) ) ) -}}
&nbsp;<span class="year--original">(orig.&nbsp;{{ index . "Original Publication Year" }})</span>
{{- end -}}
</td>
<td>
{{- if index . "Date Started" -}}
{{- time.Format "Jan 2, 2006" ( index . "Date Started" ) -}}
{{- else -}}
Unknown
{{- end -}}&ndash;{{- if index . "Date Finished" -}}
{{- time.Format "Jan 2, 2006" ( index . "Date Finished" ) -}}
{{- else -}}
Unknown
{{- end -}}
</td>
</tr>
{{ end }}
<tr>
<td colspan=5><h3>Assorted</h3></td>
</tr>
{{ range ( sort ( where $.Site.Data.books.log "Date Finished" "" ) "Title" "asc" ) }}
<tr>
<td>{{ if index . "Date Added" }}{{ time.Format "Jan 2, 2006" ( index . "Date Added" ) }}{{ else }}n/a{{end }}</td>
<td>
<p>
{{- with ( where ( where $.Site.Pages "Section" "books" ) "Title" .Title ) -}}
{{ range . }}
<a href="{{ .RelPermalink }}">
{{ end }}
{{- end -}}
<cite class="book">{{ .Title }}</cite>{{ if .Edition }} <span class="book--edition">({{ .Edition }})</span>{{ end }}
{{- with ( where ( where $.Site.Pages "Section" "books" ) "Title" .Title ) -}}
</a>
{{- end -}}
</p>
</td>
<td>
<p class="author">{{ .Author }}</p>
{{- if ( index . "Additional Authors" ) -}}
<p class="author--additional">Additional: {{ index . "Additional Authors" }}</p>
{{- end -}}
</td>
<td>
<p class="year">{{- index . "Year Published" -}}
{{- if ( and ( ne ( index . "Original Publication Year" ) "" ) ( ne ( index . "Original Publication Year" ) ( index . "Year Published" ) ) ) -}}
&nbsp;<span class="year--original">(orig.&nbsp;{{ index . "Original Publication Year" }})</span>
{{- end -}}
</td>
<td>
{{- if index . "Date Started" -}}
{{- time.Format "Jan 2, 2006" ( index . "Date Started" ) -}}
{{- else -}}
Unknown
{{- end -}}&ndash;{{- if index . "Date Finished" -}}
{{- time.Format "Jan 2, 2006" ( index . "Date Finished" ) -}}
{{- else -}}
Unknown
{{- end -}}
</td>
</tr>
{{ end }}
{{ else if ( eq ( .Scratch.Get "listMode" ) "wishlist" ) }}
{{ range ( sort $.Site.Data.books.wishlist "Title" "asc" ) }}
<tr>
<td>{{ if index . "Date Added" }}{{ time.Format "Jan 2, 2006" ( index . "Date Added" ) }}{{ else }}n/a{{end }}</td>
<td>
<p>
{{- with ( where ( where $.Site.Pages "Section" "books" ) "Title" .Title ) -}}
{{ range . }}
<a href="{{ .RelPermalink }}">
{{ end }}
{{- end -}}
<cite class="book">{{ .Title }}</cite>{{ if .Edition }} <span class="book--edition">({{ .Edition }})</span>{{ end }}
{{- with ( where ( where $.Site.Pages "Section" "books" ) "Title" .Title ) -}}
</a>
{{- end -}}
</p>
</td>
<td>
<p class="author">{{ .Author }}</p>
{{- if ( index . "Additional Authors" ) -}}
<p class="author--additional">Additional: {{ index . "Additional Authors" }}</p>
{{- end -}}
</td>
<td>
<p class="year">{{- index . "Year Published" -}}
{{- if ( index . "Original Publication Year" ) -}}
<span class="year--original">(orig.&nbsp;{{ index . "Orginal Publication Year" }})</span>
{{- end -}}
</td>
<td>n/a</td>
</tr>
{{ end }}
{{ end }}