Skip to content

Add frontpage templates and support non-language courses#5

Merged
geirjr merged 3 commits intomainfrom
claude/fix-naturfag-test-chapters-WWtv7
Mar 6, 2026
Merged

Add frontpage templates and support non-language courses#5
geirjr merged 3 commits intomainfrom
claude/fix-naturfag-test-chapters-WWtv7

Conversation

@geirjr
Copy link
Copy Markdown
Contributor

@geirjr geirjr commented Mar 6, 2026

What does this PR do?

This PR introduces a flexible frontpage template system and extends Papertek to support non-language courses (like science, math, and social studies). Key changes:

  1. Three frontpage templates (classic, subject, minimal) — allowing different course types to have appropriate layouts

    • classic: Language courses with curriculum selector and vocab trainer
    • subject: Subject courses with chapter card grid and hero section
    • minimal: Compact lesson list for small courses
  2. Color theme system — Named themes (science/green, humanities/indigo, math/pink, social/orange) applied via data-theme attribute

  3. Non-language course support — Added naturfag-vg1 (Norwegian science) curriculum and refactored language detection to use nb (Norwegian) as default instead of hardcoded de (German)

  4. Template-aware renderingrenderLessonList() now dispatches to template-specific renderers (renderSubjectLayout, renderMinimalLayout)

  5. Improved content loading — Graceful fallbacks for missing vocabulary banks and content modules, allowing courses without external API dependencies

  6. CLI enhancementscreate-edu-app.js now prompts for frontpage template and color theme during project generation

Type of change

  • New feature
  • Refactoring

Checklist

  • No hardcoded language-specific values (uses language-utils.js, defaults to nb instead of de)
  • Works offline (vocabulary banks and content modules have graceful fallbacks)
  • Supports both language and non-language courses
  • Template system is extensible for future frontpage designs

Test Plan

  • Verify npm run validate:schemas and npm run validate:config pass
  • Test creating a new project with each template: classic, subject, minimal
  • Verify subject template renders chapter cards with progress bars
  • Verify minimal template renders compact lesson list
  • Test that non-language courses (naturfag) load without vocabulary API errors
  • Verify color themes apply correctly via data-theme attribute

https://claude.ai/code/session_017rtsVGshceLbjsQaDx7HyA

claude added 3 commits March 6, 2026 12:29
The migration module had a top-level `await fetchCoreBank('de', 'nounbank')`
that ran unconditionally when imported, causing a 404 crash on non-language
courses like naturfag that have no German vocabulary data.

Changes:
- Move nounbank fetch from top-level await into convertKnownWordsToNewFormat()
  so it only runs during actual migration and gracefully handles 404
- Make migrateProgressData() async to support the lazy fetch
- Add naturfag-vg1 to the curriculum registry with proper nb language config
  so getTargetLanguageCode() doesn't fall back to 'de'
- Add 'nb' case to shell.js enforceLanguageConsistency() so naturfag pages
  don't get force-switched to the German curriculum

🤖 Generated with Papertek — Framework for Education

Co-Authored-By: Claude <noreply@anthropic.com>

https://claude.ai/code/session_017rtsVGshceLbjsQaDx7HyA
…-language courses

The framework assumed German ('de') and 'tysk1-vg1' as defaults throughout
the engine, causing crashes and incorrect behavior for non-language courses
like naturfag.

Changes across 13 files:
- Replace all `|| 'de'` fallbacks with `|| 'nb'` (neutral UI locale)
- Replace hardcoded 'tysk1-vg1' defaults in store.js with dynamic
  _defaultCurriculum() that reads from the curriculum registry
- Use config.contentPath/config.languageDir for content path resolution
  instead of hardcoded language-to-directory mappings
- Make getCurriculumConfig() fallback to first registered curriculum
  instead of assuming tysk1-vg1
- Wrap top-level vocab fetches in try/catch (test.js, gender-trainer,
  verb-trainer) so non-language courses don't crash on missing banks
- Make content-loader.js skip vocabulary bank loading entirely when
  target language equals native language (non-language courses)
- Fix AppShell constructor to use neutral defaults for title and theme

🤖 Generated with Papertek — Framework for Education

Co-Authored-By: Claude <noreply@anthropic.com>

https://claude.ai/code/session_017rtsVGshceLbjsQaDx7HyA
The framework now supports multiple frontpage layouts that teachers can
choose when creating a new educational app, making it suitable for both
language courses and subject-based courses like science/math/history.

Templates:
- classic — Language course style (curriculum selector, vocab trainer link)
- subject — Subject course style (chapter card grid, hero section)
- minimal — Simple compact list layout (clean rows)

Changes:
- templates/frontpage/{classic,subject,minimal}.html — Three HTML templates
- ui.js — Added renderSubjectLayout() and renderMinimalLayout() renderers
  that dispatch based on data-frontpage-template attribute on <body>
- shell.js — Skip shell header/tools rendering for subject/minimal templates
  (they handle their own layout)
- papertek.css — Added 4 named color themes (science/green,
  humanities/indigo, math/pink, social/orange) via data-theme attribute
- create-edu-app.js — Added frontpage template and color theme prompts,
  generates index.html from selected template, auto-suggests 'subject'
  for same-language courses
- papertek.config.template.js — Added frontpageTemplate option

🤖 Generated with Papertek — Framework for Education

Co-Authored-By: Claude <noreply@anthropic.com>
@geirjr geirjr merged commit 6654b39 into main Mar 6, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants