Skip to content

[site] make program title dynamic #14919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
243 changes: 243 additions & 0 deletions themes/devopsdays-theme/layouts/partials/program.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
{{- $.Scratch.Set "first" "true" -}}
{{- with .Params.icons -}}
{{- $.Scratch.Set "icons" (. | upper ) -}}
{{- end -}}
{{- $e := partial "functions/get-event-data" . -}}
{{- $p := index $.Site.Data.events (index (split (.Permalink | relURL) "/") 2) "program" -}}
{{ if eq $p nil }}
{{ $p = $e }}
{{ end }}
{{- if $e.startdate -}}
{{/* {{- range where $.Site.Pages "Type" "talk" -}} */}}
{{ if (where (readDir (printf "content/events/%s/" $e.name)) "Name" "program") }}
{{ range os.ReadDir (printf "content/events/%s/program/" $e.name) }}
{{ $filename := (printf "/events/%s/program/%s" $e.name .Name) }}
{{/* {{ with $.Site.GetPage (printf "content/events/2022-chicago/program/%s" .Name) }} */}}
{{ with $.Site.GetPage $filename }}
{{/* {{- $talk_path := split .File.Path .Site.Params.PathSeparator -}} */}}
{{- if eq (index (split (.Permalink | relURL) "/") 2) $e.name -}}
{{- $.Scratch.Set "base_file_name" .File.BaseFileName -}}
{{- $.Scratch.Set .File.BaseFileName .Title -}}
{{- with .Params.vimeo -}}
{{- $.Scratch.Set (printf "%s-video_link" ($.Scratch.Get "base_file_name")) (printf "https://player.vimeo.com/video/%s" .) }}
{{- end -}}
{{- with .Params.youtube -}}
{{- $.Scratch.Set (printf "%s-video_link" ($.Scratch.Get "base_file_name")) (printf "https://www.youtube.com/embed/%s" .) }}
{{- end -}}
{{- with .Params.speakerdeck -}}
{{- $.Scratch.Set (printf "%s-slides_link" ($.Scratch.Get "base_file_name")) . }}
{{- end -}}
{{- with .Params.slideshare -}}
{{- $.Scratch.Set (printf "%s-slides_link" ($.Scratch.Get "base_file_name")) . }}
{{- end -}}
{{- with .Params.googleslides -}}
{{- $.Scratch.Set (printf "%s-slides_link" ($.Scratch.Get "base_file_name")) (printf "https://docs.google.com/presentation/d/%s" .) }}
{{- end -}}
{{- with .Params.pdf -}}
{{- $.Scratch.Set (printf "%s-slides_link" ($.Scratch.Get "base_file_name")) . }}
{{- end -}}
{{- with .Params.notist -}}
{{- $.Scratch.Set (printf "%s-slides_link" ($.Scratch.Get "base_file_name")) (printf "https://noti.st/%s" .) }}
{{- end -}}
{{- with .Params.slideslive -}}
{{- $.Scratch.Set (printf "%s-slides_link" ($.Scratch.Get "base_file_name")) (printf "https://slideslive.com/%s" .) }}
{{- end -}}
{{- with .Params.slides -}}
{{- $.Scratch.Set (printf "%s-slides_link" ($.Scratch.Get "base_file_name")) . }}
{{- end -}}
{{- if isset .Params "speakers" -}}
{{- if ne .Params.speakers "" -}}
{{- $.Scratch.Set "speaker_len" (.Params.speakers | len) -}}
{{- $.Scratch.Set "speaker_count" 0 -}}
{{- end -}}
{{- end -}}
{{- range .Params.speakers -}}
{{- $.Scratch.Set "speaker_count" (add ($.Scratch.Get "speaker_count") 1) -}}
{{- $.Scratch.Set "speakername" . -}}
{{/* {{- range where $.Site.Pages "Type" "speaker" -}}
{{- if eq (index (split (.Permalink | relURL) "/") 2) $e.name -}} */}}
{{ if (where (readDir (printf "content/events/%s/" $e.name)) "Name" "speakers") }}
{{ range os.ReadDir (printf "content/events/%s/speakers/" $e.name) }}
{{ $filename := (printf "/events/%s/speakers/%s" $e.name .Name) }}
{{ with $.Site.GetPage $filename }}
{{- if eq .File.BaseFileName ($.Scratch.Get "speakername") -}}
{{- $.Scratch.Add (printf "%s-speaker" ($.Scratch.Get "base_file_name")) .Title -}}
{{- if ne ($.Scratch.Get "speaker_count") ($.Scratch.Get "speaker_len") -}}
{{- $.Scratch.Add (printf "%s-speaker" ($.Scratch.Get "base_file_name")) ", " -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
<!-- end if eq $talk_slug $e.name -->
{{- end -}}
{{- end -}}
{{- end -}}
<!-- end range where $.Site.Pages "Type" "speaker" -->
<!-- Get the dates for the program -->
{{- with $p -}}
{{- range .program -}}
{{- $.Scratch.SetInMap "dates" .date .date -}}
{{- end -}}
{{- end -}}
<!-- new experimental program end -->
{{- if or $e.timeoffset $e.timezone -}}
<script>
var userLang = navigator.language || navigator.userLanguage;
var date = new Date();
var userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
var userTimeAbbreviation = Intl.DateTimeFormat(userLang,{ timeZone: userTimeZone, timeZoneName: 'short' }).formatToParts().find(part => part.type==='timeZoneName').value;
</script>
{{- end -}}
{{- if $e.timezone -}}
<script>
var eventTimeOffset = (Intl.DateTimeFormat(userLang,{ timeZone: "{{ $e.timezone }}", timeZoneName: 'longOffset' }).formatToParts().find(part => part.type==='timeZoneName').value).slice(3,99);
var eventTimeAbbreviation = Intl.DateTimeFormat(userLang,{ timeZone: "{{ $e.timezone }}", timeZoneName: 'short' }).formatToParts().find(part => part.type==='timeZoneName').value;
</script>
{{- end -}}
<div class="row">
<div class="col">
<div id="accordion" role="tablist" aria-multiselectable="true">
{{- range ($.Scratch.GetSortedMapValues "dates") -}}
{{- $.Scratch.Set "date" . -}}
{{- with $p -}}
{{- if .program -}}
<div class="card">
<div class="card-header" role="tab" id="{{printf "headingOne-%s" ($.Scratch.Get "date") }}">
<h5 class="mb-0">
{{- dateFormat "January 2, 2006" ($.Scratch.Get "date") -}}
</a>
</h5>
</div>
<div id='{{printf "#collapse-%s" ($.Scratch.Get "date") }}" class="collapse show" role="tabpanel" aria-labelledby="{{printf "headingOne-%s" ($.Scratch.Get "date") }}'>
<div class="card-block">
<div class="row">
<div class="col-lg-6">
{{- $program := (where .program "date" ($.Scratch.Get "date")) -}}
{{- $program_len := (len $program) -}}
{{- $.Scratch.Set "program_len" $program_len -}}
{{- $.Scratch.Set "program_counter" 0 -}}
{{- range where .program "date" ($.Scratch.Get "date") -}}
{{- $.Scratch.Set "program_counter" (add ($.Scratch.Get "program_counter") 1) -}}
<div class = "row program-row">
<div class="col-lg-3 col-md-3 program-element {{ printf "program-%s" .type }}" {{ if .background_color }}style="background-color: {{ .background_color }}"{{end}}>
{{ .start_time }}
-
{{ .end_time }}
{{- if $e.timezone -}}
&nbsp;<script>document.write(eventTimeAbbreviation)</script>
{{- end -}}
{{- if or $e.timeoffset $e.timezone -}}
<br>
{{- if $e.timeoffset -}}
<script>
var localstarttime = new Date("{{- dateFormat "2006-01-02" ($.Scratch.Get "date") -}}T"+{{- .start_time -}}+":00"+{{- $e.timeoffset -}});
var localendtime = new Date("{{- dateFormat "2006-01-02" ($.Scratch.Get "date") -}}T"+{{- .end_time -}}+":00"+{{- $e.timeoffset -}});
</script>
{{- end -}}
{{- if not $e.timeoffset -}}
<script>
var localstarttime = new Date("{{- dateFormat "2006-01-02" ($.Scratch.Get "date") -}}T"+{{ .start_time }}+":00"+eventTimeOffset);
var localendtime = new Date("{{- dateFormat "2006-01-02" ($.Scratch.Get "date") -}}T"+{{ .end_time }}+":00"+eventTimeOffset);
</script>
{{- end -}}
<script>
document.write("<strong>");
document.write(String(localstarttime.getHours()).padStart(2,"0")+":"+String(localstarttime.getMinutes()).padStart(2,"0"));
document.write("&nbsp;-&nbsp;");
document.write(String(localendtime.getHours()).padStart(2,"0")+":"+String(localendtime.getMinutes()).padStart(2,"0"));
document.write("&nbsp;");
document.write(userTimeAbbreviation);
document.write("</strong>");
</script>
{{- end -}}
</div>
<div class="col-lg-8 col-md-6 program-element {{ printf "program-%s" .type }}" {{ if .background_color }}style="background-color: {{ .background_color }}"{{end}}>
{{- if eq .type "custom" -}}
{{- if .custom_url -}}
<a href="{{ .custom_url | safeURL }}">{{ .title }}<br/></a>
{{- else -}}
{{ .title }}<br/>
{{- end -}}
{{- if .comments -}}
<span class="program-page-desc">{{ .comments | markdownify }}<br/></span>
{{- end -}}
{{- else if or (eq .type "talk") (eq .type "workshop") -}}
{{- if .custom_url -}}
<a href="{{ .custom_url | safeURL }}">{{ $.Scratch.Get (printf "%s-speaker" .title) }} - {{ $.Scratch.Get .title }}</a><br/>
{{- else -}}
<a href='{{ (printf "/events/%s/program/%s" $e.name .title) }}'>{{ $.Scratch.Get (printf "%s-speaker" .title) }} - {{ $.Scratch.Get .title }}</a><br/>
{{- end -}}
{{- if eq ($.Scratch.Get "icons") "TRUE" -}}
{{- with ($.Scratch.Get (printf "%s-video_link" .title)) -}}&nbsp;<a href="{{ . }}"><i class="fa fa-video-camera" aria-hidden="true"></i></a>&nbsp;{{- end -}}
{{- with ($.Scratch.Get (printf "%s-slides_link" .title)) -}}&nbsp;<a href="{{ . }}"><i class="fa fa-file-text-o" aria-hidden="true"></i></a>&nbsp;{{- end -}}
{{- end -}}
{{- if .comments -}}
<span class="program-page-desc">{{ .comments | markdownify }}<br/></span>
{{- end -}}
{{- else if eq .type "ignite" -}}
{{ .title }}
<!-- new ignite code start -->
<ul class = "list-unstyled">
{{- if .block -}}
{{- $block := .block -}}
{{- range $p.ignites -}}
{{- if eq .block $block -}}
<li>
<a href="/events/{{ $e.name }}/program/{{ .title }}">{{ $.Scratch.Get (printf "%s-speaker" .title) }} - {{ $.Scratch.Get .title }}</a>
{{- if eq ($.Scratch.Get "icons") "TRUE" -}}
{{- with ($.Scratch.Get (printf "%s-video_link" .title)) -}}&nbsp;<a href="{{ . }}"><i class="fa fa-video-camera" aria-hidden="true"></i></a>&nbsp;{{- end -}}
{{- with ($.Scratch.Get (printf "%s-slides_link" .title)) -}}&nbsp;<a href="{{ . }}"><i class="fa fa-file-text-o" aria-hidden="true"></i></a>&nbsp;{{- end -}}
{{- end -}}
</li>
{{- end -}}
{{- end -}}
{{- else -}}
{{- range where $p.ignites "date" ($.Scratch.Get "date") -}}
{{- if not .block -}}
<li>
<a href="/events/{{ $e.name }}/program/{{ .title }}">{{ $.Scratch.Get (printf "%s-speaker" .title) }} - {{ $.Scratch.Get .title }}</a>
{{- if eq ($.Scratch.Get "icons") "TRUE" -}}
{{- with ($.Scratch.Get (printf "%s-video_link" .title)) -}}&nbsp;<a href="{{ . }}"><i class="fa fa-video-camera" aria-hidden="true"></i></a>&nbsp;{{- end -}}
{{- with ($.Scratch.Get (printf "%s-slides_link" .title)) -}}&nbsp;<a href="{{ . }}"><i class="fa fa-file-text-o" aria-hidden="true"></i></a>&nbsp;{{- end -}}
{{- end -}}
</li>
{{- end -}}
{{- end -}}
{{- end -}}
</ul>
<!-- new ignite code end -->
<!-- do open-space stuff here -->
{{- else if (eq .type "open-space") -}}
{{- if .custom_url -}}
<a href="{{ .custom_url | safeURL }}">{{ .title }}</a><br/>
{{- else -}}
<a href="/open-space-format/">{{ .title }}</a><br/>
{{- end -}}
{{- else -}}
{{ .title }}
{{- end -}}
</div>
</div>
{{- if eq (div ($.Scratch.Get "program_len") 2) ($.Scratch.Get "program_counter") -}}
</div>
<div class="col-lg-6">
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
</div>
</div>
</div>
</div>
</div>
{{- end -}}
</div>
</div>
</div>
<!--end row-->
</div>
</div>
{{- end -}}
Loading
Loading