.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.favicons.proxy.FaviconProxyConfig Class Reference
+ Inheritance diagram for searx.favicons.proxy.FaviconProxyConfig:
+ Collaboration diagram for searx.favicons.proxy.FaviconProxyConfig:

Public Member Functions

Callable|None get_resolver (self, str name)
 
 favicon (self, **replacements)
 
 favicon_data_url (self, **replacements)
 

Static Public Attributes

int max_age = 60 * 60 * 24 * 7
 
str secret_key = get_setting("server.secret_key")
 
int resolver_timeout = get_setting("outgoing.request_timeout")
 
dict resolver_map = msgspec.field(default_factory=_initial_resolver_map)
 
str favicon_path = get_setting("ui.static_path") + "/themes/{theme}/img/empty_favicon.svg"
 
str favicon_mime_type = "image/svg+xml"
 

Detailed Description

Configuration of the favicon proxy.

Definition at line 44 of file proxy.py.

Member Function Documentation

◆ favicon()

searx.favicons.proxy.FaviconProxyConfig.favicon ( self,
** replacements )
Returns pathname and mimetype of the default favicon.

Definition at line 86 of file proxy.py.

86 def favicon(self, **replacements):
87 """Returns pathname and mimetype of the default favicon."""
88 return (
89 pathlib.Path(self.favicon_path.format(**replacements)),
90 self.favicon_mime_type,
91 )
92

References searx.favicons.proxy.FaviconProxyConfig.favicon_mime_type, searx.favicons.proxy.FaviconProxyConfig.favicon_path, and searx.format.

◆ favicon_data_url()

searx.favicons.proxy.FaviconProxyConfig.favicon_data_url ( self,
** replacements )
Returns data image URL of the default favicon.

Definition at line 93 of file proxy.py.

93 def favicon_data_url(self, **replacements):
94 """Returns data image URL of the default favicon."""
95
96 cache_key = ", ".join(f"{x}:{replacements[x]}" for x in sorted(list(replacements.keys()), key=str))
97 data_url = DEFAULT_FAVICON_URL.get(cache_key)
98 if data_url is not None:
99 return data_url
100
101 fav, mimetype = CFG.favicon(**replacements)
102 # hint: encoding utf-8 limits favicons to be a SVG image
103 with fav.open("r", encoding="utf-8") as f:
104 data_url = f.read()
105
106 data_url = urllib.parse.quote(data_url)
107 data_url = f"data:{mimetype};utf8,{data_url}"
108 DEFAULT_FAVICON_URL[cache_key] = data_url
109 return data_url
110
111

◆ get_resolver()

Callable | None searx.favicons.proxy.FaviconProxyConfig.get_resolver ( self,
str name )
Returns the callable object (function) of the resolver with the
``name``.  If no resolver is registered for the ``name``, ``None`` is
returned.

Definition at line 68 of file proxy.py.

68 def get_resolver(self, name: str) -> Callable | None:
69 """Returns the callable object (function) of the resolver with the
70 ``name``. If no resolver is registered for the ``name``, ``None`` is
71 returned.
72 """
73 fqn = self.resolver_map.get(name)
74 if fqn is None:
75 return None
76 mod_name, _, func_name = fqn.rpartition('.')
77 mod = importlib.import_module(mod_name)
78 func = getattr(mod, func_name)
79 if func is None:
80 raise ValueError(f"resolver {fqn} is not implemented")
81 return func
82

References searx.favicons.proxy.FaviconProxyConfig.resolver_map.

Member Data Documentation

◆ favicon_mime_type

searx.favicons.proxy.FaviconProxyConfig.favicon_mime_type = "image/svg+xml"
static

Definition at line 84 of file proxy.py.

Referenced by searx.favicons.proxy.FaviconProxyConfig.favicon().

◆ favicon_path

str searx.favicons.proxy.FaviconProxyConfig.favicon_path = get_setting("ui.static_path") + "/themes/{theme}/img/empty_favicon.svg"
static

Definition at line 83 of file proxy.py.

Referenced by searx.favicons.proxy.FaviconProxyConfig.favicon().

◆ max_age

int searx.favicons.proxy.FaviconProxyConfig.max_age = 60 * 60 * 24 * 7
static

Definition at line 47 of file proxy.py.

◆ resolver_map

dict searx.favicons.proxy.FaviconProxyConfig.resolver_map = msgspec.field(default_factory=_initial_resolver_map)
static

Definition at line 62 of file proxy.py.

Referenced by searx.favicons.proxy.FaviconProxyConfig.get_resolver().

◆ resolver_timeout

int searx.favicons.proxy.FaviconProxyConfig.resolver_timeout = get_setting("outgoing.request_timeout")
static

Definition at line 57 of file proxy.py.

◆ secret_key

str searx.favicons.proxy.FaviconProxyConfig.secret_key = get_setting("server.secret_key")
static

Definition at line 53 of file proxy.py.


The documentation for this class was generated from the following file: