From 1584b2db62563c3577cf15a8a00a2e3112e51721 Mon Sep 17 00:00:00 2001 From: George Cushen Date: Mon, 11 Feb 2019 13:59:09 +0000 Subject: [PATCH] refactor: consolidate and simplify compact views - Consolidate the code for all compact views into a single file - Make authors clickable in all compact views - Improve archetypes BREAKING CHANGES: `abstract_short` field dropped in publications and talks in favour of `summary` field. See #918 See https://github.com/gcushen/hugo-academic/issues/916#issuecomment-462274214 --- archetypes/publication/index.md | 21 ++--- archetypes/talk/index.md | 47 +++++----- exampleSite/content/talk/example/index.md | 52 +++++------ layouts/partials/li_compact.html | 89 +++++++++++++++++++ layouts/partials/li_list.html | 14 +-- layouts/partials/post_li_compact.html | 36 -------- layouts/partials/publication_li_compact.html | 42 --------- layouts/partials/talk_li_compact.html | 60 ------------- layouts/partials/widgets/posts.html | 2 +- layouts/partials/widgets/publications.html | 2 +- .../widgets/publications_featured.html | 2 +- layouts/partials/widgets/talks.html | 2 +- layouts/partials/widgets/talks_featured.html | 2 +- layouts/project/single.html | 6 +- layouts/section/post.html | 2 +- layouts/section/publication.html | 2 +- layouts/section/talk.html | 2 +- 17 files changed, 171 insertions(+), 212 deletions(-) create mode 100644 layouts/partials/li_compact.html delete mode 100644 layouts/partials/post_li_compact.html delete mode 100644 layouts/partials/publication_li_compact.html delete mode 100644 layouts/partials/talk_li_compact.html diff --git a/archetypes/publication/index.md b/archetypes/publication/index.md index caebbd84..d250c33e 100644 --- a/archetypes/publication/index.md +++ b/archetypes/publication/index.md @@ -1,10 +1,9 @@ +++ title = "{{ replace .Name "-" " " | title }}" date = {{ .Date }} -draft = false # Authors. Comma separated list, e.g. `["Bob Smith", "David Jones"]`. -authors = [""] +authors = [] # Publication type. # Legend: @@ -21,13 +20,22 @@ publication_types = ["0"] publication = "" publication_short = "" -# Abstract and optional shortened version. +# Abstract. abstract = "" + +# Summary. An optional shortened abstract. abstract_short = "" +# Digital Object Identifier (DOI) +doi = "" + # Is this a featured publication? (true/false) featured = false +# Tags (optional). +# Set `tags = []` for no tags, or use the form `tags = ["A Tag", "Another Tag"]` for one or more tags. +tags = [] + # Projects (optional). # Associate this publication with one or more of your projects. # Simply enter your project's folder or file name without extension. @@ -44,10 +52,6 @@ projects = [] # Otherwise, set `slides = ""`. slides = "" -# Tags (optional). -# Set `tags = []` for no tags, or use the form `tags = ["A Tag", "Another Tag"]` for one or more tags. -tags = [] - # Links (optional). url_pdf = "" url_preprint = "" @@ -63,9 +67,6 @@ url_source = "" # Uncomment line below to enable. For multiple links, use the form `[{...}, {...}, {...}]`. # url_custom = [{name = "Custom Link", url = "http://example.org"}] -# Digital Object Identifier (DOI) -doi = "" - # Featured image # To use, add an image named `featured.jpg/png` to your page's folder. [image] diff --git a/archetypes/talk/index.md b/archetypes/talk/index.md index e8a65157..50693ac9 100644 --- a/archetypes/talk/index.md +++ b/archetypes/talk/index.md @@ -1,7 +1,9 @@ +++ title = "{{ replace .Name "-" " " | title }}" date = {{ .Date }} # Schedule page publish date. -draft = false + +# Authors. Comma separated list, e.g. `["Bob Smith", "David Jones"]`. +authors = [] # Talk start and end times. # End time can optionally be hidden by prefixing the line with `#`. @@ -9,23 +11,37 @@ time_start = {{ .Date }} time_end = {{ .Date }} all_day = false -# Authors. Comma separated list, e.g. `["Bob Smith", "David Jones"]`. -authors = [] - -# Abstract and optional shortened version. -abstract = "" -abstract_short = "" +# Location of event. +location = "" # Name of event and optional event URL. event = "" event_url = "" -# Location of event. -location = "" +# Abstract. What's your talk about? +abstract = "" + +# Summary. An optional shortened abstract. +summary = "" # Is this a featured talk? (true/false) featured = false +# Tags (optional). +# Set `tags = []` for no tags, or use the form `tags = ["A Tag", "Another Tag"]` for one or more tags. +tags = [] + +# Markdown Slides (optional). +# Associate this page with Markdown slides. +# Simply enter your slide deck's filename without extension. +# E.g. `slides = "example-slides"` references +# `content/slides/example-slides.md`. +# Otherwise, set `slides = ""`. +slides = "" + +# Optional filename of your slides within your talk folder or a URL. +url_slides = "" + # Projects (optional). # Associate this talk with one or more of your projects. # Simply enter your project's folder or file name without extension. @@ -34,21 +50,8 @@ featured = false # Otherwise, set `projects = []`. projects = [] -# Slides (optional). -# Associate this page with Markdown slides. -# Simply enter your slide deck's filename without extension. -# E.g. `slides = "example-slides"` references -# `content/slides/example-slides.md`. -# Otherwise, set `slides = ""`. -slides = "" - -# Tags (optional). -# Set `tags = []` for no tags, or use the form `tags = ["A Tag", "Another Tag"]` for one or more tags. -tags = [] - # Links (optional). url_pdf = "" -url_slides = "" url_video = "" url_code = "" diff --git a/exampleSite/content/talk/example/index.md b/exampleSite/content/talk/example/index.md index f263197b..7dfcddc1 100644 --- a/exampleSite/content/talk/example/index.md +++ b/exampleSite/content/talk/example/index.md @@ -1,7 +1,9 @@ +++ title = "Example Talk" -date = 2017-01-01T00:00:00 # Schedule page publish date. -draft = false +date = 2017-01-01T00:00:00 # Schedule page publish date (not talk date). + +# Authors. Comma separated list, e.g. `["Bob Smith", "David Jones"]`. +authors = [] # Talk start and end times. # End time can optionally be hidden by prefixing the line with `#`. @@ -9,23 +11,37 @@ time_start = 2030-06-01T13:00:00 time_end = 2030-06-01T15:00:00 all_day = false -# Authors. Comma separated list, e.g. `["Bob Smith", "David Jones"]`. -authors = [] - -# Abstract and optional shortened version. -abstract = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis posuere tellus ac convallis placerat. Proin tincidunt magna sed ex sollicitudin condimentum. Sed ac faucibus dolor, scelerisque sollicitudin nisi. Cras purus urna, suscipit quis sapien eu, pulvinar tempor diam." -abstract_short = "An example talk using Academic's Markdown slides feature." +# Location of event. +location = "London, United Kingdom" # Name of event and optional event URL. event = "Academic Theme Conference" event_url = "https://example.org" -# Location of event. -location = "London, United Kingdom" +# Abstract. What's your talk about? +abstract = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis posuere tellus ac convallis placerat. Proin tincidunt magna sed ex sollicitudin condimentum. Sed ac faucibus dolor, scelerisque sollicitudin nisi. Cras purus urna, suscipit quis sapien eu, pulvinar tempor diam." + +# Summary. An optional shortened abstract. +summary = "An example talk using Academic's Markdown slides feature." # Is this a featured talk? (true/false) featured = false +# Tags (optional). +# Set `tags = []` for no tags, or use the form `tags = ["A Tag", "Another Tag"]` for one or more tags. +tags = [] + +# Markdown Slides (optional). +# Associate this talk with Markdown slides. +# Simply enter your slide deck's filename without extension. +# E.g. `slides = "example-slides"` references +# `content/slides/example-slides.md`. +# Otherwise, set `slides = ""`. +slides = "example-slides" + +# Optional filename of your slides within your talk folder or a URL. +url_slides = "" + # Projects (optional). # Associate this talk with one or more of your projects. # Simply enter your project's folder or file name without extension. @@ -34,27 +50,11 @@ featured = false # Otherwise, set `projects = []`. projects = ["internal-project"] -# Tags (optional). -# Set `tags = []` for no tags, or use the form `tags = ["A Tag", "Another Tag"]` for one or more tags. -tags = [] - -# Slides (optional). -# Associate this talk with Markdown slides. -# Simply enter your slide deck's filename without extension. -# E.g. `slides = "example-slides"` references -# `content/slides/example-slides.md`. -# Otherwise, set `slides = ""`. -slides = "example-slides" - # Links (optional). url_pdf = "" -url_slides = "" url_video = "" url_code = "" -# Does the content use math formatting? -math = true - # Featured image # To use, add an image named `featured.jpg/png` to your page's folder. [image] diff --git a/layouts/partials/li_compact.html b/layouts/partials/li_compact.html new file mode 100644 index 00000000..a466e0b1 --- /dev/null +++ b/layouts/partials/li_compact.html @@ -0,0 +1,89 @@ +{{ $item := . }} + +{{ $microdata_type := "CreativeWork" }} +{{ $show_authors_only := false }}{{/* Show authors only or full metadata? */}} +{{ $show_buttons := false }} + +{{/* Dynamic view adjusts to content type. */}} +{{ if eq $item.Type "post" }} + {{ $microdata_type = "BlogPosting" }} +{{ else if eq $item.Type "talk" }} + {{ $microdata_type = "Event" }} + {{ $show_authors_only = true }} + {{ $show_buttons = true }} +{{ else if eq $item.Type "publication" }} + {{ $microdata_type = "ScholarlyArticle" }} + {{ $show_authors_only = true }} + {{ $show_buttons = true }} +{{ end }} + +{{/* Get summary. */}} +{{ $summary := "" }} +{{ if $item.Params.summary }} + {{ $summary = $item.Params.summary | markdownify | emojify }} +{{ else if .Params.abstract }} + {{ $summary = .Params.abstract | markdownify | emojify }} +{{ else if $item.Truncated }} + {{ $summary = $item.Summary }} +{{ end }} + +
+
+ +

