Модуль:Wikidata: відмінності між версіями
[неперевірена версія] | [перевірена версія] |
Вилучено вміст Додано вміст
Немає опису редагування |
м Відкинуто редагування AlexKozur (обговорення) до зробленого 89.67.88.153 Мітка: Відкіт |
||
Рядок 1:
-- settings, may differ from project to project
local fileDefaultSize = '267x400px';
local outputReferences = true;
Рядок 678 ⟶ 676:
return ''
else
local globe =
-- TODO: round seconds with precision
local coord = '{{coord'
if (value['precision'] == nil) or (value['precision'] < 1/60) then -- по умолчанию с точностью до секунды
Рядок 718 ⟶ 717:
end
--[[
]]
function formatCommonsMedia( value, options )
local image =
if options['border'] and options['border'] ~= '' then▼
image = image .. '|border'▼
end▼
if options[ 'caption' ]
caption = options[ 'caption' ];
if not string.match( size, 'px$' )▼
and not string.match( size, 'пкс$' ) -- TODO: использовать перевод для языка вики ▼
then▼
size = size .. 'px'▼
if caption ~= '' then
end▼
caption = '<span data-wikidata-qualifier-id="P2096" style="display:block">' .. caption .. '</span>';
else▼
size = fileDefaultSize;▼
image = image .. '|' .. size;▼
if not string.find( value, '[%[%]%{%}]' ) then
▲ if options[ 'alt' ] and options[ 'alt' ] ~= '' then
if size and size ~= '' then
▲ image = image .. '<br>' .. options['description']
▲ then
else
▲ size = fileDefaultSize;
if options[ 'alt' ] and options[ 'alt' ] ~= '' then
image = image .. '|' .. options[ 'alt' ];
end
if caption ~= '' then
image = image .. '<br>' .. caption;
end
▲ else
image = image .. caption .. getCategoryByCode( 'media-contains-markup' );
end
end
Рядок 819 ⟶ 834:
--[[
Функція для оформлення числових значень
Приймає: об'єкт-значення і таблицю параметрів,
Повертає: рядок оформленого тексту
]]
local function formatQuantity( value, options )
-- діапазон значень
local amount = string.gsub( value['amount'], '^%+', '' );
local lang = mw.language.getContentLanguage();
Рядок 842 ⟶ 857:
local diff = tonumber( value.upperBound ) - tonumber( amount )
if diff > 0 then -- временная провека, пока у большинства значений не будет убрано ±0
out = out .. '
end
end
Рядок 916 ⟶ 931:
return propertyEntity.datatype;
end
local function formatLangRefs( options )
local langRefs = ''
if ( options.qualifiers and options.qualifiers.P407 ) then
for i, qualifier in pairs( options.qualifiers.P407 ) do
if ( qualifier
and qualifier.datavalue
and qualifier.datavalue.type == 'wikibase-entityid' ) then
local langRefEntity = getEntityFromId( qualifier.datavalue.value.id )
if ( langRefEntity and langRefEntity.claims ) then
local langRefCodeClaims = WDS.filter( langRefEntity.claims, 'P218' )
if langRefCodeClaims then
for _, claim in pairs( langRefCodeClaims ) do
if ( claim.mainsnak
and claim.mainsnak
and claim.mainsnak.datavalue
and claim.mainsnak.datavalue.type == 'string' ) then
local langRefCode = claim.mainsnak.datavalue.value
langRefs = langRefs .. '​' .. options.frame:expandTemplate{ title = 'ref-' ..langRefCode }
end
end
end
end
end
end
end
return langRefs
end
Рядок 1079 ⟶ 1123:
-- сообщение об отсутвии локализованного названия
-- not good, but better than nothing
return '[[d:' .. entityId .. '|' .. entityId .. ']]<span style="border-bottom: 1px dotted; cursor: help; white-space: nowrap" title="вікідані не мають української назви елемента. Ви можете помогти, вказавши її.">?</span>'
end
Рядок 1225 ⟶ 1269:
-- обробка за типом значення
local datatype = getPropertyDatatype( propertyId );
if
local func = getUserFunction( args, 'value' );
value = func( {}, args, value );
elseif datatype == 'commonsMedia' and not string.find( value, '[%[%]%{%}]' ) then
value = formatCommonsMedia( value, args );
elseif datatype == 'math' then
Рядок 1236 ⟶ 1283:
value = moduleUrl.formatUrlSingle( nil, args, value );
end
▲ end
-- оборачиваем в тег для JS-функций
if string.match( propertyId, '^P%d+$' ) then
Рядок 1257 ⟶ 1299:
end
end
|