update wikipedia widget

This commit is contained in:
Evgeny
2021-08-11 14:35:56 +03:00
parent 6d642629b5
commit bf0d9a5f4f
4 changed files with 14 additions and 4 deletions

View File

@@ -32,7 +32,7 @@ function on_network_result_summary(result)
local parsed = json.decode(result)
local extract = get_extract(parsed)
ui:show_lines({ extract:sub(1, 200) }, { title })
ui:show_lines({ extract:smart_sub(200) }, { title })
end
function on_click()
@@ -41,6 +41,16 @@ end
-- utils --
function string:smart_sub(max)
local pos1, pos2 = self:find("%.", max-50)
if pos1 < max+50 then
return self:sub(1, pos1+1)
else
return self:sub(1, max)
end
end
function get_extract(parsed)
for k,v in pairs(parsed.query.pages) do
for k, v in pairs(v) do