66 647
contributi
(Additional semantic properties for character) |
(Link alla stagione) |
||
(28 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 1: | Riga 1: | ||
-- Keyword: wikitrek | -- Keyword: wikitrek | ||
local LabelOrLink = require('Modulo:DTBase').LabelOrLink | local LabelOrLink = require('Modulo:DTBase').LabelOrLink | ||
local DescrWithTemplate = require('Modulo:DTGenerico').DescrWithTemplate | |||
local p = {} | local p = {} | ||
Riga 12: | Riga 13: | ||
end | end | ||
if | if AddSemantic == nil then | ||
AddSemantic = true | AddSemantic = true | ||
end | end | ||
Riga 29: | Riga 30: | ||
-- mw.wikibase.getSitelink(actorQ) | -- mw.wikibase.getSitelink(actorQ) | ||
local actorLabel = mw.wikibase.getLabel(actorQ) | local actorLabel = mw.wikibase.getLabel(actorQ) | ||
local actorLink = mw.wikibase.getSitelink(actorQ) or "Special:AboutTopic/" .. actorQ | |||
local CharQ | local CharQ | ||
Riga 47: | Riga 49: | ||
end]==] | end]==] | ||
CharLink = mw.wikibase.getSitelink(CharQ) or CharLabelEntity | --CharLink = mw.wikibase.getSitelink(CharQ) or CharLabelEntity | ||
CharLink = mw.wikibase.getSitelink(CharQ) or "Special:AboutTopic/" .. CharQ | |||
MakeWikiLink = true | MakeWikiLink = true | ||
else | else | ||
Riga 88: | Riga 91: | ||
{{#set:|Keyla Detmer=Emily Coutts}} | {{#set:|Keyla Detmer=Emily Coutts}} | ||
]=] | ]=] | ||
--Character | |||
if MakeWikiLink then | if MakeWikiLink then | ||
if AddSemantic then | if AddSemantic then | ||
Result['Character'] = Prefix .. '[[ | if string.sub(CharLink, 1, 8) == "Special:" then | ||
Result['Character'] = Prefix .. '[[' .. CharLink .. '|' .. CharLabel .. ']]' .. Suffix .. frame:callParserFunction('#set:', 'Personaggio=' .. CharLabel) | |||
else | |||
Result['Character'] = Prefix .. '[[' .. CharLink .. '|' .. CharLabel .. ']]' .. Suffix .. frame:callParserFunction('#set:', 'Personaggio=' .. CharLink) | |||
end | |||
else | else | ||
Result['Character'] = Prefix .. '[[' .. CharLink .. '|' .. CharLabel .. ']]' .. Suffix | Result['Character'] = Prefix .. '[[' .. CharLink .. '|' .. CharLabel .. ']]' .. Suffix | ||
Riga 98: | Riga 106: | ||
end | end | ||
--Actor | |||
if AddSemantic then | if AddSemantic then | ||
--Result['Actor'] = '[[Interprete::' .. actorLabel .. ']]' .. frame:callParserFunction('#set:', actorLabel .. '=' .. CharLabel) | --Result['Actor'] = '[[Interprete::' .. actorLabel .. ']]' .. frame:callParserFunction('#set:', actorLabel .. '=' .. CharLabel) | ||
Result['Actor'] = '[[ | if string.sub(CharLink, 1, 8) == "Special:" then | ||
Result['Actor'] = '[[' .. actorLink .. '|' .. actorLabel .. ']]' .. frame:callParserFunction('#set:', actorLabel .. '=' .. CharLabel) .. frame:callParserFunction('#set:', 'Interprete=' .. actorLabel) | |||
else | |||
Result['Actor'] = '[[' .. actorLink .. '|' .. actorLabel .. ']]' .. frame:callParserFunction('#set:', actorLabel .. '=' .. CharLink) .. frame:callParserFunction('#set:', 'Interprete=' .. actorLabel) | |||
end | |||
else | else | ||
Result['Actor'] = '[[' .. actorLabel .. ']]' | Result['Actor'] = '[[' .. actorLink .. '|' .. actorLabel .. ']]' | ||
end | end | ||
Result['Type'] = AppearanceType | Result['Type'] = AppearanceType | ||
Riga 113: | Riga 126: | ||
local CurrItem = mw.wikibase.getEntityIdForCurrentPage() | local CurrItem = mw.wikibase.getEntityIdForCurrentPage() | ||
if not CurrItem then | if not CurrItem then | ||
return nil | |||
end | end | ||
Riga 122: | Riga 135: | ||
local Results = {} | local Results = {} | ||
local Statements = mw.wikibase.getAllStatements(CurrItem, 'P2') | local Statements = mw.wikibase.getAllStatements(CurrItem, 'P2') | ||
if #Statements == 0 then | |||
return nil | |||
end | |||
for _, Statement in pairs(Statements) do | for _, Statement in pairs(Statements) do | ||
local Result | local Result | ||
Riga 238: | Riga 256: | ||
end | end | ||
Result['SeasonNumber'] = string.format('%u', Item | Result['SeasonNumber'] = string.format('%u', Item.claims['P18'][1].mainsnak.datavalue.value.amount) | ||
if Item.claims['P16'] then | |||
SeriesQ = Item.claims['P16'][1].mainsnak.datavalue.value.id | |||
else | |||
SeriesQ = mw.wikibase.getEntity(Item.claims['P14'][1].mainsnak.datavalue.value.id).claims['P16'][1].mainsnak.datavalue.value.id | |||
end | |||
Result['SeriesName'] = mw.wikibase.getLabel(SeriesQ) | Result['SeriesName'] = mw.wikibase.getLabel(SeriesQ) | ||
Result['FileName'] = mw.wikibase.getEntity(SeriesQ)['claims']['P3'][1] | Result['FileName'] = mw.wikibase.getEntity(SeriesQ)['claims']['P3'][1].mainsnak.datavalue.value | ||
Result['SeriesAbbr'] = mw.wikibase.getEntity(SeriesQ)['claims']['P24'][1] | Result['SeriesAbbr'] = mw.wikibase.getEntity(SeriesQ)['claims']['P24'][1].mainsnak.datavalue.value | ||
return Result | return Result | ||
Riga 266: | Riga 289: | ||
--return frame:expandTemplate{ title = 'DataBoxEpisodio' } .. string.char(10) .. "[[" .. mw.title.getCurrentTitle().text .. "]] è un episodio della stagione " .. SeasonData.SeasonNumber .. " di ''[[" .. SeasonData.SeriesName .. "]]''." .. string.char(10) | --return frame:expandTemplate{ title = 'DataBoxEpisodio' } .. string.char(10) .. "[[" .. mw.title.getCurrentTitle().text .. "]] è un episodio della stagione " .. SeasonData.SeasonNumber .. " di ''[[" .. SeasonData.SeriesName .. "]]''." .. string.char(10) | ||
return "[[" .. mw.title.getCurrentTitle().text .. "]] è un episodio della stagione " .. SeasonData.SeasonNumber .. " di ''[[" .. SeasonData.SeriesName .. "]]''." .. string.char(10) | return "[[" .. mw.title.getCurrentTitle().text .. "]] è un episodio della stagione " .. SeasonData.SeasonNumber .. " di ''[[" .. SeasonData.SeriesName .. "]]''." .. string.char(10) | ||
end | |||
function p.IncipitTree(frame) | |||
local SeasonData = p.SeasonInfoRaw() | |||
mw.smw.set("Serie=" .. SeasonData.SeriesName) | |||
mw.smw.set("Istanza=Episodio di " .. SeasonData.SeriesAbbr) | |||
mw.smw.set("Stagione=" .. SeasonData.SeasonNumber) | |||
if not mw.wikibase.getDescription() then | |||
if not mw.wikibase.getEntity().claims['P20'] then | |||
return "'''''" .. mw.title.getCurrentTitle().text .. "''''' è un episodio della [[Stagione " .. SeasonData.SeasonNumber .. " di " .. SeasonData.SeriesAbbr .. "|stagione " .. SeasonData.SeasonNumber .. "]] di ''[[" .. SeasonData.SeriesName .. "]]''." .. string.char(10) | |||
else | |||
return "''''" .. mw.title.getCurrentTitle().text .. "'''' è " .. mw.wikibase.getEntity().claims['P20'][1].mainsnak.datavalue['value'] .. string.char(10) | |||
end | |||
else | |||
--return "'''''" .. mw.title.getCurrentTitle().text .. "'''''" .. " è " .. mw.wikibase.getDescription() .. string.char(10) | |||
return "'''''" .. mw.title.getCurrentTitle().text .. "'''''" .. " è " .. DescrWithTemplate(frame) .. string.char(10) | |||
end | |||
end | end | ||
return p | return p |