Content deleted Content added
fix frame error; ignore lang code from Wikidata if it's English |
update to use new mw.wikibase API changes |
||
(18 intermediate revisions by 4 users not shown) | |||
Line 40:
end
-- Fetches the official website URL
local
-- Get objects for all official sites on Wikidata.
local websites = quickPcall(function ()
return mw.wikibase.
end)
Line 71:
return e1
end
return ws1._index < ws2._index
end)
local url = quickPcall(function ()
return websites[1].mainsnak.datavalue.value
end)
return iso639_3▼
end▼
end)▼
-- Cache the result so that we only do the heavy lifting once per #invoke.
return
end
return
end
-- Render the URL link, plus other visible output.
local function renderUrl(options)
if not options.url and not options.wikidataurl then
local qid = mw.wikibase.getEntityIdForCurrentPage()
'No URL found. Please specify a URL here or add one to Wikidata.' ..
'</strong>'
if qid then
result = result.. ' [[File:OOjs UI icon edit-ltr-progressive.svg |frameless |text-top |10px |alt=Edit this at Wikidata |link=https://www.wikidata.org/wiki/' .. qid .. '#P856|Edit this at Wikidata]]'
▲ end
end
local ret = {}
ret[#ret + 1] = string.format(
'<span class="official-website">%s</span>',
makeUrl(options.url or options.wikidataurl, options.display)
)
if options.wikidataurl and not options.url then
local qid = mw.wikibase.getEntityIdForCurrentPage()
if qid then
ret[#ret + 1] = '[[File:OOjs UI icon edit-ltr-progressive.svg |frameless |text-top |10px |alt=Edit this at Wikidata |link=https://www.wikidata.org/wiki/' .. qid .. '#P856|Edit this at Wikidata]]'
if options.format == 'flash' then
ret[#ret + 1] = mw.getCurrentFrame():expandTemplate{
title = '
args = {
}
end
if options.mobile then
ret[#ret + 1] = '(' .. makeUrl(options.mobile, 'Mobile') .. ')'
▲ end
end
return table.concat(ret, ' ')
Line 149 ⟶ 141:
function p._main(args)
local
local wikidataurl = fetchWikidataUrl()
local formattedUrl = renderUrl{
url = url,
wikidataurl = wikidataurl,
display = args[2] or args.name or 'Official website',
format = args.format,
}
return formattedUrl .. renderTrackingCategory(url,
end
|