The extensions that were in Toolshed's own repository, a folder each: brreg, dashboard-icons, databricks, docker, github, homebrew, norway, projects, scripts, secrets, wikipedia and yr. Toolshed installs them from here, in Settings → Extensions → From a repository, and the README says how
This commit is contained in:
44 files changed
+7978
-1
No files matched your search
@@ -0,0 +1,145 @@
|
||||
-- Icons for self-hosted apps from dashboardicons.com: "di plex" shows them as tiles. Enter copies
|
||||
-- the icon's address, its SVG when it has one, for a dashboard like Homarr or Homepage; ⌘K copies
|
||||
-- the SVG or PNG address, its name or the picture, or opens it on the site.
|
||||
|
||||
local cdn = "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/"
|
||||
local list_file = toolshed.cache_dir() .. "/metadata.json"
|
||||
-- New icons arrive every few days; a week-old list still finds nearly all of them.
|
||||
local refresh_seconds = 7 * 24 * 3600
|
||||
|
||||
local modified = toolshed.file.modified
|
||||
|
||||
local function download(max_seconds)
|
||||
local tmp = list_file .. ".download"
|
||||
toolshed.exec({ "curl", "-sSfL", "--max-time", tostring(max_seconds), "-o", tmp, cdn .. "metadata.json" })
|
||||
assert(os.rename(tmp, list_file))
|
||||
end
|
||||
|
||||
-- refresh downloads a stale list again in the background, quietly, so no search waits for it:
|
||||
-- once a run of Toolshed, at its first search, as the list read then is kept.
|
||||
local refreshed = false
|
||||
local function refresh()
|
||||
if refreshed then return end
|
||||
refreshed = true
|
||||
local changed = modified(list_file)
|
||||
if changed and os.time() - changed > refresh_seconds then
|
||||
toolshed.activities.set {
|
||||
key = "refresh", title = toolshed.t("jobs.refresh.title"), description = toolshed.t("jobs.refresh.description"), quiet = true, timeout = 120,
|
||||
run = { "sh", "-c", 'curl -sSfL --max-time 60 -o "$0.download" "$1" && mv "$0.download" "$0"', list_file, cdn .. "metadata.json" },
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
local icons
|
||||
local function load()
|
||||
refresh()
|
||||
if icons then return icons end
|
||||
if not modified(list_file) then download(1.5) end -- the first search ever has to wait
|
||||
local f = assert(io.open(list_file, "r"))
|
||||
local metadata = toolshed.json.decode(f:read("*a"))
|
||||
f:close()
|
||||
icons = {}
|
||||
for name, meta in pairs(metadata) do
|
||||
table.insert(icons, {
|
||||
name = name,
|
||||
base = meta.base,
|
||||
aliases = table.concat(meta.aliases or {}, " "),
|
||||
categories = table.concat(meta.categories or {}, ", "),
|
||||
})
|
||||
end
|
||||
table.sort(icons, function(a, b) return a.name < b.name end)
|
||||
return icons
|
||||
end
|
||||
|
||||
local function address(ctx, format)
|
||||
return cdn .. format .. "/" .. ctx.data.name .. "." .. format
|
||||
end
|
||||
|
||||
return toolshed.toolbox {
|
||||
key = "dashboard-icons",
|
||||
title = "Dashboard Icons",
|
||||
description = "i18n:toolbox.description",
|
||||
icon = "image",
|
||||
tint = "blue",
|
||||
grid = true,
|
||||
|
||||
tools = { {
|
||||
key = "search",
|
||||
title = "Dashboard Icons",
|
||||
words = { "di" },
|
||||
examples = { "di plex", "di home assistant" },
|
||||
keywords = { "ikoner" },
|
||||
items = true,
|
||||
|
||||
search = function(rest)
|
||||
local found = {}
|
||||
for _, icon in ipairs(load()) do
|
||||
local score = math.max(
|
||||
toolshed.match(rest, icon.name),
|
||||
toolshed.match(rest, icon.aliases),
|
||||
toolshed.match(rest, icon.categories) * 0.8)
|
||||
if score > 0 then table.insert(found, { icon = icon, score = score }) end
|
||||
end
|
||||
table.sort(found, function(a, b)
|
||||
if a.score ~= b.score then return a.score > b.score end
|
||||
return a.icon.name < b.icon.name
|
||||
end)
|
||||
local items = {}
|
||||
for i = 1, math.min(#found, 50) do
|
||||
local icon = found[i].icon
|
||||
table.insert(items, {
|
||||
title = icon.name,
|
||||
subtitle = icon.categories,
|
||||
-- The original: an SVG is mostly a tenth of the PNG's size, and some PNGs made from SVGs
|
||||
-- came out blank, like jellyglance's.
|
||||
image = cdn .. icon.base .. "/" .. icon.name .. "." .. icon.base,
|
||||
data = { name = icon.name, base = icon.base },
|
||||
})
|
||||
end
|
||||
return items
|
||||
end,
|
||||
|
||||
actions = {
|
||||
{
|
||||
key = "copy-address", title = "i18n:action.search.copy-address",
|
||||
run = function(ctx)
|
||||
toolshed.clipboard.copy(address(ctx, ctx.data.base))
|
||||
return toolshed.t(ctx.data.base == "svg" and "svg-copied" or "png-copied-no-svg")
|
||||
end,
|
||||
},
|
||||
{
|
||||
key = "copy-svg-address", title = "i18n:action.search.copy-svg-address",
|
||||
run = function(ctx)
|
||||
if ctx.data.base ~= "svg" then error(toolshed.t("no-svg")) end
|
||||
toolshed.clipboard.copy(address(ctx, "svg"))
|
||||
return toolshed.t("svg-copied")
|
||||
end,
|
||||
},
|
||||
{
|
||||
key = "copy-png-address", title = "i18n:action.search.copy-png-address",
|
||||
run = function(ctx)
|
||||
toolshed.clipboard.copy(address(ctx, "png"))
|
||||
return toolshed.t("png-copied")
|
||||
end,
|
||||
},
|
||||
{
|
||||
key = "copy-image", title = "i18n:action.search.copy-image",
|
||||
run = function(ctx)
|
||||
toolshed.clipboard.copy_image(address(ctx, "png"))
|
||||
return toolshed.t("image-copied")
|
||||
end,
|
||||
},
|
||||
{
|
||||
key = "copy-name", title = "i18n:action.search.copy-name",
|
||||
run = function(ctx)
|
||||
toolshed.clipboard.copy(ctx.data.name)
|
||||
return toolshed.t("name-copied")
|
||||
end,
|
||||
},
|
||||
{
|
||||
key = "open", title = "i18n:action.search.open",
|
||||
run = function(ctx) toolshed.open("https://dashboardicons.com/icons/" .. ctx.data.name) end,
|
||||
},
|
||||
},
|
||||
} },
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
[toolbox.description]
|
||||
other = "Finds icons for self-hosted apps on dashboardicons.com"
|
||||
|
||||
[action.search.copy-address]
|
||||
other = "Copy Address"
|
||||
|
||||
[action.search.copy-svg-address]
|
||||
other = "Copy SVG Address"
|
||||
|
||||
[action.search.copy-png-address]
|
||||
other = "Copy PNG Address"
|
||||
|
||||
[action.search.copy-image]
|
||||
other = "Copy Image"
|
||||
|
||||
[action.search.copy-name]
|
||||
other = "Copy Name"
|
||||
|
||||
[action.search.open]
|
||||
other = "Open on dashboardicons.com"
|
||||
|
||||
[svg-copied]
|
||||
other = "SVG address copied"
|
||||
|
||||
[png-copied]
|
||||
other = "PNG address copied"
|
||||
|
||||
[png-copied-no-svg]
|
||||
other = "PNG address copied: this icon has no SVG"
|
||||
|
||||
[no-svg]
|
||||
other = "This icon has no SVG, only a PNG"
|
||||
|
||||
[image-copied]
|
||||
other = "Image copied"
|
||||
|
||||
[name-copied]
|
||||
other = "Name copied"
|
||||
|
||||
[jobs.refresh.title]
|
||||
other = "Downloads the icon list"
|
||||
|
||||
[jobs.refresh.description]
|
||||
other = "Keeps the icon list up to date"
|
||||
@@ -0,0 +1,44 @@
|
||||
[toolbox.description]
|
||||
other = "Finner ikoner for selvhostede apper på dashboardicons.com"
|
||||
|
||||
[action.search.copy-address]
|
||||
other = "Kopier adresse"
|
||||
|
||||
[action.search.copy-svg-address]
|
||||
other = "Kopier SVG-adresse"
|
||||
|
||||
[action.search.copy-png-address]
|
||||
other = "Kopier PNG-adresse"
|
||||
|
||||
[action.search.copy-image]
|
||||
other = "Kopier bilde"
|
||||
|
||||
[action.search.copy-name]
|
||||
other = "Kopier navn"
|
||||
|
||||
[action.search.open]
|
||||
other = "Åpne på dashboardicons.com"
|
||||
|
||||
[svg-copied]
|
||||
other = "SVG-adresse kopiert"
|
||||
|
||||
[png-copied]
|
||||
other = "PNG-adresse kopiert"
|
||||
|
||||
[png-copied-no-svg]
|
||||
other = "PNG-adresse kopiert: dette ikonet har ingen SVG"
|
||||
|
||||
[no-svg]
|
||||
other = "Dette ikonet har ingen SVG, bare PNG"
|
||||
|
||||
[image-copied]
|
||||
other = "Bilde kopiert"
|
||||
|
||||
[name-copied]
|
||||
other = "Navn kopiert"
|
||||
|
||||
[jobs.refresh.title]
|
||||
other = "Laster ned ikonlisten"
|
||||
|
||||
[jobs.refresh.description]
|
||||
other = "Holder ikonlisten oppdatert"
|
||||
Reference in new issue
Block a user