More languages
More actions
mNo edit summary |
m (Testing function which returns sitename based on url) |
||
Line 11: | Line 11: | ||
function p.Sitename(frame) | function p.Sitename(frame) | ||
local extDataTable = mw.ext.externalData.getExternalData(frame.args[1])[1]["__text"] | local extDataTable = mw.ext.externalData.getExternalData(frame.args[1])[1]["__text"] | ||
local | local dataLines = splitLines(extDataTable) | ||
local sitename = '' | |||
for i,line in ipairs(dataLines) do | |||
if line:match("og:site_name") then | |||
sitename = line:match("content=\"(%a+)\"") | |||
end | |||
end | |||
return sitename | |||
end | end | ||
return p | return p |
Revision as of 12:22, 23 April 2024
function splitLines(text)
local lines = {}
for line in text:gmatch("[^\r\n]+") do
table.insert(lines, line)
end
return lines
end
local p = {}
function p.Sitename(frame)
local extDataTable = mw.ext.externalData.getExternalData(frame.args[1])[1]["__text"]
local dataLines = splitLines(extDataTable)
local sitename = ''
for i,line in ipairs(dataLines) do
if line:match("og:site_name") then
sitename = line:match("content=\"(%a+)\"")
end
end
return sitename
end
return p