Editing
Module:WikidataCheck
From Thetacola Wiki
Jump to navigation
Jump to search
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 p = {} function p.wikidatacheck(frame) local pframe = frame:getParent() local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself local args = pframe.args -- the arguments passed TO the template, in the wikitext that transcludes the template local property = config.property local value = config.value or "" local catbase = config.category local namespaces = config.namespaces local nocatsame = config.nocatsame or "" local qid = config.qid or "" local ok = false -- one-way flag to check if we're in a good namespace local ns = mw.title.getCurrentTitle().namespace for v in mw.text.gsplit( namespaces, ",", true) do if tonumber(v) == ns then ok = true end end if not ok then -- not in one of the approved namespaces return "" end local entity if qid == "" then entity = mw.wikibase.getEntityObject() else entity = mw.wikibase.getEntityObject(qid) end if not entity then -- no Wikidata item return "[[Category:" .. catbase .. " not in Wikidata]]" end if value == "" then return nil -- Using Wikidata end local claims = entity.claims or {} local hasProp = claims[property] if not hasProp then -- no claim of that property return "[[Category:" .. catbase .. " not in Wikidata]]" -- bad. Bot needs to add the property end for i, v in ipairs(hasProp) do -- Now we try to iterate over all possible values? propValue = (v.mainsnak.datavalue or {}).value if propValue == value then if nocatsame == "" then return "[[Category:" .. catbase .. " same as Wikidata]]" -- yay! else return nil -- if nocatsame, the "same as" category is not added end end end return "[[Category:" .. catbase .. " different from Wikidata]]" -- needs human review :( end return p
Summary:
Please note that all contributions to Thetacola Wiki 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
Project:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Documentation subpage
(
edit
)
Template:High-use
(
edit
)
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Nowrap
(
edit
)
Template:Ombox
(
edit
)
Template:Para
(
edit
)
Template:Property
(
edit
)
Template:Sandbox other
(
edit
)
Template:Str left
(
edit
)
Template:Template link
(
edit
)
Template:Template link expanded
(
edit
)
Template:Tl
(
edit
)
Template:Tlx
(
edit
)
Template:Wikidata
(
edit
)
Template:WikidataCheck/doc
(
edit
)
Template:Wikidata property link
(
edit
)
Module:Arguments
(
edit
)
Module:Effective protection level
(
edit
)
Module:High-use
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Message box/ombox.css
(
edit
)
Module:String
(
edit
)
Module:Template link general
(
edit
)
Module:Transclusion count
(
edit
)
Module:Transclusion count/data/W
(
edit
)
Module:Wd
(
edit
)
Module:WikidataCheck/doc
(
edit
)
Module:Yesno
(
edit
)
Navigation menu
Page actions
Module
Discussion
Read
Edit source
History
Page actions
Module
Discussion
More
Tools
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Search
Tools
What links here
Related changes
Special pages
Page information