Skip to content

Commit

Permalink
create more json outputs with useful data
Browse files Browse the repository at this point in the history
We already create `/index.json` which is used for searching.
This creates two more:
- `/status.json` provides:
    - information about all the existing taxonomies & media
    - information about which transcripts are missing which field.
    - provides the number of transcripts for each language.
- `/directories.json` provides
    - information about all the existing directories (supports nesting
      up to 2 levels) and their total number of transcripts
  • Loading branch information
kouloumos committed Nov 21, 2023
1 parent a604a39 commit 016dc44
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 1 deletion.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ The `preview_branch.sh` script allows you to preview how the changes in your bra
./preview_branch.sh <your-github-account> <your-branch-name>
```

### Website's metadata

Metadata about the content of the website are automatically generated and can be found at:

- [btctranscripts.com/status.json](https://btctranscripts.com/status.json)
```
// information about the existing taxonomies & media
existing: {categories: [...], media: [...], speakers: [...], tags: [...] }
// information about which transcripts are missing which metadata field
missing: {categories: [...], date: [...], media: [...], speakers: [...], tags: [...], transcript_by: [...] }
// total number of transcripts for each language
transcripts: { en: 'xxx', es: 'xxx', pt: 'xxx', zh: 'xxx'}
```
- [btctranscripts.com/directories.json](https://btctranscripts.com/directories.json): information about all the existing directories and their total number of transcript (supports nesting up to 2 levels, which is the maximum nesting that we currently have, e.g. `scalingbitcoin/tokyo-2018/edgedevplusplus`).


## i18n

All i18n snippets can be found in the `/i18n` folder. Pre-configured languages are currently Spanish and Portuguese. If you'd like to propose a new language, you can do so by modifying the [site config](https://github.com/bitcointranscripts/bitcointranscripts.github.io/blob/master/config.toml) and translating the appropraite [i18n file](https://github.com/bitcointranscripts/bitcointranscripts.github.io/blob/master/i18n).
Expand Down
20 changes: 19 additions & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,26 @@ DefaultContentLanguage = "en"
languageName = "简体中文"
weight = 3

[mediaTypes."application/json"]
suffixes = ["json"]

[outputFormats.Index]
mediaType = "application/json"
baseName = "index"
isPlainText = true

[outputFormats.Status]
mediaType = "application/json"
baseName = "status"
isPlainText = true

[outputFormats.Directories]
mediaType = "application/json"
baseName = "directories"
isPlainText = true

[outputs]
home = [ "HTML", "JSON"]
home = [ "HTML", "Status", "Directories", "Index"]
page = [ "HTML"]

[params]
Expand Down
29 changes: 29 additions & 0 deletions themes/ace-documentation/layouts/_default/list.directories.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{ range .Site.Sections }}
{{ $sectionKey := .File.ContentBaseName }}
{{ if ne $sectionKey "" }}
{{ $section := newScratch }}
{{ $.Scratch.SetInMap "result" $sectionKey (len .Pages) }}

{{ range .Pages }}
{{ if eq .BundleType "branch" }}
{{ $subsectionKey := .File.ContentBaseName }}
{{ $subsection := newScratch }}
{{ $section.Set $subsectionKey (len .Pages) }}

{{ range .Pages }}
{{ if eq .BundleType "branch" }}
{{ $subsection.Set .File.ContentBaseName (len .Pages) }}
{{ end }}
{{ end }}
{{ if gt ($subsection.Values | len) 0 }}
{{ $section.Set $subsectionKey $subsection.Values }}
{{ end }}
{{ end }}
{{ end }}
{{ if gt ($section.Values | len) 0 }}
{{ $.Scratch.SetInMap "result" $sectionKey $section.Values }}
{{ end }}
{{ end }}
{{ end }}

{{ $.Scratch.Get "result" | jsonify }}
File renamed without changes.
56 changes: 56 additions & 0 deletions themes/ace-documentation/layouts/_default/list.status.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{{- $.Scratch.Set "missing" (dict "speakers" (slice) "date" (slice) "transcript_by" (slice) "categories" (slice) "tags" (slice) "media" (slice)) -}}
{{- $.Scratch.Set "es" 0 -}}
{{- $.Scratch.Set "pt" 0 -}}
{{- $.Scratch.Set "zh" 0 -}}

{{- range .Site.RegularPages -}}
{{- $params := .Params -}}
{{- $path := .Permalink -}}
{{- range $key, $value := $.Scratch.Get "missing" -}}
{{- if not (isset $params $key) -}}

{{- $.Scratch.SetInMap "missing" $key ($value | append $path) -}}
{{- end -}}
{{- end -}}

{{- with .Translations -}}
{{- range . -}}
{{- $lang := .Lang -}}
{{- $.Scratch.Add $lang 1 -}}
{{- end -}}
{{- end -}}

{{- end -}}

{{- $.Scratch.Set "transcripts" (dict "en" (len .Site.RegularPages) "es" ($.Scratch.Get "es") "pt" ($.Scratch.Get "pt") "zh" ($.Scratch.Get "zh")) -}}

{{ $speakerData := slice }}
{{ $tagData := slice }}
{{ $categoryData := slice }}

{{ range $speaker, $not_used := .Site.Taxonomies.speakers }}
{{ $speakerData = $speakerData | append $speaker }}
{{ end }}

{{ range $tag, $not_used := .Site.Taxonomies.tags }}
{{ $tagData = $tagData | append $tag }}
{{ end }}

{{ range $category, $not_used := .Site.Taxonomies.categories }}
{{ $categoryData = $tagData | append $category }}
{{ end }}

{{ $media := slice }}

{{ range .Site.RegularPages }}
{{ $mediaValue := .Params.media }}
{{ if $mediaValue }}
{{ $media = $media | append $mediaValue }}
{{ end }}
{{ end }}

{{ $jsonData := dict "speakers" $speakerData "tags" $tagData "categories" $categoryData "media" $media }}
{{- $.Scratch.SetInMap "status" "existing" $jsonData -}}
{{- $.Scratch.SetInMap "status" "missing" ($.Scratch.Get "missing") -}}
{{- $.Scratch.SetInMap "status" "transcripts" ($.Scratch.Get "transcripts") -}}
{{- $.Scratch.Get "status" | jsonify -}}

0 comments on commit 016dc44

Please sign in to comment.