「モジュール:Wd」の版間の差分

en:Module:Wd 2017年10月22日 (日) 08:19(UTC)より
template>K-iczn
(en:Module:Wd 2017年10月11日 (水) 06:56(UTC)より)
template>K-iczn
(en:Module:Wd 2017年10月22日 (日) 08:19(UTC)より)
18行目: 18行目:
end
end


p.commands = {
p.valueCommands = {
property  = "property",
property  = "property",
properties = "properties",
properties = "properties",
24行目: 24行目:
qualifiers = "qualifiers",
qualifiers = "qualifiers",
reference  = "reference",
reference  = "reference",
references = "references",
references = "references"
}
 
p.nameCommands = {
label      = "label",
label      = "label",
title      = "title",
title      = "title",
118行目: 121行目:
["sep%r"]    = nil,  -- none
["sep%r"]    = nil,  -- none
["punc"]    = nil  -- none
["punc"]    = nil  -- none
}
local rankTable = {
["preferred"]  = 1,
["normal"]    = 2,
["deprecated"] = 3
}
}


200行目: 209行目:
end
end


function replaceAlias(ID)
function replaceAlias(id)
if p.aliasesP[ID] then
if p.aliasesP[id] then
ID = p.aliasesP[ID]
id = p.aliasesP[id]
end
end
return ID
return id
end
end


function errorText(code, param)  
function errorText(code, param)  
local error = i18n["errors"][code]
local text = i18n["errors"][code]
if param then error = mw.ustring.gsub(error, "$1", param) end
if param then text = mw.ustring.gsub(text, "$1", param) end
return error
return text
end
end
function throwError(errorMessage, param)
function throwError(errorMessage, param)
error(errorText(errorMessage, param))
error(errorText(errorMessage, param))
302行目: 312行目:


function parseWikidataURL(url)
function parseWikidataURL(url)
local ID
local id
if url:match('^http[s]?://') then
if url:match('^http[s]?://') then
ID = split(url, "Q")
id = split(url, "Q")
if ID[2] then
if id[2] then
return "Q" .. ID[2]
return "Q" .. id[2]
end
end
end
end
575行目: 585行目:
return root, params
return root, params
end
function convertRank(rank)
if rank == "preferred" then
return 1
elseif rank == "normal" then
return 2
elseif rank == "deprecated" then
return 3
else
return 4  -- default (in its literal sense)
end
end
end


