Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Hike395/CommonsLink
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local getArgs = require('Module:Arguments').getArgs local p = {} function p.test(frame) local args = getArgs(frame) return p._test(args) end function p._test(args) local qid = mw.wikibase.getEntityIdForTitle(args[1]) if not qid then return nil end local result = '<tr><td>'..args[1]..'</td>' local P935 = mw.wikibase.getBestStatements(qid, "P935")[1] result = result..'<td>' local interesting = false local gallery = nil if P935 and P935.mainsnak.datavalue then gallery = P935.mainsnak.datavalue.value result = result..gallery end if not gallery then interesting = true end result = result..'</td><td>' local category = nil local P373 = mw.wikibase.getBestStatements(qid, "P373")[1] if P373 and P373.mainsnak.datavalue then category = 'Category:'..P373.mainsnak.datavalue.value result = result..category end if not category then interesting = true end result = result..'</td><td>' local commonsSitelink = mw.wikibase.getSitelink(qid,"commonswiki") local sitelinkCat = false if commonsSitelink then local comparison if mw.ustring.sub(commonsSitelink,1,9) == "Category:" then comparison = category sitelinkCat = true else comparison = gallery end if commonsSitelink ~= comparison then result = result..'<b>'..commonsSitelink..'</b>' interesting = true else result = result..commonsSitelink end else interesting = true end result = result..'</td><td>' local P910 = mw.wikibase.getBestStatements(qid, "P910")[1] if P910 then local tmcid = P910.mainsnak.datavalue and P910.mainsnak.datavalue.value.id local sitelink = mw.wikibase.getSitelink(tmcid, "commonswiki") if sitelink then if not sitelinkCat and sitelink ~= category then result = result..'<b>'..sitelink..'</b>' interesting = true else result = result..sitelink end end end result = result..'</td></tr>' if (args.interesting or args.int) and not interesting then return nil end return result end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Hike395/CommonsLink/doc
(
edit
)