Browse Source

refactor: publication types as TOML at data/publication_types.toml

George Cushen 6 years ago
parent
commit
ced350c547

+ 1 - 1
assets/sass/main.scss

@@ -1,6 +1,6 @@
 {{- $scr := .Scratch -}}
 {{- $site := $scr.Get "site" -}}
-{{- partial "css/parse_theme.css" . -}}
+{{- partial "functions/parse_theme" . -}}
 
 $sta-font-size: {{ $scr.Get "font_size" }};
 $sta-font-size-small: {{ $scr.Get "font_size_small" }};

+ 12 - 0
data/publication_types.toml

@@ -0,0 +1,12 @@
+# Publication types.
+# Each item in the list corresponds to an item in the language packs.
+types = [ "pub_uncat",
+          "pub_conf",
+          "pub_journal",
+          "pub_preprint",
+          "pub_report",
+          "pub_book",
+          "pub_book_section",
+          "pub_thesis",
+          "pub_patent"
+        ]

+ 6 - 0
layouts/partials/functions/get_pub_types.html

@@ -0,0 +1,6 @@
+{{/* Get Publication Types */}}
+{{ $pub_types := slice }}
+{{ range site.Data.publication_types.types }}
+  {{ $pub_types = $pub_types | append (i18n . | default "Uncategorized") }}
+{{ end }}
+{{ return $pub_types }}

+ 0 - 0
layouts/partials/css/parse_theme.css → layouts/partials/functions/parse_theme.html


+ 1 - 1
layouts/partials/header.html

@@ -42,7 +42,7 @@
   {{ end }}
   <link rel="alternate" hreflang="{{ site.LanguageCode | default "en-us" }}" href="{{ .Permalink }}">
 
-  {{ partial "css/parse_theme.css" . }}
+  {{ partial "functions/parse_theme" . }}
   {{ $css := site.Data.assets.css }}
   {{ $js := site.Data.assets.js }}
   {{ if ne ($scr.Get "primary") "#fff" }}

+ 0 - 1
layouts/partials/pub_types.html

@@ -1 +0,0 @@
-{{ $.Scratch.Set "pub_types" (slice (i18n "pub_uncat" | default "Uncategorized") (i18n "pub_conf" | default "Conference paper") (i18n "pub_journal" | default "Journal article") (i18n "pub_preprint" | default "Preprint") (i18n "pub_report" | default "Report") (i18n "pub_book" | default "Book") (i18n "pub_book_section" | default "Book section") (i18n "pub_thesis" | default "Thesis") (i18n "pub_patent" | default "Patent") ) }}

+ 1 - 2
layouts/publication/single.html

@@ -18,8 +18,7 @@
         <div class="row">
           <div class="col-12 col-md-3 pub-row-heading">{{ i18n "publication_type" }}</div>
           <div class="col-12 col-md-9">
-            {{ partial "pub_types.html" $ }}
-            {{ $pub_types := $.Scratch.Get "pub_types" }}
+            {{ $pub_types := partial "functions/get_pub_types" $ }}
             {{ range $index, $pubtype := .Params.publication_types }}
             <a href="{{ (site.GetPage "section" "publication").RelPermalink }}#{{ . | urlize }}">
               {{ index $pub_types (int .) }}

+ 1 - 2
layouts/section/publication.html

@@ -25,10 +25,9 @@
         <div class="col-auto">
           <select class="pub-filters pubtype-select form-control form-control-sm" data-filter-group="pubtype">
             <option value="*">{{ i18n "publication_type" }}</option>
-            {{ partial "pub_types.html" $ }}
+            {{ $pub_types := partial "functions/get_pub_types" $ }}
             {{ range $index, $taxonomy := site.Taxonomies.publication_types }}
             <option value=".pubtype-{{ (int $index) }}">
-              {{ $pub_types := $.Scratch.Get "pub_types" }}
               {{ index $pub_types (int $index) }}
             </option>
             {{ end }}