From 669b9c43fa06434f25d82de8e70c4fcfd4bc7805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Sat, 13 Jun 2020 19:43:09 -0500 Subject: [PATCH] Fix category and tags for search --- content/pages/buscar.php.md | 8 +++++++- plugins/tipue-search/tipue_search.py | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/content/pages/buscar.php.md b/content/pages/buscar.php.md index 5443e89..e9de76a 100644 --- a/content/pages/buscar.php.md +++ b/content/pages/buscar.php.md @@ -65,6 +65,9 @@ if (isset($_GET['q']) && !empty($_GET['q'])) { $score = 0; $page['description'] = htmlentities($page['description']); + // convert keyworks_tags to strings + $tags = implode(", ", $page['keywords']); + foreach ($keywords as $word) { if (preg_match("/$word/i", $page['url'])) { $score += 35; @@ -72,7 +75,10 @@ if (isset($_GET['q']) && !empty($_GET['q'])) { if (preg_match("/$word/i", $page['title'])) { $score += 35; } - if (preg_match("/$word/i", $page['tags'])) { + if (preg_match("/$word/i", $tags)) { + $score += 35; + } + if (preg_match("/$word/i", $page['category'])) { $score += 30; } // It replaces uppercase matches with lowercase matches, but it's fine for now. diff --git a/plugins/tipue-search/tipue_search.py b/plugins/tipue-search/tipue_search.py index a55c91c..5928576 100644 --- a/plugins/tipue-search/tipue_search.py +++ b/plugins/tipue-search/tipue_search.py @@ -109,9 +109,14 @@ class Tipue_Search_JSON_Generator(object): video_src = article.og_video if getattr( article, 'og_video', 'None') != 'None' else '' + # category video_category = article.category.name if getattr( article, 'category', 'None') != 'None' else '' + # tags + data_tags = ['%s' % (tag) for tag in article.tags] + video_tags = dict((num, tag) for num, tag in enumerate(data_tags)) + node = {'title': video_title, 'description': video_text, 'videoThumbnail': url_image, @@ -123,7 +128,8 @@ class Tipue_Search_JSON_Generator(object): 'published': video_publish, 'publishedText': video_publish_text, 'time': video_time, - 'tags': video_category, + 'category': video_category, + 'keywords': video_tags, 'url': video_url} self.json_nodes.append(node)