mirror of
https://github.com/Ahwxorg/librey/
synced 2024-12-06 19:16:48 +01:00
feat: adding Maps tab (merge pull request #85 from davidovski/maps)
Add Map tab
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -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",
|
||||
|
||||
|
||||
@@ -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
@@ -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 |
Reference in New Issue
Block a user