Módulo:Infobox/Formato de arquivo
Este módulo não apresenta nenhuma documentação. Por favor, documente-o caso o saiba usar ou tenha conhecimentos para tal. |
-- Módulo para mostrar formato de dados
-- Importar os módulos necessários
local wikidata = require( 'Module:Infobox/Wikidata' )
local general = require( 'Module:Infobox/Funções' )
local localdata = require( 'Module:Infobox/Localdata' )
-- Variáveis e funções utilizadas em certas linhas da info caixa
local isContainer = wikidata.isInstance('Q167772', item, 0)
local function specification(number)
if (number == '1') then
return '[[Formato proprietário]] [[Categoria:Formato fechado]]'
elseif (number == '2') then
return '[[Formato aberto]] [[Categoria:Formato aberto]]'
end
return nil
end
local function mostrarHexa(x)
local t = ""
for c in x:gmatch".." do
t = t .. c .. " "
end
return "<code>" .. t:gsub("^%s*(.-)%s*$", "%1") .. "</code> ([[Sistema hexadecimal|hexa]])"
end
local function mostrarAssinatura(value, qual)
if not qual then
return "<code>" .. value .. "</code>"
end
local qualifierId = qual[1].datavalue.value.id
--for k,v in pairs(qual) do
-- qualifierId = v.datavalue.value.id
-- break
--end
if (qualifierId == "Q82828") then
return mostrarHexa(value)
elseif (qualifierId == "Q8815") then
return "<code>" .. value .. "</code> ([[American Standard Code for Information Interchange|ascii]])"
elseif (qualifierId == "Q35432091") then
return "<code>" .. value .. "</code> ([[Base PRONOM|PRONOM]] [[Expressão regular|regex]])"
elseif (qualifierId == "Q125267") then
return "<code>" .. value .. "</code> ([[PCRE|PCRE]])"
elseif (qualifierId == "Q185612") then
return "<code>" .. value .. "</code> ([[Expressão regular|regex]])"
else
return "<code>" .. value .. "</code>"
end
end
-- voir https://fr.wikipedia.org/wiki/Aide:Infobox_en_Lua
return {
maincolor = '#C0C0C0',
parts = {
-- parâmetro 'nome completo' em subtítulo
general.title('computador', nil, 'nome completo'),
general.mainimage('!Artigos sem imagens'),
general.logo(),
{ type = 'table', title = 'Características', rows = {
{ type = 'row',
label = '[[Extensão de nome de ficheiro|Extensão]]',
plurallabel = '[[Extensão de nome de ficheiro|Extensões]]',
value = {'extensão', 'extensao'},
wikidata = {
-- As propriedade e gama são preferidas
entity = item,
property = 'P1195',
rank = 'valid',
conjtype = 'comma',
linkback = 'P1195',
displayformat = function(snak)
return '<code>.' .. snak.datavalue.value .. '</code>'
end,
}
},
{ type = 'row',
label = '[[Compressão de dados|Compressaõ]]',
value = 'compressao',
},
{ type = 'row',
label = 'Cores',
value = 'profundidade_cor',
},
{ type = 'row',
label = 'Espaço de cor',
value = 'espaço_de_cor',
},
{ type = 'row',
label = '[[Licença de Software|Licença]]',
value = 'licença',
},
{ type = 'row',
label = 'Programas',
value = 'programas',
},
{ type = 'row',
label = 'Variantes',
value = 'variantes',
},
{ type = 'row',
label = '[[MIME|Tipo MIME]]',
value = {'mime', '_nomimecode', 'tipo_MIME'},
wikidata = {
property = 'P1163',
separator = ' ',
rank = 'valid',
ucfirst = '-',
displayformat = function(snak)
return '<code> ' .. snak.datavalue.value .. '</code>'
end,
}
},
{ type = 'row',
label = '[[:fr:Base PRONOM|PUID]]',
value = 'puid',
wikidata = {
entity = item, property = 'P2748', excludespecial = true,
conjtype = 'comma',
linkback = 'P2748',
urlpattern = 'https://www.nationalarchives.gov.uk/pronom/$1' -- definido a forma do url para esta propriedade
}
},
{ type = 'row',
label = '[[Número mágico (informática)|Número mágico]]',
plurallabel = '[[Número mágico (informática)|Números mágicos]]',
value = {'assinatura', 'mágica'},
-- Mostrar apenas o tipo de assinatura (P3294)
wikidata = {
property = 'P4152', excludespecial = true, conjtype = '<br />',
linkback = 'P4152',
statementformat = function(statement)
return mostrarAssinatura(statement.mainsnak.datavalue.value, wikidata.getQualifiers(statement, {"P3294"}))
end
}
},
{ type = 'row',
label = 'Desenvolvido por',
value = 'desenvolvedor',
property = 'P178',
},
{ type = 'row',
label = 'Versão inicial',
value = {'versão inicial', 'lançado'},
property = 'P577',
},
{ type = 'row',
label = '[[Liberação de software|Última versão]]',
value = {'última versão lançada', 'última_versão_lançada', 'última_data_de_lançamento'},
},
{ type = 'row',
label = 'Tipo de formato',
value = {'tipo', 'tipo de formato'},
property = 'P136',
},
{ type = 'row',
label = '[[:fr:Format conteneur|Contêiner]] de ficheiros',
value = {'contêiner de', 'arquivador de', 'arquivadode'},
wikidata = {
property = 'P527',
condition = function() return isContainer end,
ucfirst = '-'
}
},
{ type = 'row',
label = '[[:fr:Format conteneur|Contêiner]] para',
value = 'contêiner para',
},
{ type = 'row',
label = 'Extensão de',
value = 'extensão de',
property = 'P144',
},
{ type = 'row',
label = 'Origem de',
value = 'origem de',
},
{ type = 'row',
label = 'Norma',
value = 'norma'
},
{ type = 'row',
label = '[[Organização Internacional de Normalização|ISO]]',
blockers = 'norma', -- para evitar os duplicados esta linha Wikidata está desactivada apenas quando o campo "norma" está informada
property = 'P503'
},
{ type = 'row',
label = 'Especificação',
value = function ( localdata )
return specification(localdata['especificação'] or localdata['especificacao'] )
end,
},
{ type = 'row',
label = 'Características',
value = 'características',
},
general.website(),
} },
}
}