pub / serci

Search the web with !keywords
git clone https://https://src.jayvii.de/pub/serci.git
Home | Log | Files | Exports | Refs | README | RSS

commit 8cdc4bd08f59f236e99ebb19d614fc965e4473f7
parent da3324fa1d0800399cbd55fc65c2055443557e61
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date:   Tue,  9 Jul 2024 21:44:44 +0200

feat: search engine categories

Diffstat:
Mconfig/config.php | 107++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
Mindex.php | 157++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------
2 files changed, 211 insertions(+), 53 deletions(-)

diff --git a/config/config.php b/config/config.php @@ -6,135 +6,146 @@ */ $searches = array( - /* MetaGer */ "metager_web" => array( "name" => "MetaGer Web", "website" => "https://metager.de/?focus=web", "query" => "https://metager.de/meta/meta.ger3?focus=web&eingabe=%s", + "categories" => array("web", "meta"), "keywords" => array("metager_web", "metager", "meta", "mg", "metaweb") ), "metager_map" => array( "name" => "MetaGer Maps", "website" => "https://metager.de/?fokus=maps", "query" => "https://maps.metager.de/en/%s/guess", + "categories" => array("map"), "keywords" => array( "metager_map", "metager_maps", "mgmap", "metamap", "map", "maps" ) ), - /* Qwant */ "qwant_web" => array( "name" => "Qwant Web", "website" => "https://qwant.com/?t=web", "query" => "https://www.qwant.com/?t=web&q=%s", + "categories" => array("web"), "keywords" => array("qwant_web", "qwant", "qw") ), "qwant_img" => array( "name" => "Qwant Images", "website" => "https://qwant.com/?t=images", "query" => "https://www.qwant.com/?t=images&q=%s", + "categories" => array("img"), "keywords" => array("qwant_img", "qwimg", "images", "image", "img") ), "qwant_video" => array( "name" => "Qwant Videos", "website" => "https://qwant.com/?t=videos", "query" => "https://www.qwant.com/?t=videos&q=%s", + "categories" => array("vid"), "keywords" => array("qwant_video", "qwvid") ), - /* Mojeek */ "mojeek_web" => array( "name" => "Mojeek Web", "website" => "https://mojeek.com", "query" => "https://www.mojeek.com/search?q=%s", + "categories" => array("web"), "keywords" => array("mojeek_web", "mojeek", "mj") ), - /* Translations and Languages */ "dictcc" => array( "name" => "dict.cc", "website" => "https://dict.cc", "query" => "https://m.dict.cc/?s=%s", + "categories" => array("lang"), "keywords" => array("dictcc", "dict", "translate", "tl") ), "leo" => array( "name" => "LEO (en-de)", "website" => "https://leo.org", "query" => "https://dict.leo.org/englisch-deutsch/%s", + "categories" => array("lang"), "keywords" => array("leo") ), "deepl" => array( "name" => "DeepL (en-de)", "website" => "https://deepl.com", "query" => "https://www.deepl.com/translator#de/en/%s", + "categories" => array("lang"), "keywords" => array("deepl") ), "duden" => array( "name" => "Duden", "website" => "https://www.duden.de", "query" => "https://www.duden.de/suchen/dudenonline/%s", + "categories" => array("lang"), "keywords" => array("duden", "ger", "de") ), - /* Videos */ "sepiasearch" => array( "name" => "Sepia Search", "website" => "https://sepiasearch.org", "query" => "https://sepiasearch.org/search?search=%s", + "categories" => array("vid", "fedi"), "keywords" => array("sepiasearch", "sepia", "peertube", "pt", "video", "videos") ), "youtube" => array( "name" => "YouTube", "website" => "https://www.youtube.com", "query" => "https://www.youtube.com/results?search_query=%s", + "categories" => array("vid"), "keywords" => array("youtube", "yt") ), - /* Maps */ "openstreetmap" => array( "name" => "OpenStreetMap", "website" => "https://www.openstreetmap.org", "query" => "https://www.openstreetmap.org/search?query=%s", + "categories" => array("map"), "keywords" => array("openstreetmap", "osm") ), - /* Science */ "base" => array( "name" => "BASE", "website" => "https://www.base-search.net", "query" => "https://www.base-search.net/Search/Results?lookfor=%s", + "categories" => array("sci"), "keywords" => array("base", "basesearch", "science") ), "semanticscholar" => array( "name" => "Semantic Scholar", "website" => "https://semanticscholar.org", "query" => "https://semanticscholar.org/search?q=%s", + "categories" => array("sci"), "keywords" => array("semanticscholar", "scholar", "literature") ), "google_scholar" => array( "name" => "Google Scholar", "website" => "https://scholar.google.com", "query" => "https://scholar.google.com/scholar?q=%s", + "categories" => array("sci"), "keywords" => array("google_scholar", "gscholar") ), - /* Wikis */ "wikipedia" => array( "name" => "Wikipedia", "website" => "https://wikipedia.org", "query" => "https://wikipedia.org/wiki/%s", + "categories" => array("wiki"), "keywords" => array("wikipedia", "wiki", "wp", "wk") ), "archwiki" => array( "name" => "Arch Wiki", "website" => "https://wiki.archlinux.org", "query" => "https://wiki.archlinux.org/index.php?search=%s", + "categories" => array("wiki", "linux"), "keywords" => array("archwiki", "arch", "aw") ), "debianwiki" => array( "name" => "Debian Wiki", "website" => "https://wiki.debian.org", "query" => "https://wiki.debian.org/?action=fullsearch&value=%s", + "categories" => array("wiki", "linux"), "keywords" => array("debianwiki", "debian", "deb", "dw") ), - /* Coding */ "stackoverflow" => array( "name" => "Stackoverflow", "website" => "https://stackoverflow.com", "query" => "https://stackoverflow.com/search?q=%s", + "categories" => array("code", "forum"), "keywords" => array("stackoverflow", "so", "code") ), // "w3schools" => array( @@ -147,91 +158,163 @@ $searches = array( "name" => "W3schools (via Mojeek)", /* Workaround to avoid Google */ "website" => "https://www.w3schools.com", "query" => "https://www.mojeek.com/search?q=site:www.w3schools.com+%s", + "categories" => array("code", "learn"), "keywords" => array("w3schools", "w3school", "www", "w3", "webdev") ), - /* Code Repositories */ "github" => array( "name" => "GitHub", "website" => "https://github.com", "query" => "https://github.com/search?q=%s", + "categories" => array("code", "git"), "keywords" => array("github", "gh") ), "codeberg" => array( "name" => "Codeberg", "website" => "https://codeberg.org", "query" => "https://codeberg.org/explore/repos?only_show_relevant=true&q=%s", + "categories" => array("code", "git"), "keywords" => array("codeberg", "cb") ), "sourcehut" => array( "name" => "Sourcehut", "website" => "https://sr.ht", "query" => "https://sr.ht/projects?search=%s", + "categories" => array("code", "git"), "keywords" => array("sourcehut", "srht", "sir") ), - /* Software Repositories */ "dockerhub" => array( "name" => "dockerhub", "website" => "https://hub.docker.com", "query" => "https://hub.docker.com/search?q=%s", + "categories" => array("software", "linux"), "keywords" => array("dockerhub", "docker", "dh") ), "flathub" => array( "name" => "Flathub", "website" => "https://flathub.org", "query" => "https://flathub.org/apps/search?q=%s", + "categories" => array("software", "linux"), "keywords" => array("flathub", "flatpak", "fh", "fp") ), "fdroid" => array( "name" => "F-Droid", "website" => "https://f-droid.org", "query" => "https://search.f-droid.org/?q=%s", + "categories" => array("software", "android"), "keywords" => array("fdroid", "f-droid", "fd", "android") ), "cran" => array( "name" => "CRAN", "website" => "https://cran.r-project.org", "query" => "https://search.r-project.org/?P=%s", + "categories" => array("code", "docu"), "keywords" => array("cran", "rcran", "r-cran", "r") ), "pypi" => array( "name" => "PyPI", "website" => "https://pypi.org", "query" => "https://pypi.org/search/?q=%s", + "categories" => array("code"), "keywords" => array("pypi", "python", "py") ), "npm" => array( "name" => "NPM", "website" => "https://www.npmjs.com", "query" => "https://www.npmjs.com/search?q=%s", + "categories" => array("code"), "keywords" => array("npm", "npmjs", "node", "js") ), "php" => array( "name" => "PHP Manual", "website" => "https://www.php.net", "query" => "https://www.php.net/manual-lookup.php?pattern=%s", + "categories" => array("docu"), "keywords" => array("php", "phpdoc", "phpdocs", "phpman", "phpmans") ), - /* Misc */ "symbl" => array( "name" => "SYMBL", "website" => "https://symbl.cc", "query" => "https://symbl.cc/search/?q=%s", + "categories" => array("misc"), "keywords" => array("symbl", "symbol", "unicode") ), "waybackmachine" => array( "name" => "Wayback Machine", "website" => "https://web.archive.org", "query" => "https://web.archive.org/web/99999999000000*/%s", + "categories" => array("archive"), "keywords" => array("waybackmachine", "webarchive", "wbm", "wb") ), "internetarchive" => array( "name" => "Internet Archive", "website" => "https://archive.org", "query" => "https://archive.org/search?query=%s", + "categories" => array("archive"), "keywords" => array("internetarchive", "archive", "ia") ), ); +/* Categories */ +$categories = array( + "meta" => array( + "name" => "Meta search engines", + ), + "web" => array( + "name" => "General web search", + ), + "img" => array( + "name" => "Images" + ), + "vid" => array( + "name" => "Videos" + ), + "map" => array( + "name" => "Mapping and navigation" + ), + "lang" => array( + "name" => "Languages and translation" + ), + "fedi" => array( + "name" => "Fediverse" + ), + "sci" => array( + "name" => "Science" + ), + "wiki" => array( + "name" => "Wikis and encyclopedias" + ), + "linux" => array( + "name" => "GNU+Linux" + ), + "android" => array( + "name" => "Android" + ), + "code" => array( + "name" => "Coding platforms" + ), + "git" => array( + "name" => "GIT forges and repositories" + ), + "software" => array( + "name" => "Software repositories" + ), + "forum" => array( + "name" => "Forums and message boards" + ), + "learn" => array( + "name" => "Learning" + ), + "docu" => array( + "name" => "Documentation and manuals" + ), + "misc" => array( + "name" => "Miscellaneous searches" + ), + "archive" => array( + "name" => "Archives" + ) +); + /* Default Search Engine * Search Engine to use when no (known) keyword is given */ diff --git a/index.php b/index.php @@ -127,9 +127,9 @@ </li> </ul> - <!-- Search Engine Table --> + <!-- Search Engine Lists --> <h3>Search Engines</h3> - <span> + <p> Default Search: <a href="<?php echo $searches[$default_search]["website"]; ?>" target="_blank"> @@ -137,47 +137,122 @@ echo $searches[$default_search]["name"]; ?> </a> - </span> - <table> - <tr> - <th>Engine</th> - <th>keywords</th> - <tr> - - <?php - /* Print one table row for each configured search engine */ - foreach (array_keys($searches) as $key) { - ?> - - <tr> - <td> - <a href="<?php echo $searches[$key]["website"]; ?>" - target="_blank"> - <?php - echo $searches[$key]["name"]; - ?> - </a> - </td> - <td> - <code> - <?php - echo "!" . - implode( - "</code>, <code>!", - $searches[$key]["keywords"] - ); - ?> - </code> - </td> - </tr> - - <?php - /* End for-loop across search engines */ - } - ?> + </p> + + <!-- Toggle-Button --> + <button onclick="toggle_details();"> + Toggle Categories + </button> + + <!-- List all Search engines in full table --> + <details open> + <summary>All Search Engines</summary> + <table> + <tr> + <th>Engine</th> + <th>keywords</th> + <tr> + + <?php + /* Print table row for each configured search engine */ + foreach (array_keys($searches) as $key) { + ?> + + <tr> + <td> + <a href="<?php echo $searches[$key]["website"]; ?>" + target="_blank"> + <?php + echo $searches[$key]["name"]; + ?> + </a> + </td> + <td> + <code> + <?php + echo "!" . + implode( + "</code>, <code>!", + $searches[$key]["keywords"] + ); + ?> + </code> + </td> + </tr> + + <?php + /* End for-loop across search engines */ + } + ?> + </table> + </details> + + <!-- Search Engine Categorical Lists --> + <?php + foreach (array_keys($categories) as $cat) { + ?> + + <details> + <summary><?php echo $categories[$cat]["name"]; ?></summary> + <table> + <tr> + <th>Engine</th> + <th>keywords</th> + <tr> + <?php + /* Print one table row for each search engine in category */ + foreach (array_keys($searches) as $key) { + /* Skrip, if search engine is not in current category */ + if ( + array_search($cat, $searches[$key]["categories"]) + === false + ) { + continue; + } + ?> + <tr> + <td> + <a href="<?php echo $searches[$key]["website"]; ?>" + target="_blank"> + <?php + echo $searches[$key]["name"]; + ?> + </a> + </td> + <td> + <code> + <?php + echo "!" . + implode( + "</code>, <code>!", + $searches[$key]["keywords"] + ); + ?> + </code> + </td> + </tr> + <?php + } + ?> + </table> + </details> + <?php + } + ?> - </table> </body> + <!-- Script for toggling Search Engine tables --> + <script> + toggle_details = function() { + var setas = (1 - document.querySelector('details').open); + document.querySelectorAll('details').forEach( + function(d) { + d.open = setas; + } + ); + } + </script> + </html>