Files
community-plugins/rss-notifier/panel.luau
T
NilsonlinuxandGitHub f672176186 rss-notifier Update v1.0.1 (#236)
* Add nilsonlinux/rss-notifier plugin v1.0.0

* fix: correct all validation errors for rss-notifier

* Update tags in plugin.toml for rss-notifier

* Revise README for RSS Notifier plugin

Updated README to reflect plugin name and improved clarity.

* Update README.md by removing unnecessary content

Removed placeholder text and installation instructions from README.

* Update README with plugin details and usage instructions

Expanded README to include plugin details, usage instructions, and settings configuration.

* Traduz README.md para português e atualiza conteúdo

Atualiza o README.md com informações em português sobre o plugin RSS/Atom Notifier, incluindo uso, configurações e notas sobre o funcionamento.

* Update tags in plugin.toml

Removed 'rss' tag from the plugin configuration.

* Revise README for RSS Notifier plugin

Updated the README to reflect changes in the plugin description, installation instructions, usage details, settings, and dependencies.

* Enhance README with plugin details and usage

Updated README.md to include detailed plugin features, settings, and usage instructions.

* Update README for RSS Utils plugin

* Add files via upload

* Add xdg-open as a dependency in plugin.toml

* Revise README for RSS/Atom Notifier plugin

Updated configuration options and usage instructions in README.

* Add Brazilian Portuguese translation file

* Revise README for clarity and updated instructions

Updated README to improve clarity and consistency, including installation and usage instructions.

* Add xdg-open as a dependency in README

Updated dependencies section to include xdg-open.

* Fix formatting of requirements section in README

* Add files via upload

* feat: add individual item delete option and scrollbar

- Implemented the ability to delete individual feed items using an 'X' button.
- Added a fixed height scrollbar to the panel list.
- Fixed badge synchronization and command communication for the V5 Beta 6 environment.

* fix tags e correções de funcionamento

* Add dependencies section to plugin.toml

* Add files via upload

* Enhance README with plugin details

Updated README with plugin ID and entries table.

* thumbnail update

Thumbnail updated. Following the plugin update.

* Bump version from 1.0.0 to 1.0.1

Added outlines to the control buttons. Also fixed a bug where recent feeds wouldn't list upon starting a session.

* Change button variant from 'ghost' to 'outline'

Added outlines to the control buttons. Also fixed a bug where recent feeds wouldn't list upon starting a session.
2026-08-03 22:35:58 -04:00

140 lines
4.1 KiB
Luau

-- panel.luau
-- Janela pop-up mostrada ao clicar no widget da barra: lista os itens mais
-- recentes, ou um estado vazio com icone quando nao ha nada novo.
local items = {}
-- declaradas antes para permitir referencia cruzada entre elas
local render
local dismissItem
local itemRow
local emptyState
local function openLink(link)
if not link or link == "" then
return
end
-- escapa aspas simples pra evitar quebrar o comando do shell
local safe = link:gsub("'", "'\\''")
noctalia.runAsync("xdg-open '" .. safe .. "'")
end
dismissItem = function(item)
-- remove localmente (resposta imediata) e avisa o service pra nao
-- reaparecer nas proximas atualizacoes
for i, it in ipairs(items) do
if it == item then
table.remove(items, i)
break
end
end
render()
local id = item.id or item.link or item.title
if id then
local safe = tostring(id):gsub("'", "'\\''")
noctalia.runAsync("noctalia msg plugin nilsonlinux/rss-notifier:fetcher all dismiss '" .. safe .. "'")
end
end
itemRow = function(item)
return ui.row({
key = item.id or item.link or item.title,
gap = 6,
padding = 10,
radius = 8,
fill = "surface_variant/0.4",
align = "center",
}, {
ui.column({
gap = 2,
flexGrow = 1,
onClick = function() openLink(item.link) end,
}, {
ui.label({ text = item.title or "(sem titulo)", fontWeight = "bold", maxLines = 2 }),
ui.label({ text = item.feedTitle or "", fontSize = 12, color = "outline" }),
}),
ui.button({
glyph = "close",
variant = "outline",
controlSize = "sm",
tooltip = "Dispensar",
onClick = function() dismissItem(item) end,
}),
})
end
emptyState = function()
return ui.column({ gap = 10, align = "center", padding = 32, flexGrow = 1, justify = "center" }, {
ui.glyph({ name = "rss", size = 32, color = "outline" }),
ui.label({ text = "Nenhuma atualização", color = "outline" }),
})
end
render = function()
local body
if #items == 0 then
body = emptyState()
else
local rows = {}
for _, item in ipairs(items) do
table.insert(rows, itemRow(item))
end
body = ui.scroll({ gap = 6, flexGrow = 1 }, rows)
end
local headerButtons = {}
if #items > 0 then
table.insert(headerButtons, ui.button({ glyph = "trash", variant = "outline", controlSize = "sm", tooltip = "Limpar tudo", onClick = "onClearAllClicked" }))
end
table.insert(headerButtons, ui.button({ glyph = "refresh", variant = "outline", controlSize = "sm", tooltip = "Atualizar agora", onClick = "onRefreshClicked" }))
table.insert(headerButtons, ui.button({ glyph = "close", variant = "outline", controlSize = "sm", onClick = "onCloseClicked" }))
panel.render(ui.column({ gap = 10, padding = 12, fill = true }, {
ui.row({ align = "center", justify = "space_between" }, {
ui.label({ text = "RSS/Atom Notifier", fontSize = 15, fontWeight = "bold" }),
ui.row({ gap = 4 }, headerButtons),
}),
ui.separator({}),
body,
}))
end
noctalia.state.watch("items", function(raw)
local ok, decoded = pcall(noctalia.json.decode, raw or "[]")
items = (ok and decoded) or {}
render()
end)
function onOpen(_context)
-- o painel so e criado na primeira vez que e aberto - se o service ja
-- tinha publicado itens antes disso (ex: na checagem de boot), o watch()
-- sozinho nao pega esse valor antigo. Busca o estado atual na abertura.
local ok, raw = pcall(noctalia.state.get, "items")
if ok and raw then
local decodeOk, decoded = pcall(noctalia.json.decode, raw)
if decodeOk and decoded then
items = decoded
end
end
render()
-- abrir o painel conta como "li as novidades": zera o badge no service
noctalia.runAsync("noctalia msg plugin nilsonlinux/rss-notifier:fetcher all mark-read")
end
function onRefreshClicked()
noctalia.runAsync("noctalia msg plugin nilsonlinux/rss-notifier:fetcher all refresh")
end
function onClearAllClicked()
items = {}
render()
noctalia.runAsync("noctalia msg plugin nilsonlinux/rss-notifier:fetcher all clear-all")
end
function onCloseClicked()
panel.close()
end