From ef54f0021267d039f7444d709296c627882d4495 Mon Sep 17 00:00:00 2001
From: Ben Busby <contact@benbusby.com>
Date: Wed, 6 Mar 2024 10:14:52 -0700
Subject: [PATCH] Only show redirects on error page if query is available

The redirects portion of the error page is only needed in scenarios
where the instance is rate limited, in which case the user's query is
provided to the error template. If this isn't provided, it should just
display the error and allow the user to redirect to the home page.

Fixes #1122
---
 app/templates/error.html | 165 ++++++++++++++++++++-------------------
 1 file changed, 83 insertions(+), 82 deletions(-)

diff --git a/app/templates/error.html b/app/templates/error.html
index 99e87b3..dcaf3cf 100644
--- a/app/templates/error.html
+++ b/app/templates/error.html
@@ -19,87 +19,88 @@
         {{ error_message }}
     </p>
     <hr>
-    <p>
-        <h4><a class="link" href="https://farside.link">{{ translation['continue-search'] }}</a></h4>
-        <ul>
-            <li>
-                <a href="https://github.com/benbusby/whoogle-search">Whoogle</a>
-                <ul>
-                    <li>
-                        <a class="link-color" href="{{farside}}/whoogle/search?q={{query}}{{params}}">
-                            {{farside}}/whoogle/search?q={{query}}
-                        </a>
-                    </li>
-                </ul>
-            </li>
-            <li>
-                <a href="https://github.com/searxng/searxng">SearXNG</a>
-                <ul>
-                    <li>
-                        <a class="link-color" href="{{farside}}/searxng/search?q={{query}}">
-                            {{farside}}/searxng/search?q={{query}}
-                        </a>
-                    </li>
-                </ul>
-            </li>
-        </ul>
-        <hr>
-        <h4>Other options:</h4>
-        <ul>
-            <li>
-                <a href="https://kagi.com">Kagi</a>
-                <ul>
-                    <li>Recommended by Whoogle maintainer</li>
-                    <li>Requires account</li>
-                    <li>
-                        <a class="link-color" href="https://kagi.com/search?q={{query}}">
-                            kagi.com/search?q={{query}}
-                        </a>
-                    </li>
-                </ul>
-            </li>
-            <li>
-                <a href="https://duckduckgo.com">DuckDuckGo</a>
-                <ul>
-                    <li>
-                        <a class="link-color" href="https://duckduckgo.com/search?q={{query}}">
-                            duckduckgo.com/search?q={{query}}
-                        </a>
-                    </li>
-                </ul>
-            </li>
-            <li>
-                <a href="https://search.brave.com">Brave Search</a>
-                <ul>
-                    <li>
-                        <a class="link-color" href="https://search.brave.com/search?q={{query}}">
-                            search.brave.com/search?q={{query}}
-                        </a>
-                    </li>
-                </ul>
-            </li>
-            <li>
-                <a href="https://ecosia.com">Ecosia</a>
-                <ul>
-                    <li>
-                        <a class="link-color" href="https://ecosia.com/search?q={{query}}">
-                            ecosia.com/search?q={{query}}
-                        </a>
-                    </li>
-                </ul>
-            </li>
-            <li>
-                <a href="https://google.com">Google</a>
-                <ul>
-                    <li>
-                        <a class="link-color" href="https://google.com/search?q={{query}}">
-                            google.com/search?q={{query}}
-                        </a>
-                    </li>
-                </ul>
-            </li>
-        </ul>
-        <hr>
-    </p>
+    {% if query and translation %}
+        <p>
+            <h4><a class="link" href="https://farside.link">{{ translation['continue-search'] }}</a></h4>
+            <ul>
+                <li>
+                    <a href="https://github.com/benbusby/whoogle-search">Whoogle</a>
+                    <ul>
+                        <li>
+                            <a class="link-color" href="{{farside}}/whoogle/search?q={{query}}{{params}}">
+                                {{farside}}/whoogle/search?q={{query}}
+                            </a>
+                        </li>
+                    </ul>
+                </li>
+                <li>
+                    <a href="https://github.com/searxng/searxng">SearXNG</a>
+                    <ul>
+                        <li>
+                            <a class="link-color" href="{{farside}}/searxng/search?q={{query}}">
+                                {{farside}}/searxng/search?q={{query}}
+                            </a>
+                        </li>
+                    </ul>
+                </li>
+            </ul>
+            <hr>
+            <h4>Other options:</h4>
+            <ul>
+                <li>
+                    <a href="https://kagi.com">Kagi</a>
+                    <ul>
+                        <li>Requires account</li>
+                        <li>
+                            <a class="link-color" href="https://kagi.com/search?q={{query}}">
+                                kagi.com/search?q={{query}}
+                            </a>
+                        </li>
+                    </ul>
+                </li>
+                <li>
+                    <a href="https://duckduckgo.com">DuckDuckGo</a>
+                    <ul>
+                        <li>
+                            <a class="link-color" href="https://duckduckgo.com/search?q={{query}}">
+                                duckduckgo.com/search?q={{query}}
+                            </a>
+                        </li>
+                    </ul>
+                </li>
+                <li>
+                    <a href="https://search.brave.com">Brave Search</a>
+                    <ul>
+                        <li>
+                            <a class="link-color" href="https://search.brave.com/search?q={{query}}">
+                                search.brave.com/search?q={{query}}
+                            </a>
+                        </li>
+                    </ul>
+                </li>
+                <li>
+                    <a href="https://ecosia.com">Ecosia</a>
+                    <ul>
+                        <li>
+                            <a class="link-color" href="https://ecosia.com/search?q={{query}}">
+                                ecosia.com/search?q={{query}}
+                            </a>
+                        </li>
+                    </ul>
+                </li>
+                <li>
+                    <a href="https://google.com">Google</a>
+                    <ul>
+                        <li>
+                            <a class="link-color" href="https://google.com/search?q={{query}}">
+                                google.com/search?q={{query}}
+                            </a>
+                        </li>
+                    </ul>
+                </li>
+            </ul>
+            <hr>
+        </p>
+    {% endif %}
     <a class="link" href="home">Return Home</a>
 </div>