Procházet zdrojové kódy

publications: Add APA style + Change `list_format` (Close #305 #296)

* Add APA citation style
* Change `list_format` in pub. widgets and pub. `_index.md` archive
  * New options: 0 = Simple, 1 = Detailed, 2 = APA, 3 = MLA
* Change default `list_format` in exampleSite
* Link title in publication list items
* Open most related links (e.g. PDF) in new tab
George Cushen před 7 roky
rodič
revize
a1b681758e

+ 4 - 3
exampleSite/content/home/publications.md

@@ -17,9 +17,10 @@ count = 10
 
 # List format.
 #   0 = Simple
-#   1 = Classic
-#   2 = Detailed
-list_format = 0
+#   1 = Detailed
+#   2 = APA
+#   3 = MLA
+list_format = 3
 
 # Filter by publication type.
 # -1: Any

+ 4 - 3
exampleSite/content/home/publications_selected.md

@@ -15,9 +15,10 @@ weight = 10
 
 # List format.
 #   0 = Simple
-#   1 = Classic
-#   2 = Detailed
-list_format = 2
+#   1 = Detailed
+#   2 = APA
+#   3 = MLA
+list_format = 1
 
 # Filter by publication type.
 # -1: Any

+ 4 - 3
exampleSite/content/publication/_index.md

@@ -6,9 +6,10 @@ highlight = false
 
 # List format.
 #   0 = Simple
-#   1 = Classic
-#   2 = Detailed
-list_format = 0
+#   1 = Detailed
+#   2 = APA
+#   3 = MLA
+list_format = 3
 
 # Optional featured image (relative to `static/img/` folder).
 [header]

+ 16 - 0
layouts/partials/publication_li_apa.html

@@ -0,0 +1,16 @@
+<div class="pub-list-item" style="margin-bottom: 1rem" itemscope itemtype="http://schema.org/CreativeWork">
+  <i class="fa fa-file-text-o pub-icon" aria-hidden="true"></i>
+  <span itemprop="author">
+    {{ with .Params.authors }}
+      {{- delimit . ", " | markdownify -}}
+    {{- end -}}
+  </span>
+  ({{- .Date.Format "2006" -}}).
+  <a href="{{ .Permalink }}" itemprop="name">{{ .Title }}</a>.
+  {{ if .Params.publication_short }}
+    {{- .Params.publication_short | markdownify -}}
+  {{ else }}
+    {{- .Params.publication | markdownify -}}
+  {{ end }}.
+  <p>{{ partial "publication_links" (dict "content" . "is_list" 1) }}</p>
+</div>

+ 1 - 1
layouts/partials/publication_li_classic.html → layouts/partials/publication_li_mla.html

@@ -5,7 +5,7 @@
       {{- delimit . ", " | markdownify -}}
     {{- end -}}
   </span>.
-  <span itemprop="name">{{ .Title }}</span>.
+  <a href="{{ .Permalink }}" itemprop="name">{{ .Title }}</a>.
   {{ if .Params.publication_short }}
     {{- .Params.publication_short | markdownify -}}
   {{ else }}

+ 1 - 1
layouts/partials/publication_li_simple.html

@@ -1,5 +1,5 @@
 <div class="pub-list-item" style="margin-bottom: 1rem" itemscope itemtype="http://schema.org/CreativeWork">
   <i class="fa fa-file-text-o pub-icon" aria-hidden="true"></i>
-  <span itemprop="name">{{ .Title }}</span>
+  <a href="{{ .Permalink }}" itemprop="name">{{ .Title }}</a>
   <p>{{ partial "publication_links" (dict "content" . "is_list" 1) }}</p>
 </div>

+ 6 - 6
layouts/partials/publication_links.html

@@ -7,27 +7,27 @@
 </a>
 {{ end }}
 {{ with $.Params.url_pdf }}
-<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}">
+<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}" target="_blank">
   {{ i18n "btn_pdf" }}
 </a>
 {{ end }}
 {{ with $.Params.url_slides }}
-<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}">
+<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}" target="_blank">
   {{ i18n "btn_slides" }}
 </a>
 {{ end }}
 {{ with $.Params.url_video }}
-<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}">
+<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}" target="_blank">
   {{ i18n "btn_video" }}
 </a>
 {{ end }}
 {{ with $.Params.url_code }}
-<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}">
+<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}" target="_blank">
   {{ i18n "btn_code" }}
 </a>
 {{ end }}
 {{ with $.Params.url_dataset }}
-<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}">
+<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}" target="_blank">
   {{ i18n "btn_dataset" }}
 </a>
 {{ end }}
@@ -37,7 +37,7 @@
 </a>
 {{ end }}
 {{ range $.Params.url_custom }}
-<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ .url | absURL }}">
+<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ .url | absURL }}" target="_blank">
   {{ .name }}
 </a>
 {{ end }}

+ 4 - 2
layouts/partials/widgets/publications.html

@@ -28,9 +28,11 @@
     {{ $recent_pubs := $.Scratch.Get "recent_pubs" }}
     {{ range first $page.Params.count $recent_pubs }}
       {{ if eq $page.Params.list_format 1 }}
-        {{ partial "publication_li_classic" . }}
-      {{ else if eq $page.Params.list_format 2 }}
         {{ partial "publication_li_detailed" . }}
+      {{ else if eq $page.Params.list_format 2 }}
+        {{ partial "publication_li_apa" . }}
+      {{ else if eq $page.Params.list_format 3 }}
+        {{ partial "publication_li_mla" . }}
       {{ else }}
         {{ partial "publication_li_simple" . }}
       {{ end }}

+ 4 - 2
layouts/partials/widgets/publications_selected.html

@@ -19,9 +19,11 @@
     {{ $sel_pubs := $.Scratch.Get "sel_pubs" }}
     {{ range $sel_pubs }}
       {{ if eq $page.Params.list_format 1 }}
-        {{ partial "publication_li_classic" . }}
-      {{ else if eq $page.Params.list_format 2 }}
         {{ partial "publication_li_detailed" . }}
+      {{ else if eq $page.Params.list_format 2 }}
+        {{ partial "publication_li_apa" . }}
+      {{ else if eq $page.Params.list_format 3 }}
+        {{ partial "publication_li_mla" . }}
       {{ else }}
         {{ partial "publication_li_simple" . }}
       {{ end }}

+ 4 - 2
layouts/section/publication.html

@@ -52,9 +52,11 @@
 
         <div class="grid-sizer col-md-12 isotope-item pubtype-{{ $.Scratch.Get "pubtype" }} year-{{ .Date.Format "2006" }}">
           {{ if eq $.Params.list_format 1 }}
-            {{ partial "publication_li_classic" . }}
-          {{ else if eq $.Params.list_format 2 }}
             {{ partial "publication_li_detailed" . }}
+          {{ else if eq $.Params.list_format 2 }}
+            {{ partial "publication_li_apa" . }}
+          {{ else if eq $.Params.list_format 3 }}
+            {{ partial "publication_li_mla" . }}
           {{ else }}
             {{ partial "publication_li_simple" . }}
           {{ end }}