From 1cc7c23718e46707d1a785170702ce2256d3d0ab Mon Sep 17 00:00:00 2001 From: davidovski Date: Sat, 11 Nov 2023 23:27:14 +0000 Subject: [PATCH 1/2] Add OSM search --- engines/maps/openstreetmap.php | 37 ++++++++++++++++++++++++++++++++++ locale/en.php | 1 + misc/search_engine.php | 4 ++++ search.php | 2 +- 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 engines/maps/openstreetmap.php diff --git a/engines/maps/openstreetmap.php b/engines/maps/openstreetmap.php new file mode 100644 index 00000000..63fd2188 --- /dev/null +++ b/engines/maps/openstreetmap.php @@ -0,0 +1,37 @@ +query)); + $results = array(); + + // TODO allow the nominatim instance to be customised + $url = "https://nominatim.openstreetmap.org/search?q=$query_encoded&format=json"; + + return $url; + } + + + public function parse_results($response) { + $json_response = json_decode($response, true); + if (!$json_response) + return array(); + + $results = array(); + foreach ($json_response as $item) { + array_push($results, array( + "title" => $item["name"], + "description" => $item["display_name"], + "url" => "https://www.openstreetmap.org/node/" . $item["osm_id"], + "base_url" => "www.openstreetmap.org" + )); + } + return $results; + } + + public static function print_results($results, $opts) { + TextSearch::print_results($results, $opts); + } + } +?> diff --git a/locale/en.php b/locale/en.php index 1cb4b86e..a123b2c4 100644 --- a/locale/en.php +++ b/locale/en.php @@ -18,6 +18,7 @@ "category_videos" => "Videos", "category_torrents" => "Torrents", "category_tor" => "Tor", + "category_maps" => "Maps", "feature_disabled" => "The host has disabled this feature :C", diff --git a/misc/search_engine.php b/misc/search_engine.php index a0326403..378cae88 100644 --- a/misc/search_engine.php +++ b/misc/search_engine.php @@ -135,6 +135,10 @@ function init_search($opts, $mh) { require "engines/ahmia/hidden_service.php"; return new TorSearch($opts, $mh); + case 5: + require "engines/maps/openstreetmap.php"; + return new OSMRequest($opts, $mh); + default: require "engines/text/text.php"; return new TextSearch($opts, $mh); diff --git a/search.php b/search.php index 0f710874..18a6e33d 100644 --- a/search.php +++ b/search.php @@ -53,7 +53,7 @@ function print_page_buttons($type, $query, $page) {
Date: Sat, 11 Nov 2023 23:43:27 +0000 Subject: [PATCH 2/2] add map icon --- static/images/maps_result.png | Bin 0 -> 1978 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 static/images/maps_result.png diff --git a/static/images/maps_result.png b/static/images/maps_result.png new file mode 100644 index 0000000000000000000000000000000000000000..d9fdf23f4ba4b2039d11fa28a44c579e06d60d6c GIT binary patch literal 1978 zcmV;r2SxaaP)EX>4Tx04R}tkv&MmKp2MKwn{}S4i*%3$k003MMWHI6^c+H)C#RSm|Xe?O&XFE z7e~Rh;NZ_<)xpJCR|i)?5c~mgb#YR3krKa43N2#110C4=2nH^EBa^-VH8n`nfjb4rri6e@tQNBOx zvch?bvs$UK);;+PLwRjwnd`L1ki;UEAVPqQ8p^1^LX38e6ccGWPk8u89KT2|nOtQs zax9<<6_Voz|AXJXH49UdZc-=#bidg4M-&L|0?oQ@e;?a+^8^Sy16NwxUu^)hpQP8@ zTI2{A*aj}H+nT%wTe57b!c7VDzv6000?uMObu0Z*6U5Zgc=ca%Ew3 zWn>_CX>@2HM@dakSAh-}000G%NklxNGibV?= zD-lIw>QN&i#)J?>jryQ3hU)_njV~H~Gtn44A;zeYL?J{?G_6>W94e%k23ivT@TZCt z75{+HO4_kKotcgg{cdtnJLAl4ZSR=w$jOAE~ zC9$KxH2#RaWw)3aNC0)!EWyRth}YmO4C5Re#2xwkx$G9x0|lV2nltc5d<-R4pc6Yr za@&*m0ltr2Ww)3b2mp1}jNnc99NwI@{}Hcuunc2Ksr~pNzJ@2tZgF_Fc}Gr=aRnx4 zTd1y@A)Jp71;iBY$355^FynX$HsH0mHqrQY?m6)hsH*CQ5Vh#RCMQTvb4S%|mmsyR2_z6qPq#ft;z>_p>}xCM27 zFTty0$RzHJK^@$H@8Fw>&Y5Mm*c&H28DLjndD3uU5eRFH#)BUS^{ox%6=-k(OEHu0 zBgy9mPvzPL;r-|FEBrGIv@!Dx;nH}12mXR*a7n24h4@?6m>+<;YBu5v3G*4@>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