asciimoo/searx — pull request #147 by Cqoicebordel (2014-12-12 18:29:45+00:00)
Title: Detect favicons

I finded the way engines icons were found a bit counter productive : if a theme creator wanted to add or remove an icon, he had to modify the python source, and it would apply to all themes.

With this pull request, the list of engines can be deleted (I didn't do it, I will explain later) : a new array is created containing all images names in the '{theme}/img' folder, and passed to the template to test if the favicon searched (in the format of the theme) is in the list.
I modified Oscar to represent that.

I left default and courgette as is because of two things : I have already a pull request on those, and didn't want to experience conflicts...
And two, because there is a possibility in those theme to do something like that and didn't know if it should be done :
if favicon in list:use favicon
else: use {result_host}/favicon.ico

I didn't delete the engine array to keep a backward compatibility with themes in the wild.
When we will be ready, we delete the array, and put 'result['favicon'] = engine' outside of the for and if and we will be good to go.

BTW, the path to icons is currently '{theme}/img' because themes don't use the same folder across the board. A bit of cleaning should be done to use '{theme}/img/icons'