Content deleted Content added
removing Module:Link_language reliance |
update to use new mw.wikibase API changes |
||
(14 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 76:
return websites[1].mainsnak.datavalue.value
end)
return {▼
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>'
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
return result
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]]'
end▼
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
return table.concat(ret, ' ')
end
-- Render the tracking
local function
if mw.title.getCurrentTitle().namespace ~= 0 then
return ''
end
local
if not url and not wikidataurl then
elseif not url and wikidataurl then
elseif url and wikidataurl then
if url:gsub('/%s*$', '') ~= wikidataurl:gsub('/%s*$', '') then
end
else
▲ if langName then
▲ end
category = string.format('[[Category:%s]]', category)▼
end
end
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 ..
end
|