Skip to content
Snippets Groups Projects
Commit 39fadcf5 authored by Robert Lanzafame's avatar Robert Lanzafame
Browse files

Merge branch 'main' into pa-1-material

parents 2af47e28 c8644891
No related branches found
No related tags found
2 merge requests!90Publish Week 1,!81Pa 1 material
......@@ -185,3 +185,26 @@ To run a `.sh` in Windows, make sure you have Git installed. If Windows still do
### Thebe Lite
Thebe Lite is used to allow interactive code within the notebook. For more information on its use, read the `Live Code` page in the `Cookbook` section. For technical information, read the [Thebe Lite readme](thebe_lite/THEBE_LITE.md).
## Publishing the MUDE Websites
We have 2 websites, the "website" and the "book"
Each website has a "published" and "draft" version: the first is the official version and builds when a merge into the publish branch happens. The second is our draft book and will automatically build when you merge into main. This is where we will stage, review contents prior to sharing with students (also testing interactive functionality). I advise you to just bookmark them in a way that clarifies the difference between “draft” and “published” versions
Thus, there are 4 websites:
* Published website: [https://mude.citg.tudelft.nl/](https://mude.citg.tudelft.nl/)
* Draft website: [https://mude.citg.tudelft.nl/draft/](https://mude.citg.tudelft.nl/draft/)
* Published book: [https://mude.citg.tudelft.nl/book](https://mude.citg.tudelft.nl/book)
* Draft book: [https://mude.citg.tudelft.nl/book-draft](https://mude.citg.tudelft.nl/book-draft)
Draft book and draft website is protected with:
```
Username: teacher
Password: access
```
A new feature is added: anything in `_toc.yml` between `# START REMOVE-FROM-PUBLISH` and `# END REMOVE-FROM-PUBLISH` will be automatically removed from the published version of the book (the banner warning about a draft book is also automatically removed).
If you need to remove the published version, a push to branch `purge-book` will deploy the book in that branch. It is set up with all unnecessary files removed and a 1-page Jupyter Book. The branch is protected with permission granted only to those with maintainer role.
\ No newline at end of file
......@@ -3,20 +3,21 @@ author: MUDE Teachers and the Student Army
logo: _static/MUDE_Logo-small.png
execute:
execute_notebooks: 'off'
execute_notebooks: "off"
sphinx:
config:
# Bibliography style
bibtex_reference_style: author_year
extra_extensions:
- sphinx_inline_tabs
- sphinx_grasple
- sphinx.ext.imgconverter
- sphinx_inline_tabs
- sphinx_grasple
- sphinx.ext.imgconverter
bibtex_bibfiles:
- _bibliography/references_pd.bib
launch_buttons:
thebe: true
draft_banner: '⚠️This is a draft website. The most recent published version can be found <a href="https://mude.citg.tudelft.nl/book/intro.html">here</a>.⚠️'
// Keep track of the scroll position
const NAVIGATION_ELEMENT_CLASS = "bd-sidebar-primary";
document.addEventListener("DOMContentLoaded", () => {
addEventListener("beforeunload", () => {
let elements = document.getElementsByClassName(NAVIGATION_ELEMENT_CLASS);
if (elements.length === 0) {
console.warn("No sidebar found, cannot save scroll position");
return;
}
localStorage.setItem("navigationScrollPosition", elements[0].scrollTop);
});
let elements = document.getElementsByClassName(NAVIGATION_ELEMENT_CLASS);
if (elements.length === 0) {
console.warn("No sidebar found, cannot restore scroll position");
return;
}
let scrollPosition = localStorage.getItem("navigationScrollPosition");
if (scrollPosition == null) {
return;
}
// Convert scroll position into a positive number and apply it
let parsedPosition = Math.abs(scrollPosition);
console.debug(`Restoring scroll position to ${parsedPosition}`);
elements[0].scrollTop = isNaN(parsedPosition) ? 0 : parsedPosition;
});
......@@ -142,6 +142,7 @@ parts:
- file: sandbox/1-5-NumericalMethods/1-general-solvers.ipynb
- file: sandbox/1-5-NumericalMethods/2-implicit-ode-solver.ipynb
# START REMOVE-FROM-PUBLISH
- caption: MUDE Cookbook
chapters:
- file: cookbook/blank
......@@ -159,6 +160,7 @@ parts:
- file: cookbook/example_quiz_interactive.ipynb
- file: cookbook/coding_theory_widgets.ipynb
- file: cookbook/theory_questions
# END REMOVE-FROM-PUBLISH
- caption: Old Material
chapters:
- file: old/blank
......@@ -247,7 +249,7 @@ parts:
title: Assignment 2
- file: EVA/MUDE/01_06_4-1-EVA2_teacher.ipynb
title: Solution 2
# START REMOVE-FROM-PUBLISH
# Coding
- caption: Coding (Last Year)
chapters:
......@@ -287,4 +289,4 @@ parts:
- file: old/coding/2-2/1_2.ipynb
- file: old/coding/2-2/1-part-2.md
- file: old/coding/2-2/1-part-3.md
# END REMOVE-FROM-PUBLISH
......@@ -3,39 +3,3 @@
Welcome to the MUDE textbook.
_this is where stuff will be written later_
````{admonition} Update for MUDE Teachers
:class: note
I got rid of the README that used to be here, because you should have your workflow set by now, and you should know by now that you can always check it on GitLab [here](https://gitlab.tudelft.nl/mude/book/). **I'll put recent updates here for the 2 weeks leading up to the start of Q1**:
- Draft of Programming Part is ready---the first content for the "new" book to be placed! Note that it is located in `book/book/programming`.
- As you finalize the ToC for your material, move it to the same level directory as the programming part. All Parts should be a sub-directory of `book`.
- By the start of Q1, all material in `cookbook`, `old`, `sandbox` should be removed, moved or hidden (preferably by YOU!)
- **Aug 24**: draft ToC prepared for afternoon collaboration session.
````
Table of Contents notes (can turn into text on this page later):
- Modeling is a clear topic and has it's own part. Q2 topics are separated though, at least for this year
- Modeling can be both the model (and it's underlying mathematics) as well as conceptual processes. Both are very applicatble to
- Data is difficult to separate from modeling, probability and statistics topics, so it doesn't have it's own heading
- Uncertainty is far too broad a topic, so we instead rely on sub-topics like probability, statistics, observation theory, error propagation, etc
- "Uncertainty and Data" are especially difficult to extract from each other
- Modeling and Probability parts cover weeks 1.1, 1.2, 1.5, 1.6, 1.7, 1.8 (partial)
- 2.1: FVM
- 2.2: FEM
- 2.3
- 2.7-2.8: Risk & Reliability (also may be used partially in 1.7-1.8)
````{admonition} Dicatorial Proclamation by the MUDE Manager
:class: warning
The MUDE content formerly known as **coding** shall henceforth be called **programming.**
Don't like it? Too bad, maybe you can become manager next year and change it back. I have plenty of reasons, but rather than type them I believe they are better discussed over a cold beverage.
````
<!-- ```{note}
Right now, the home page of the book simply displays `README.md` which is located at `./book/` or you can [read on GitLab here](https://gitlab.tudelft.nl/mude/book/-/blob/main/README.md).
```
```{include} ../README.md
``` -->
......@@ -4,14 +4,30 @@ set -euo pipefail
START_SERVER=${1:-false}
PAGE_ROOT=${2:-"/"}
IS_PUBLISH_DEPLOYMENT=${3:-false}
# Pre-process the book
if [ "$IS_PUBLISH_DEPLOYMENT" = true ]; then
echo "Using publish deployment strategy"
# Remove chapters from the book which are not to be published
sed --in-place=".bak" '/# START REMOVE-FROM-PUBLISH/,/# END REMOVE-FROM-PUBLISH/{//!d}' book/_toc.yml
else
echo "Using draft deployment strategy"
# Add a banner which identifies the book as a draft
if ! command -v yq &> /dev/null; then
echo "yq could not be found, the banner will not be added"
else
cp book/_config.yml book/_config.yml.bak
yq -i '.html.announcement = .draft_banner' book/_config.yml
fi
fi
# Build the jupyter book, everything else is post-processing
jupyter-book clean book/
jupyter-book build book/
# Note: the structure of thebe_lite mimicks where thing are needed in the html folder
cp thebe_lite/* book/_build/html/ -r
sed "s,const PAGE_ROOT = \"/\";,const PAGE_ROOT = \"$PAGE_ROOT\";,g" thebe_lite/_static/sphinx-thebe.js > book/_build/html/_static/sphinx-thebe.js
sed "s,const PAGE_ROOT = \"/\";,const PAGE_ROOT = \"$PAGE_ROOT\";,g" thebe_lite/_static/sphinx-thebe.js >book/_build/html/_static/sphinx-thebe.js
rm book/_build/html/THEBE_LITE.md
# Copy all non notebook, markdown or build files into the build for local access in pyodide etc.
......@@ -22,28 +38,25 @@ rm book/_build/html/THEBE_LITE.md
# 4. xargs: will execute the script inside the quotes
# 5. grep: finds a file's parent's path by matching against the section of the string ending in a '/'
# 6. mkdir: makes all the parent directories, -p will do so recrusively
# 7. cp: finally copies all files from the /book folder to /book/_build/html
# 7. cp: finally copies all files from the /book folder to /book/_build/html
find book/ -type f | grep -v "^book/_.*\|.*\.\(md\|ipynb\)" | cut -c 6- | xargs -i sh -c 'echo "book/_build/html/{}" | grep -o "^.*/" | xargs -d "\n" mkdir -p; cp book/"{}" book/_build/html/"{}"'
# Check whether python has the alias 'python' or 'python3'
if command -v python3 > /dev/null 2>&1
then
if command -v python3 >/dev/null 2>&1; then
python_command="python3"
else
if command -v python > /dev/null 2>&1
then
if command -v python >/dev/null 2>&1; then
python_command="python"
fi
fi
if [ "$python_command" = "" ] ; then
if [ "$python_command" = "" ]; then
echo "Book successfully built. If you want to use interactive elements, start a local HTTP server for the _build/html folder."
exit 0
fi
# Serves the files on port 8000, localhost (127.0.0.1:8000)
if [ "$START_SERVER" = true ] ; then
if [ "$START_SERVER" = true ]; then
echo "Starting server on port 8000"
$python_command -m http.server 8000 --directory book/_build/html
else
......@@ -51,8 +64,8 @@ else
start a server locally using the command:
$python_command -m http.server 8000 --directory book/_build/html.
Or run this script again (book will build again!):
${0} true"
${0} true"
fi
echo "To close a python server run the commeand:
kill-server.sh"
\ No newline at end of file
kill-server.sh"
......@@ -175,8 +175,8 @@ var configureThebe = () => {
updateThebeButtonStatus(
`<span class='launch_msg'>Launching Pyodide kernel: </span><span class='status'>` +
data.status +
"</span>"
data.status +
"</span>"
);
if (data.status === "attached") {
......@@ -301,7 +301,7 @@ function override_pyodide_lookup(fs, server_path) {
currentDirectory += directory + "/";
try {
fs.mkdir(currentDirectory);
} catch {}
} catch { }
}
}
......@@ -430,9 +430,8 @@ var initThebe = async () => {
// 4. Execute the override_pyodide_lookup function in JS, and bake in the relative path from root in the book (the home)
// NOTE: All functions used in override_pyodide_lookup should be nested inside it, since the web worker cannot access functions in this script
thebelab.session.kernel.requestExecute({
code: `import js; import pyodide_js; js.fs = pyodide_js.FS; js.eval("""${override_pyodide_lookup.toString()}"""); js.eval(f"override_pyodide_lookup(fs, '${
location.pathname.split("/").slice(0, -1).join("/") + "/"
}')")`,
code: `import js; import pyodide_js; js.fs = pyodide_js.FS; js.eval("""${override_pyodide_lookup.toString()}"""); js.eval(f"override_pyodide_lookup(fs, '${location.pathname.split("/").slice(0, -1).join("/") + "/"
}')")`,
});
const request = new XMLHttpRequest();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment