Skip to content

Commit 1ccc530

Browse files
TrevorAustinclaude
andcommitted
parameterize quarter and Canvas course ID via site_config.py
build.py now reads site_config.py and updates all source files (README, syllabus, lecture notes) with the current quarter name and Canvas course ID on each build. Templates use Jinja2 globals. Assignment-specific Canvas links replaced with course assignments list page so they don't need per-quarter updates. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 13a0030 commit 1ccc530

8 files changed

Lines changed: 52 additions & 8 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Lectures
2-
Notes, slides, and in-class exercises for MPCS 52553 - Web Development, as taught Winter Quarter 2026
2+
Notes, slides, and in-class exercises for MPCS 52553 - Web Development, as taught Spring Quarter 2026
33

44
### Teaching Team
55
- [Trevor Austin](mailto:trevoraustin@cs.uchicago.edu) (Lecturer)

build.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,41 @@
88
import markdown
99

1010
from preprocessor import split_slides, process_slide, rewrite_image_paths
11+
import site_config
12+
13+
QUARTER_PATTERN = re.compile(
14+
r"(Winter|Spring|Fall|Autumn|Summer)(\s+Quarter)?\s+\d{4}"
15+
)
16+
CANVAS_COURSE_PATTERN = re.compile(r"canvas\.uchicago\.edu/courses/\d+")
17+
18+
19+
def apply_config(text: str) -> str:
20+
"""Replace quarter and Canvas course ID references with current config values."""
21+
season, year = site_config.QUARTER.split()
22+
23+
def replace_quarter(match):
24+
quarter_word = match.group(2) or ""
25+
return f"{season}{quarter_word} {year}"
26+
27+
text = QUARTER_PATTERN.sub(replace_quarter, text)
28+
text = CANVAS_COURSE_PATTERN.sub(
29+
f"canvas.uchicago.edu/courses/{site_config.CANVAS_COURSE_ID}", text
30+
)
31+
return text
32+
33+
34+
def update_source_files(root: Path):
35+
"""Update source files in place with current config values."""
36+
files = [root / "README.md", root / "syllabus.md"]
37+
files.extend(sorted((root / "lecture_notes").glob("week_*.md")))
38+
39+
for filepath in files:
40+
if not filepath.exists():
41+
continue
42+
content = filepath.read_text()
43+
updated = apply_config(content)
44+
if updated != content:
45+
filepath.write_text(updated)
1146

1247

1348
def build_site(output_dir: str = "_site", base_url: str = ""):
@@ -19,6 +54,9 @@ def build_site(output_dir: str = "_site", base_url: str = ""):
1954
root = Path(__file__).parent
2055
out = Path(output_dir)
2156

57+
# Update source files with current config values
58+
update_source_files(root)
59+
2260
# Clean output
2361
if out.exists():
2462
shutil.rmtree(out)
@@ -28,6 +66,8 @@ def build_site(output_dir: str = "_site", base_url: str = ""):
2866
# with pre-rendered HTML and this is a static site generator, not a web app
2967
env = Environment(loader=FileSystemLoader(root / "templates"), autoescape=False)
3068
env.globals["base_url"] = base_url
69+
env.globals["quarter"] = site_config.QUARTER
70+
env.globals["canvas_url"] = f"https://canvas.uchicago.edu/courses/{site_config.CANVAS_COURSE_ID}"
3171

3272
# Copy static assets
3373
shutil.copytree(root / "static" / "css", out / "css")

lecture_notes/week_1.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class: center, middle
22
# Web Development
3-
## Winter 2026
3+
## Spring 2026
44
MPCS 52553
55
---
66

@@ -56,7 +56,7 @@ abhyas@uchicago.edu
5656
---
5757

5858
# In-Class Exercise 1
59-
Let's get started on Canvas: https://canvas.uchicago.edu/courses/71107/assignments/860058
59+
Let's get started on Canvas: https://canvas.uchicago.edu/courses/71107/assignments
6060
---
6161

6262
# Objectives
@@ -203,5 +203,5 @@ https://www.w3.org/History/1989/proposal.html
203203
---
204204

205205
# Take-Home Exercise 1: Resume Styling
206-
- Assignment submissions are on [Canvas](https://canvas.uchicago.edu/courses/57047/assignments)
206+
- Assignment submissions are on [Canvas](https://canvas.uchicago.edu/courses/71107/assignments)
207207
- Get the code to get started on [GitHub](https://classroom.github.com/a/-zZ8uRTP)

lecture_notes/week_3.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Content-Type: text/html; charset=UTF-8
9999
<body>
100100
<titlebar>
101101
<h1>Web Development</h1>
102-
<h3>MPCS 52553 - Winter Quarter 2025</h3>
102+
<h3>MPCS 52553 - Spring Quarter 2026</h3>
103103
</titlebar>
104104
<main>
105105
<ul>

lecture_notes/week_4.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,6 @@ Good explanation why the above weird behaviors happen.
173173

174174
# Exercise 4
175175

176-
[Exercise 4 on Canvas](https://canvas.uchicago.edu/courses/67344/assignments/811127)
176+
[Exercise 4 on Canvas](https://canvas.uchicago.edu/courses/71107/assignments)
177177

178178
[Exercise 4 on GitHub](https://github.com/UChicagoWebDev/exercise-4)

lecture_notes/week_9.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class: center, middle
2-
# Web Development Winter 2026
2+
# Web Development Spring 2026
33
## Week 9: Security, WebSockets, and Deployment
44
---
55

site_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"""Course configuration. Update these values at the start of each quarter."""
2+
3+
QUARTER = "Spring 2026"
4+
CANVAS_COURSE_ID = "71107"

templates/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{% block content %}
66
<div class="homepage">
77
<h1>Web Development</h1>
8-
<h3>MPCS 52553 — Spring 2026</h3>
8+
<h3>MPCS 52553 — {{ quarter }}</h3>
99
<ul>
1010
<li><a href="{{ base_url }}/syllabus/">Syllabus</a></li>
1111
<li><a href="{{ base_url }}/lecture_notes/">Lecture Notes</a></li>

0 commit comments

Comments
 (0)