Модуль:HF/Infobox/Jutsu: различия между версиями
Перейти к навигации
Перейти к поиску
[непроверенная версия] | [непроверенная версия] |
Нет описания правки |
Нет описания правки |
||
Строка 1: | Строка 1: | ||
local Infobox = {} | local Infobox = {} | ||
------------------------------------- | |||
------------------------------------ | -- Библиотеки и глобальные функции -- | ||
-- | ------------------------------------- | ||
------------------------------------ | -- "Высокочастотные" функции | ||
-- " | |||
local HF = require('Module:HF') | local HF = require('Module:HF') | ||
-- | -- Анализирует параметры вызова и шаблона, урезает пробелы и удаляет пробелы. | ||
local getArgs = require('Module:Arguments').getArgs | local getArgs = require('Module:Arguments').getArgs | ||
-- | -- Формирует списки | ||
local L = require('Module:List') | local L = require('Module:List') | ||
-- | -- Языковые функции | ||
local language = mw.language.new('ru') | local language = mw.language.new('ru') | ||
-- | -- Вспомогательные функции (локальные, чтобы не беспокоиться о пространствах имен) | ||
local arraymap = require('Module:HF/Infobox').arraymap | local arraymap = require('Module:HF/Infobox').arraymap | ||
local arrayTable = require('Module:HF/Infobox').arrayTable | local arrayTable = require('Module:HF/Infobox').arrayTable | ||
Строка 19: | Строка 18: | ||
local extra1 = require('Module:HF/Infobox').extra1 | local extra1 = require('Module:HF/Infobox').extra1 | ||
-- | -- Заголовок страницы любой страницы, вызывающей функцию | ||
local pageTitle = mw.title.getCurrentTitle().text | local pageTitle = mw.title.getCurrentTitle().text | ||
-- | -- Полезные константы | ||
local stripLinkToTarget = '^%[*([^%[|]*)|?' | local stripLinkToTarget = '^%[*([^%[|]*)|?' | ||
local stripPageTitleToBase = "[^(]*" | local stripPageTitleToBase = "[^(]*" | ||
Строка 28: | Строка 27: | ||
local extra1pattern = '^[^~]*~([^~]*)' | local extra1pattern = '^[^~]*~([^~]*)' | ||
------------------------------------------------ | ------------------------------------------------------------- | ||
-- | -- Локальные функции (используются только в данном модуле) -- | ||
------------------------------------------------ | ------------------------------------------------------------- | ||
-- Replaces {{IsUnnamed}} | -- Replaces {{IsUnnamed}} | ||
local function nameCheck ( target ) | local function nameCheck ( target ) | ||
Строка 54: | Строка 53: | ||
if mw.title.getCurrentTitle().isContentPage == true then | if mw.title.getCurrentTitle().isContentPage == true then | ||
table.insert( out, HF.Category('Дзюцу') ) | table.insert( out, HF.Category('Дзюцу') ) | ||
--local _editFormURL = mw.html.create('span') | |||
if args[' | -- :css('float','right'):css('font-size','x-small') | ||
-- :wikitext( HF.Link('Special:FormEdit/Jutsu/' .. pageTitle, 'edit') ):allDone() | |||
--local editFormURL = tostring(_editFormURL) | |||
if args['english'] then | |||
mw.smw.set { | mw.smw.set { | ||
['Название'] = args['название'], | ['Название'] = args['название'], | ||
Строка 61: | Строка 63: | ||
} | } | ||
end | end | ||
-- Название кандзи | |||
if args['кандзи'] then | if args['кандзи'] then | ||
mw.smw.set { | mw.smw.set { | ||
['Кандзи'] = args['кандзи'], | ['Кандзи'] = args['кандзи'], | ||
['Названия'] = args[' | ['Названия'] = args['kanji'] | ||
} | } | ||
else | else | ||
mw.smw.set { ['Обслуживание'] = 'Кандзи' } | mw.smw.set { ['Обслуживание'] = 'Кандзи' } | ||
end | end | ||
--Название киридзи | |||
if args['киридзи'] then | if args['киридзи'] then | ||
mw.smw.set{ | mw.smw.set{ | ||
Строка 76: | Строка 80: | ||
} | } | ||
end | end | ||
if args[' | |||
local teams = mw.text.split( args[' | if args['команды'] then | ||
local teams = mw.text.split( args['команды'], ',%s*' ) | |||
for _, v in ipairs(teams) do | for _, v in ipairs(teams) do | ||
mw.smw.set{ ['Команда'] = mw.text.trim(v) } | mw.smw.set{ ['Команда'] = mw.text.trim(v) } | ||
end | end | ||
end | end | ||
if args['изображение'] then | if args['изображение'] then | ||
local images = mw.text.split( args['изображение'], '\n') | local images = mw.text.split( args['изображение'], '\n') | ||
Строка 92: | Строка 98: | ||
mw.smw.set{ ['Обслуживание'] = 'Отсутствующее изображение' } | mw.smw.set{ ['Обслуживание'] = 'Отсутствующее изображение' } | ||
end | end | ||
if args['безымянное дзюцу'] == 'Да' then | if args['безымянное дзюцу'] == 'Да' then | ||
mw.smw.set{ ['Обслуживание'] = 'Название' } | mw.smw.set{ ['Обслуживание'] = 'Название' } | ||
table.insert( out, ( | table.insert( out, (''%s''):format( pageTitle:match("[^(]*") ) ) | ||
else | else | ||
table.insert( out, pageTitle:match("[^(]*") ) | table.insert( out, pageTitle:match("[^(]*") ) | ||
end | end | ||
--local popup = frame:newParserValue( | |||
-- "{{#queryformlink:form=Image query|link text=" .. | |||
-- "[[File:Camera font awesome.svg|15px|link=]]" .. | |||
-- "|query string=Image_query[jutsu]=" .. pageTitle .. | |||
-- "&_run|wpRunQuery=true|popup|tooltip=Images of " .. pageTitle .. " }}" | |||
--) | |||
--return table.concat( out ) .. popup:expand() .. ( args['ref'] or '' ) .. editFormURL | |||
return table.concat( out ) .. ( args['ref'] or '' ) | return table.concat( out ) .. ( args['ref'] or '' ) | ||
elseif mw.title.getCurrentTitle().namespace == 10 | elseif mw.title.getCurrentTitle().namespace == 10 | ||
Строка 108: | Строка 123: | ||
table.insert( out, args['название'] or pageTitle:match("[^(]*") ) | table.insert( out, args['название'] or pageTitle:match("[^(]*") ) | ||
end | end | ||
return table.concat( out ) .. ( args['ref'] or '' ) | return table.concat( out ) .. ( args['ref'] or '' ) | ||
end | end | ||
Строка 117: | Строка 133: | ||
type(args['классификация дзюцу']) == 'string' | type(args['классификация дзюцу']) == 'string' | ||
and mw.text.split( args['классификация дзюцу'], ',%s*' ) | and mw.text.split( args['классификация дзюцу'], ',%s*' ) | ||
if type(classifications) == 'table' then | if type(classifications) == 'table' then | ||
local out = {} | local out = {} | ||
local icons = {} | local icons = {} | ||
local kekkei = { | local kekkei = { | ||
[' | ['кэккэй мора'] = true, | ||
[' | ['кэккэй тота'] = true, | ||
[' | ['кэккэй гэнкай'] = true | ||
} | } | ||
for _,classification in ipairs(classifications) do | for _,classification in ipairs(classifications) do | ||
Строка 130: | Строка 147: | ||
local options = { | local options = { | ||
['SemanticPropertyName'] = 'Клан', | ['SemanticPropertyName'] = 'Клан', | ||
['PrependText'] = 'Клан | ['PrependText'] = 'Клан', | ||
['PrependTemplate'] = 'Карточка/Наруто/Значки', | ['PrependTemplate'] = 'Карточка/Наруто/Значки', | ||
['Print'] = 'none', | ['Print'] = 'none', | ||
Строка 163: | Строка 180: | ||
local options = { | local options = { | ||
['SemanticPropertyName'] = 'Природа чакры', | ['SemanticPropertyName'] = 'Природа чакры', | ||
['PrependText'] = ' | ['PrependText'] = 'Стихия', | ||
['PrependTemplate'] = 'Карточка/Наруто/Значки', | ['PrependTemplate'] = 'Карточка/Наруто/Значки', | ||
['Link'] = 'default' | ['Link'] = 'default' | ||
Строка 176: | Строка 193: | ||
local out = {} | local out = {} | ||
for _, v in ipairs( array ) do | for _, v in ipairs( array ) do | ||
table.insert( out , HF.Link('Ранг дзюцу::'..v, v..'- | table.insert( out , HF.Link('Ранг дзюцу::'..v, v..'-ранг') ) | ||
end | end | ||
return table.concat( out, ',' ) | return table.concat( out, ',' ) | ||
Строка 196: | Строка 213: | ||
['Короткий'] = 'Короткий диапазон (0-5м)', | ['Короткий'] = 'Короткий диапазон (0-5м)', | ||
['Средний'] = 'Средний диапазон (5-10м)', | ['Средний'] = 'Средний диапазон (5-10м)', | ||
['Длинный'] = ' | ['Длинный'] = 'Длинный диапазон (10м+)', | ||
['Короткий, Средний, Длинный'] = 'Все диапазоны', | ['Короткий, Средний, Длинный'] = 'Все диапазоны', | ||
['Короткий, Средний'] = 'Короткий | ['Короткий, Средний'] = 'Короткий в Средний диапазон (0-10м)', | ||
['Средний, Длинный'] = 'Средний | ['Средний, Длинный'] = 'Средний в Длинный диапазон (5м+)', | ||
['Короткий, Длинный'] = 'Короткий или | ['Короткий, Длинный'] = 'Короткий или Длинный диапазон (0-5м или 10м+)' | ||
} | } | ||
arrayTable ( args['диапазон дзюцу'], ',%s*', { ['SemanticPropertyName'] = 'Диапазон дзюцу' } ) | arrayTable ( args['диапазон дзюцу'], ',%s*', { ['SemanticPropertyName'] = 'Диапазон дзюцу' } ) | ||
return ranges[args['диапазон дзюцу']] or args[' | return ranges[args['диапазон дзюцу']] or args['диапазон дзюцу']..'-диапазон' | ||
end | end | ||
Строка 210: | Строка 227: | ||
local options = { | local options = { | ||
['SemanticPropertyName'] = 'Родительское дзюцу', | ['SemanticPropertyName'] = 'Родительское дзюцу', | ||
['Link'] = ' | ['Link'] = 'Unnamed', | ||
['UnnamedFormat'] = true | ['UnnamedFormat'] = true | ||
} | } | ||
local | local parents = arrayTable ( args['родительское дзюцу'], ',%s*', options ) | ||
return L.makeList( 'unbulleted', | return L.makeList( 'unbulleted', parents ) | ||
end | end | ||
Строка 226: | Строка 243: | ||
} | } | ||
local mq = mw.smw.ask { | local mq = mw.smw.ask { | ||
(HF.Link('Concept:%s')):format( mtypes[args[' | (HF.Link('Concept:%s')):format( mtypes[args['jutsu media']] or 'Дзюцу/Канонический' ), | ||
(HF.Link('Родительское дзюцу::%s')):format( mw.title.getCurrentTitle().prefixedText ), | (HF.Link('Родительское дзюцу::%s')):format( mw.title.getCurrentTitle().prefixedText ), | ||
'?Появляется в', | '?Появляется в', | ||
Строка 239: | Строка 256: | ||
} | } | ||
if type(mq) == 'table' then | if type(mq) == 'table' then | ||
for _, | for _, parent in ipairs(mq) do | ||
local mainlink = | local mainlink = | ||
( | ( | ||
parent['Обслуживание'] == 'Название' | |||
or ( | or ( | ||
type( | type(parent['Обслуживание']) == 'table' | ||
and table.concat( | and table.concat(parent['Обслуживание']):match('Название') | ||
) | ) | ||
) | ) | ||
and ( | and (''%s''):format( | ||
HF.Link( | HF.Link( | ||
parent['main']:match(stripLinkToTarget), | |||
parent['main']:match('%[%[:?([^|]*)|?'):match(stripPageTitleToBase) | |||
) | ) | ||
) | ) | ||
or HF.Link( | or HF.Link( | ||
parent['main']:match(stripLinkToTarget), | |||
parent['main']:match('%[%[:?([^|]*)|?'):match(stripPageTitleToBase) | |||
) | ) | ||
local dq = mw.smw.ask { | local dq = mw.smw.ask { | ||
(HF.Link('Concept:%s')):format( mtypes[args['медиа']] or 'Дзюцу/Канонический' ), | (HF.Link('Concept:%s')):format( mtypes[args['медиа']] or 'Дзюцу/Канонический' ), | ||
(HF.Link('Родительское дзюцу::%s')):format( | (HF.Link('Родительское дзюцу::%s')):format( parent['main']:match(stripLinkToTarget) ), | ||
('userparam=%s'):format( args['медиа'] or 'Аниме, Манга' ), | ('userparam=%s'):format( args['медиа'] or 'Аниме, Манга' ), | ||
'mainlabel=main', | 'mainlabel=main', | ||
Строка 345: | Строка 362: | ||
local puppetry = user:match('~~марионетка~(.*)$') | local puppetry = user:match('~~марионетка~(.*)$') | ||
if puppetry then | if puppetry then | ||
puppetry = (' ( | puppetry = (' (Использование марионеток %s)') | ||
:format(mw.text.listToText(mw.text.split(puppetry, '~'))) | :format(mw.text.listToText(mw.text.split(puppetry, '~'))) | ||
end | end | ||
Строка 379: | Строка 396: | ||
end | end | ||
local Summons = ((#sl > 0) | local Summons = ((#sl > 0) | ||
and ( pageTitle == 'Техника | and ( pageTitle == 'Техника Призыва' or pageTitle == 'Destruction Bug Host Technique' )) | ||
and ( ' (%s)' ):format( table.concat( sl, ", " ) ) | and ( ' (%s)' ):format( table.concat( sl, ", " ) ) | ||
or '' | or '' |
Версия от 00:17, 14 февраля 2021
Этому шаблону не хватает документации. Вы можете помочь проекту, сделав описание шаблона: что он делает, как его использовать, какие параметры он принимает. Это поможет другим использовать его. Для оформления можете воспользоваться {{doc}} или {{doc-inline}}. Не забывайте помещать описание внутрь <noinclude></noinclude>. P.S. Также не забываем про категорию. |
local Infobox = {}
-------------------------------------
-- Библиотеки и глобальные функции --
-------------------------------------
-- "Высокочастотные" функции
local HF = require('Module:HF')
-- Анализирует параметры вызова и шаблона, урезает пробелы и удаляет пробелы.
local getArgs = require('Module:Arguments').getArgs
-- Формирует списки
local L = require('Module:List')
-- Языковые функции
local language = mw.language.new('ru')
-- Вспомогательные функции (локальные, чтобы не беспокоиться о пространствах имен)
local arraymap = require('Module:HF/Infobox').arraymap
local arrayTable = require('Module:HF/Infobox').arrayTable
local base = require('Module:HF/Infobox').base
local extra1 = require('Module:HF/Infobox').extra1
-- Заголовок страницы любой страницы, вызывающей функцию
local pageTitle = mw.title.getCurrentTitle().text
-- Полезные константы
local stripLinkToTarget = '^%[*([^%[|]*)|?'
local stripPageTitleToBase = "[^(]*"
local basepattern = '^[^~]*'
local extra1pattern = '^[^~]*~([^~]*)'
-------------------------------------------------------------
-- Локальные функции (используются только в данном модуле) --
-------------------------------------------------------------
-- Replaces {{IsUnnamed}}
local function nameCheck ( target )
local nq = mw.smw.ask{ HF.Link(target:match(stripLinkToTarget)), '?Обслуживание' }
if type(nq) == 'table'
and (
nq[1]['Обслуживание'] == 'Название'
or (type(nq[1]['Обслуживание']) == 'table' and table.concat(nq[1]['Обслуживание']):match('Название'))
)
then
return true
else return nil
end
end
----------------------------------------------------------
-- Public functions (called from a Template or article) --
----------------------------------------------------------
-- Creates the infobox main title
function Infobox.titleJutsu(frame)
local args = getArgs(frame)
local out = {}
if mw.title.getCurrentTitle().isContentPage == true then
table.insert( out, HF.Category('Дзюцу') )
--local _editFormURL = mw.html.create('span')
-- :css('float','right'):css('font-size','x-small')
-- :wikitext( HF.Link('Special:FormEdit/Jutsu/' .. pageTitle, 'edit') ):allDone()
--local editFormURL = tostring(_editFormURL)
if args['english'] then
mw.smw.set {
['Название'] = args['название'],
['Названия'] = args['название']
}
end
-- Название кандзи
if args['кандзи'] then
mw.smw.set {
['Кандзи'] = args['кандзи'],
['Названия'] = args['kanji']
}
else
mw.smw.set { ['Обслуживание'] = 'Кандзи' }
end
--Название киридзи
if args['киридзи'] then
mw.smw.set{
['Киридзи'] = args['киридзи']:match(stripLinkToTarget),
['Названия'] = args['киридзи']
}
end
if args['команды'] then
local teams = mw.text.split( args['команды'], ',%s*' )
for _, v in ipairs(teams) do
mw.smw.set{ ['Команда'] = mw.text.trim(v) }
end
end
if args['изображение'] then
local images = mw.text.split( args['изображение'], '\n')
for _, image in ipairs(images) do
if type(image) == 'string' then
mw.smw.set{ ['Изображение'] = 'File:' .. image:match("[^:;]*") }
end
end
else
mw.smw.set{ ['Обслуживание'] = 'Отсутствующее изображение' }
end
if args['безымянное дзюцу'] == 'Да' then
mw.smw.set{ ['Обслуживание'] = 'Название' }
table.insert( out, (''%s''):format( pageTitle:match("[^(]*") ) )
else
table.insert( out, pageTitle:match("[^(]*") )
end
--local popup = frame:newParserValue(
-- "{{#queryformlink:form=Image query|link text=" ..
-- "[[File:Camera font awesome.svg|15px|link=]]" ..
-- "|query string=Image_query[jutsu]=" .. pageTitle ..
-- "&_run|wpRunQuery=true|popup|tooltip=Images of " .. pageTitle .. " }}"
--)
--return table.concat( out ) .. popup:expand() .. ( args['ref'] or '' ) .. editFormURL
return table.concat( out ) .. ( args['ref'] or '' )
elseif mw.title.getCurrentTitle().namespace == 10
and not pageTitle:match('/testcases') then
return nil
else
if args['безымянное дзюцу'] == 'Да' then
table.insert( out, ("''%s''"):format( args['название'] or pageTitle:match("[^(]*") ) )
else
table.insert( out, args['название'] or pageTitle:match("[^(]*") )
end
return table.concat( out ) .. ( args['ref'] or '' )
end
end
function Infobox.jutsuClassification(frame)
local args = getArgs(frame)
local classifications =
type(args['классификация дзюцу']) == 'string'
and mw.text.split( args['классификация дзюцу'], ',%s*' )
if type(classifications) == 'table' then
local out = {}
local icons = {}
local kekkei = {
['кэккэй мора'] = true,
['кэккэй тота'] = true,
['кэккэй гэнкай'] = true
}
for _,classification in ipairs(classifications) do
if classification:match(extra1pattern) then
if classification:match(basepattern):lower() == 'hiden' then
local options = {
['SemanticPropertyName'] = 'Клан',
['PrependText'] = 'Клан',
['PrependTemplate'] = 'Карточка/Наруто/Значки',
['Print'] = 'none',
['Link'] = 'default'
}
local clans = arrayTable( classification:match('^[^~]*~(.*)'), '~', options, frame )
table.insert( icons, table.concat( clans ) )
elseif kekkei[classification:match(basepattern):lower()] then
local options = {
['SemanticPropertyName'] = 'Кэккэй Гэнкай',
['PrependText'] = 'Кэккэй Гэнкай',
['PrependTemplate'] = 'Карточка/Наруто/Значки',
['Print'] = 'none',
['Link'] = 'default'
}
local clans = arrayTable( classification:match('^[^~]*~(.*)'), '~', options, frame )
table.insert( icons, table.concat( clans ) )
end
end
if classification:match(basepattern) and #classification > 1 then
mw.smw.set { ['Классификация дзюцу'] = classification:match(basepattern) }
table.insert( out, HF.Link(classification:match(basepattern)) )
end
end
return table.concat( icons ) .. table.concat( out, ', ' )
else return nil
end
end
function Infobox.jutsuType(frame)
local args = getArgs(frame)
local options = {
['SemanticPropertyName'] = 'Природа чакры',
['PrependText'] = 'Стихия',
['PrependTemplate'] = 'Карточка/Наруто/Значки',
['Link'] = 'default'
}
local values = arrayTable ( args['тип дзюцу'], ',%s*', options, frame )
return L.makeList( 'unbulleted' , values )
end
function Infobox.jutsuRank(frame)
local args = getArgs(frame)
local array = mw.text.split( args['ранг дзюцу'], ',' )
local out = {}
for _, v in ipairs( array ) do
table.insert( out , HF.Link('Ранг дзюцу::'..v, v..'-ранг') )
end
return table.concat( out, ',' )
end
function Infobox.jutsuClass(frame)
local args = getArgs(frame)
local options = {
['SemanticPropertyName'] = 'Тип класса дзюцу',
['Link'] = 'none'
}
local classes = arrayTable ( args['тип класса дзюцу'], ',%s*', options, frame )
return table.concat( classes, ', ' )
end
function Infobox.jutsuRange(frame)
local args = getArgs(frame)
local ranges = {
['Короткий'] = 'Короткий диапазон (0-5м)',
['Средний'] = 'Средний диапазон (5-10м)',
['Длинный'] = 'Длинный диапазон (10м+)',
['Короткий, Средний, Длинный'] = 'Все диапазоны',
['Короткий, Средний'] = 'Короткий в Средний диапазон (0-10м)',
['Средний, Длинный'] = 'Средний в Длинный диапазон (5м+)',
['Короткий, Длинный'] = 'Короткий или Длинный диапазон (0-5м или 10м+)'
}
arrayTable ( args['диапазон дзюцу'], ',%s*', { ['SemanticPropertyName'] = 'Диапазон дзюцу' } )
return ranges[args['диапазон дзюцу']] or args['диапазон дзюцу']..'-диапазон'
end
function Infobox.jutsuParent(frame)
local args = getArgs(frame)
local options = {
['SemanticPropertyName'] = 'Родительское дзюцу',
['Link'] = 'Unnamed',
['UnnamedFormat'] = true
}
local parents = arrayTable ( args['родительское дзюцу'], ',%s*', options )
return L.makeList( 'unbulleted', parents )
end
function Infobox.jutsuMedia(frame)
local args = getArgs(frame)
local out = {}
local mtypes = {
['Фильм'] = 'Дзюцу/НеКанонический',
['Игра'] = 'Дзюцу/НеКанонический',
['Игра, Фильм'] = 'Дзюцу/НеКанонический'
}
local mq = mw.smw.ask {
(HF.Link('Concept:%s')):format( mtypes[args['jutsu media']] or 'Дзюцу/Канонический' ),
(HF.Link('Родительское дзюцу::%s')):format( mw.title.getCurrentTitle().prefixedText ),
'?Появляется в',
'?Обслуживание',
('userparam=%s'):format(args['медиа']),
'mainlabel=main',
'limit=200'
}
local hasNCderivatives = mw.smw.ask {
(HF.Link('Concept:%s')):format( 'Дзюцу/НеКанонический' ),
(HF.Link('Родительское дзюцу::%s')):format( mw.title.getCurrentTitle().prefixedText )
}
if type(mq) == 'table' then
for _, parent in ipairs(mq) do
local mainlink =
(
parent['Обслуживание'] == 'Название'
or (
type(parent['Обслуживание']) == 'table'
and table.concat(parent['Обслуживание']):match('Название')
)
)
and (''%s''):format(
HF.Link(
parent['main']:match(stripLinkToTarget),
parent['main']:match('%[%[:?([^|]*)|?'):match(stripPageTitleToBase)
)
)
or HF.Link(
parent['main']:match(stripLinkToTarget),
parent['main']:match('%[%[:?([^|]*)|?'):match(stripPageTitleToBase)
)
local dq = mw.smw.ask {
(HF.Link('Concept:%s')):format( mtypes[args['медиа']] or 'Дзюцу/Канонический' ),
(HF.Link('Родительское дзюцу::%s')):format( parent['main']:match(stripLinkToTarget) ),
('userparam=%s'):format( args['медиа'] or 'Аниме, Манга' ),
'mainlabel=main',
'named args=yes',
'limit=20'
}
local derivatives = {}
if type( dq ) == 'table' then
for _, derived in ipairs(dq) do
local dlink = (
derived['Обслуживание'] == 'Название'
or type(derived['Обслуживание']) == 'table'
and table.concat(derived['Обслуживание']):match('Название')
)
and ("''%s''"):format(
HF.Link(
derived['main']:match(stripLinkToTarget),
derived['main']:match('%[%[:?([^|]*)|?'):match(stripPageTitleToBase)
)
)
or HF.Link(
derived['main']:match(stripLinkToTarget),
derived['main']:match('%[%[:?([^|]*)|?'):match(stripPageTitleToBase)
)
table.insert( derivatives, dlink )
end
table.insert( out, mainlink .. L.makeList( 'bulleted', derivatives ) )
else
table.insert( out, mainlink )
end
end
return L.makeList( 'bulleted', out )
elseif type(hasNCderivatives) == 'table' then
local t =
mw.title.new( 'SearchByProperty', 'Special' ).prefixedText
local q = mw.uri.buildQueryString{
['property'] = 'Родительское дзюцу',
['value'] = mw.uri.encode(
mw.title.getCurrentTitle().prefixedText,
'WIKI'
)
}
local searchlink = HF.ExternalLink(
tostring(mw.uri.fullUrl(t,q)),
'Все производные дзюцу'
)
return ('<center class="smwsearch">%s</center>'):format( searchlink )
end
end
function Infobox.jutsuRelated(frame)
local args = getArgs(frame)
return arraymap( args['родственные дзюцу'], ',%s*', HF.Link('%s'), ', ' )
end
function Infobox.jutsuUsers(frame)
local args = getArgs(frame)
local out = {}
-- Valid media types
local mtypes = {
anime = true, manga = true, novel = true,
game = true, movie = true, ['фильм канон'] = true
}
-- Divides users into actionable items (even if there's only one)
local users = args['пользователи'] and mw.text.split( args['пользователи'], ',%s*' )
-- Checks if any user entries exist, and if they don't, return nil
if type(users) ~= 'table' then return nil end
-- For each user
for _, user in ipairs( users ) do
-- checks if the entry is real or empty
if type(user) == 'string' and #user < 1 then break end
-- separates user name from media
local prime, media = user:match('([^%~]*)%~?([^%~]*)')
local link = HF.Link(
base( prime ):match(stripLinkToTarget),
base( prime ):match(stripLinkToTarget):match(stripPageTitleToBase)
)
link = nameCheck( prime ) == true
and ("''%s''"):format( link )
or link
--- AdditionalInfo
-- Puppetry handling
local puppetry = user:match('~~марионетка~(.*)$')
if puppetry then
puppetry = (' (Использование марионеток %s)')
:format(mw.text.listToText(mw.text.split(puppetry, '~')))
end
-- "with" handling
local with = user:match('~~с~([^%~]*)')
and (' (с %s)'):format(user:match('~~с~([^%~]*)'))
local AdditionalInfo = puppetry or with or ''
--- Media
local Media = ''
if media
and mtypes[media:lower()]
and media:lower() ~= 'фильм канон'
then
Media = ('<sup> (%s)</sup>')
:format( language:ucfirst( media ) )
elseif media
and media:lower() == 'фильм канон'
then
Media = '<sup> (Фильм)</sup>'
end
--- Summons
local cq = mw.smw.ask {
(HF.Link('Контракт::%s')):format( prime:match(stripLinkToTarget) ),
'mainlabel=main'
}
local sl = {}
if type(cq) == 'table' then
for _, v in ipairs( cq ) do
table.insert( sl, v['main'] )
end
end
local Summons = ((#sl > 0)
and ( pageTitle == 'Техника Призыва' or pageTitle == 'Destruction Bug Host Technique' ))
and ( ' (%s)' ):format( table.concat( sl, ", " ) )
or ''
-- SMW set
local setmtype = ( media and mtypes[ media:lower() ] )
and language:ucfirst( media:lower() )
or 'null'
mw.smw.set {
['Пользователи техники'] = prime .. ';' .. setmtype
}
table.insert( out, link .. AdditionalInfo .. Summons .. Media )
end
return L.makeList( 'bulleted', out )
end
---------------------------------------------------------
-- Exported functions (used in this and other Modules) --
---------------------------------------------------------
-- None.
-------------------------------------------------
-- Output (send it back to whatever called it) --
-------------------------------------------------
return Infobox