Skip to content

Commit

Permalink
Add support for upcoming episodes (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstratton authored Nov 23, 2020
1 parent 120d700 commit 4a467b7
Show file tree
Hide file tree
Showing 17 changed files with 390 additions and 25 deletions.
35 changes: 33 additions & 2 deletions REFERENCE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
# Reference for castanet

# Table of contents

<!-- TOC -->autoauto- [Reference for castanet](#reference-for-castanet)auto- [Table of contents](#table-of-contents)auto - [The config file](#the-config-file)auto - [Top-level items](#top-level-items)auto - [General Parameters](#general-parameters)auto - [Feed Parameters](#feed-parameters)auto - [Social Parameters](#social-parameters)auto - [Host/Author Parameters](#hostauthor-parameters)auto - [Host Social Parameters](#host-social-parameters)auto - [Link Parameters](#link-parameters)auto - [A note about `BaseURL`](#a-note-about-baseurl)auto - [Pagination setting with grid layout](#pagination-setting-with-grid-layout)auto - [Permalinks](#permalinks)auto - [Menus](#menus)auto - [Podlove Subscribe Button](#podlove-subscribe-button)auto - [Episodes](#episodes)auto - [Guests](#guests)auto - [Guest Pages](#guest-pages)auto - [Hosts](#hosts)auto - [Host Pages](#host-pages)auto - [Sponsors](#sponsors)autoauto<!-- /TOC -->
<!-- TOC depthFrom:2 updateOnSave:false-->

- [The config file](#the-config-file)
- [Top-level items](#top-level-items)
- [General Parameters](#general-parameters)
- [Feed Parameters](#feed-parameters)
- [Favicon parameters](#favicon-parameters)
- [Social Parameters](#social-parameters)
- [Host/Author Parameters](#hostauthor-parameters)
- [Host Social Parameters](#host-social-parameters)
- [Link Parameters](#link-parameters)
- [A note about `BaseURL`](#a-note-about-baseurl)
- [Pagination setting with grid layout](#pagination-setting-with-grid-layout)
- [Permalinks](#permalinks)
- [Menus](#menus)
- [Podlove Subscribe Button](#podlove-subscribe-button)
- [Episodes](#episodes)
- [Upcoming Episodes](#upcoming-episodes)
- [Guests](#guests)
- [Guest Pages](#guest-pages)
- [Hosts](#hosts)
- [Host Pages](#host-pages)
- [Sponsors](#sponsors)

## The config file

Expand Down Expand Up @@ -256,6 +277,7 @@ podcast_bytes = "123456789"
title = "Back to School"
youtube = ""
truncate = ""
upcoming = false
+++
Expand Down Expand Up @@ -284,6 +306,15 @@ Graphical user interface influencer value proposition startup hackathon iPad ana
| `truncate` | No | The number of characters to truncate the summary on the row layout.. The default value (if not set) is 600 characters. | "700" |
| `guid` | No | A fixed, globally unique identifier for the episode which should never change. If one is not specified the URL of the `podcast_file` will be used instead. | "aae20190418" |
| `transcript` | No | The path to the transcript file. The file can have Markdown or be in HTML. It must be relative to the root of your site (this is a file path, not a URL). It is recommended to put them in your `static` directory so that Hugo doesn't try to process them. | "/static/transcripts/chatops.txt" |
| `upcoming` | No | Boolean value if the episode should be considered "upcoming" and not published. Values include `true` or `false`. If set to `true`, the episode will not show up in episode lists (including guest and host pages) and will not be part of the feed. Upcoming episodes will be listed on the "Upcoming" page if created. | true |

### Upcoming Episodes

If you would like to display upcoming episodes, you need to do a couple things. First, you will need to create a page where the upcoming episodes will be listed. You can check out `exampleSite` for an example, but basically, you want to create `content/upcoming/_index.md`.

Any episodes that have `upcoming` in their frontmatter set to `true` will be listed here, but not listed on any other pages (feed, home page, guest pages, etc). Additionally, episodes that are marked as "upcoming" will not display a YouTube video or audio player, even if those parameters are set.

Note: you will need to set `buildFuture = true` in your `config.toml` to allow Hugo to build upcoming episodes that are dated in the future.

## Guests

Expand Down
1 change: 1 addition & 0 deletions archetypes/episode.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ images = ["img/episode/default-social.jpg"]
explicit = "no" # values are "yes" or "no"
# media_override # if you want to use a specific URL for the audio file
# truncate = ""
# upcoming = true # set to true if you want this to be listed as upcoming, etc, etc
+++
6 changes: 6 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ theme = "castanet"
googleAnalytics = ""
themesdir = "../.."
paginate = "9"
buildFuture = true


[permalinks]
Expand Down Expand Up @@ -36,6 +37,11 @@ paginate = "9"
identifier = "guests"
url = "/guest"

[[Menu.Main]]
name = "Upcoming Episodes"
identifier = "upcoming"
url = "/upcoming"

[[Menu.Main]]
name = "Resources"
identifier = "resources"
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/episode/june.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ podcast_bytes = ""
tags = []
title = "School's Out For Summer"
youtube = ""

upcoming = false
+++

Bootstrapping alpha seed money scrum project. Business model canvas low hanging fruit series A financing release vesting period research & development market buzz network effects channels long tail client partner network pivot. Innovator market android buyer gamification. User experience gamification interaction design sales. Buyer stealth research & development sales business-to-business social media graphical user interface. Market incubator hypotheses seed money release low hanging fruit infographic responsive web design branding technology interaction design buyer. Ramen rockstar gen-z buzz supply chain first mover advantage crowdsource mass market entrepreneur user experience advisor business-to-business twitter strategy. Termsheet low hanging fruit lean startup crowdfunding customer. Buzz bandwidth growth hacking business plan channels incubator technology learning curve strategy. Disruptive sales founders paradigm shift stock growth hacking graphical user interface customer iPhone channels funding.
Expand Down
4 changes: 3 additions & 1 deletion exampleSite/content/episode/sept.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ Description = "Bootstrapping alpha seed money scrum project. Business model canv
aliases = ["/12"]
author = "Matt"
categories = []
date = "2016-09-25T04:10:01-05:00"
date = "2020-12-25T04:10:01-05:00"
episode = "12"
episode_image = "img/episode/sept.jpg"
#episode_banner = "img/episode/default-banner.jpg"
explicit = "no"
guests = ["jsmith", "ccooper"]
hosts = ["mstratton","bkromhout"]
sponsors = ["bluthcompany"]
images = ["img/episode/default-social.jpg"]
news_keywords = []
Expand All @@ -20,6 +21,7 @@ title = "Back to School"
youtube = ""
truncate = ""
transcript = "/static/transcripts/chatops.txt"
upcoming = true
+++

Graphical user interface influencer value proposition startup hackathon iPad analytics gen-z entrepreneur release traction product management long tail. Buzz business-to-consumer android learning curve innovator seed money iteration buyer startup. Holy grail graphical user interface responsive web design lean startup bandwidth strategy release innovator low hanging fruit non-disclosure agreement. Strategy handshake iPhone interaction design early adopters. Low hanging fruit crowdfunding vesting period. Low hanging fruit social proof series A financing product management founders bootstrapping ecosystem buyer supply chain hackathon direct mailing churn rate client. Scrum project direct mailing ecosystem monetization innovator. Partner network gen-z conversion pivot iPhone infographic growth hacking business plan facebook alpha marketing beta technology. Focus crowdsource venture strategy user experience. Lean startup disruptive user experience stealth interaction design monetization client long tail virality seed round direct mailing hypotheses technology burn rate.
Expand Down
6 changes: 6 additions & 0 deletions exampleSite/content/upcoming/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
+++
date = "2016-09-25T02:11:48-05:00"
description = "about this site"
title = "Upcoming Episodes"
+++
these are episodes that aren't published yet
32 changes: 20 additions & 12 deletions layouts/episode/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
<div class="row">
<div class="col">
<h1>{{ title .Title }}</h1>
<small>Posted on {{ dateFormat "Monday, Jan 2, 2006" .Date }}</small>
{{- if ne $.Params.upcoming true -}}
<small>Posted on {{ dateFormat "Monday, Jan 2, 2006" .Date }}</small>
{{- else -}}
<small>Scheduled for {{ dateFormat "Monday, Jan 2, 2006" .Date }}</small>
{{- end -}}
</div>
</div>

Expand Down Expand Up @@ -44,23 +48,27 @@ <h1>{{ title .Title }}</h1>
<!-- end square row -->
{{ end }}
{{- with .Params.podcast_file -}}
<div class="row">
<div class="col-md-12 player_row">
{{- if ne $.Params.upcoming true -}}
<div class="row">
<div class="col-md-12 player_row">

<audio id="player2" style="width: 100%" controls preload="none">
<source src="{{ $.Site.Params.media_prefix }}{{ . }}" type="audio/mp3">
</audio>
<audio id="player2" style="width: 100%" controls preload="none">
<source src="{{ $.Site.Params.media_prefix }}{{ . }}" type="audio/mp3">
</audio>
</div>
</div>
</div>
{{- end -}}
{{- end -}}
{{- with .Params.youtube -}}
<div class = "row youtube_row">
<div class = "col">
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="//www.youtube.com/embed/{{ . }}" allowfullscreen></iframe>
{{- if ne $.Params.upcoming true -}}
<div class = "row youtube_row">
<div class = "col">
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="//www.youtube.com/embed/{{ . }}" allowfullscreen></iframe>
</div>
</div>
</div>
</div>
{{- end -}}
{{- end -}}

<!-- transcript POC begin-->
Expand Down
2 changes: 1 addition & 1 deletion layouts/guest/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ <h3>Episodes Featuring {{ .Title }}</h3>
<div class="list-group guest_episode_list">
{{ range $name := ($.Scratch.Get "guest-names") }}
{{- $.Scratch.Set "guest-name" $name -}}
{{- range $page := where $.Site.Pages "Type" "episode" -}}
{{- range $page := (where ( where site.RegularPages "Type" "in" site.Params.mainSections) ".Params.upcoming" "!=" true ) -}}
{{- range $page.Params.guests -}}
{{- if eq . ($.Scratch.Get "guest-name") -}}
<a href = "{{$page.Permalink}}" class = "guest_page_episode_link list-group-item list-group-item-action">{{$page.Title}}</a>
Expand Down
2 changes: 1 addition & 1 deletion layouts/host/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h1>Hosts of {{ .Site.Title }}</h1>
</div>
</div>
{{ with .Content }}
<div clas = "row">
<div class = "row">
<div class = "col">
{{ . }}
</div>
Expand Down
4 changes: 2 additions & 2 deletions layouts/host/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h1>{{ title .Title }}</h1>
<h3>Episodes Hosted By {{ .Title }}</h3>
<div class="list-group guest_episode_list">
{{ $.Scratch.Set "host-name" .File.BaseFileName }}
{{ range $page := where $.Site.Pages "Type" "episode" }}
{{ range $page := (where ( where site.RegularPages "Type" "in" site.Params.mainSections) ".Params.upcoming" "!=" true ) }}
{{ range $page.Params.hosts }}
{{ if eq . ($.Scratch.Get "host-name") }}
<a href = "{{$page.Permalink}}" class = "guest_page_episode_link list-group-item list-group-item-action">{{$page.Title}}</a>
Expand All @@ -94,7 +94,7 @@ <h3>Episodes Hosted By {{ .Title }}</h3>
{{- with .Params.Aka -}}
{{ range $name := . }}
{{- $.Scratch.Set "host-name" $name -}}
{{- range $page := where $.Site.Pages "Type" "episode" -}}
{{- range $page := (where ( where site.RegularPages "Type" "in" site.Params.mainSections) ".Params.upcoming" "!=" true ) -}}
{{- range $page.Params.hosts -}}
{{- if eq . ($.Scratch.Get "host-name") -}}
<a href = "{{$page.Permalink}}" class = "guest_page_episode_link list-group-item list-group-item-action">{{$page.Title}}</a>
Expand Down
117 changes: 117 additions & 0 deletions layouts/partials/grid-upcoming.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<section class="episode-list">

<div class = "col episode-list-header">
<h2 class = "episode-list-header">All Episodes</h2>
</div>

<div class = "row">

{{ $paginator := .Paginate (where ( where site.RegularPages "Type" "in" site.Params.mainSections) ".Params.upcoming" "==" true ) }}

{{ range $paginator.Pages }}
{{ $.Scratch.Set "episode" .File.BaseFileName }}
<div class="col-md-4 grid_episode_col">
<div class="episode-image-homepage">
<a href="{{ .Permalink }}">
<img src="{{ .Params.episode_image | absURL }}" class="img-fluid" alt="{{ .Title }}" />



</a>
</div>
<div class="grid_episode_detail">
<a href="{{ .Permalink }}" class= "grid_episode_title"><h3>{{ title .Title }}</h3></a>
<small class = "grid_episode_title">Scheduled for {{ dateFormat "Monday, Jan 2, 2006" .Date }}</small>
</div>

</div>
{{ end }}


</div>

</section>
{{ if gt $paginator.TotalPages 1 }}
<div class = "row">
<div class = "col">


<nav class="pagination justify-content-center">

{{ $pag := $.Paginator }}
{{ $window := $.Site.Params.paginateWindow | default 1 }}
{{ if gt $pag.TotalPages 1 }}
{{ $total := $pag.TotalPages }}
{{ $size := add 5 (add $window $window) }}
{{ $cur := $pag.PageNumber }}
{{ if gt $total $size }}
{{ if lt $cur (sub $size (add $window 1)) }}
{{ $.Scratch.Set "show" (seq 1 (sub $size 2)) }}
{{ else if lt (sub $total $cur) (sub $size (add $window 2)) }}
{{ $.Scratch.Set "show" (seq (add (sub $total $size) 3) $total) }}
{{ else }}
{{ $.Scratch.Set "show" (seq (sub $cur $window) (add $cur $window)) }}
{{ end }}
{{ $.Scratch.Add "show" 1 }}
{{ $.Scratch.Add "show" $total }}
{{ else }}
{{ $.Scratch.Set "show" (seq 1 $total) }}
{{ end }}

<ul class="pagination pagination-lg">
<!-- first page button -->
{{if $paginator.HasPrev }}
{{ if gt $paginator.PageNumber 2 }}
{{- with $paginator.First -}}
{{- $url := trim (string .URL) "/" | absURL -}}
<li class="page-item">
<a href="{{ $url }}" aria-label="First" class="page-link"><span aria-hidden="true">&laquo;&laquo;</span></a>
</li>
{{- end -}}
{{ end }}
{{ end }}


<!-- prev page button -->
{{- with $paginator.HasPrev -}}
<li class="page-item">
<a href="{{ $paginator.Prev.URL }}" class="page-link"> &laquo; </a>
</li>
{{ end }}

<!-- page # buttons -->
{{ range $pag.Pagers }}
{{ $cur := .PageNumber }}
{{- $url := trim (string $.URL) "/" | absURL -}}
{{ if in ($.Scratch.Get "show") $cur }}
<li class = "{{ if eq . $pag }}active{{ end }} page-item"><a href="{{ .URL }}" class="page-link hidden-md-down">{{ .PageNumber }}</a></li>
{{ else if in (slice 2 (sub $total 1)) $cur }}
<li class="disabled page-item"><a name="" class="page-link hidden-md-down">&hellip;</a></li>
{{ end }}
{{ end }}

<!-- next page button -->
{{- with $paginator.HasNext -}}
<li class="page-item">
<a href="{{ $paginator.Next.URL }}" class="page-link"> &raquo; </a>
</li>
{{ end }}

<!-- last page button -->
{{ if lt $paginator.PageNumber (sub $paginator.TotalPages 1) }}
{{- with $paginator.Last -}}
{{- $url := trim (string .URL) "/" | absURL -}}
<li class="page-item">
<a href="{{ $url }}" aria-label="Last" class="page-link"><span aria-hidden="true">&raquo;&raquo;</span></a>
</li>
{{- end -}}
{{ end }}

</ul>
{{ end }}
</nav>
</div>
</div>
{{ end }}
</div>
</div>
3 changes: 2 additions & 1 deletion layouts/partials/grid.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ <h2 class = "episode-list-header">All Episodes</h2>

<div class = "row">

{{ $paginator := .Paginate (where site.RegularPages "Type" "in" site.Params.mainSections) }}
{{ $paginator := .Paginate (where ( where site.RegularPages "Type" "in" site.Params.mainSections) ".Params.upcoming" "!=" true ) }}

{{ range $paginator.Pages }}
{{ $.Scratch.Set "episode" .File.BaseFileName }}
<div class="col-md-4 grid_episode_col">
Expand Down
Loading

0 comments on commit 4a467b7

Please sign in to comment.