「モジュール:Wd」の版間の差分
ナビゲーションに移動
検索に移動
en:Module:Wd 2017年5月20日 (土) 11:08(UTC)より
template>K-iczn (en:Module:Wd 2017年5月17日 (水) 06:18(UTC)より) |
template>K-iczn (en:Module:Wd 2017年5月20日 (土) 11:08(UTC)より) |
||
605行目: | 605行目: | ||
if snak.snaktype == 'value' then | if snak.snaktype == 'value' then | ||
if snak.datavalue.type == 'string' then | if snak.datavalue.type == 'string' then | ||
if | if snak.datatype == 'url' and link then | ||
-- create link explicitly | -- create link explicitly | ||
if raw then | if raw then | ||
613行目: | 613行目: | ||
return "[" .. snak.datavalue.value .. " " .. snak.datavalue.value .. "]" | return "[" .. snak.datavalue.value .. " " .. snak.datavalue.value .. "]" | ||
end | end | ||
elseif snak.datatype == 'commonsMedia' then | |||
if link then | |||
if raw then | |||
-- will render as a linked number like [1] | |||
return "[https://commons.wikimedia.org/wiki/File:" .. mw.ustring.gsub(snak.datavalue.value, " ", "_") .. "]" | |||
else | |||
return "[https://commons.wikimedia.org/wiki/File:" .. mw.ustring.gsub(snak.datavalue.value, " ", "_") .. " " .. snak.datavalue.value .. "]" | |||
end | |||
elseif not raw then | |||
return "[[File:" .. snak.datavalue.value .. "]]" | |||
else | |||
return snak.datavalue.value | |||
end | |||
elseif snak.datatype == 'geo-shape' and link then | |||
if raw then | |||
-- will render as a linked number like [1] | |||
return "[https://commons.wikimedia.org/wiki/" .. mw.ustring.gsub(snak.datavalue.value, " ", "_") .. "]" | |||
else | |||
return "[https://commons.wikimedia.org/wiki/" .. mw.ustring.gsub(snak.datavalue.value, " ", "_") .. " " .. snak.datavalue.value .. "]" | |||
end | |||
elseif snak.datatype == 'math' and not raw then | |||
return mw.getCurrentFrame():extensionTag("math", snak.datavalue.value) | |||
else | else | ||
return snak.datavalue.value | return snak.datavalue.value | ||
1,710行目: | 1,732行目: | ||
end | end | ||
-- check for optional item | -- check for optional entity ID of either item or property | ||
if nextArg:sub(1,1):upper() == "Q" then | if nextArg:sub(1,1):upper() == "Q" then | ||
_.entity = mw.wikibase.getEntity(nextArg) -- item ID given | _.entity = mw.wikibase.getEntity(nextArg) -- entity ID of an item given | ||
_.propertyID = mw.text.trim(args[nextIndex] or "") -- property ID | |||
nextIndex = nextIndex + 1 | |||
elseif nextArg:sub(1,9):lower() == "property:" then | |||
nextArg = mw.text.trim(nextArg:sub(10)) | |||
if aliasesP[nextArg] then | |||
nextArg = aliasesP[nextArg] | |||
end | |||
_.entity = mw.wikibase.getEntity(nextArg) -- entity ID of a property given | |||
_.propertyID = mw.text.trim(args[nextIndex] or "") -- property ID | _.propertyID = mw.text.trim(args[nextIndex] or "") -- property ID | ||
nextIndex = nextIndex + 1 | nextIndex = nextIndex + 1 | ||
else | else | ||
_.entity = mw.wikibase.getEntity() -- no | _.entity = mw.wikibase.getEntity() -- no entity ID given, use item connected to current page | ||
_.propertyID = nextArg -- property ID | _.propertyID = nextArg -- property ID | ||
end | end | ||
1,893行目: | 1,925行目: | ||
if ID == "" then | if ID == "" then | ||
ID = nil | ID = nil | ||
elseif ID:sub(1,9):lower() == "property:" then | |||
ID = mw.text.trim(ID:sub(10)) | |||
end | end | ||
end | end |