29def response(resp):
30 results = []
31
32 query = resp.search_params["query"].lower()
33 json_results = loads(resp.text[5:])
34
35 outlined = not re.findall(filled_regex, query)
36 query = re.sub(filled_regex, "", query).strip()
37 svg_type = "fill1" if not outlined else "default"
38
39 query_parts = query.split(" ")
40
41 for result in json_results["icons"]:
42 for part in query_parts:
43 if part in result["name"] or part in result["tags"] or part in result["categories"]:
44 break
45 else:
46 continue
47
48 tags = [tag.title() for tag in result["tags"]]
49 categories = [category.title() for category in result["categories"]]
50
51 results.append(
52 {
53 'template': 'images.html',
54 'url': result_url.format(icon_name=result["name"], query=result["name"], fill=0 if outlined else 1),
55 'img_src': img_src_url.format(icon_name=result["name"], svg_type=svg_type),
56 'title': result["name"].replace("_", "").title(),
57 'content': ", ".join(tags) + " / " + ", ".join(categories),
58 }
59 )
60
61 return results