rel="noopener noreferrer"
Browse files
app.py
CHANGED
@@ -2,47 +2,131 @@ from fh_bootstrap import *
|
|
2 |
from itertools import chain
|
3 |
from markdown import markdown
|
4 |
|
5 |
-
md_exts=
|
6 |
-
def Markdown(s, exts=md_exts, **kw): return Div(NotStr(markdown(s, extensions=exts)), **kw)
|
7 |
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
hf_url = "https://hf.co/nbroad"
|
11 |
li_url = "https://www.linkedin.com/in/nicholas-m-broad/"
|
12 |
kaggle_url = "https://www.kaggle.com/nbroad"
|
13 |
yt_url = "https://www.youtube.com/@nicholasbroad1881"
|
14 |
tw_url = "https://twitter.com/nbroad1881"
|
15 |
fh_url = "https://fastht.ml/"
|
16 |
-
fh_logo =
|
|
|
17 |
|
18 |
def BstPage(selidx, title, *c):
|
19 |
-
navitems = [(
|
20 |
-
|
21 |
ra_items = (
|
22 |
A(
|
23 |
-
Image(
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
)
|
32 |
-
ftlinks = [
|
33 |
-
for k,v in dict(Home=
|
|
|
34 |
return (
|
35 |
Title(title),
|
36 |
-
Script(
|
37 |
Container(
|
38 |
-
Navbar(
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
def Sections(h2s, texts):
|
45 |
-
colors =
|
46 |
-
div_cls =
|
47 |
-
return chain(
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
from itertools import chain
|
3 |
from markdown import markdown
|
4 |
|
5 |
+
md_exts = "codehilite", "smarty", "extra", "sane_lists"
|
|
|
6 |
|
7 |
+
|
8 |
+
def Markdown(s, exts=md_exts, **kw):
|
9 |
+
return Div(NotStr(markdown(s, extensions=exts)), **kw)
|
10 |
+
|
11 |
+
|
12 |
+
ghurl = "https://github.com/nbroad1881"
|
13 |
+
hf_logo_svg = (
|
14 |
+
"https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.svg"
|
15 |
+
)
|
16 |
hf_url = "https://hf.co/nbroad"
|
17 |
li_url = "https://www.linkedin.com/in/nicholas-m-broad/"
|
18 |
kaggle_url = "https://www.kaggle.com/nbroad"
|
19 |
yt_url = "https://www.youtube.com/@nicholasbroad1881"
|
20 |
tw_url = "https://twitter.com/nbroad1881"
|
21 |
fh_url = "https://fastht.ml/"
|
22 |
+
fh_logo = "assets/fasthtml_logo.svg"
|
23 |
+
|
24 |
|
25 |
def BstPage(selidx, title, *c):
|
26 |
+
navitems = [("Home", "/"), ("About", "/about"), ("Blog", "/blog")]
|
27 |
+
|
28 |
ra_items = (
|
29 |
A(
|
30 |
+
Image(
|
31 |
+
src=hf_logo_svg,
|
32 |
+
width=28,
|
33 |
+
height=28,
|
34 |
+
cls="my-0 px-0 mx-0 py-0",
|
35 |
+
left=False,
|
36 |
+
pad=0,
|
37 |
+
),
|
38 |
+
cls="ms-2 my-0 px-1 btn-lg btn",
|
39 |
+
role="button",
|
40 |
+
href=hf_url,
|
41 |
+
target="_blank",
|
42 |
+
rel="noopener noreferrer",
|
43 |
+
),
|
44 |
+
Icon(
|
45 |
+
"fab fa-github",
|
46 |
+
dark=False,
|
47 |
+
sz="lg",
|
48 |
+
href=ghurl,
|
49 |
+
cls="ms-2 px-2",
|
50 |
+
target="_blank",
|
51 |
+
rel="noopener noreferrer",
|
52 |
+
),
|
53 |
+
Icon(
|
54 |
+
"fab fa-linkedin",
|
55 |
+
dark=False,
|
56 |
+
sz="lg",
|
57 |
+
href=li_url,
|
58 |
+
cls="ms-2 px-2",
|
59 |
+
target="_blank",
|
60 |
+
rel="noopener noreferrer",
|
61 |
+
),
|
62 |
+
Icon(
|
63 |
+
"fab fa-kaggle",
|
64 |
+
dark=False,
|
65 |
+
sz="lg",
|
66 |
+
href=kaggle_url,
|
67 |
+
cls="ms-2 px-2",
|
68 |
+
target="_blank",
|
69 |
+
rel="noopener noreferrer",
|
70 |
+
),
|
71 |
+
Icon(
|
72 |
+
"fab fa-youtube",
|
73 |
+
dark=False,
|
74 |
+
sz="lg",
|
75 |
+
href=yt_url,
|
76 |
+
cls="ms-2 px-2",
|
77 |
+
target="_blank",
|
78 |
+
rel="noopener noreferrer",
|
79 |
+
),
|
80 |
+
Icon(
|
81 |
+
"fab fa-twitter",
|
82 |
+
dark=False,
|
83 |
+
sz="lg",
|
84 |
+
href=tw_url,
|
85 |
+
cls="ms-2 px-2",
|
86 |
+
target="_blank",
|
87 |
+
rel="noopener noreferrer",
|
88 |
+
),
|
89 |
)
|
90 |
+
ftlinks = [
|
91 |
+
A(k, href=v, cls="nav-link px-2 text-muted") for k, v in dict(Home="/").items()
|
92 |
+
]
|
93 |
return (
|
94 |
Title(title),
|
95 |
+
Script("initTOC()"),
|
96 |
Container(
|
97 |
+
Navbar(
|
98 |
+
"nav",
|
99 |
+
selidx,
|
100 |
+
items=navitems,
|
101 |
+
ra_items=ra_items,
|
102 |
+
cls="navbar-light bg-secondary rounded-lg",
|
103 |
+
image=f"",
|
104 |
+
hdr_href="",
|
105 |
+
placement=PlacementT.Default,
|
106 |
+
expand=SizeT.Md,
|
107 |
+
toggle_left=False,
|
108 |
+
),
|
109 |
+
Toc(Container(H1(title, cls="pb-2 pt-1"), *c, cls="mt-3")),
|
110 |
+
BstFooter(
|
111 |
+
"Made using FastHTML", File(fh_logo), img_href=fh_url, cs=ftlinks
|
112 |
+
),
|
113 |
+
typ=ContainerT.Xl,
|
114 |
+
cls="mt-3",
|
115 |
+
data_bs_spy="scroll",
|
116 |
+
data_bs_target="#toc",
|
117 |
+
),
|
118 |
+
)
|
119 |
+
|
120 |
|
121 |
def Sections(h2s, texts):
|
122 |
+
colors = "yellow", "pink", "teal", "blue"
|
123 |
+
div_cls = "py-2 px-3 mt-4 bg-light-{} rounded-lg"
|
124 |
+
return chain(
|
125 |
+
[
|
126 |
+
Div(
|
127 |
+
H2(h2, id=f"sec{i+1}", cls=div_cls.format(colors[i % 4])),
|
128 |
+
Div(txt, cls="px-2"),
|
129 |
+
)
|
130 |
+
for i, (h2, txt) in enumerate(zip(h2s, texts))
|
131 |
+
]
|
132 |
+
)
|