From 5a1e20a6577f9ad1f27dd5b003995a49eb781258 Mon Sep 17 00:00:00 2001 From: Ali Abdalla Date: Fri, 11 Mar 2022 18:24:35 +0200 Subject: [PATCH] fix search bug in guides (#809) Former-commit-id: c95ca81cb719d8c0e198e2a22ea9cf8cd0f4e388 --- website/homepage/render_html.py | 8 +++++--- website/homepage/src/guides_main_template.html | 16 +++------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/website/homepage/render_html.py b/website/homepage/render_html.py index 8a3f190d82..72a8ea7e99 100644 --- a/website/homepage/render_html.py +++ b/website/homepage/render_html.py @@ -52,8 +52,11 @@ def render_index(): generated_template.write(output_html) +guide_files = ["getting_started.md"] +all_guides = sorted(os.listdir(GRADIO_GUIDES_DIR)) +guide_files.extend([file for file in all_guides if file != "getting_started.md"]) guides = [] -for guide in sorted(os.listdir(GRADIO_GUIDES_DIR)): +for guide in guide_files: if guide.lower() == "readme.md": continue guide_name = guide[:-3] @@ -107,10 +110,9 @@ for guide in sorted(os.listdir(GRADIO_GUIDES_DIR)): def render_guides_main(): - filtered_guides = [guide for guide in guides if guide["name"] != "getting_started"] with open("src/guides_main_template.html", encoding="utf-8") as template_file: template = Template(template_file.read()) - output_html = template.render(guides=filtered_guides, navbar_html=navbar_html) + output_html = template.render(guides=guides, navbar_html=navbar_html) os.makedirs(os.path.join("generated", "guides"), exist_ok=True) with open( os.path.join("generated", "guides", "index.html"), "w", encoding="utf-8" diff --git a/website/homepage/src/guides_main_template.html b/website/homepage/src/guides_main_template.html index ea34808374..ecdaa8f6c5 100644 --- a/website/homepage/src/guides_main_template.html +++ b/website/homepage/src/guides_main_template.html @@ -122,18 +122,6 @@
- - -
-

Getting Started -

-
-
-
-
- - {% for guide in guides %}
{{ guide.pretty_name }}
+ {% if guide.tags is not none %}

{% for tag in guide.tags %} {{ tag }}{% if not loop.last %}, {% endif %} {% endfor %}

+ {% endif %}
@@ -232,7 +222,7 @@ if (txtValue.toUpperCase().indexOf(filter) > -1 || guideContent.toUpperCase().indexOf(filter) > -1) { a[{{ loop.index - 1}}].style.display = ""; } else { - a[{{ loop.index - 1 }}].style.display = "none"; + a[{{ loop.index - 1}}].style.display = "none"; counter++; } {% endfor %}