tipuesearch_content.json: update filter only articles and improved JSON API
This commit is contained in:
@@ -62,9 +62,9 @@ if (isset($_GET['q'])) {
|
||||
$keywords = explode(' ', $keywords);
|
||||
$found_results = [];
|
||||
|
||||
foreach ($web_content["pages"] as $page) {
|
||||
foreach ($web_content["videos"] as $page) {
|
||||
$score = 0;
|
||||
$page['text'] = htmlentities($page['text']);
|
||||
$page['description'] = htmlentities($page['description']);
|
||||
|
||||
foreach ($keywords as $word) {
|
||||
if (preg_match("/$word/i", $page['url'])) {
|
||||
@@ -78,16 +78,16 @@ if (isset($_GET['q'])) {
|
||||
}
|
||||
// It replaces uppercase matches with lowercase matches, but it's fine for now.
|
||||
if ($stop_words_ignored == 1) {
|
||||
$page['text'] = preg_replace("/$word/i", $word, $page['text'], -1, $match_count);
|
||||
$page['description'] = preg_replace("/$word/i", $word, $page['description'], -1, $match_count);
|
||||
} else {
|
||||
$page['text'] = preg_replace("/$word/i", '<span class="tipue_search_content_bold highlighted">' . $word . '</span>', $page['text'], -1, $match_count);
|
||||
$page['description'] = preg_replace("/$word/i", '<span class="tipue_search_content_bold highlighted">' . $word . '</span>', $page['description'], -1, $match_count);
|
||||
}
|
||||
if ($match_count > 0) {
|
||||
$score += 10 * $match_count;
|
||||
}
|
||||
}
|
||||
if ($score != 0) {
|
||||
$found_results[] = ['score' => $score, 'title' => $page['title'], 'url' => $page['url'], 'text' => $page['text']];
|
||||
$found_results[] = ['score' => $score, 'title' => $page['title'], 'url' => $page['url'], 'description' => $page['description']];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ if (isset($_GET['q'])) {
|
||||
printf('<div class="tipue_search_content_title"><a class="is-cyan" href="%s">%s</a></div>', $found_result['url'], $found_result['title']);
|
||||
printf('<div class="tipue_search_content_url"><a href="%s">%s</a></div>', $found_result['url'], $found_result['url']);
|
||||
|
||||
$description_words = explode(' ', $found_result['text']);
|
||||
$description_words = explode(' ', $found_result['description']);
|
||||
$description_words_count = count($description_words);
|
||||
$first_match = false;
|
||||
for ($i = 0; $i < $description_words_count; $i++) {
|
||||
|
||||
Reference in New Issue
Block a user