Skip to content

Commit d06386a

Browse files
committed
Fix bug with nested url
1 parent c8094f7 commit d06386a

File tree

6 files changed

+46
-28
lines changed

6 files changed

+46
-28
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,5 @@ dmypy.json
129129
.pyre/
130130

131131
# Ignore folders
132-
.ignore/
132+
.ignore/
133+
.bookvenv/

.streamlit/config.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
gatherUsageStats = false
33

44
[theme]
5-
base="light"
6-
primaryColor="#4E2A84"
7-
backgroundColor="snow"
8-
secondaryBackgroundColor="#B6ACD150"
5+
base = "light"
6+
primaryColor = "#4E2A84"
7+
backgroundColor = "snow"
8+
secondaryBackgroundColor = "#d2cddf"
99

1010
[runner]
1111
magicEnabled = true

book/assets/style.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,17 @@ tr .math {
1414
font-size: 1.2rem;
1515
}
1616

17-
[data-testid="stSidebar"] {
17+
/* [data-testid="stSidebar"] {
1818
background-color: #4E2A84;
1919
}
2020
21+
[data-testid="stNavSectionHeader"] {
22+
color: white;
23+
}
24+
25+
[data-testid="stSidebarNavLink"] span {
26+
color: snow;
27+
} */
2128

2229
[data-testid="stSidebar"] p {
2330
font-size: 1.0rem;

book/pages.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,26 @@ def generate_pages(page_week: Callable) -> dict[str, StreamlitPage]:
3939

4040
for i, topic in enumerate(list_of_topics, start=1):
4141
if not topic.startswith("~"):
42+
title = f"{topic}"
43+
url_path = title.replace(" ", "_").replace("-", "").strip().lower()
44+
# print(title, url_path)
45+
4246
pages[topic] = st.Page(
4347
partial(page_week, topic),
44-
title=(title := f"{topic}"),
45-
url_path=title.replace(" ", "_").replace("-", "").strip().lower(),
48+
title=title,
49+
url_path=url_path,
4650
icon=":material/article:",
4751
)
4852

4953
else:
54+
title = " - " + topic.replace("~", "")
55+
url_path = title.replace("-", "").strip().replace(" ", "_").lower()
56+
# print(title, url_path)
57+
5058
pages[topic] = st.Page(
5159
partial(page_week, topic),
52-
title=(title := " - " + topic.replace("~", "")),
53-
url_path=title.replace("-", "").strip().replace(" ", "_").lower(),
60+
title=title,
61+
url_path=url_path,
5462
icon="🐍",
5563
)
5664

book/week_03/Week_3.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from .subpages import making_epanet, adjacency_matrix
1313

1414
TOC = Literal[
15-
"Pipes in series/parallel",
15+
"Pipes in series and parallel",
1616
"Branched systems",
1717
"Looped networks",
1818
"Newton method",
@@ -24,7 +24,7 @@
2424
def page_week_03(option: TOC):
2525
st.title(option.replace("~", ""))
2626

27-
if option == "Pipes in series/parallel":
27+
if option == "Pipes in series and parallel":
2828
cols = st.columns(2)
2929
with cols[1]:
3030
st.pyplot(pipes_in_series())
@@ -589,7 +589,7 @@ def three_reservoirs_problem(
589589

590590
return error
591591

592-
st.subheader("### 🍠 Find the root ", anchor=False)
592+
st.subheader("🍠 Find the root ", anchor=False)
593593

594594
with st.echo():
595595
solution = root(
@@ -617,13 +617,13 @@ def three_reservoirs_problem(
617617

618618
st.divider()
619619
st.warning("What was the pressure in the junction?")
620-
620+
621621
elif option == "~Building an EPANET":
622622
making_epanet()
623-
623+
624624
elif option == "~Adjacency matrix":
625625
adjacency_matrix()
626-
626+
627627
else:
628628
r"### 🚧 Under construction 🚧"
629629

@@ -954,5 +954,3 @@ def write_network_equations():
954954
"""
955955

956956
return None
957-
958-

hydraulics_book.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import streamlit as st
22
import os
3+
34
from book.pages import all_pages
45
from book.common import page_config_common, apply_css_style, sidebar_common, badges
56

67

78
def entrypoint_page():
8-
9-
st.title("🌊 Hydraulics and Hydrology with Python 🌊", anchor="Hydraulics and Hydrology with Python")
9+
st.title(
10+
"🌊 Hydraulics and Hydrology with Python 🌊",
11+
anchor="Hydraulics and Hydrology with Python",
12+
)
1013
st.markdown(" ")
11-
14+
1215
left_col, right_col = st.columns([2, 1])
1316

1417
with right_col:
@@ -24,7 +27,7 @@ def entrypoint_page():
2427
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">
2528
<img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/80x15.png" />
2629
</a>
27-
<br />This work is licensed under a
30+
<br />This work is licensed under a
2831
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">
2932
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License
3033
</a>.
@@ -39,8 +42,8 @@ def entrypoint_page():
3942
with left_col:
4043
st.markdown(
4144
R"""
42-
This material was first made to support the course
43-
:violet[CIV-ENV 340: Hydraulics and Hydrology] that I taught during
45+
This material was first made to support the course
46+
:violet[CIV-ENV 340: Hydraulics and Hydrology] that I taught during
4447
the Spring quarter of 2023 at Northwestern University. It is divided
4548
in the ten weeks of the quarter, covering concepts in hydraulics of
4649
presurized pipe systems, open channel flow, and basic hydrology. This
@@ -56,7 +59,7 @@ class included short computational projects, in which we...
5659

5760
st.page_link(
5861
all_pages["Week 6 - More channel flow"]["~Solve IVP"],
59-
label=":violet-background[... made a gradually-variable flow profiles calculator]",
62+
label=":violet-background[... made a gradually-variable flow calculator]",
6063
use_container_width=True,
6164
)
6265

@@ -72,9 +75,11 @@ class included short computational projects, in which we...
7275
use_container_width=True,
7376
)
7477

78+
st.markdown("""⁂""")
79+
7580
st.markdown("""
7681
The pages marked with a 🐍 indicate the projects involving using Python.
77-
The rest correspond to supplemental material for the lectures, like
82+
The rest correspond to supplemental material for the lectures, like
7883
diagrams and interactive plots.
7984
""")
8085

@@ -89,14 +94,13 @@ def main():
8994
)
9095

9196
all_pages.update({"Cover": {"Introduction": entry_page}})
92-
9397
pages_for_nav = {k: list(v.values()) for k, v in all_pages.items()}
98+
9499
nav = st.navigation(pages_for_nav)
95100
nav.run()
96101

97102

98103
if __name__ == "__main__":
99-
100104
if not st.session_state.get("set_mplrc", False):
101105
os.environ["MATPLOTLIBRC"] = (
102106
os.getcwd() + "/book/assets/matplotlib/matplotlibrc"

0 commit comments

Comments
 (0)