Skip to content
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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,15 @@ For each module you import, add a `replace` directive to your `go.mod` file - if
## To locally develop your site

Check [org-cyf/README.md](/org-cyf/README.md) on how to set up your local environment. Once that is done you can `cd` into the site you wish to develop, and run `npm run start:dev` to get a live preview.

## Shortcodes

### `next-class-day-plan`

The `next-class-day-plan` shortcode pulls sprint pages from the existing `syllabus`/`module` menu hierarchy.

Example:

```
{{< next-class-day-plan >}}
```
41 changes: 41 additions & 0 deletions common-theme/layouts/shortcodes/next-class-day-plan.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{{/* Compute link to next class day plan */}}
{{ $weekdays := dict "Sunday" 0 "Monday" 1 "Tuesday" 2 "Wednesday" 3 "Thursday" 4 "Friday" 5 "Saturday" 6 }}

{{/* Resolve base time: prefer .Page.Date (shortcode context), else .Date, else now */}}
{{ $now := now }}
{{ with .Page }}
{{ with .Date }}
{{ $now = . }}
{{ end }}
{{ else }}
{{ with .Date }}
{{ $now = . }}
{{ end }}
{{ end }}

{{ $todayIdx := index $weekdays ($now.Format "Monday") }}
{{ $daysUntilSat := mod (add (sub 6 $todayIdx) 7) 7 | int }}
{{ $nextClass := $now.AddDate 0 0 $daysUntilSat }}

{{ $year := int ($nextClass.Format "2006") }}
{{ $month := int ($nextClass.Format "1") }}
{{ $quarterMonth := add (mul (div (sub $month 1) 3) 3) 1 }}
{{ $start := time (printf "%04d-%02d-01" $year $quarterMonth) }}
{{ $startIdx := index $weekdays ($start.Format "Monday") }}
{{ $daysToSat := mod (add (sub 6 $startIdx) 7) 7 | int }}
{{ $courseStart := $start.AddDate 0 0 $daysToSat }}

{{ $startUnix := $courseStart.Unix }}
{{ $classUnix := $nextClass.Unix }}
{{ $daysFromStart := div (sub $classUnix $startUnix) 86400 }}
{{ $sprint := add 1 (div $daysFromStart 7) }}

{{/* Gather day plan pages within the current module */}}
{{ $module := .Page.CurrentSection }}
{{ $dayPlans := sort (where $module.Pages "Params.menu_level" "intersect" (slice "module")) "Weight" }}

{{ with index $dayPlans (sub $sprint 1) }}
<a href="{{ .RelPermalink }}">Day plan for sprint {{ $sprint }}</a>
{{ else }}
<span>Day plan coming soon</span>
{{ end }}
14 changes: 8 additions & 6 deletions org-cyf-itp/content/_index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
+++
title="Intro to Programming"
menus_to_map=["start here", "course schedule", "next steps"]
description="New? Lost? [Quickstart](how-this-works/prep/#overview)"
emoji= "🧑🏿‍🏫"
+++
+++
title="Intro to Programming"
menus_to_map=["start here", "course schedule", "next steps"]
description="New? Lost? [Quickstart](how-this-works/prep/#overview)"
emoji= "🧑🏿‍🏫"
+++

Here’s how you find out what to do when: {{< next-class-day-plan >}}
58 changes: 58 additions & 0 deletions org-cyf-theme/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions org-cyf-theme/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "org-cyf-theme",
"version": "1.0.0",
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"fix-instructions": "echo 'Fix: pass .Date to the partial or change the partial to use .Date when available. Example partial snippet: {{ $base := time.Now }} {{ with .Date }}{{ $base = . }}{{ end }} {{ $next := $base.AddDate 0 0 7 }} Next class: {{ $next.Format \"Jan 2, 2006\" }}'"
},
"devDependencies": {
"prettier": "^2.8.8",
"prettier-plugin-go-template": "^0.0.13"
}
}