introduce search interface
This commit is contained in:
@@ -2,7 +2,7 @@ from lxml.html.clean import clean_html, Cleaner
|
||||
import environ
|
||||
import pysolr
|
||||
from .convert import post_to_solr
|
||||
from urllib.parse import urljoin
|
||||
from urllib.parse import urljoin,urlparse
|
||||
from fet2020api import fet2020postapi
|
||||
import yaml
|
||||
env=environ.Env(
|
||||
@@ -43,9 +43,17 @@ def result_to_posts(result):
|
||||
urljoin(env('TARGET'),
|
||||
p["url"]).rstrip("/")+" "+\
|
||||
str(strip_html(highlights[p["slug"]]["text_txt"]))
|
||||
def create_highlights(p):
|
||||
return str(strip_html(highlights[p["slug"]]["text_txt"]))
|
||||
|
||||
for post in posts:
|
||||
post["text"] = create_text(post)
|
||||
if post:
|
||||
post["text"] = create_text(post)
|
||||
post["highlights"]=create_highlights(post)
|
||||
if post["url"]: post["url"]= urljoin(env('TARGET'),post["url"]).rstrip("/")
|
||||
if post["image"]:post["image"]=urljoin(env('TARGET'),urlparse(post["image"]).path)
|
||||
return posts
|
||||
|
||||
class SolrFet2020():
|
||||
def __init__(self):
|
||||
self.solr=pysolr.Solr(
|
||||
|
||||
Reference in New Issue
Block a user