Skip to content

Commit

Permalink
Merge pull request #73 from axelknock/main
Browse files Browse the repository at this point in the history
add page title (FastHTML gallery) and favicon
  • Loading branch information
Isaac-Flath authored Feb 4, 2025
2 parents 3c0184b + 923be3c commit bc18107
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Binary file added gallery.ico
Binary file not shown.
22 changes: 15 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ def get_module_path(p,base_dir): return f'{base_dir}.{".".join(Path(p).parts[1:]

application_routes = [Mount(f"/app/{get_route(root)}", import_module(get_module_path(root,'examples')).app) for root, dirs, files in os.walk('examples') if 'app.py' in files]

site_title = 'FastHTML Gallery'
descr = 'A gallery of FastHTML components showing common patterns in FastHTML apps, including chat bubbles, cascading dropdowns, interactive charts, etc.'
ghub_link = A(UkIcon("github"), title="FastHTML Gallery on Github",
href="https://github.com/AnswerDotAI/FastHTML-Gallery"),

hdrs = (
*Socials(title='FastHTML Gallery', description=descr, site_name='gallery.fastht.ml', twitter_site='@isaac_flath', image=f'/social.png', url=''),
*Socials(title=site_title, description=descr, site_name='gallery.fastht.ml', twitter_site='@isaac_flath', image=f'/social.png', url=''),
toggle_script,
*Theme.blue.headers(highlightjs=True),)
*Theme.blue.headers(highlightjs=True),
Link(rel='icon', type='image/x-ico', href="/files/gallery.ico"))

app = FastHTML(routes=application_routes+ [Mount('/files', StaticFiles(directory='.')),], hdrs=hdrs, pico=False)

Expand Down Expand Up @@ -103,11 +107,13 @@ def homepage():
cols_min=1, cols_sm=1, cols_md=2, cols_lg=3, cols_xl=3),
cls='pt-6', open=True)))

return (NavBarContainer(
NavBarLSide(H1("FastHTML Gallery" )),
return (Title(site_title),
NavBarContainer(
NavBarLSide(H1(site_title)),
NavBarRSide(
Button(submit=False)("Toggle Animations", onclick="toggleAnimations()"),
A(Button("Table View"), href="/table"))),
A(Button("Table View"), href="/table"),
ghub_link)),
Container(*all_cards))


Expand Down Expand Up @@ -144,11 +150,13 @@ def SectionTable(section):

@app.get("/table")
def table_view():
return (NavBarContainer(
return (Title(site_title),
NavBarContainer(
NavBarLSide(H1("FastHTML Gallery Table View")),
NavBarRSide(
Button(submit=False)("Toggle Animations", onclick="toggleAnimations()"),
A(Button("Card View"), href="/"))),
A(Button("Card View"), href="/"),
ghub_link)),
Container(*[SectionTable(section) for section in directories]))

serve()

0 comments on commit bc18107

Please sign in to comment.