+ +

+ + {{ with $summary }} +
+ {{ . | truncate 135 }} +
+ {{ end }} + + + + {{ if $show_buttons }} + + {{ end }} + +
+
+ {{ $resource := ($item.Resources.ByType "image").GetMatch "*featured*" }} + {{ with $resource }} + {{ $image := .Resize "150x" }} + + + + {{end}} +
+
diff --git a/layouts/partials/li_list.html b/layouts/partials/li_list.html index 1b9a5810..790ba3d2 100644 --- a/layouts/partials/li_list.html +++ b/layouts/partials/li_list.html @@ -1,23 +1,24 @@ {{ $item := . }} -{{ $microdata_type := "http://schema.org/CreativeWork" }} +{{ $microdata_type := "CreativeWork" }} {{ $icon := "fa-file-alt" }} {{ $show_authors := false }} {{ $show_buttons := false }} {{/* Dynamic view adjusts to content type. */}} {{ if eq $item.Type "post" }} - {{ $microdata_type = "http://schema.org/BlogPosting" }} + {{ $microdata_type = "BlogPosting" }} {{ $icon = "fa-newspaper" }} {{ else if eq $item.Type "talk" }} - {{ $microdata_type = "http://schema.org/Event" }} + {{ $microdata_type = "Event" }} {{ $icon = "fa-calendar-alt" }} {{ else if eq $item.Type "publication" }} + {{ $microdata_type = "ScholarlyArticle" }} {{ $show_authors = true }} {{ $show_buttons = true }} {{ end }} -
+
@@ -29,6 +30,9 @@ {{ if not $item.Params.all_day }} {{ (time $date).Format ($.Site.Params.time_format | default "3:04 PM") }} {{ end }} + {{ with .Params.time_end }} + — {{ (time .).Format ($.Site.Params.time_format | default "3:04 PM") }} + {{ end }} {{ with $item.Params.location }} @@ -37,7 +41,7 @@
{{ end }} - {{ if $show_authors }} + {{ if and $show_authors $item.Params.authors }} diff --git a/layouts/partials/post_li_compact.html b/layouts/partials/post_li_compact.html deleted file mode 100644 index 568a1f92..00000000 --- a/layouts/partials/post_li_compact.html +++ /dev/null @@ -1,36 +0,0 @@ -{{ $post := . }} - -
-
- -

