feat: adding Maps tab (merge pull request #85 from davidovski/maps)

Add Map tab
This commit is contained in:
Ahwx
2023-11-12 22:17:32 +01:00
committed by GitHub
5 changed files with 43 additions and 1 deletions
+37
View File
@@ -0,0 +1,37 @@
<?php
require "engines/text/text.php";
class OSMRequest extends EngineRequest {
public function get_request_url() {
$query_encoded = str_replace("%22", "\"", urlencode($this->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);
}
}
?>
+1
View File
@@ -18,6 +18,7 @@ return array(
"category_videos" => "Videos",
"category_torrents" => "Torrents",
"category_tor" => "Tor",
"category_maps" => "Maps",
"feature_disabled" => "The host has disabled this feature :C",
+4
View File
@@ -135,6 +135,10 @@
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);
+1 -1
View File
@@ -53,7 +53,7 @@
<input type="hidden" name="p" value="0">
<div class="sub-search-button-wrapper">
<?php
$categories = array("general", "images", "videos", "torrents", "tor");
$categories = array("general", "images", "videos", "torrents", "tor", "maps");
foreach ($categories as $category)
{
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB