nbroad HF staff commited on
Commit
9d1d9ac
1 Parent(s): 281ac5e

rel="noopener noreferrer"

Browse files
Files changed (1) hide show
  1. app.py +111 -27
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='codehilite', 'smarty', 'extra', 'sane_lists'
6
- def Markdown(s, exts=md_exts, **kw): return Div(NotStr(markdown(s, extensions=exts)), **kw)
7
 
8
- ghurl = 'https://github.com/nbroad1881'
9
- hf_logo_svg = "https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.svg"
 
 
 
 
 
 
 
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 = 'assets/fasthtml_logo.svg'
 
17
 
18
  def BstPage(selidx, title, *c):
19
- navitems = [('Home', '/'), ('About', '/about'), ('Blog', '/blog')]
20
-
21
  ra_items = (
22
  A(
23
- Image(src=hf_logo_svg, width=28, height=28, cls="my-0 px-0 mx-0 py-0", left=False, pad=0),
24
- cls="ms-2 my-0 px-1 btn-lg btn", role="button", href=hf_url, target="_blank"
25
- ),
26
- Icon('fab fa-github', dark=False, sz='lg', href=ghurl, cls='ms-2 px-2', target="_blank"),
27
- Icon("fab fa-linkedin", dark=False, sz='lg', href=li_url, cls='ms-2 px-2', target="_blank"),
28
- Icon("fab fa-kaggle", dark=False, sz='lg', href=kaggle_url, cls='ms-2 px-2', target="_blank"),
29
- Icon("fab fa-youtube", dark=False, sz='lg', href=yt_url, cls='ms-2 px-2', target="_blank"),
30
- Icon("fab fa-twitter", dark=False, sz='lg', href=tw_url, cls='ms-2 px-2', target="_blank"),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  )
32
- ftlinks = [A(k, href=v, cls='nav-link px-2 text-muted')
33
- for k,v in dict(Home='/').items()]
 
34
  return (
35
  Title(title),
36
- Script('initTOC()'),
37
  Container(
38
- Navbar('nav', selidx, items=navitems, ra_items=ra_items, cls='navbar-light bg-secondary rounded-lg',
39
- image=f'', hdr_href="", placement=PlacementT.Default, expand=SizeT.Md, toggle_left=False),
40
- Toc(Container(H1(title, cls='pb-2 pt-1'), *c, cls='mt-3')),
41
- BstFooter('Made using FastHTML', File(fh_logo), img_href=fh_url, cs=ftlinks),
42
- typ=ContainerT.Xl, cls='mt-3', data_bs_spy='scroll', data_bs_target='#toc'))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
  def Sections(h2s, texts):
45
- colors = 'yellow', 'pink', 'teal', 'blue'
46
- div_cls = 'py-2 px-3 mt-4 bg-light-{} rounded-lg'
47
- return chain([Div(H2(h2, id=f'sec{i+1}', cls=div_cls.format(colors[i%4])), Div(txt, cls='px-2'))
48
- for i,(h2,txt) in enumerate(zip(h2s, texts))])
 
 
 
 
 
 
 
 
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
+ )