#meta
og = {}
function og.fetch(url)
local response = http.request(url)
if response.ok then
local parser = js.new(js.window.DOMParser)
local document = parser.parseFromString(response.body, "text/html")
local og_properties = {}
for meta in each(document.getElementsByTagName("meta")) do
local prop = tostring(meta.getAttribute("property"))
if prop:startsWith("og:") then
og_properties[prop:sub(4)] = meta.getAttribute("content")
end
end
return og_properties
else
return { error = "Status code "..response.status }
end
end
function og.card(url, width)
width = width or 350
local og = og.fetch(url)
if og.error then return widget.markdown("==OG Error: "..og.error.."==") end
return widget.html(dom.div {
style = "width:"..width.."px;background-color:rgba(0,0,0,0.15);padding:3px 10px;border-radius:5px;",
dom.sub { og.site or og.site_name }, dom.br {},
dom.h3 { dom.a { href = og.url, og.title } },
dom.p { og.description or "" },
dom.img {
style = "width:"..width.."px;border-radius:5px;",
src = og.image
}
})
end
${og.card("https://store.steampowered.com/app/3496520/MIO_Memories_in_Orbit_Demo/")}