[gimp-web/testing] Fix search bar to use duckduckgo if no js



commit 3e43676736d76b9733089423802ab6f8e57ce14e
Author: Pat David <pat patdavid net>
Date:   Sun May 29 23:58:19 2016 -0500

    Fix search bar to use duckduckgo if no js
    
    JS is a requirement for the tipue static search on the site
    to work.  IF the use has disabled JS, default to sending
    them to searching the site using duckduckgo.
    
    There's an intermediate problem becaues the non-js version
    of duckduckgo doesn't accept a site= parameter in it's
    query string :\.  They expect you to munge the site= param
    with the query itself.  Which we can't do without resorting
    to JS, which we wouldn't have to do IF JS was enabled in
    the first place (and so on and so forth...).
    
    So, if no JS - duckduckgo will be used.  The user wil be
    sent to ddg, which will then send them to the non-js version
    of _their_ site.  At least this way to site= param stays
    intact.

 themes/newgimp/templates/base.html   |   26 ++++++++++++++++++++++++--
 themes/newgimp/templates/search.html |   26 ++++++++++++++++++++++++--
 2 files changed, 48 insertions(+), 4 deletions(-)
---
diff --git a/themes/newgimp/templates/base.html b/themes/newgimp/templates/base.html
index 20e0832..1479624 100644
--- a/themes/newgimp/templates/base.html
+++ b/themes/newgimp/templates/base.html
@@ -233,8 +233,19 @@
 
                 <div class='row clearfix'>
                     <div class='column full'>
-                        <form action='/search.html'>
-                            <input type='text' name='q' id='tipue_search_input' autocomplete='off' required>
+                        <form action='https://duckduckgo.com/' id='search-form'> 
+                        {# <form action='/search.html' id='search-form'> #}
+                            {# <input type='text' name='q' id='tipue_search_input' autocomplete='off' 
required> #}
+                            <input type='text' name='q' id='tipue_search_input' autocomplete='off' required 
placeholder='Search with DuckDuckGo'>
+                            <input type='hidden' name='sites' value='www.gimp.org'>
+                            {#
+                            # These only work for js-enabled browsers...
+                            <input type='hidden' name='ia' value='web'>
+                            <input type='hidden' name='kj' value='%230e2426'>
+                            <input type='hidden' name='kx' value='%230e2426'>
+                            <input type='hidden' name='km' value='m'>
+                            <input type='hidden' name='k9' value='%23497bad'>
+                            #}
                         </form>
                     </div>
                 </div>
@@ -247,5 +258,16 @@
     {# We use this for the sliding menu on small responsive screen (phone/tablet) #}
     <script async src="/js/push-menu.js"></script>
 
+    <script>
+        var searchForm = document.getElementById('search-form');
+        var tipue_input = document.getElementById('tipue_search_input');
+        while( searchForm.firstChild ){
+            searchForm.removeChild( searchForm.firstChild );
+        }
+        tipue_input.placeholder = "Search GIMP.org";
+        searchForm.appendChild( tipue_input );
+        searchForm.action = "/search.html";
+    </script>
+
 </body>
 </html>
diff --git a/themes/newgimp/templates/search.html b/themes/newgimp/templates/search.html
index dee7ec5..ca6104a 100644
--- a/themes/newgimp/templates/search.html
+++ b/themes/newgimp/templates/search.html
@@ -60,8 +60,20 @@
         <div class='container'>
             <div class='row clearfix'>
                 <div class='column full'>
-                    <form action="search.html">
-                        <input type="text" name="q" id="tipue_search_input" autocomplete="off" required 
style='width:100%;'>
+
+                    <form action='https://duckduckgo.com/' id='search-form'> 
+                    {# <form action='/search.html' id='search-form'> #}
+                        {# <input type='text' name='q' id='tipue_search_input' autocomplete='off' required> 
#}
+                        <input type='text' name='q' id='tipue_search_input' autocomplete='off' required 
placeholder='Search with DuckDuckGo' style='width:100%;'>
+                        <input type='hidden' name='sites' value='www.gimp.org'>
+                        {#
+                        # These only work for js-enabled browsers...
+                        <input type='hidden' name='ia' value='web'>
+                        <input type='hidden' name='kj' value='%230e2426'>
+                        <input type='hidden' name='kx' value='%230e2426'>
+                        <input type='hidden' name='km' value='m'>
+                        <input type='hidden' name='k9' value='%23497bad'>
+                        #}
                     </form>
                     <div id="tipue_search_content">
                     </div>
@@ -120,5 +132,15 @@
                 });
     });
     </script>
+    <script>
+        var searchForm = document.getElementById('search-form');
+        var tipue_input = document.getElementById('tipue_search_input');
+        while( searchForm.firstChild ){
+            searchForm.removeChild( searchForm.firstChild );
+        }
+        tipue_input.placeholder = "Search GIMP.org";
+        searchForm.appendChild( tipue_input );
+        searchForm.action = "/search.html";
+    </script>
 
 {% endblock %}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]