From 4173d48130e26feef12bb72214653194067f274f Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Mon, 25 Nov 2024 21:10:15 -0500 Subject: [PATCH] Added intro to stats page --- layouts/_default/stats.html | 149 ++++++++++++++++++++++++++++++++++++ themes/pulp | 2 +- 2 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 layouts/_default/stats.html diff --git a/layouts/_default/stats.html b/layouts/_default/stats.html new file mode 100644 index 0000000..6c8a18f --- /dev/null +++ b/layouts/_default/stats.html @@ -0,0 +1,149 @@ +{{ define "main" }} + +{{ partial "header.html" . }} +
+
+ {{ $scratch := newScratch }} + {{ $posts := where site.RegularPages "Type" "blog" }} + + {{ range last 1 $posts }} + {{ $numYears := div (sub now.Unix .Date.Unix) 31536000 }} + {{ $firstDate := .Date.Format "January 2, 2006"}} + {{ $scratch.Set "firstDate" $firstDate}} + {{ $scratch.Set "numYears" $numYears }} + {{ end }} + + + {{ range first 1 $posts }} + {{ $latestDate := .Date.Format "January 2, 2006"}} + {{ $scratch.Set "latestDate" $latestDate }} + {{ end }} + + {{ $postCount := len $posts }} + + +

+ My most recent blog post was written on {{ $scratch.Get "latestDate" }} + with my first ever one written on {{ $scratch.Get "firstDate" }}. + This means I've been publishing for {{ $scratch.Get "numYears"}} years! + Over which I have written a total of {{ $postCount }} posts. +

+
+ {{ .Content }} + {{ $tags := .Site.Taxonomies.tags }} + + + {{ $scratch.Set "longCount" 0 }} + {{ range $posts }} + + {{ $scratch.Add "wordcount" .WordCount }} + + {{ if ge .WordCount ($scratch.Get "longCount") }} + {{ $scratch.Set "longestPost" . }} + {{ $scratch.Set "longCount" .WordCount }} + {{ end }} + {{ end }} + + + {{ $mostPopularTag := index .Site.Taxonomies.tags.ByCount 0 }} + + + {{ $wordCount := $scratch.Get "wordcount" }} + {{ $avgPostLength := div $wordCount $postCount }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Total Words Written{{ $wordCount | lang.FormatNumberCustom 0 }}
Average Words per Post{{ $avgPostLength | lang.FormatNumberCustom 0 }}
Number of Topics{{ len $tags | lang.FormatNumberCustom 0 }}
Most Popular Topic + {{ with $mostPopularTag }} + {{ .Page.Title }} with {{ .Count }} posts + {{ end }} +
Longest Post Published + {{ with $scratch.Get "longestPost" }} + {{ .Title }} with {{ .WordCount }} words + {{ end }} +
Total Wikipedia Edits + {{ $data := getJSON "https://en.wikipedia.org/w/api.php?action=query&list=users&ususers=BrandonRozek&usprop=editcount&format=json" }} + {{ range first 1 $data.query.users }} + {{ .editcount }} + {{ end }} +
Total OpenStreetMap Edits + {{ $data := getJSON "https://api.openstreetmap.org/api/0.6/user/16068861.json" }} + {{ $data.user.changesets.count }} +
+ + {{ $grouped := $posts.GroupByDate "2006" }} + +

Posts Per Year

+ +
+ + +
+ + + + {{ $chartPre := "{type: 'line',data: {labels: [" }} + {{ $chartYearKeys := trim ($scratch.Get "yearKeys") ","}} + {{ $chartYearCount := trim ($scratch.Get "yearCount") ","}} + {{ $chartMid := "],datasets: [{label: 'Posts Published',data: [" }} + {{ $chartPost := "],backgroundColor: 'rgb(54, 128, 56)',borderColor: 'rgb(54, 128, 56)',borderWidth: 3}]},options: {maintainAspectRatio: false, animation: false, scales: {y: {ticks: {beginAtZero: true}}}}}" + }} + + + {{ $chartData := printf "%s" $chartPost | printf "%s%s" $chartYearCount | printf "%s%s" $chartMid | printf "%s%s" $chartYearKeys | printf "%s%s" $chartPre | printf "%s" }} + + +
+
+
+{{ end }} diff --git a/themes/pulp b/themes/pulp index 13ecf4a..70f42b3 160000 --- a/themes/pulp +++ b/themes/pulp @@ -1 +1 @@ -Subproject commit 13ecf4a4a362cbb8a10ff5260298581eb1fa6c99 +Subproject commit 70f42b3d844d63b5833d983a9efa2dc55d145875