27def response(resp):
28 results = []
29
30 query_parts = resp.search_params['query'].lower().split(' ')
31 for item in resp.json():
32 keyword = item['Reference'].lower()
33 if not any(query_part in keyword for query_part in query_parts):
34 continue
35
36 img_format = None
37 for format_name in ('SVG', 'PNG', 'WebP'):
38 if item[format_name] == 'Yes':
39 img_format = format_name.lower()
40 break
41
42 img_src = f'{icons_cdn_base_url}/gh/selfhst/icons/{img_format}/{item["Reference"]}.{img_format}'
43 result = {
44 'template': 'images.html',
45 'url': img_src,
46 'title': item['Name'],
47 'content': '',
48 'img_src': img_src,
49 'img_format': img_format,
50 'publishedDate': parser.parse(item['CreatedAt']),
51 }
52 results.append(result)
53
54 return results