- -

- - {{ $summary := "" }} - {{ if $post.Params.summary }} - {{ $summary = $post.Params.summary | markdownify }} - {{ else if $post.Truncated }} - {{ $summary = $post.Summary }} - {{ end }} - {{ with $summary }} -
- {{ . | truncate 135 }} -
- {{ end }} - -
- {{ partial "page_metadata" (dict "content" $post "is_list" 1) }} -
- -
-
- {{ $resource := ($post.Resources.ByType "image").GetMatch "*featured*" }} - {{ with $resource }} - {{ $image := .Resize "150x" }} - - - - {{end}} -
-
diff --git a/layouts/partials/publication_li_compact.html b/layouts/partials/publication_li_compact.html deleted file mode 100644 index abd47cfb..00000000 --- a/layouts/partials/publication_li_compact.html +++ /dev/null @@ -1,42 +0,0 @@ -
-
- -

- -

- - {{ $summary := "" }} - {{ if .Params.abstract_short }} - {{ $summary = .Params.abstract_short | markdownify }} - {{ else if .Params.abstract }} - {{ $summary = .Params.abstract | markdownify }} - {{ else if .Truncated }} - {{ $summary = .Summary }} - {{ end }} - {{ with $summary }} -
- {{ . | truncate 135 }} -
- {{ end }} - - - - - -
-
- {{ $resource := (.Resources.ByType "image").GetMatch "*featured*" }} - {{ with $resource }} - {{ $image := .Resize "150x" }} - - - - {{end}} -
-
diff --git a/layouts/partials/talk_li_compact.html b/layouts/partials/talk_li_compact.html deleted file mode 100644 index 3d836a05..00000000 --- a/layouts/partials/talk_li_compact.html +++ /dev/null @@ -1,60 +0,0 @@ -
-
- -

