File tree Expand file tree Collapse file tree 7 files changed +52
-23
lines changed
Expand file tree Collapse file tree 7 files changed +52
-23
lines changed Original file line number Diff line number Diff line change @@ -85,11 +85,16 @@ <h2 class="e-heading__4 c-objectives__title is-invisible">
8585 {{ partial "block/data.html" (dict "Scratch" $.Page.Scratch "src" $src "name" $name "page" .) }}
8686 {{/* Retrieve the blockData from Scratch */}}
8787 {{ $blockData := $.Page.Scratch.Get "blockData" }}
88+ {{ $links := slice }}
89+ {{ $anchorifiedName := $name | urlize }}
90+ {{ if in $prep.Params.blocks . }}{{ $links = $links | append (dict "href" (printf "../prep#%s" $anchorifiedName) "text" "Prep") }}{{ end }}
91+ {{ if in $issueBlocks . }}{{ $links = $links | append (dict "href" (printf "../backlog#%s" $anchorifiedName) "text" "Backlog") }}{{ end }}
92+ {{ if in $dayplan.Params.blocks . }}{{ $links = $links | append (dict "href" (printf "../day-plan#%s" $anchorifiedName) "text" "Day Plan") }}{{ end }}
8893 {{/* Depending on the type of block, call the appropriate partial */}}
8994 {{ if or (eq $blockData.type "readme") (eq $blockData.type "issue") }}
90- {{ partial "objectives/remote" (dict "blockData" $blockData "pageContext" $pageContext "showTitle " $blockData.name) }}
95+ {{ partial "objectives/remote" (dict "blockData" $blockData "pageContext" $pageContext "title " $blockData.name "links" $links ) }}
9196 {{ else }}
92- {{ partial "objectives/local.html" (dict "blockData" $blockData "pageContext" $pageContext "showTitle" true) }}
97+ {{ partial "objectives/local.html" (dict "blockData" $blockData "pageContext" $pageContext "showTitle" true "links" $links ) }}
9398 {{ end }}
9499
95100 {{ end }}
Original file line number Diff line number Diff line change 2323 {{ end }}
2424
2525 {{/* extract objectives */}}
26- {{ $extractedObjectives := partial "strings/extract-github-objectives.html" $ response.body }}
26+ {{ $extractedObjectives := partial "strings/extract-github-objectives.html" (dict "URL" $blockData.api "body" $ response.body) }}
2727 {{/* remove "Learning Objectives" heading from remaining text */}}
2828 {{ $strippedBody := replace $response.body "### Learning Objectives" "" }}
2929
3232 < summary >
3333 < h3 class ="e-heading__4 "> Learning Objectives</ h3 >
3434 </ summary >
35- {{ range $extractedObjectives }}
36- {{ . | page.RenderString }}
37- {{ end }}
35+ {{ partial "objectives/block" $extractedObjectives }}
3836 </ details >
3937 {{ end }}
4038 </ header >
Original file line number Diff line number Diff line change 2828 </ h2 >
2929 {{ partial "time.html" $pageContext }}
3030 </ header >
31- {{ $extractedObjectives := partial "strings/extract-github-objectives.html" $ decodedContent }}
31+ {{ $extractedObjectives := partial "strings/extract-github-objectives.html" (dict "URL" $blockData.api "body" $ decodedContent) }}
3232 {{ if gt (len $extractedObjectives) 0 }}
3333 < details open >
3434 < summary > < h3 class ="e-heading__5 "> Learning Objectives</ h3 > </ summary >
35- {{ range $extractedObjectives }}
36- {{ . | page.RenderString }}
37- {{ end }}
35+ {{ partial "objectives/block" $extractedObjectives }}
3836 </ details >
3937 {{ end }}
4038 < div class ="c-block__content c-copy ">
Original file line number Diff line number Diff line change 1+ {{ $scope := . }}
2+ {{ $objectives := $scope.objectives }}
3+ {{ $showTitle := $scope.showTitle }}
4+ {{ $title := $scope.title }}
5+ {{ $links := $scope.links }}
6+
7+ {{ if $showTitle }}< h5 > {{ $title }}{{range $links}} (< a class ="e-link " href ="{{ .href }} "> {{.text}}</ a > ){{end}}</ h5 > {{ end }}
8+ {{ partial "objectives/block.html" $objectives }}
Original file line number Diff line number Diff line change 77{{ $localBlock := $pageContext.GetPage $scope.blockData.api }}
88{{ $showTitle := .showTitle |default false }}
99
10- {{ with $localBlock.Page.Params.Objectives }}
11- {{ if $showTitle }}< h5 > {{ $localBlock.Page.Title }}</ h5 > {{ end }}
12- {{ partial "objectives/block.html" . }}
10+ {{ if $localBlock.Page.Params.Objectives }}
11+ {{ partial "objectives/for-success.html" (dict "objectives" $localBlock.Page.Params.Objectives "showTitle" $showTitle "title" $localBlock.Page.Title "links" $scope.links) }}
1312{{ end }}
Original file line number Diff line number Diff line change 44
55{{ $response := resources.GetRemote .blockData.api .blockData.headers }}
66{{ $blockType := .blockData.type }}
7- {{ $showTitle := .showTitle | default false }}
7+ {{ $title := .title }}
8+ {{ $links := .links }}
9+ {{ $url := .blockData.api }}
810{{/* 404s lead to GetRemote returning nil rather than an error. */}}
911{{ if eq $response nil }}
10- {{ errorf "Couldn't find anything at %s" .blockData.api }}
12+ {{ errorf "Couldn't find anything at %s" $url }}
1113{{ end }}
1214
1315{{ with $response }}
2022 {{ $response = $response.body }}
2123 {{ end }}
2224
23- {{ $extractedObjectives := partial "strings/extract-github-objectives.html" $ response }}
25+ {{ $extractedObjectives := partial "strings/extract-github-objectives.html" (dict "URL" $url "body" $ response) }}
2426 {{ if gt (len $extractedObjectives) 0 }}
25- {{ if $showTitle }}< h5 > {{ $showTitle }}</ h5 > {{ end }}
26- {{ range $extractedObjectives }}
27- {{ . | page.RenderString }}
28- {{ end }}
27+ {{ partial "objectives/for-success.html" (dict "objectives" $extractedObjectives "showTitle" $title "title" $title "links" $links) }}
2928 {{ end }}
3029{{ end }}
Original file line number Diff line number Diff line change 1- {{ $strippedText := . | replaceRE "<!--|--> " "" | replaceRE "\r\n" "\n" }}
1+ {{ $url := .URL }}
2+ {{ $body := .body }}
3+
4+ {{ $strippedText := $body | replaceRE "<!--|--> " "" | replaceRE "\r\n" "\n" }}
25
36{{/* Find fenced objectives in text */}}
47{{ $regexFence := "```objectives\\s*([^`]*?)\\s*```" }}
5- {{ $extractedObjectives := findRE $regexFence $strippedText }}
8+ {{ $extractedObjectivesBlocks := findRE $regexFence $strippedText }}
69
710{{/* Find shortcoded objectives in text */}}
811<!--prettier-ignore-->
912{{ $regexShortcode := "{{< objectives > }}([^`]*?){{</ objectives > }}" }}
10- {{ $extractedObjectives = $extractedObjectives | append (findRE $regexShortcode $strippedText) }}
13+ {{ $extractedShortcodeBlocks := findRE $regexShortcode $strippedText }}
14+
15+
16+ {{ $extractedObjectives := slice }}
17+ {{ range (slice $extractedObjectivesBlocks $extractedShortcodeBlocks) }}
18+ {{ range . }}
19+ {{ range (split . "\n")}}
20+ {{ if or (eq . "{{< objectives > }}") (eq . "{{</ objectives > }}") (eq . "```objectives") (eq . "```") (eq . "") }}
21+ {{ continue }}
22+ {{ else if hasPrefix . "- [ ] "}}
23+ {{ $extractedObjectives = $extractedObjectives | append (substr . 6) }}
24+ {{ else if hasPrefix . "- "}}
25+ {{ $extractedObjectives = $extractedObjectives | append (printf "- [ ] %s" (substr . 2)) }}
26+ {{ else }}
27+ {{ errorf "Unexpected learning objective from remote content from URL %s: %s" $url . }}
28+ {{ end }}
29+ {{ end }}
30+ {{ end }}
31+ {{ end }}
32+
1133{{ return $extractedObjectives }}
You can’t perform that action at this time.
0 commit comments