595行目: 593行目:
for i, v in ipairs(claims) do
for i, v in ipairs(claims) do
rankPos = convertRank(v.rank)
rankPos = rankTable[v.rank] or 4
ranks[rankPos][#ranks[rankPos] + 1] = v
ranks[rankPos][#ranks[rankPos] + 1] = v
end
end
606行目: 604行目:
end
end


-- if ID == nil then item connected to current page is used
-- if id == nil then item connected to current page is used
function getShortName(ID)
function Config:getLabel(id, raw, link, short)
local args = {p.aliasesP.shortName}
if ID then
args[p.args.eid] = ID
end
return p._property(args)  -- "property" is single
end
 
-- if ID == nil then item connected to current page is used
function Config:getLabel(ID, raw, link, short)
raw = raw or false
link = link or false
short = short or false
local label = nil
local label = nil
local title = nil
local title = nil
local prefix= ""
local prefix= ""
local lang
local lang
if not id then
id = mw.wikibase.getEntityIdForCurrentPage()
if not id then
return ""
end
end
id = id:upper()  -- just to be sure
if raw then
if raw then
if not ID then
-- check if given id actually exists
label = mw.wikibase.getEntityIdForCurrentPage()
if mw.wikibase.getEntity(id) then
elseif mw.wikibase.getEntity(ID) then
label = id
label = ID
if ID:sub(1,1) == "P" then
if id:sub(1,1) == "P" then
prefix = "Property:"
prefix = "Property:"
end
end
645行目: 637行目:
-- try short name first if requested
-- try short name first if requested
if short then
if short then
label = getShortName(ID)
label = p._property({p.aliasesP.shortName, [p.args.eid] = id}) -- get short name
if label == "" then
if label == "" then
654行目: 646行目:
-- get label
-- get label
if not label then
if not label then
label, lang = mw.wikibase.getLabelWithLang(ID)
label, lang = mw.wikibase.getLabelWithLang(id)
-- don't allow language fallback
-- don't allow language fallback
668行目: 660行目:
-- build a link if requested
-- build a link if requested
if not title then
if not title then
if not ID then
if id:sub(1,1) == "Q" then
title = mw.title.getCurrentTitle().prefixedText
title = mw.wikibase.sitelink(id)
elseif ID:sub(1,1) == "Q" then
elseif id:sub(1,1) == "P" then
title = mw.wikibase.sitelink(ID)
elseif ID:sub(1,1) == "P" then
-- properties have no sitelink, link to Wikidata instead
-- properties have no sitelink, link to Wikidata instead
title = ID
title = id
prefix = "d:Property:"
prefix = "d:Property:"
end
end
757行目: 747行目:


function Config:convertUnit(unit, raw, link, short, unitOnly)
function Config:convertUnit(unit, raw, link, short, unitOnly)
raw = raw or false
link = link or false
short = short or false
unitOnly = unitOnly or false
local space = " "
local space = " "
local label = ""
local label = ""
791行目: 776行目:


function Config:getValue(snak, raw, link, short, anyLang, unitOnly, noSpecial)
function Config:getValue(snak, raw, link, short, anyLang, unitOnly, noSpecial)
raw = raw or false
link = link or false
short = short or false
anyLang = anyLang or false
unitOnly = unitOnly or false
noSpecial = noSpecial or false
if snak.snaktype == 'value' then
if snak.snaktype == 'value' then
if snak.datavalue.type == 'string' then
local datatype = snak.datavalue.type
if snak.datatype == 'url' and link then
local subtype = snak.datatype
local datavalue = snak.datavalue.value
if datatype == 'string' then
if subtype == 'url' and link then
-- create link explicitly
-- create link explicitly
if raw then
if raw then
-- will render as a linked number like [1]
-- will render as a linked number like [1]
return "[" .. snak.datavalue.value .. "]"
return "[" .. datavalue .. "]"
else
else
return "[" .. snak.datavalue.value .. " " .. snak.datavalue.value .. "]"
return "[" .. datavalue .. " " .. datavalue .. "]"
end
end
elseif snak.datatype == 'commonsMedia' then
elseif subtype == 'commonsMedia' then
if link then
if link then
return buildWikilink("c:File:" .. snak.datavalue.value, snak.datavalue.value)
return buildWikilink("c:File:" .. datavalue, datavalue)
elseif not raw then
elseif not raw then
return "[[File:" .. snak.datavalue.value .. "]]"
return "[[File:" .. datavalue .. "]]"
else
else
return snak.datavalue.value
return datavalue
end
end
elseif snak.datatype == 'geo-shape' and link then
elseif subtype == 'geo-shape' and link then
return buildWikilink("c:" .. snak.datavalue.value, snak.datavalue.value)
return buildWikilink("c:" .. datavalue, datavalue)
elseif snak.datatype == 'math' and not raw then
elseif subtype == 'math' and not raw then
return mw.getCurrentFrame():extensionTag("math", snak.datavalue.value)
return mw.getCurrentFrame():extensionTag("math", datavalue)
else
else
return snak.datavalue.value
return datavalue
end
end
elseif snak.datavalue.type == 'monolingualtext' then
elseif datatype == 'monolingualtext' then
if anyLang then
if anyLang then
return snak.datavalue.value['text'], snak.datavalue.value['language']
return datavalue['text'], datavalue['language']
elseif snak.datavalue.value['language'] == self.langCode then
elseif datavalue['language'] == self.langCode then
return snak.datavalue.value['text']
return datavalue['text']
else
else
return nil
return nil
end
end
elseif snak.datavalue.type == 'quantity' then
elseif datatype == 'quantity' then
local value = ""
local value = ""
local unit
local unit
837行目: 819行目:
if not unitOnly then
if not unitOnly then
-- get value and strip + signs from front
-- get value and strip + signs from front
value = mw.ustring.gsub(snak.datavalue.value['amount'], "^\+(.+)$", "%1")
value = mw.ustring.gsub(datavalue['amount'], "^\+(.+)$", "%1")
if raw then
if raw then
850行目: 832行目:
end
end
unit = self:convertUnit(snak.datavalue.value['unit'], raw, link, short, unitOnly)
unit = self:convertUnit(datavalue['unit'], raw, link, short, unitOnly)
if unit then
if unit then
857行目: 839行目:
return value
return value
elseif snak.datavalue.type == 'time' then
elseif datatype == 'time' then
local y, m, d, p, yDiv, yRound, yFull, value, calendarID, dateStr
local y, m, d, p, yDiv, yRound, yFull, value, calendarID, dateStr
local yFactor = 1
local yFactor = 1
865行目: 847行目:
local mayAddCalendar = false
local mayAddCalendar = false
local calendar = ""
local calendar = ""
local precision = snak.datavalue.value['precision']
local precision = datavalue['precision']
if precision == 11 then
if precision == 11 then
876行目: 858行目:
end
end
y, m, d = parseDate(snak.datavalue.value['time'], p)
y, m, d = parseDate(datavalue['time'], p)
if y < 0 then
if y < 0 then
1,002行目: 984行目:
if mayAddCalendar then
if mayAddCalendar then
calendarID = parseWikidataURL(snak.datavalue.value['calendarmodel'])
calendarID = parseWikidataURL(datavalue['calendarmodel'])
if calendarID and calendarID == aliasesQ.prolepticJulianCalendar then
if calendarID and calendarID == aliasesQ.prolepticJulianCalendar then
1,065行目: 1,047行目:
return value
return value
elseif snak.datavalue.type == 'globecoordinate' then
elseif datatype == 'globecoordinate' then
-- logic from https://github.com/DataValues/Geo
-- logic from https://github.com/DataValues/Geo
1,101行目: 1,083行目:
end
end
latitude = snak.datavalue.value['latitude']
latitude = datavalue['latitude']
longitude = snak.datavalue.value['longitude']
longitude = datavalue['longitude']
if latitude < 0 then
if latitude < 0 then
1,122行目: 1,104行目:
end
end
precision = snak.datavalue.value['precision']
precision = datavalue['precision']
latitude = math.floor(latitude / precision + 0.5) * precision
latitude = math.floor(latitude / precision + 0.5) * precision
1,179行目: 1,161行目:
if link then
if link then
globe = parseWikidataURL(snak.datavalue.value['globe'])
globe = parseWikidataURL(datavalue['globe'])
if globe then
if globe then
1,191行目: 1,173行目:
return value
return value
elseif snak.datavalue.type == 'wikibase-entityid' then
elseif datatype == 'wikibase-entityid' then
local label
local label
local itemID = snak.datavalue.value['numeric-id']
local itemID = datavalue['numeric-id']
if snak.datatype == 'wikibase-item' then
if subtype == 'wikibase-item' then
itemID = "Q" .. itemID
itemID = "Q" .. itemID
elseif snak.datatype == 'wikibase-property' then
elseif subtype == 'wikibase-property' then
itemID = "P" .. itemID
itemID = "P" .. itemID
else
else
return '<strong class="error">' .. errorText('unknown-data-type', snak.datatype) .. '</strong>'
return '<strong class="error">' .. errorText('unknown-data-type', subtype) .. '</strong>'
end
end
1,211行目: 1,193行目:
return label
return label
else
else
return '<strong class="error">' .. errorText('unknown-data-type', snak.datavalue.type) .. '</strong>'
return '<strong class="error">' .. errorText('unknown-data-type', datatype) .. '</strong>'
end
end
elseif snak.snaktype == 'somevalue' and not noSpecial then
elseif snak.snaktype == 'somevalue' and not noSpecial then
1,378行目: 1,360行目:
end
end
if flag == p.commands.property or flag == p.commands.properties then
if flag == p.valueCommands.property or flag == p.valueCommands.properties then
param = parameters.property
param = parameters.property
elseif flag == p.commands.qualifier or flag == p.commands.qualifiers then
elseif flag == p.valueCommands.qualifier or flag == p.valueCommands.qualifiers then
self.states.qualifiersCount = self.states.qualifiersCount + 1
self.states.qualifiersCount = self.states.qualifiersCount + 1
param = parameters.qualifier .. self.states.qualifiersCount
param = parameters.qualifier .. self.states.qualifiersCount
self.separators["sep"..param] = {copyTable(defaultSeparators["sep%q\\d"])}
self.separators["sep"..param] = {copyTable(defaultSeparators["sep%q\\d"])}
elseif flag == p.commands.reference or flag == p.commands.references then
elseif flag == p.valueCommands.reference or flag == p.valueCommands.references then
param = parameters.reference
param = parameters.reference
else
else
1,412行目: 1,394行目:
end
end


function Config:qualifierMatches(claim, ID, value)
function Config:qualifierMatches(claim, id, value)
local qualifiers
local qualifiers
if claim.qualifiers then qualifiers = claim.qualifiers[ID] end
if claim.qualifiers then qualifiers = claim.qualifiers[id] end
if qualifiers then
if qualifiers then
for i, v in pairs(qualifiers) do
for i, v in pairs(qualifiers) do
1,535行目: 1,517行目:
-- check if the claim's rank and time period match
-- check if the claim's rank and time period match
rankPos = convertRank(claim.rank)
rankPos = rankTable[claim.rank] or 4
matches = (matches and self.conf:rankMatches(rankPos) and self.conf:timeMatches(claim))
matches = (matches and self.conf:rankMatches(rankPos) and self.conf:timeMatches(claim))
1,866行目: 1,848行目:
-- gets a detail of one particular type for a reference
-- gets a detail of one particular type for a reference
function State:getReferenceDetail(snaks, dType, raw, link, anyLang, noUnset)
function State:getReferenceDetail(snaks, dType, raw, link, anyLang, noUnset)
raw = raw or false
link = link or false
anyLang = anyLang or false
noUnset = noUnset or false
local switchLang = anyLang
local switchLang = anyLang
local value = nil
local value = nil
1,905行目: 1,882行目:
-- gets the details of one particular type for a reference
-- gets the details of one particular type for a reference
function State:getReferenceDetails(snaks, dType, raw, link, anyLang, noUnset)
function State:getReferenceDetails(snaks, dType, raw, link, anyLang, noUnset)
raw = raw or false
link = link or false
anyLang = anyLang or false
noUnset = noUnset or false
local values = {}
local values = {}
2,046行目: 2,018行目:
end
end


function p.property(frame)
function extractEntityFromInput(id, allowUnknown)
loadSubmodules(frame)
if id:sub(1,1):upper() == "Q" then
return p._property(copyTable(frame.args))
return id:upper()
elseif id:sub(1,9):lower() == "property:" then
return replaceAlias(mw.text.trim(id:sub(10))):upper()  -- entity ID of a property was given
elseif allowUnknown and id ~= "" then
return replaceAlias(id):upper()
else
return nil
end
end
end


function p._property(args)
function extractEntityFromArgs(args, nextIndex, handleUnknownPos)
loadSubmodules()
local id, eidArg
return valueCommand(args, p.commands.property)
end
if args[nextIndex] then
 
args[nextIndex] = mw.text.trim(args[nextIndex])
function p.properties(frame)
else
loadSubmodules(frame)
args[nextIndex] = ""
return p._properties(copyTable(frame.args))
end
end
 
id = extractEntityFromInput(args[nextIndex], handleUnknownPos)
function p._properties(args)
eidArg = args[p.args.eid]
loadSubmodules()
return valueCommand(args, p.commands.properties)
if id then
end
return id, nextIndex + 1
 
elseif not eidArg then
function p.qualifier(frame)
return mw.wikibase.getEntityIdForCurrentPage(), nextIndex  -- by default, use item-entity connected to current page
loadSubmodules(frame)
else
return p._qualifier(copyTable(frame.args))
return extractEntityFromInput(eidArg, true), nextIndex
end
end
 
function p._qualifier(args)
loadSubmodules()
return valueCommand(args, p.commands.qualifier)
end
 
function p.qualifiers(frame)
loadSubmodules(frame)
return p._qualifiers(copyTable(frame.args))
end
 
function p._qualifiers(args)
loadSubmodules()
return valueCommand(args, p.commands.qualifiers)
end
 
function p.reference(frame)
loadSubmodules(frame)
return p._reference(copyTable(frame.args))
end
 
function p._reference(args)
loadSubmodules()
return valueCommand(args, p.commands.reference)
end
 
function p.references(frame)
loadSubmodules(frame)
return p._references(copyTable(frame.args))
end
 
function p._references(args)
loadSubmodules()
return valueCommand(args, p.commands.references)
end
end


2,113行目: 2,058行目:
local hooks = {count = 0}
local hooks = {count = 0}
local nextArg = args[1]
local nextIndex = 1
local nextIndex = 2
-- process flags and commands
-- process flags and commands
while _:processFlagOrCommand(nextArg) do
while _:processFlagOrCommand(args[nextIndex]) do
nextArg = args[nextIndex]
nextIndex = nextIndex + 1
nextIndex = nextIndex + 1
end
end
if nextArg then
_.entityID, nextIndex = extractEntityFromArgs(args, nextIndex, false)
nextArg = mw.text.trim(nextArg)
else
-- if eid was expliclty set to empty, then this returns an empty string
nextArg = ""
if _.entityID == nil then
return ""
end
end
-- check for optional entity ID of either item or property
_.entity = mw.wikibase.getEntity(_.entityID)
if nextArg:sub(1,1):upper() == "Q" then
_.propertyID = replaceAlias(args[nextIndex]):upper()
_.entityID = nextArg:upper()  -- entity ID of an item was given
nextIndex = nextIndex + 1
_.entity = mw.wikibase.getEntity(_.entityID) -- get the item-entity based on the given ID
_.propertyID = mw.text.trim(args[nextIndex] or "")  -- property ID
if _.states.qualifiersCount > 0 then
nextIndex = nextIndex + 1
-- do further processing if "qualifier(s)" command was given
elseif nextArg:sub(1,9):lower() == "property:" then
_.entityID = replaceAlias(mw.text.trim(nextArg:sub(10))):upper() -- entity ID of a property was given
_.entity = mw.wikibase.getEntity(_.entityID)  -- get the property-entity based on the given ID
_.propertyID = mw.text.trim(args[nextIndex] or "")  -- property ID
nextIndex = nextIndex + 1
else
-- no positional entity ID was given, so get entity ID from 'eid' if it was given
if args[p.args.eid] then
if args[p.args.eid]:sub(1,1):upper() == "Q" then
_.entityID = args[p.args.eid]:upper() 
elseif args[p.args.eid]:sub(1,9):lower() == "property:" then
_.entityID = replaceAlias(mw.text.trim(args[p.args.eid]:sub(10))):upper()
else
-- might be entity ID of a property, or a bogus entity ID that will fail later on
_.entityID = replaceAlias(args[p.args.eid]):upper()
if _.entityID == "" then
-- explicitly return if value for 'eid' is empty
return ""
end
end
else
_.entityID = mw.wikibase.getEntityIdForCurrentPage()  -- by default, use item-entity connected to current page
end
_.entity = mw.wikibase.getEntity(_.entityID)
_.propertyID = nextArg  -- property ID
end
-- check if given property ID is an alias
_.propertyID = replaceAlias(_.propertyID):upper()
if _.states.qualifiersCount > 0 then
-- do further processing if "qualifier(s)" command was given
if #args - nextIndex + 1 > _.states.qualifiersCount then
if #args - nextIndex + 1 > _.states.qualifiersCount then
2,177行目: 2,087行目:
for i = 1, _.states.qualifiersCount do
for i = 1, _.states.qualifiersCount do
nextArg = mw.text.trim(args[nextIndex] or "") -- is a qualifierID
-- check if given qualifier ID is an alias and add it
_.qualifierIDs[parameters.qualifier..i] = replaceAlias(mw.text.trim(args[nextIndex] or "")):upper()
nextIndex = nextIndex + 1
nextIndex = nextIndex + 1
-- check if given qualifier ID is an alias and add it
_.qualifierIDs[parameters.qualifier..i] = replaceAlias(nextArg):upper()
end
end
elseif _.states[parameters.reference] then
elseif _.states[parameters.reference] then
-- do further processing if "reference(s)" command was given
-- do further processing if "reference(s)" command was given
nextArg = args[nextIndex] -- claim ID or literal value (possibly nil)
if args[nextIndex] then
nextIndex = nextIndex + 1
_.propertyValue = mw.text.trim(args[nextIndex])
if nextArg then
_.propertyValue = mw.text.trim(nextArg)
end
end
-- not incrementing nextIndex because it is never used after this
end
end
2,283行目: 2,189行目:
-- must come AFTER defining the hooks
-- must come AFTER defining the hooks
if _.sourcedOnly and not _.states[parameters.reference] then
if _.sourcedOnly and not _.states[parameters.reference] then
_:processFlagOrCommand(p.commands.reference)  -- use singular "reference" to minimize overhead
_:processFlagOrCommand(p.valueCommands.reference)  -- use singular "reference" to minimize overhead
end
end
2,325行目: 2,231行目:
return ""
return ""
end
end
end
function p.label(frame)
loadSubmodules(frame)
return p._label(copyTable(frame.args))
end
function p._label(args)
loadSubmodules()
return nameCommand(args, p.commands.label)
end
function p.title(frame)
loadSubmodules(frame)
return p._title(copyTable(frame.args))
end
function p._title(args)
loadSubmodules()
return nameCommand(args, p.commands.title)
end
function p.alias(frame)
loadSubmodules(frame)
return p._alias(copyTable(frame.args))
end
function p._alias(args)
loadSubmodules()
return nameCommand(args, p.commands.alias)
end
function p.aliases(frame)
loadSubmodules(frame)
return p._aliases(copyTable(frame.args))
end
function p._aliases(args)
loadSubmodules()
return nameCommand(args, p.commands.aliases)
end
end


2,371行目: 2,237行目:
_.curState = State.new(_)
_.curState = State.new(_)
local ID = nil
local value = nil
local value = nil
local nextIndex = 1
local nextArg = args[1]
while _:processFlag(args[nextIndex]) do
local nextIndex = 2
while _:processFlag(nextArg) do
nextArg = args[nextIndex]
nextIndex = nextIndex + 1
nextIndex = nextIndex + 1
end
end
if nextArg then
_.entityID, nextIndex = extractEntityFromArgs(args, nextIndex, true)
nextArg = mw.text.trim(nextArg)
else
nextArg = ""
end
-- check for optional entity ID of either item or property
-- if eid was expliclty set to empty, then this returns an empty string
if nextArg:sub(1,1):upper() == "Q" then
if _.entityID == nil then
ID = nextArg:upper()  -- entity ID of an item was given
return ""
elseif nextArg:sub(1,9):lower() == "property:" then
ID = replaceAlias(mw.text.trim(nextArg:sub(10))):upper()  -- entity ID of a property was given
else
-- might be entity ID of a property, or a bogus entity ID that will fail later on
ID = replaceAlias(nextArg):upper()
if ID:sub(1,1) ~= "P" then
if ID == "" then
-- no positional entity ID was given, so get entity ID from 'eid' if it was given
if args[p.args.eid] then
if args[p.args.eid]:sub(1,1):upper() == "Q" then
ID = args[p.args.eid]:upper() 
elseif args[p.args.eid]:sub(1,9):lower() == "property:" then
ID = replaceAlias(mw.text.trim(args[p.args.eid]:sub(10))):upper()
else
-- might be entity ID of a property, or a bogus entity ID that will fail later on
ID = replaceAlias(args[p.args.eid]):upper()
if ID == "" then
-- explicitly return if value for 'eid' is empty
return ""
end
end
else
ID = nil
end
end
end
end
if ID then
_.entityID = ID
else
_.entityID = mw.wikibase.getEntityIdForCurrentPage()
end
end
-- serve according to the given command
-- serve according to the given command
if funcName == p.commands.label then
if funcName == p.nameCommands.label then
value = _:getLabel(ID, _.curState.rawValue, _.curState.linked, _.curState.shortName)
value = _:getLabel(_.entityID, _.curState.rawValue, _.curState.linked, _.curState.shortName)
elseif funcName == p.commands.title then
elseif funcName == p.nameCommands.title then
_.pageTitle = true
_.pageTitle = true
if not ID then
if _.entityID:sub(1,1) == "Q" then
value = mw.title.getCurrentTitle().prefixedText
value = mw.wikibase.sitelink(_.entityID)
elseif ID:sub(1,1) == "Q" then
value = mw.wikibase.sitelink(ID)
end
end
2,442行目: 2,264行目:
value = buildWikilink(value)
value = buildWikilink(value)
end
end
elseif funcName == p.commands.alias or funcName == p.commands.aliases then
elseif funcName == p.nameCommands.alias or funcName == p.nameCommands.aliases then
local aliases, parsedFormat, formatParams, sep
local aliases, parsedFormat, formatParams, sep
local hooks = {count = 0}
local hooks = {count = 0}
if funcName == p.commands.alias then
if funcName == p.nameCommands.alias then
_.curState.singleValue = true
_.curState.singleValue = true
end
end
2,484行目: 2,306行目:
_.curState.puncMark = _.separators["punc"]
_.curState.puncMark = _.separators["punc"]
_.entity = mw.wikibase.getEntity(ID)
_.entity = mw.wikibase.getEntity(_.entityID)
if _.entity and _.entity.aliases then aliases = _.entity.aliases[_.langCode] end
if _.entity and _.entity.aliases then aliases = _.entity.aliases[_.langCode] end
2,501行目: 2,323行目:
return value
return value
end
end
-- modules that include this module should call the functions with an underscore prepended, e.g.: p._property(args)
function establishCommands(commandList, commandFunc)
for commandIndex, commandName in pairs(commandList) do
local function wikitextWrapper(frame)
loadSubmodules(frame)
return commandFunc(copyTable(frame.args), commandName)
end
p[commandName] = wikitextWrapper
local function luaWrapper(args)
loadSubmodules()
return commandFunc(args, commandName)
end
p["_" .. commandName] = luaWrapper
end
end
establishCommands(p.valueCommands, valueCommand)
establishCommands(p.nameCommands, nameCommand)


-- main function that is supposed to be used by wrapper templates
-- main function that is supposed to be used by wrapper templates
匿名利用者