Commit 29ab964
authored
Refactoring and API (#505)
Add JSON API with two flavors: input (what we get from "forks") and output
(available at at `/v0/naucse.json`)
* The API is described and validated using jsonschema.
* Uses HTML for content, never Markdown.
* Relative URLs use a custom `naucse:` schema for the API. This gets converted
in the HTML "sanitization" step.
* The API is v0; consumers are expected to coordinate with us until it is
finalized.
The part that should be in "forks" is moved to the `naucse_render` module,
which became its own repo & PyPI package.
When one course's build fails, everything fails. No silent "an error occured"
pages.
* Only fully applies in "freeze mode" (with `NAUCSE_FREEZE=1`, or Flask
in non-debug mode).
* In debug mode, lessons are rendered on demand instead of at startup.
Doesn't do fancy guessing of repo URL&branch for edit info.
Use `NAUCSE_MAIN_REPO_URL` and `NAUCSE_MAIN_REPO_BRANCH` if needed
(e.g. on Travis).
The model is better defined. Notably:
* A *course* has a list of *sessions*
* A session has a list of *materials*
* A material may be for a *lesson* (or an external link)
* A course (!) has *lessons* (which are referenced by materials).
(All lessons are in a course; there's a special hidden `lessons` course
containing the "local"/"canonical" lessons.)
The distinction between forks and local content is disappearing (but still
present).
The distinction between "courses" and "runs" in the model is disappearing:
mostly they just have different slugs (e.g. `courses/mi-pyt` vs.
`2018/pyladies-brno-jaro`) and are in different collections for lookup.
Instead of `FORKS_ENABLED=true`, there's `NAUCSE_TRUSTED_REPOS='*'`.
You can filter allowed repos a bit (docs TODO).
The model is different (`converters.py` is utilities for stuff you can
load/dump from/to a versioned JSON API).
Pages request LaTeX using "`modules: {'katex': '0.7.1'}`.
This should become a general mechanism to request some extra functionality
(like JS/CSS).
Model objects have info about their URLs.
---
PR & review: #505
Helps resolve: #494
Thanks to Miro Hrnočok, Petr Messner and Mikuláš Poul for review and minor fixes.1 parent be4bf4d commit 29ab964
78 files changed
Lines changed: 4339 additions & 3971 deletions
File tree
- lessons/beginners/install
- naucse
- templates
- content
- utils
- test_naucse
- fixtures
- course-data
- empty-directory
- empty-lessons-dir/lessons
- expected-dumps
- run-years
- session-times
- licenses
- cc-by-sa-40
- cc0
- minimal-courses
- courses/minimal
- lessons
- runs/2019/minimal
- test_content
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | | - | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | | - | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| |||
0 commit comments