From 11e16e957d20d12f6b4210f66a5f00e48f16f362 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Sun, 1 Feb 2026 10:32:55 +0000 Subject: [PATCH 1/2] Include links to original sources in success pages This: * Makes it easier to see what things are self-study vs have expected evidence from backlog. * Makes it easier to link back to where the topics were introduced. The way we go about this is: 1. When fetching remote learning objectives, parse out to accumulate the list of LOs, rather than just grabbing the whole markdown block 2. Pass LOs through a `{{}}` shortcode, rather than just pulling the shortcode in through the raw markdown. 3. Pass links to the original blocks into the rendering block. 4. Send both local and remote learning objectives through the same rendering block (`common-theme/layouts/partials/objectives/for-success.html`) which now includes links back. --- common-theme/layouts/_default/success.html | 9 +++++-- .../layouts/partials/block/issue.html | 6 ++--- .../layouts/partials/block/readme.html | 6 ++--- .../partials/objectives/for-success.html | 8 ++++++ .../layouts/partials/objectives/local.html | 5 ++-- .../layouts/partials/objectives/remote.html | 13 +++++----- .../strings/extract-github-objectives.html | 26 ++++++++++++++++--- 7 files changed, 50 insertions(+), 23 deletions(-) create mode 100644 common-theme/layouts/partials/objectives/for-success.html diff --git a/common-theme/layouts/_default/success.html b/common-theme/layouts/_default/success.html index 1f0e03d46..7ed1994be 100644 --- a/common-theme/layouts/_default/success.html +++ b/common-theme/layouts/_default/success.html @@ -84,11 +84,16 @@ {{ partial "time.html" $pageContext }} - {{ $extractedObjectives := partial "strings/extract-github-objectives.html" $decodedContent }} + {{ $extractedObjectives := partial "strings/extract-github-objectives.html" (dict "URL" $blockData.api "body" $decodedContent) }} {{ if gt (len $extractedObjectives) 0 }}

Learning Objectives

