add icon_provider setting
This commit is contained in:
@@ -26,6 +26,7 @@ You can customize the list and order of websites in settings.
|
|||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| `links` | `string_list` | `see below` | Websites list and order. |
|
| `links` | `string_list` | `see below` | Websites list and order. |
|
||||||
| `notify` | `bool` | `false` | Toggle notification when launching website. |
|
| `notify` | `bool` | `false` | Toggle notification when launching website. |
|
||||||
|
| `icon_provider` | `select` | `google` | Icon download source. |
|
||||||
|
|
||||||
Default links:
|
Default links:
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -29,13 +29,25 @@ local function extractDomain(url)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function faviconUrl(domain)
|
local function faviconUrl(domain)
|
||||||
return "https://www.google.com/s2/favicons?sz=64&domain=" .. noctalia.string.urlEncode(domain)
|
local provider = noctalia.getConfig("icon_provider")
|
||||||
|
local encoded = noctalia.string.urlEncode(domain)
|
||||||
|
|
||||||
|
if provider == "duckduckgo" then
|
||||||
|
return "https://icons.duckduckgo.com/ip3/" .. encoded .. ".ico"
|
||||||
|
elseif provider == "direct" then
|
||||||
|
return "https://" .. domain .. "/favicon.ico"
|
||||||
|
else
|
||||||
|
return "https://www.google.com/s2/favicons?sz=64&domain=" .. encoded
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function faviconCachePath(domain)
|
local function faviconCachePath(domain)
|
||||||
|
local provider = noctalia.getConfig("icon_provider")
|
||||||
|
|
||||||
local dir = noctalia.pluginDir() .. "/cache"
|
local dir = noctalia.pluginDir() .. "/cache"
|
||||||
local safe = domain:gsub("[^%w%.%-]", "_")
|
local safe = domain:gsub("[^%w%.%-]", "_")
|
||||||
local path = dir .. "/" .. safe .. ".png"
|
|
||||||
|
local path = dir .. "/" .. safe .. "_" .. provider .. ".png"
|
||||||
return path, dir
|
return path, dir
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -33,3 +33,15 @@ type = "bool"
|
|||||||
label_key = "settings.notify.label"
|
label_key = "settings.notify.label"
|
||||||
description_key = "settings.notify.description"
|
description_key = "settings.notify.description"
|
||||||
default = true
|
default = true
|
||||||
|
|
||||||
|
[[setting]]
|
||||||
|
key = "icon_provider"
|
||||||
|
type = "select"
|
||||||
|
label_key = "settings.icon_provider.label"
|
||||||
|
description_key = "settings.icon_provider.description"
|
||||||
|
default = "google"
|
||||||
|
options = [
|
||||||
|
{ value = "google", label_key = "settings.icon_provider.google" },
|
||||||
|
{ value = "duckduckgo", label_key = "settings.icon_provider.duckduckgo" },
|
||||||
|
{ value = "direct", label_key = "settings.icon_provider.direct" },
|
||||||
|
]
|
||||||
|
|||||||
@@ -7,6 +7,13 @@
|
|||||||
"notify": {
|
"notify": {
|
||||||
"label": "Notify",
|
"label": "Notify",
|
||||||
"description": "Notify when opening link."
|
"description": "Notify when opening link."
|
||||||
|
},
|
||||||
|
"icon_provider": {
|
||||||
|
"label": "Icon Provider",
|
||||||
|
"description": "Icon download source.",
|
||||||
|
"google": "Google",
|
||||||
|
"duckduckgo": "DuckDuckGo",
|
||||||
|
"direct": "Site's own favicon.ico"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user