Module:EditAtWikidata: Difference between revisions
Appearance
No edit summary Tag: Reverted |
No edit summary Tag: Reverted |
||
| Line 1: | Line 1: | ||
function p._showMessage(args) | function p._showMessage(args) | ||
local local_parm = trimToNil(args[1]) | local local_parm = trimToNil(args[1]) | ||
if local_parm then return "" end | if local_parm then return "" end | ||
local qid | local qid | ||
if mw and mw.wikibase and mw.wikibase.getEntityIdForCurrentPage then | if mw and mw.wikibase and mw.wikibase.getEntityIdForCurrentPage then | ||
| Line 25: | Line 10: | ||
end | end | ||
-- | if not qid then | ||
-- Show a message when no Wikidata entity exists, or return empty string to show nothing | |||
return "[No Wikidata entity found for this page]" | |||
end | |||
if qid and mw and mw.wikibase and mw.wikibase.entityExists and mw.wikibase.entityExists(qid) then | if qid and mw and mw.wikibase and mw.wikibase.entityExists and mw.wikibase.entityExists(qid) then | ||
local anchor = trimToNil(args.pid) | local anchor = trimToNil(args.pid) | ||
| Line 39: | Line 28: | ||
"]]" | "]]" | ||
end | end | ||
return "" | return "" | ||
end | end | ||
Revision as of 17:51, 30 May 2025
Documentation for this module may be created at Module:EditAtWikidata/doc
function p._showMessage(args)
local local_parm = trimToNil(args[1])
if local_parm then return "" end
local qid
if mw and mw.wikibase and mw.wikibase.getEntityIdForCurrentPage then
qid = trimToNil(args.qid) or mw.wikibase.getEntityIdForCurrentPage()
else
qid = trimToNil(args.qid)
end
if not qid then
-- Show a message when no Wikidata entity exists, or return empty string to show nothing
return "[No Wikidata entity found for this page]"
end
if qid and mw and mw.wikibase and mw.wikibase.entityExists and mw.wikibase.entityExists(qid) then
local anchor = trimToNil(args.pid)
local space = trimToNil(args.nbsp) and " " or " "
return
space ..
"[[File:OOjs UI icon edit-ltr-progressive.svg|frameless|text-top|10px" ..
"|alt=" .. i18n.message ..
"|link=https://www.wikidata.org/wiki/" .. qid ..
(anchor and ("#" .. anchor) or "") ..
"|class=noprint" ..
"|" .. i18n.message ..
"]]"
end
return ""
end