This commit is contained in:
worktop 2024-03-08 16:01:23 -05:00
parent 90556d90b3
commit 0c04a1b0a0
2 changed files with 89 additions and 66 deletions

View File

@ -1,12 +1,3 @@
<script>
function simulateLinkClick() {
var link = document.querySelector('.day a');
if (link) {
link.click();
}
}
</script>
{{ $date := now }} {{ $date := now }}
{{ $month := $date.Month | int }} {{ $month := $date.Month | int }}
@ -50,16 +41,95 @@ function simulateLinkClick() {
<h3 class="day-num">{{ . }}</h3> <h3 class="day-num">{{ . }}</h3>
<h3 class="mobile-date">{{ $startDate | time.Format ":date_long" }} </h3> <h3 class="mobile-date">{{ $startDate | time.Format ":date_long" }} </h3>
{{ $eventCount := 0 }}
{{ range where $.Site.RegularPages "Section" "eq" "events" }} {{ range where $.Site.RegularPages "Section" "eq" "events" }}
{{ $eventStart := time.AsTime .Params.start_date }} {{ $eventStart := time.AsTime .Params.start_date }}
{{ $eventEnd := time.AsTime .Params.end_date }} {{ $eventEnd := time.AsTime .Params.end_date }}
{{ if and ( or ($eventEnd.After $startDate) ($eventEnd.Equal $startDate)) (or ( $eventStart.Before $endDate ) ( $eventStart.Equal $endDate )) }} {{ if and ( or ($eventEnd.After $startDate) ($eventEnd.Equal $startDate)) (or ( $eventStart.Before $endDate ) ( $eventStart.Equal $endDate )) }}
{{ $eventCount = add $eventCount 1 }}
<div class="event" > <div class="event" >
<a href="{{ .RelPermalink }}">{{.Title}}</a> <a href="{{ .RelPermalink }}">{{.Title}}</a>
</div> </div>
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ if gt $eventCount 1 }}
{{ errorf "Error: Multiple events per day currently unsuported"}}
{{ end }}
</div>
{{ end }}
</div>
</div>
<script>
function simulateLinkClick() {
var link = document.querySelector('.div a');
if (link) {
link.click();
}
}
</script>
{{ $date := $date.AddDate 0 1 0 }}
{{ $month := $date.Month | int }}
{{ $year := $date.Year }}
{{ $t1 := printf "%4d-%02d-01" $year $month }}
{{ $t1 := time.AsTime $t1 }}
{{ $t2 := $t1.AddDate 0 1 0 }}
{{ $daysInMonth := $t2.Sub $t1 }}
{{ $daysInMonth := $daysInMonth.Hours }}
{{ $daysInMonth := div $daysInMonth 24 }}
<div class="calendar">
{{ if eq .Site.Language.Lang "pl" }}
{{ $polish_month_names := slice "Styczeń" "Luty" "Marzec" "Kwiecień" "Maj" "Czerwiec" "Lipiec" "Sierpień" "Wrzesień" "Październik" "Listopad" "Grudzień" }}
{{ $month := sub $month 1}}
{{ $label := index $polish_month_names $month }}
<a class="month">{{ printf "%s %d" $label $year }}</a>
{{ else }}
<a class="month">{{ time.Format "January 2006" $t1 }}</a>
{{ end }}
<div class="weekdays" >
{{ $days := slice "sun" "mon" "tues" "wend" "thurs" "fri" "sat" }}
{{ range $days }}<p>{{ i18n (printf "days.%s" .) }}</p>{{ end }}
</div>
<div class="days">
{{ $padding := $t1.Weekday | int }}
{{ if gt $padding 0 }}
{{ range seq 1 $padding }}
<div class="pad-day"></div>
{{ end }}
{{ end }}
{{ range seq 1 $daysInMonth }}
<div class="day">
{{ $startDate := time.AsTime ( printf "%4d-%02d-%02dT00:00:00" $year $month . ) }}
{{ $endDate := time.AsTime ( printf "%4d-%02d-%02dT23:59:59" $year $month . ) }}
<h3 class="day-num">{{ . }}</h3>
<h3 class="mobile-date">{{ $startDate | time.Format ":date_long" }} </h3>
{{ $eventCount := 0 }}
{{ range where $.Site.RegularPages "Section" "eq" "events" }}
{{ $eventStart := time.AsTime .Params.start_date }}
{{ $eventEnd := time.AsTime .Params.end_date }}
{{ if and ( or ($eventEnd.After $startDate) ($eventEnd.Equal $startDate)) (or ( $eventStart.Before $endDate ) ( $eventStart.Equal $endDate )) }}
{{ $eventCount = add $eventCount 1 }}
<div class="event" >
<a href="{{ .RelPermalink }}">{{.Title}}</a>
</div>
{{ end }}
{{ end }}
{{ if gt $eventCount 1 }}
{{ errorf "Error: Multiple events per day currently unsuported"}}
{{ end }}
</div> </div>
{{ end }} {{ end }}
</div> </div>
@ -108,74 +178,22 @@ function simulateLinkClick() {
<h3 class="day-num">{{ . }}</h3> <h3 class="day-num">{{ . }}</h3>
<h3 class="mobile-date">{{ $startDate | time.Format ":date_long" }} </h3> <h3 class="mobile-date">{{ $startDate | time.Format ":date_long" }} </h3>
{{ $eventCount := 0 }}
{{ range where $.Site.RegularPages "Section" "eq" "events" }} {{ range where $.Site.RegularPages "Section" "eq" "events" }}
{{ $eventStart := time.AsTime .Params.start_date }} {{ $eventStart := time.AsTime .Params.start_date }}
{{ $eventEnd := time.AsTime .Params.end_date }} {{ $eventEnd := time.AsTime .Params.end_date }}
{{ if and ( or ($eventEnd.After $startDate) ($eventEnd.Equal $startDate)) (or ( $eventStart.Before $endDate ) ( $eventStart.Equal $endDate )) }} {{ if and ( or ($eventEnd.After $startDate) ($eventEnd.Equal $startDate)) (or ( $eventStart.Before $endDate ) ( $eventStart.Equal $endDate )) }}
{{ $eventCount = add $eventCount 1 }}
<div class="event" > <div class="event" >
<a href="{{ .RelPermalink }}">{{.Title}}</a> <a href="{{ .RelPermalink }}">{{.Title}}</a>
</div> </div>
{{ end }} {{ end }}
{{ end }} {{ end }}
</div> {{ if gt $eventCount 1 }}
{{ end }} {{ errorf "Error: Multiple events per day currently unsuported"}}
</div>
</div>
{{ $date := $date.AddDate 0 1 0 }}
{{ $month := $date.Month | int }}
{{ $year := $date.Year }}
{{ $t1 := printf "%4d-%02d-01" $year $month }}
{{ $t1 := time.AsTime $t1 }}
{{ $t2 := $t1.AddDate 0 1 0 }}
{{ $daysInMonth := $t2.Sub $t1 }}
{{ $daysInMonth := $daysInMonth.Hours }}
{{ $daysInMonth := div $daysInMonth 24 }}
<div class="calendar">
{{ if eq .Site.Language.Lang "pl" }}
{{ $polish_month_names := slice "Styczeń" "Luty" "Marzec" "Kwiecień" "Maj" "Czerwiec" "Lipiec" "Sierpień" "Wrzesień" "Październik" "Listopad" "Grudzień" }}
{{ $month := sub $month 1}}
{{ $label := index $polish_month_names $month }}
<a class="month">{{ printf "%s %d" $label $year }}</a>
{{ else }}
<a class="month">{{ time.Format "January 2006" $t1 }}</a>
{{ end }}
<div class="weekdays" >
{{ $days := slice "sun" "mon" "tues" "wend" "thurs" "fri" "sat" }}
{{ range $days }}<p>{{ i18n (printf "days.%s" .) }}</p>{{ end }}
</div>
<div class="days">
{{ $padding := $t1.Weekday | int }}
{{ if gt $padding 0 }}
{{ range seq 1 $padding }}
<div class="pad-day"></div>
{{ end }} {{ end }}
{{ end }}
{{ range seq 1 $daysInMonth }}
<div class="day" onclick="simulateLinkClick()" >
{{ $startDate := time.AsTime ( printf "%4d-%02d-%02dT00:00:00" $year $month . ) }}
{{ $endDate := time.AsTime ( printf "%4d-%02d-%02dT23:59:59" $year $month . ) }}
<h3 class="day-num">{{ . }}</h3>
<h3 class="mobile-date">{{ $startDate | time.Format ":date_long" }} </h3>
{{ range where $.Site.RegularPages "Section" "eq" "events" }}
{{ $eventStart := time.AsTime .Params.start_date }}
{{ $eventEnd := time.AsTime .Params.end_date }}
{{ if and ( or ($eventEnd.After $startDate) ($eventEnd.Equal $startDate)) (or ( $eventStart.Before $endDate ) ( $eventStart.Equal $endDate )) }}
<div class="event" >
<a href="{{ .RelPermalink }}">{{.Title}}</a>
</div>
{{ end }}
{{ end }}
</div> </div>
{{ end }} {{ end }}
</div> </div>

View File

@ -54,16 +54,21 @@ function simulateLinkClick() {
<h3 class="day-num">{{ . }}</h3> <h3 class="day-num">{{ . }}</h3>
<h3 class="mobile-date">{{ $startDate | time.Format ":date_long" }} </h3> <h3 class="mobile-date">{{ $startDate | time.Format ":date_long" }} </h3>
{{ $eventCount := 0 }}
{{ range where $.Site.RegularPages "Section" "eq" "events" }} {{ range where $.Site.RegularPages "Section" "eq" "events" }}
{{ $eventStart := time.AsTime .Params.start_date }} {{ $eventStart := time.AsTime .Params.start_date }}
{{ $eventEnd := time.AsTime .Params.end_date }} {{ $eventEnd := time.AsTime .Params.end_date }}
{{ if and ( or ($eventEnd.After $startDate) ($eventEnd.Equal $startDate)) (or ( $eventStart.Before $endDate ) ( $eventStart.Equal $endDate )) }} {{ if and ( or ($eventEnd.After $startDate) ($eventEnd.Equal $startDate)) (or ( $eventStart.Before $endDate ) ( $eventStart.Equal $endDate )) }}
{{ $eventCount = add $eventCount 1 }}
<div class="event" > <div class="event" >
<a href="{{ .RelPermalink }}">{{.Title}}</a> <a href="{{ .RelPermalink }}">{{.Title}}</a>
</div> </div>
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ if gt $eventCount 1 }}
{{ errorf "Error: Multiple events per day currently unsuported" }}
{{ end }}
</div> </div>
{{ end }} {{ end }}
</div> </div>