- -

- - {{ $summary := "" }} - {{ if .Params.abstract_short }} - {{ $summary = .Params.abstract_short | markdownify }} - {{ else if .Params.abstract }} - {{ $summary = .Params.abstract | markdownify }} - {{ else if .Truncated }} - {{ $summary = .Summary }} - {{ end }} - {{ with $summary }} -
- {{ . | truncate 135 }} -
- {{ end }} - - - - - -
-
- {{ $resource := (.Resources.ByType "image").GetMatch "*featured*" }} - {{ with $resource }} - {{ $image := .Resize "150x" }} - - - - {{end}} -
-
diff --git a/layouts/partials/widgets/posts.html b/layouts/partials/widgets/posts.html index a2b63c13..f2978194 100644 --- a/layouts/partials/widgets/posts.html +++ b/layouts/partials/widgets/posts.html @@ -31,7 +31,7 @@ {{ else if eq $page.Params.view 3 }} {{ partial "post_li_card" . }} {{ else }} - {{ partial "post_li_compact" . }} + {{ partial "li_compact" . }} {{ end }} {{end}} diff --git a/layouts/partials/widgets/publications.html b/layouts/partials/widgets/publications.html index 61d51612..822e503d 100644 --- a/layouts/partials/widgets/publications.html +++ b/layouts/partials/widgets/publications.html @@ -28,7 +28,7 @@ {{ else if eq $page.Params.view 4 }} {{ partial "publication_li_citation" . }} {{ else }} - {{ partial "publication_li_compact" . }} + {{ partial "li_compact" . }} {{ end }} {{ end }} diff --git a/layouts/partials/widgets/publications_featured.html b/layouts/partials/widgets/publications_featured.html index 2bab40d1..6e2ba6d4 100644 --- a/layouts/partials/widgets/publications_featured.html +++ b/layouts/partials/widgets/publications_featured.html @@ -25,7 +25,7 @@ {{ else if eq $page.Params.view 4 }} {{ partial "publication_li_citation" . }} {{ else }} - {{ partial "publication_li_compact" . }} + {{ partial "li_compact" . }} {{ end }} {{ end }} diff --git a/layouts/partials/widgets/talks.html b/layouts/partials/widgets/talks.html index c3ed3839..b691cd2e 100644 --- a/layouts/partials/widgets/talks.html +++ b/layouts/partials/widgets/talks.html @@ -24,7 +24,7 @@ {{ else if eq $page.Params.view 3 }} {{ partial "talk_li_card" . }} {{ else }} - {{ partial "talk_li_compact" . }} + {{ partial "li_compact" . }} {{ end }} {{ end }} diff --git a/layouts/partials/widgets/talks_featured.html b/layouts/partials/widgets/talks_featured.html index 808602d5..47ede597 100644 --- a/layouts/partials/widgets/talks_featured.html +++ b/layouts/partials/widgets/talks_featured.html @@ -16,7 +16,7 @@ {{ else if eq $page.Params.view 3 }} {{ partial "talk_li_card" . }} {{ else }} - {{ partial "talk_li_compact" . }} + {{ partial "li_compact" . }} {{ end }} {{ end }}
diff --git a/layouts/project/single.html b/layouts/project/single.html index 401d8661..08a58519 100644 --- a/layouts/project/single.html +++ b/layouts/project/single.html @@ -27,7 +27,7 @@ {{ else if eq $page.Site.Params.projects.post_view 3 }} {{ partial "post_li_card" . }} {{ else }} - {{ partial "post_li_compact" . }} + {{ partial "li_compact" . }} {{ end }} {{ end }} {{ end }} @@ -44,7 +44,7 @@ {{ else if eq $page.Site.Params.projects.publication_view 4 }} {{ partial "publication_li_citation" . }} {{ else }} - {{ partial "publication_li_compact" . }} + {{ partial "li_compact" . }} {{ end }} {{ end }} {{ end }} @@ -59,7 +59,7 @@ {{ else if eq $page.Site.Params.projects.talk_view 3 }} {{ partial "talk_li_card" . }} {{ else }} - {{ partial "talk_li_compact" . }} + {{ partial "li_compact" . }} {{ end }} {{ end }} {{ end }} diff --git a/layouts/section/post.html b/layouts/section/post.html index d2f2bfce..be828582 100644 --- a/layouts/section/post.html +++ b/layouts/section/post.html @@ -16,7 +16,7 @@ {{ else if eq $.Params.view 3 }} {{ partial "post_li_card" . }} {{ else }} - {{ partial "post_li_compact" . }} + {{ partial "li_compact" . }} {{ end }} {{ end }} diff --git a/layouts/section/publication.html b/layouts/section/publication.html index de15cf5d..8ed53423 100644 --- a/layouts/section/publication.html +++ b/layouts/section/publication.html @@ -65,7 +65,7 @@ {{ else if eq $.Params.view 4 }} {{ partial "publication_li_citation" . }} {{ else }} - {{ partial "publication_li_compact" . }} + {{ partial "li_compact" . }} {{ end }} diff --git a/layouts/section/talk.html b/layouts/section/talk.html index 2e8a419a..3886880c 100644 --- a/layouts/section/talk.html +++ b/layouts/section/talk.html @@ -24,7 +24,7 @@ {{ else if eq $.Params.view 3 }} {{ partial "talk_li_card" . }} {{ else }} - {{ partial "talk_li_compact" . }} + {{ partial "li_compact" . }} {{ end }} {{ end }}