add api option to search.php
@@ -1,4 +1,7 @@
1
1
<?php
2
3
$api = isset($_GET['api']);
4
2
5
function flattenValues(mixed $value, string $prefix = ''): array
3
6
{
4
7
$out = [];
@@ -128,3 +131,8 @@ function makeSnippet(string $text, string $query, int $maxLen = 120): string
128
131
return $snippet;
129
132
}
130
133
134
if ($api) {
135
$query = $_GET['query'];
136
$results = searchAllJson(__DIR__ . DIRECTORY_SEPARATOR . 'data', $query);
137
echo json_encode($results);
138
}
@@ -1,4 +1,7 @@1
<?php1
<?php2
3
$api = isset($_GET['api']);4
2
function flattenValues(mixed $value, string $prefix = ''): array5
function flattenValues(mixed $value, string $prefix = ''): array3
{6
{4
$out = [];7
$out = [];@@ -128,3 +131,8 @@ function makeSnippet(string $text, string $query, int $maxLen = 120): string128
return $snippet;131
return $snippet;129
}132
}130
133
134
if ($api) {135
$query = $_GET['query'];136
$results = searchAllJson(__DIR__ . DIRECTORY_SEPARATOR . 'data', $query);137
echo json_encode($results);138
}