Modul:WikidataCommonscat: Forskjell mellom sideversjoner
Hopp til navigering
Hopp til søk
Ingen redigeringsforklaring |
Ingen redigeringsforklaring |
||
Linje 14: | Linje 14: | ||
end |
end |
||
-- |
-- Returner commons categori til artikkelen fra wikidata |
||
function p.wikidatacommonscat(frame) |
function p.wikidatacommonscat(frame) |
||
if not mw.wikibase then |
if not mw.wikibase then |
||
Linje 27: | Linje 27: | ||
return "b" |
return "b" |
||
end |
end |
||
local p373 = claims.p373 |
local p373 = claims.p373 -- ikke P men p |
||
if not p373 then |
if not p373 then |
||
return "c" |
return "c" |
||
Linje 56: | Linje 56: | ||
return p.wikidatacommonscat(frame) |
return p.wikidatacommonscat(frame) |
||
else |
else |
||
return commonscat |
return commonscat |
||
end |
end |
||
else |
else |
||
return p.wikidatacommonscat(frame) |
return p.wikidatacommonscat(frame) -- ser ikke ut til å komme hit |
||
end |
end |
||
return p.wikidatacommonscat(frame) |
return p.wikidatacommonscat(frame) -- ser ikke ut til å komme hit |
||
end |
end |
||
Sideversjonen fra 10. mai 2013 kl. 19:01
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.getEntity() if not artikkel then return "a" end local claims = artikkel.claims if not claims then return "b" end local p373 = claims.p373 -- ikke P men p if not p373 then return "c" end return p373[0].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.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