Modul:WikidataCommonscat: Forskjell mellom sideversjoner
Hopp til navigering
Hopp til søk
(trenger ikke kategori - artikler hvor comcat er tom som på Wikidata) |
(change mw.wikibase.getEntitiy (deprecated) to mw.wikibase.getEntityObject) |
||
Linje 19: | Linje 19: | ||
return "" |
return "" |
||
end |
end |
||
local artikkel = mw.wikibase. |
local artikkel = mw.wikibase.getEntityObject() |
||
if not artikkel then |
if not artikkel then |
||
return "" |
return "" |
||
Linje 27: | Linje 27: | ||
return "" |
return "" |
||
end |
end |
||
local p373 = claims. |
local p373 = claims.P373 -- ikke p men P |
||
if not p373 then |
if not p373 then |
||
return "" |
return "" |
||
end |
end |
||
return p373[ |
return p373[1].mainsnak.datavalue.value |
||
end |
end |
||
Sideversjonen fra 2. mar. 2015 kl. 14:43
Modul som brukes av {{Commonscat fra Wikidata}}
local p = {} function dump( out ) if type( out ) == 'table' then local s = '{ ' for k,v in pairs( out ) do if type( k ) ~= 'number' then k = '"'..k..'"' end s = s .. '['..k..'] = ' .. dump( v ) .. ',' end return s .. '} <br>' else return tostring( out ) end end -- Returner commons categori til artikkelen fra wikidata function p.wikidatacommonscat(frame) if not mw.wikibase then return "" end local artikkel = mw.wikibase.getEntityObject() if not artikkel then return "" end local claims = artikkel.claims if not claims then return "" end local p373 = claims.P373 -- ikke p men P if not p373 then return "" end return p373[1].mainsnak.datavalue.value end function p.framecommonscat(frame) local args = frame.args if args[1] == nil then local pFrame = frame:getParent(); args = pFrame.args; for k,v in pairs( frame.args ) do args[k] = v; end end if args['comcat'] then return args['comcat'] end return "" end function p.comparecommonscat(frame) local comcatframe = p.framecommonscat(frame) local comcatwikidata = p.wikidatacommonscat(frame) if comcatframe == comcatwikidata then if comcatframe == "" then return "" else return "[[Kategori:Artikler hvor comcat er samme som på Wikidata]]" end else if comcatwikidata == "" then return "[[Kategori:Artikler hvor comcat mangler på Wikidata]]" end if comcatframe == "" then return "[[Kategori:Artikler uten comcat]]" end return "[[Kategori:Artikler med comcat forskjellig fra Wikidata]]" end end function p.velgcommonscat(frame) local commonscat = p.framecommonscat(frame) if commonscat then if commonscat == "" then return p.wikidatacommonscat(frame) else return commonscat end else return p.wikidatacommonscat(frame) -- ser ikke ut til å komme hit end return p.wikidatacommonscat(frame) -- ser ikke ut til å komme hit end return p