- {{ range $extractedObjectives }} - {{ . | page.RenderString }} - {{ end }} + {{ partial "objectives/block" $extractedObjectives }}
{{ end }}
diff --git a/common-theme/layouts/partials/objectives/for-success.html b/common-theme/layouts/partials/objectives/for-success.html new file mode 100644 index 000000000..e10994dcb --- /dev/null +++ b/common-theme/layouts/partials/objectives/for-success.html @@ -0,0 +1,8 @@ +{{ $scope := . }} +{{ $objectives := $scope.objectives }} +{{ $showTitle := $scope.showTitle }} +{{ $title := $scope.title }} +{{ $links := $scope.links }} + +{{ if $showTitle }}
{{ $title }} {{range $links}}{{.text}}{{end}}
{{ end }} +{{ partial "objectives/block.html" $objectives }} diff --git a/common-theme/layouts/partials/objectives/local.html b/common-theme/layouts/partials/objectives/local.html index 64880055b..ab08df7a3 100644 --- a/common-theme/layouts/partials/objectives/local.html +++ b/common-theme/layouts/partials/objectives/local.html @@ -7,7 +7,6 @@ {{ $localBlock := $pageContext.GetPage $scope.blockData.api }} {{ $showTitle := .showTitle |default false }} -{{ with $localBlock.Page.Params.Objectives }} - {{ if $showTitle }}
{{ $localBlock.Page.Title }}
{{ end }} - {{ partial "objectives/block.html" . }} +{{ if $localBlock.Page.Params.Objectives }} +{{ partial "objectives/for-success.html" (dict "objectives" $localBlock.Page.Params.Objectives "showTitle" $showTitle "title" $localBlock.Page.Title "links" $scope.links) }} {{ end }} diff --git a/common-theme/layouts/partials/objectives/remote.html b/common-theme/layouts/partials/objectives/remote.html index 13a890ba1..40761c42e 100644 --- a/common-theme/layouts/partials/objectives/remote.html +++ b/common-theme/layouts/partials/objectives/remote.html @@ -4,10 +4,12 @@ {{ $response := resources.GetRemote .blockData.api .blockData.headers }} {{ $blockType := .blockData.type }} -{{ $showTitle := .showTitle | default false }} +{{ $title := .title }} +{{ $links := .links }} +{{ $url := .blockData.api }} {{/* 404s lead to GetRemote returning nil rather than an error. */}} {{ if eq $response nil }} - {{ errorf "Couldn't find anything at %s" .blockData.api }} + {{ errorf "Couldn't find anything at %s" $url }} {{ end }} {{ with $response }} @@ -20,11 +22,8 @@ {{ $response = $response.body }} {{ end }} - {{ $extractedObjectives := partial "strings/extract-github-objectives.html" $response }} + {{ $extractedObjectives := partial "strings/extract-github-objectives.html" (dict "URL" $url "body" $response) }} {{ if gt (len $extractedObjectives) 0 }} - {{ if $showTitle }}
{{ $showTitle }}
{{ end }} - {{ range $extractedObjectives }} - {{ . | page.RenderString }} - {{ end }} + {{ partial "objectives/for-success.html" (dict "objectives" $extractedObjectives "showTitle" $title "title" $title "links" $links) }} {{ end }} {{ end }} diff --git a/common-theme/layouts/partials/strings/extract-github-objectives.html b/common-theme/layouts/partials/strings/extract-github-objectives.html index 6d951c184..d70ffe5d4 100644 --- a/common-theme/layouts/partials/strings/extract-github-objectives.html +++ b/common-theme/layouts/partials/strings/extract-github-objectives.html @@ -1,11 +1,31 @@ -{{ $strippedText := . | replaceRE "" "" | replaceRE "\r\n" "\n" }} +{{ $url := .URL }} +{{ $body := .body }} + +{{ $strippedText := $body | replaceRE "" "" | replaceRE "\r\n" "\n" }} {{/* Find fenced objectives in text */}} {{ $regexFence := "```objectives\\s*([^`]*?)\\s*```" }} -{{ $extractedObjectives := findRE $regexFence $strippedText }} +{{ $extractedObjectivesBlocks := findRE $regexFence $strippedText }} {{/* Find shortcoded objectives in text */}} {{ $regexShortcode := "{{}}([^`]*?){{}}" }} -{{ $extractedObjectives = $extractedObjectives | append (findRE $regexShortcode $strippedText) }} +{{ $extractedShortcodeBlocks := findRE $regexShortcode $strippedText }} + + +{{ $extractedObjectives := slice }} +{{ range (slice $extractedObjectivesBlocks $extractedShortcodeBlocks) }} + {{ range . }} + {{ range (split . "\n")}} + {{ if or (eq . "{{}}") (eq . "{{}}") (eq . "```objectives") (eq . "```") }} + {{ continue }} + {{ else if hasPrefix . "- [ ] "}} + {{ $extractedObjectives = $extractedObjectives | append (substr . 6) }} + {{ else }} + {{ errorf "Unexpected learning objective from remote content from URL %s: %s" $url . }} + {{ end }} + {{ end }} + {{ end }} +{{ end }} + {{ return $extractedObjectives }} From 4f87da0e89ca8c2424626a77ed4c0d0f87c71ea9 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Sun, 1 Feb 2026 12:20:56 +0000 Subject: [PATCH 2/2] Handle a few more objective lines from the wild --- .../layouts/partials/strings/extract-github-objectives.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common-theme/layouts/partials/strings/extract-github-objectives.html b/common-theme/layouts/partials/strings/extract-github-objectives.html index d70ffe5d4..b7f1ba572 100644 --- a/common-theme/layouts/partials/strings/extract-github-objectives.html +++ b/common-theme/layouts/partials/strings/extract-github-objectives.html @@ -17,10 +17,12 @@ {{ range (slice $extractedObjectivesBlocks $extractedShortcodeBlocks) }} {{ range . }} {{ range (split . "\n")}} - {{ if or (eq . "{{}}") (eq . "{{}}") (eq . "```objectives") (eq . "```") }} + {{ if or (eq . "{{}}") (eq . "{{}}") (eq . "```objectives") (eq . "```") (eq . "") }} {{ continue }} {{ else if hasPrefix . "- [ ] "}} {{ $extractedObjectives = $extractedObjectives | append (substr . 6) }} + {{ else if hasPrefix . "- "}} + {{ $extractedObjectives = $extractedObjectives | append (printf "- [ ] %s" (substr . 2)) }} {{ else }} {{ errorf "Unexpected learning objective from remote content from URL %s: %s" $url . }} {{ end }}