Spaces:
Runtime error
Runtime error
Greg Wilson commited on
Commit ·
a3ca07d
1
Parent(s): ae45418
feat: finalizing templates and Makefile to link to molab
Browse files- Makefile +2 -2
- bin/build.py +4 -2
- templates/index.html +1 -1
- templates/lesson.html +1 -1
Makefile
CHANGED
|
@@ -44,8 +44,8 @@ check_exec:
|
|
| 44 |
fi
|
| 45 |
|
| 46 |
## build: build website
|
| 47 |
-
build: ${LESSON_DATA} ${
|
| 48 |
-
${PYTHON} bin/build.py --root ${ROOT} --output ${SITE} --data ${LESSON_DATA}
|
| 49 |
|
| 50 |
## links: check links locally (while 'make serve')
|
| 51 |
links:
|
|
|
|
| 44 |
fi
|
| 45 |
|
| 46 |
## build: build website
|
| 47 |
+
build: ${LESSON_DATA} ${TEMPLATES} # ${NOTEBOOK_OUT}
|
| 48 |
+
${PYTHON} bin/build.py --branch temp --root ${ROOT} --output ${SITE} --data ${LESSON_DATA}
|
| 49 |
|
| 50 |
## links: check links locally (while 'make serve')
|
| 51 |
links:
|
bin/build.py
CHANGED
|
@@ -15,7 +15,7 @@ from jinja2 import Environment, FileSystemLoader
|
|
| 15 |
from utils import get_notebook_title
|
| 16 |
|
| 17 |
|
| 18 |
-
def transform_lessons(data: dict, root: Path) -> dict:
|
| 19 |
"""Transform raw lesson data into template-ready form."""
|
| 20 |
for course_id, course in data.items():
|
| 21 |
desc = course.get("description", "").strip()
|
|
@@ -26,6 +26,7 @@ def transform_lessons(data: dict, root: Path) -> dict:
|
|
| 26 |
or re.sub(r"^\d+_", "", nb.replace(".py", "")).replace("_", " ").title(),
|
| 27 |
"html_path": f"{course_id}/{nb.replace('.py', '.html')}",
|
| 28 |
"local_html_path": nb.replace(".py", ".html"),
|
|
|
|
| 29 |
}
|
| 30 |
for nb in course.get("notebooks", [])
|
| 31 |
]
|
|
@@ -45,13 +46,14 @@ def main():
|
|
| 45 |
parser.add_argument("--root", required=True, help="Project root directory")
|
| 46 |
parser.add_argument("--output", required=True, help="Output directory")
|
| 47 |
parser.add_argument("--data", required=True, help="Path to lessons JSON file")
|
|
|
|
| 48 |
args = parser.parse_args()
|
| 49 |
|
| 50 |
root = Path(args.root)
|
| 51 |
output = Path(args.output)
|
| 52 |
output.mkdir(parents=True, exist_ok=True)
|
| 53 |
|
| 54 |
-
lessons = transform_lessons(json.loads(Path(args.data).read_text()), root)
|
| 55 |
env = Environment(loader=FileSystemLoader(root / "templates"))
|
| 56 |
current_year = datetime.date.today().year
|
| 57 |
|
|
|
|
| 15 |
from utils import get_notebook_title
|
| 16 |
|
| 17 |
|
| 18 |
+
def transform_lessons(data: dict, root: Path, branch: str) -> dict:
|
| 19 |
"""Transform raw lesson data into template-ready form."""
|
| 20 |
for course_id, course in data.items():
|
| 21 |
desc = course.get("description", "").strip()
|
|
|
|
| 26 |
or re.sub(r"^\d+_", "", nb.replace(".py", "")).replace("_", " ").title(),
|
| 27 |
"html_path": f"{course_id}/{nb.replace('.py', '.html')}",
|
| 28 |
"local_html_path": nb.replace(".py", ".html"),
|
| 29 |
+
"molab_url": f"https://molab.marimo.io/github/marimo-team/learn/blob/{branch}/{course_id}/{nb}",
|
| 30 |
}
|
| 31 |
for nb in course.get("notebooks", [])
|
| 32 |
]
|
|
|
|
| 46 |
parser.add_argument("--root", required=True, help="Project root directory")
|
| 47 |
parser.add_argument("--output", required=True, help="Output directory")
|
| 48 |
parser.add_argument("--data", required=True, help="Path to lessons JSON file")
|
| 49 |
+
parser.add_argument("--branch", required=True, help="Git branch name for molab URLs")
|
| 50 |
args = parser.parse_args()
|
| 51 |
|
| 52 |
root = Path(args.root)
|
| 53 |
output = Path(args.output)
|
| 54 |
output.mkdir(parents=True, exist_ok=True)
|
| 55 |
|
| 56 |
+
lessons = transform_lessons(json.loads(Path(args.data).read_text()), root, args.branch)
|
| 57 |
env = Environment(loader=FileSystemLoader(root / "templates"))
|
| 58 |
current_year = datetime.date.today().year
|
| 59 |
|
templates/index.html
CHANGED
|
@@ -76,7 +76,7 @@
|
|
| 76 |
<ol class="space-y-1 list-decimal pl-5">
|
| 77 |
{% for notebook in notebooks %}
|
| 78 |
<li>
|
| 79 |
-
<a href="{{ notebook.
|
| 80 |
{{ notebook.title }}
|
| 81 |
</a>
|
| 82 |
</li>
|
|
|
|
| 76 |
<ol class="space-y-1 list-decimal pl-5">
|
| 77 |
{% for notebook in notebooks %}
|
| 78 |
<li>
|
| 79 |
+
<a href="{{ notebook.molab_url }}" class="link-primary">
|
| 80 |
{{ notebook.title }}
|
| 81 |
</a>
|
| 82 |
</li>
|
templates/lesson.html
CHANGED
|
@@ -34,7 +34,7 @@
|
|
| 34 |
<ol class="space-y-1 list-decimal pl-5">
|
| 35 |
{% for notebook in lesson.notebooks %}
|
| 36 |
<li>
|
| 37 |
-
<a href="{{ notebook.
|
| 38 |
{{ notebook.title }}
|
| 39 |
</a>
|
| 40 |
</li>
|
|
|
|
| 34 |
<ol class="space-y-1 list-decimal pl-5">
|
| 35 |
{% for notebook in lesson.notebooks %}
|
| 36 |
<li>
|
| 37 |
+
<a href="{{ notebook.molab_url }}" class="link-primary">
|
| 38 |
{{ notebook.title }}
|
| 39 |
</a>
|
| 40 |
</li>
|