Skip to content

Commit 29ab964

Browse files
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

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ before_script: # encrypted variables aren't accessible in PRs
1212
- 'if [ -n "$DOCKER_HUB_PASSWORD" ]; then docker login -u "$DOCKER_HUB_USERNAME" -p "$DOCKER_HUB_PASSWORD"; fi'
1313
- 'if [ -z "$DOCKER_HUB_PASSWORD" ]; then export ARCA_BACKEND_REGISTRY_PULL_ONLY=true; fi'
1414
script:
15+
- export NAUCSE_MAIN_REPO_URL=https://github.com/$TRAVIS_REPO_SLUG
16+
- export NAUCSE_MAIN_REPO_BRANCH=$TRAVIS_BRANCH
1517
- pipenv graph
1618
- pipenv run test
17-
- pipenv run naucse list-courses # don't remove, there might be timeouts otherwise, see naucse/cli.py for details
1819
# we utilize our own timeout here to fail the build and store the cache
1920
# Travis CI would kill the entire job in 50 minutes, so we exit this after 40, to leave 10 minutes for setup + cache upload
2021
- timeout 2400 pipenv run naucse freeze --verbose
@@ -34,7 +35,7 @@ env:
3435
global:
3536
- secure: pEZZeBdTSg0WUQYfwKZCiM+VMmNf2GyCCDa5Qcw2xGaNi5Z3rb3IYntY5ACKtDazgjzul+AqHra7iEx41yictXu4wYYt1nSY7g+ilBq/SlefiTi92ZRLH9elEChOa4A2njeuFIzwLBRr4Hdnn+21Vd/uxbC0wGhRC5c11ixBVC7Kn6zatT2TXUN+zF5a63NgUDrY/SPMV0jX3nozFHOxAQmZqlV1VL7O5ihct+mLYxB6MhS1NO/v30cMwyQm9nO0wBGJ1YH5/SKk9ThvFKH15d0xLVjZMfhJ/sgqpRnuRw4awH7SV7p2BoF7/07P8VWnCNvJ+wCipd1PqAk3COgqriWCBx80auaevIDxzky4CUk/efd3WYOA4MnzSAvcjbcQjojjsi64WWwVAcWuweTA8AEYMhVdqWlMbo8E3Oa0dZcyscBo+L26OdAdKNUqeNVQ84oIcPN/iUCitLB5GVOc0cIkn9wFer66jSuwK9bRfOTmV6NaRdLt78Edo+e1wXx0sdTVasL/rtIRTJAKKUtF8D/8RFfCNopOcceAyPr/Ay3JjVEFk2rTWeZls8E8os3TN6evVawx0t2xA0qXYb6IIrb0CFxv6sz/pU7vkuzS8g+pdQnfMmNtQ01sGGyedTT4YQRcgGKmWG+kolOXQlxJCGOndgz3VGN3DCppA5Ahbfo=
3637
- ARCA_BACKEND=arca.backend.DockerBackend
37-
- FORKS_ENABLED=true
38+
- NAUCSE_TRUSTED_REPOS=*
3839
- DOCKER_HUB_USERNAME=naucse
3940
- secure: eg0Lj+IvZnNwf6rK7ZNsrhZs0V2ap9TylSOh3B+xthmwLBGB2fxtVQrjJEAimwoUEEzO6XAyGWuKa2RMtPUYx0758diEZCBT2Ct9aprhz2m9girLyUynAAfBumVv/0iMYqh9QShzfGLkF/f3Z/bkIheVhKV7jBCy5iHBLGzlSr2i4lZjFUE/lYNnQh+KCVx9HGKmSm4111x57ID+N73poe5mshWE6QYw4gSjjwdMW4SYcABwkARFHLNc1cuZYJKwXtMeN1MHlp2bjdJB2wUtoyb7b8QSoGYu87egVsAHby5+ccClecu9LC6DWgFvXs/pCBriqiHPk72TC0Zfx3pWpAhQcGZ85FqN4ZNL3q2hahodHbML38FjcbgQFNE9s1eT2q+y16R8Hy34HhvDCEx13+4xwjPHNkkjm/kQOzQ1cBwmiP52PgmsxOtNVu9sEOVmSUShf9oz15E0bpX8U+GG4cjJN15vGgfvg5lkpuVdRnoz+voi+9i3yDZ4XBD9E79LZxmHkZ5gEXdRWXnI6YmE9Ejq2csyLr4RPmicslLd24QWWSYmJ2MWzSaJmSFBiw2OZn880EqRlaVKSUS0kzvT5YYo6eb36cslSVK9QVBCAgzRuPH0GHKhnV5cPOQjgNEGISmLbTgMubxILNT077dcXL7cbB29YCN+zIyAoFH9gCs=
4041
services:

Pipfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ mistune = "*"
1818
nbconvert = "*"
1919
python-dateutil = "*"
2020
traitlets = "*"
21-
arca = {extras = ["docker"], version = ">= 0.3"}
21+
arca = {extras = ["docker"],version = ">= 0.3"}
2222
cssutils = "*"
2323
click = "*"
2424
giturlparse = "*"
@@ -30,8 +30,10 @@ jupyter_client = "*"
3030
Pygments = "*"
3131
Werkzeug = "*"
3232
GitPython = "*"
33+
jsonschema = "*"
3334
lxml = "*"
3435
pygments-pytest = "*"
36+
naucse-render = "<1.0"
3537

3638
[dev-packages]
3739
pytest = "*"

Pipfile.lock

Lines changed: 86 additions & 81 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lessons/beginners/install/linux.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Jestli ne, modul `tkinter` ještě nainstaluj:
7070
```
7171
{% endfilter %}
7272
* **Ubuntu**:
73-
{% filter markdown(inline=True) %}
73+
{% filter markdown %}
7474
```console
7575
$ sudo apt-get install python3-tk
7676
```

0 commit comments

Comments
 (0)