feat: consolidate Recent Posts/Talks/Pubs widgets into Pages widget

BREAKING CHANGES: See issue below

See #918
This commit is contained in:
George Cushen committed 2019-02-24 01:06:53 +00:00
1 parent 3eed9f56ad
commit 9985bc5e89
12 files changed
+296 -226

No files matched your search

+7 -8
View File
@@ -2,20 +2,19 @@
# Hero widget.
widget = "hero" # Do not modify this line!
active = true # Activate this widget? true/false
weight = 3 # Order that this section will appear.
title = "Academic"
# Order that this section will appear in.
weight = 3
# Hero image (optional). Enter filename of an image in the `static/img/` folder.
hero_media = "hero-academic.png"
# Background (optional).
# Choose from a background color, gradient, or image.
# Choose a dark or light text color, by setting `text_color_light`.
# Delete or comment out (by prefixing `#`) any unused options.
[background]
[design.background]
# Apply a background color, gradient, or image.
# Uncomment (by removing `#`) an option to apply it.
# Choose a light or dark text color by setting `text_color_light`.
# Any HTML color name or Hex value is valid.
# Background color.
# color = "navy"
+56 -15
View File
@@ -1,25 +1,66 @@
+++
# Recent Posts widget.
# This widget displays recent posts from `content/post/`.
widget = "posts" # Do not modify this line!
# A Recent Blog Posts section created with the Pages widget.
# This section displays recent blog posts from `content/post/`.
widget = "pages" # Do not modify this line!
active = true # Activate this widget? true/false
weight = 40 # Order that this section will appear.
title = "Recent Posts"
subtitle = ""
# Number of recent posts to list.
count = 5
[content]
# Page type to display. E.g. post, talk, or publication.
page_type = "post"
# Choose how much pages you would like to display (0 = all pages)
count = 5
# Choose how many pages you would like to offset by
offset = 0
# View.
# 1 = List
# 2 = Compact
# 3 = Card
view = 2
# Page order. Descending (desc) or ascending (asc) date.
order = "desc"
# Filter posts by tag or category.
# E.g. to only show posts tagged with `Academic`, set `filter_tag = "Academic"`
filter_tag = ""
filter_category = ""
# Filter posts by a taxonomy term.
[content.filters]
tag = ""
category = ""
publication_type = ""
exclude_featured = false
[design]
# Toggle between the various page layout types.
# 1 = List
# 2 = Compact
# 3 = Card
# 4 = Citation (publication only)
view = 2
[design.background]
# Apply a background color, gradient, or image.
# Uncomment (by removing `#`) an option to apply it.
# Choose a light or dark text color by setting `text_color_light`.
# Any HTML color name or Hex value is valid.
# Background color.
# color = "navy"
# Background gradient.
# gradient_start = "DeepSkyBlue"
# gradient_end = "SkyBlue"
# Background image.
# image = "background.jpg" # Name of image in `static/img/`.
# image_darken = 0.6 # Darken the image? Range 0-1 where 0 is transparent and 1 is opaque.
# Text color (true=light or false=dark).
text_color_light = true
[advanced]
# Custom CSS.
css_style = ""
# CSS class.
css_class = ""
+++
+56 -26
View File
@@ -1,38 +1,68 @@
+++
# Recent Publications widget.
# This widget displays recent publications from `content/publication/`.
widget = "publications" # Do not modify this line!
# A Recent Publications section created with the Pages widget.
# This section displays recent blog posts from `content/publication/`.
widget = "pages" # Do not modify this line!
active = true # Activate this widget? true/false
weight = 20 # Order that this section will appear.
title = "Recent Publications"
subtitle = ""
# Order that this section will appear in.
weight = 20
[content]
# Page type to display. E.g. post, talk, or publication.
page_type = "publication"
# Choose how much pages you would like to display (0 = all pages)
count = 5
# Choose how many pages you would like to offset by
offset = 0
# Number of publications to list.
count = 10
# Page order. Descending (desc) or ascending (asc) date.
order = "desc"
# View.
# 1 = List
# 2 = Compact
# 3 = Card
# 4 = Citation
view = 2
# Filter posts by a taxonomy term.
[content.filters]
tag = ""
category = ""
publication_type = ""
exclude_featured = false
[design]
# Toggle between the various page layout types.
# 1 = List
# 2 = Compact
# 3 = Card
# 4 = Citation (publication only)
view = 2
[design.background]
# Apply a background color, gradient, or image.
# Uncomment (by removing `#`) an option to apply it.
# Choose a light or dark text color by setting `text_color_light`.
# Any HTML color name or Hex value is valid.
# Background color.
# color = "navy"
# Background gradient.
# gradient_start = "DeepSkyBlue"
# gradient_end = "SkyBlue"
# Background image.
# image = "background.jpg" # Name of image in `static/img/`.
# image_darken = 0.6 # Darken the image? Range 0-1 where 0 is transparent and 1 is opaque.
# Filter by publication type.
# -1: Any
# 0: Uncategorized
# 1: Conference proceedings
# 2: Journal
# 3: Work in progress
# 4: Technical report
# 5: Book
# 6: Book chapter
publication_type = "-1"
# Exclude publications that are shown in the Featured Publications widget?
exclude_featured = false
# Text color (true=light or false=dark).
text_color_light = true
[advanced]
# Custom CSS.
css_style = ""
# CSS class.
css_class = ""
+++
{{% alert note %}}
+1 -1
View File
@@ -3,7 +3,7 @@
widget = "tag_cloud" # Do not modify this line!
active = true # Activate this widget? true/false
title = "Tags"
title = "Popular Topics"
subtitle = ""
# Order that this section will appear in.
+56 -14
View File
@@ -1,24 +1,66 @@
+++
# Recent and Upcoming Talks widget.
widget = "talks" # Do not modify this line!
# A Recent and Upcoming Talks section created with the Pages widget.
# This section displays recent talks from `content/talk/`.
widget = "pages" # Do not modify this line!
active = true # Activate this widget? true/false
weight = 30 # Order that this section will appear.
title = "Recent & Upcoming Talks"
subtitle = ""
# Order that this section will appear in.
weight = 30
[content]
# Page type to display. E.g. post, talk, or publication.
page_type = "talk"
# Choose how much pages you would like to display (0 = all pages)
count = 5
# Choose how many pages you would like to offset by
offset = 0
# Number of talks to list.
count = 10
# Page order. Descending (desc) or ascending (asc) date.
order = "desc"
# View.
# 1 = List
# 2 = Compact
# 3 = Card
view = 2
# Filter posts by a taxonomy term.
[content.filters]
tag = ""
category = ""
publication_type = ""
exclude_featured = false
[design]
# Toggle between the various page layout types.
# 1 = List
# 2 = Compact
# 3 = Card
# 4 = Citation (publication only)
view = 2
[design.background]
# Apply a background color, gradient, or image.
# Uncomment (by removing `#`) an option to apply it.
# Choose a light or dark text color by setting `text_color_light`.
# Any HTML color name or Hex value is valid.
# Exclude talks that are shown in the Featured Talks widget?
exclude_featured = false
# Background color.
# color = "navy"
# Background gradient.
# gradient_start = "DeepSkyBlue"
# gradient_end = "SkyBlue"
# Background image.
# image = "background.jpg" # Name of image in `static/img/`.
# image_darken = 0.6 # Darken the image? Range 0-1 where 0 is transparent and 1 is opaque.
# Text color (true=light or false=dark).
text_color_light = true
[advanced]
# Custom CSS.
css_style = ""
# CSS class.
css_class = ""
+++
+10 -10
View File
@@ -1,22 +1,22 @@
+++
# Custom widget.
# An example of using the custom widget to create your own homepage section.
# To create more sections, duplicate this file and edit the values below as desired.
# A Demo section created with the Custom widget.
# Any elements can be added in the body: https://sourcethemes.com/academic/docs/writing-markdown-latex/
# Add more sections by duplicating this file and customizing to your requirements.
widget = "custom" # Do not modify this line!
active = true # Activate this widget? true/false
weight = 60 # Order that this section will appear.
# Note: a full width section format can be enabled by commenting out the `title` and `subtitle` with a `#`.
title = "Teaching"
subtitle = ""
# Order that this section will appear in.
weight = 60
[design.background]
# Apply a background color, gradient, or image.
# Uncomment (by removing `#`) an option to apply it.
# Choose a light or dark text color by setting `text_color_light`.
# Any HTML color name or Hex value is valid.
# Background (optional).
# Choose from a background color, gradient, or image.
# Choose a dark or light text color, by setting `text_color_light`.
# Delete or comment out (by prefixing `#`) any unused options.
[background]
# Background color.
# color = "navy"
+7 -8
View File
@@ -88,21 +88,20 @@
- id: present
translation: Present
# Publications widget
# Pages widget
- id: more_publications
translation: See all publications
# Posts widget
- id: more_pages
translation: See all
- id: more_posts
translation: See all posts
# Talks widget
- id: more_talks
translation: See all talks
- id: more_publications
translation: See all publications
# Contact widget
- id: contact_name
@@ -169,7 +168,7 @@
- id: open_project_site
translation: Go to Project Site
# Default node titles
# Default titles for archive pages
- id: posts
translation: Posts
+10 -10
View File
@@ -2,19 +2,19 @@
{{ partial "navbar.html" . }}
<!-- Flag for jQuery -->
<span id="homepage" style="display: none"></span>
<span id="homepage" class="d-none"></span>
{{ $section := "" }}
{{ if .IsHome }}
{{ .Scratch.Set "section" "home" }}
{{ $section = "home" }}
{{ else }}
{{ .Scratch.Set "section" .Section }}
{{ $section = .Section }}
{{ end }}
{{ $section := .Scratch.Get "section" }}
<!-- Widgets -->
{{ range $index, $page := where (where .Data.Pages "Section" $section) ".Params.active" "!=" false }}
{{ range $index, $st := where (where .Data.Pages "Section" $section) ".Params.active" "!=" false }}
{{/* Begin widget styling */}}
{{ $bg := $page.Params.background }}
{{ $bg := $st.Params.design.background }}
{{ $style := "" }}
{{ if $bg.color }}
@@ -34,17 +34,17 @@
{{ $style = printf "%sbackground-image: %s url('%s');" $style $darken (printf "img/%s" $bg.image | absURL) }}
{{ end }}
{{ with $page.Params.css_custom }}
{{ with $st.Params.advanced.css_custom }}
{{ $style = print $style . }}
{{ end }}
{{ $params := dict "root" $ "page" $page }}
{{ $widget := or $page.Params.widget "custom" }}
{{ $params := dict "root" $ "page" $st }}
{{ $widget := or $st.Params.widget "custom" }}
{{ $widget_path := printf "widgets/%s.html" $widget }}
{{ if in (slice "slider") $widget }}
{{ partial $widget_path $params }}
{{ else }}
<section id="{{ $page.File.TranslationBaseName }}" class="home-section {{ printf "wg-%s" (replace $widget "_" "-") }} {{if $bg.text_color_light}}dark{{end}} {{if $bg.image}}parallax{{end}} {{ with $page.Params.css_class }}{{ . }}{{ end }}" {{with $style}}style="{{. | safeCSS}}"{{end}}>
<section id="{{ $st.File.TranslationBaseName }}" class="home-section {{ printf "wg-%s" (replace $widget "_" "-") }} {{if $bg.text_color_light}}dark{{end}} {{if $bg.image}}parallax{{end}} {{ with $st.Params.advanced.css_class }}{{ . }}{{ end }}" {{with $style}}style="{{. | safeCSS}}"{{end}}>
<div class="container">
{{ partial $widget_path $params }}
</div>
+93
View File
@@ -0,0 +1,93 @@
{{/* Pages Widget */}}
{{/* Initialise */}}
{{ $ := .root }}
{{ $st := .page }}
{{ $items_type := $st.Params.content.page_type | default "post" }}
{{ $items_offset := $st.Params.content.offset | default 0 }}
{{ $items_count := $st.Params.content.count | default 5 }}
{{ $items_sort := $st.Params.content.order| default "desc" }}
{{/* Query */}}
{{ $query := where $.Site.RegularPages "Type" $items_type }}
{{ $archive_page := $.Site.GetPage "Section" $items_type }}
{{/* Filters */}}
{{ if $st.Params.content.filters.tag }}
{{ $archive_page = $.Site.GetPage (printf "tags/%s" $st.Params.filters.content.tag) }}
{{ $query = $query | intersect $archive_page.Pages }}
{{ end }}
{{ if $st.Params.content.filters.category }}
{{ $archive_page = $.Site.GetPage (printf "categories/%s" $st.Params.filters.content.category) }}
{{ $query = $query | intersect $archive_page.Pages }}
{{ end }}
{{ if $st.Params.content.filters.publication_type }}
{{ $archive_page = $.Site.GetPage (printf "publication_types/%s" $st.Params.content.filters.publication_type) }}
{{ $query = $query | intersect $archive_page.Pages }}
{{ end }}
{{ if $st.Params.content.filters.exclude_featured }}
{{ $query = where $query "Params.featured" "!=" true }}
{{ end }}
{{/* Offset */}}
{{ if gt $items_offset 0 }}
{{ $query = first $items_count (after $items_offset $query) }}
{{ else }}
{{ $query = first $items_count $query }}
{{ end }}
{{/* Sort */}}
{{ $sort_by := "" }}
{{ if eq $items_type "talk" }}
{{ $sort_by = "Params.time_start" }}
{{ else }}
{{ $sort_by = "Date" }}
{{ end }}
{{ $query = sort $query $sort_by $items_sort }}
{{ $count := len $query }}
{{/* Localisation */}}
{{ $i18n := "" }}
{{ if eq $items_type "post" }}
{{ $i18n = "more_posts" }}
{{ else if eq $items_type "talk" }}
{{ $i18n = "more_talks" }}
{{ else if eq $items_type "publication" }}
{{ $i18n = "more_publications" }}
{{ else }}
{{ $i18n = "more_pages" }}
{{ end }}
<div class="row">
<div class="col-12 col-lg-4 section-heading">
<h1>{{ with $st.Title }}{{ . | markdownify | emojify }}{{ end }}</h1>
{{ with $st.Params.subtitle }}<p>{{ . | markdownify | emojify }}</p>{{ end }}
</div>
<div class="col-12 col-lg-8">
{{ with $st.Content }}<p>{{ . }}</p>{{ end }}
{{ range $post := $query }}
{{ if eq $st.Params.design.view 1 }}
{{ partial "li_list" . }}
{{ else if eq $st.Params.design.view 3 }}
{{ partial "li_card" . }}
{{ else if eq $st.Params.design.view 3 | and (eq $st.Type "publication") }}
{{ partial "li_citation" . }}
{{ else }}
{{ partial "li_compact" . }}
{{ end }}
{{end}}
{{ if gt $count $items_count }}
<div class="see-all">
<a href="{{ $archive_page.RelPermalink }}">
{{ i18n $i18n | default "See all" }}
<i class="fas fa-angle-right"></i>
</a>
</div>
{{ end }}
</div>
</div>
-48
View File
@@ -1,48 +0,0 @@
{{ $ := .root }}
{{ $page := .page }}
{{ $query := where (where $.Site.RegularPages "Type" "post") ".Params.notonhomepage" nil }}
{{ $archive_page := $.Site.GetPage "section" "post" }}
{{/* Check if a filter should be applied. */}}
{{ if $page.Params.filter_tag }}
{{ $archive_page = $.Site.GetPage (printf "tags/%s" $page.Params.filter_tag) }}
{{ $query = $query | intersect $archive_page.Pages }}
{{ else if $page.Params.filter_category }}
{{ $archive_page = $.Site.GetPage (printf "categories/%s" $page.Params.filter_category) }}
{{ $query = $query | intersect $archive_page.Pages }}
{{ end }}
{{ $count := len $query }}
<!-- Blog Posts widget -->
<div class="row">
<div class="col-12 col-lg-4 section-heading">
<h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
{{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
</div>
<div class="col-12 col-lg-8">
{{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}
{{ range $post := first $page.Params.count $query }}
{{ if eq $page.Params.view 1 }}
{{ partial "li_list" . }}
{{ else if eq $page.Params.view 3 }}
{{ partial "li_card" . }}
{{ else }}
{{ partial "li_compact" . }}
{{ end }}
{{end}}
{{ if gt $count $page.Params.count }}
<div class="see-all">
<a href="{{ $archive_page.RelPermalink }}">
{{ i18n "more_posts" | markdownify }}
<i class="fas fa-angle-right"></i>
</a>
</div>
{{ end }}
</div>
</div>
@@ -1,45 +0,0 @@
{{ $ := .root }}
{{ $page := .page }}
{{ $query := where $.Site.RegularPages "Type" "publication" }}
{{ if and ($page.Params.publication_type) (ne $page.Params.publication_type "-1") }}
{{ $query = where $query ".Params.publication_types" "intersect" (slice $page.Params.publication_type) }}
{{ end }}
{{ if $page.Params.exclude_featured }}
{{ $query = $query | intersect (where (where $.Site.RegularPages "Type" "publication") ".Params.featured" "!=" true) }}
{{ end }}
{{ $count := len $query }}
<!-- Publications widget -->
<div class="row">
<div class="col-12 col-lg-4 section-heading">
<h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
{{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
</div>
<div class="col-12 col-lg-8">
{{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}
{{ range first $page.Params.count $query }}
{{ if eq $page.Params.view 1 }}
{{ partial "li_list" . }}
{{ else if eq $page.Params.view 3 }}
{{ partial "li_card" . }}
{{ else if eq $page.Params.view 4 }}
{{ partial "li_citation" . }}
{{ else }}
{{ partial "li_compact" . }}
{{ end }}
{{ end }}
{{ if gt $count $page.Params.count }}
<div class="see-all">
<a href="{{ ($.Site.GetPage "section" "publication").RelPermalink }}">
{{ i18n "more_publications" | markdownify }}
<i class="fas fa-angle-right"></i>
</a>
</div>
{{ end }}
</div>
</div>
-41
View File
@@ -1,41 +0,0 @@
{{ $ := .root }}
{{ $page := .page }}
{{ $count := len (where $.Site.RegularPages "Type" "talk") }}
<!-- Talks widget -->
<div class="row">
<div class="col-12 col-lg-4 section-heading">
<h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
{{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
</div>
<div class="col-12 col-lg-8">
{{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}
{{ $talks := where $.Site.RegularPages "Type" "talk" }}
{{/* Exclude talks shown in Featured Talks widget? */}}
{{ if $page.Params.exclude_featured }}
{{ $talks = (where $talks ".Params.featured" "!=" true) }}
{{ end }}
{{ range first $page.Params.count (sort $talks ".Params.time_start" "desc") }}
{{ if eq $page.Params.view 1 }}
{{ partial "li_list" . }}
{{ else if eq $page.Params.view 3 }}
{{ partial "li_card" . }}
{{ else }}
{{ partial "li_compact" . }}
{{ end }}
{{ end }}
{{ if gt $count $page.Params.count }}
<div class="see-all">
<a href="{{ ($.Site.GetPage "section" "talk").RelPermalink }}">
{{ i18n "more_talks" | markdownify }}
<i class="fas fa-angle-right"></i>
</a>
</div>
{{ end }}
</div>
</div>