diff --git a/.gitignore b/.gitignore index b54ce02c31..ec5c250261 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.states **/*.db **/*.pyc **/*.swp diff --git a/pcweb/components/code_card.py b/pcweb/components/code_card.py index 7366a94c3a..5354209412 100644 --- a/pcweb/components/code_card.py +++ b/pcweb/components/code_card.py @@ -3,7 +3,9 @@ from reflex.components.datadisplay.shiki_code_block import copy_script -def install_command(command: str, show_dollar_sign: bool = True, **props) -> rx.Component: +def install_command( + command: str, show_dollar_sign: bool = True, **props +) -> rx.Component: return rx.el.button( rx.icon("copy", size=14, margin_left="5px"), rx.text( @@ -115,16 +117,22 @@ def gallery_app_card(app: dict) -> rx.Component: rx.vstack( rx.box( rx.hstack( - install_command(f"reflex init --template {app['title']}"), - rx.hstack( - repo(app["demo"]), - justify="start", - + install_command( + f"reflex init --template {app['title']}" + ), + *( + [ + rx.hstack( + repo(app["demo"]), + justify="start", + ) + ] + if "demo" in app + else [] ), ), width="310px", max_width="310px", - ), rx.cond( "Reflex" in app["author"], @@ -146,10 +154,8 @@ def gallery_app_card(app: dict) -> rx.Component: ), ), align_items="start", - class_name="brother-john" + class_name="brother-john", ), - - class_name="flex flex-row items-center gap-[6px] justify-between w-full", ), class_name="flex flex-col justify-between items-start gap-1 p-[0.625rem_0.75rem_0.625rem_0.75rem] w-full h-full", diff --git a/pcweb/pages/gallery/apps.py b/pcweb/pages/gallery/apps.py index 603b5dbccd..f84a882ad3 100644 --- a/pcweb/pages/gallery/apps.py +++ b/pcweb/pages/gallery/apps.py @@ -31,7 +31,6 @@ def get_route(path: str): def more_posts(current_post: dict) -> rx.Component: - posts = [] app_items = list(gallery_apps_data_copy.items()) current_index = next( @@ -49,8 +48,8 @@ def more_posts(current_post: dict) -> rx.Component: selected_posts = app_items[-3:] else: # Create a list of all posts except the current one - other_posts = app_items[:current_index] + app_items[current_index + 1:] - + other_posts = app_items[:current_index] + app_items[current_index + 1 :] + if len(other_posts) <= 3: # If there are 3 or fewer other posts, show all of them selected_posts = other_posts @@ -63,9 +62,9 @@ def more_posts(current_post: dict) -> rx.Component: else: # For all other cases, show one before and two after (or two before and one after if we're near the end) if current_index < len(app_items) - 2: - selected_posts = other_posts[current_index-1:current_index+2] + selected_posts = other_posts[current_index - 1 : current_index + 2] else: - selected_posts = other_posts[current_index-2:current_index+1] + selected_posts = other_posts[current_index - 2 : current_index + 1] for path, document in selected_posts: meta = document.metadata @@ -131,14 +130,20 @@ def page(document) -> rx.Component: class_name="flex flex-col gap-3 p-8", ), rx.box( - rx.link( - button_with_icon( - "View Demo", - icon="new_tab", - class_name="!w-full flex-row-reverse gap-2", - ), - is_external=True, - href=meta["demo"], + *( + [ + rx.link( + button_with_icon( + "View Demo", + icon="new_tab", + class_name="!w-full flex-row-reverse gap-2", + ), + is_external=True, + href=meta["demo"], + ) + ] + if meta.get("demo") + else [] ), rx.link( button("View Code", variant="muted", class_name="!w-full"), @@ -192,9 +197,9 @@ def page(document) -> rx.Component: title=document.metadata["title"], description=document.metadata["description"], image=document.metadata["image"], - demo=document.metadata["demo"], + demo=document.metadata["demo"] if "demo" in document.metadata else None, meta=document.metadata["meta"], )(lambda doc=document: page(doc)) # Add the route to the list of routes. - gallery_apps_routes.append(comp) \ No newline at end of file + gallery_apps_routes.append(comp) diff --git a/templates/llamaindex-app.md b/templates/llamaindex-app.md index d25f647294..6e74f38617 100644 --- a/templates/llamaindex-app.md +++ b/templates/llamaindex-app.md @@ -3,7 +3,6 @@ title: reflex-llamaindex-template description: "A minimal chat app using LLamaIndex" author: "Reflex" image: "llamaindex.png" -demo: "https://frontend-gold-orca.dev.reflexcorp.run/" source: "https://github.com/reflex-dev/reflex-llamaindex-template" meta: [ {"name": "keywords", "content": ""},