Fix category and tags for search
This commit is contained in:
parent
df45d91a9c
commit
669b9c43fa
@ -65,6 +65,9 @@ if (isset($_GET['q']) && !empty($_GET['q'])) {
|
|||||||
$score = 0;
|
$score = 0;
|
||||||
$page['description'] = htmlentities($page['description']);
|
$page['description'] = htmlentities($page['description']);
|
||||||
|
|
||||||
|
// convert keyworks_tags to strings
|
||||||
|
$tags = implode(", ", $page['keywords']);
|
||||||
|
|
||||||
foreach ($keywords as $word) {
|
foreach ($keywords as $word) {
|
||||||
if (preg_match("/$word/i", $page['url'])) {
|
if (preg_match("/$word/i", $page['url'])) {
|
||||||
$score += 35;
|
$score += 35;
|
||||||
@ -72,7 +75,10 @@ if (isset($_GET['q']) && !empty($_GET['q'])) {
|
|||||||
if (preg_match("/$word/i", $page['title'])) {
|
if (preg_match("/$word/i", $page['title'])) {
|
||||||
$score += 35;
|
$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;
|
$score += 30;
|
||||||
}
|
}
|
||||||
// It replaces uppercase matches with lowercase matches, but it's fine for now.
|
// It replaces uppercase matches with lowercase matches, but it's fine for now.
|
||||||
|
@ -109,9 +109,14 @@ class Tipue_Search_JSON_Generator(object):
|
|||||||
video_src = article.og_video if getattr(
|
video_src = article.og_video if getattr(
|
||||||
article, 'og_video', 'None') != 'None' else ''
|
article, 'og_video', 'None') != 'None' else ''
|
||||||
|
|
||||||
|
# category
|
||||||
video_category = article.category.name if getattr(
|
video_category = article.category.name if getattr(
|
||||||
article, 'category', 'None') != 'None' else ''
|
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,
|
node = {'title': video_title,
|
||||||
'description': video_text,
|
'description': video_text,
|
||||||
'videoThumbnail': url_image,
|
'videoThumbnail': url_image,
|
||||||
@ -123,7 +128,8 @@ class Tipue_Search_JSON_Generator(object):
|
|||||||
'published': video_publish,
|
'published': video_publish,
|
||||||
'publishedText': video_publish_text,
|
'publishedText': video_publish_text,
|
||||||
'time': video_time,
|
'time': video_time,
|
||||||
'tags': video_category,
|
'category': video_category,
|
||||||
|
'keywords': video_tags,
|
||||||
'url': video_url}
|
'url': video_url}
|
||||||
|
|
||||||
self.json_nodes.append(node)
|
self.json_nodes.append(node)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user