Модуль:HF/Infobox/Jutsu: различия между версиями

Материал из Викимультии — энциклопедии мультипликации
Перейти к навигации Перейти к поиску
[непроверенная версия][непроверенная версия]
Нет описания правки
Нет описания правки
Строка 11: Строка 11:
local L = require('Module:List')
local L = require('Module:List')
-- Language functions
-- Language functions
local language = mw.language.new('en')
local language = mw.language.new('ru')


-- Helper functions (local to not have to worry about namespaces)
-- Helper functions (local to not have to worry about namespaces)
Строка 33: Строка 33:
-- Replaces {{IsUnnamed}}
-- Replaces {{IsUnnamed}}
local function nameCheck ( target )
local function nameCheck ( target )
local nq = mw.smw.ask{ HF.Link(target:match(stripLinkToTarget)), '?Maintenance' }
local nq = mw.smw.ask{ HF.Link(target:match(stripLinkToTarget)), '?Обслуживание' }
if type(nq) == 'table'  
if type(nq) == 'table'  
    and (
    and (
        nq[1]['Maintenance'] == 'Name'
        nq[1]['Обслуживание'] == 'Название'
        or (type(nq[1]['Maintenance']) == 'table' and table.concat(nq[1]['Maintenance']):match('Name'))
        or (type(nq[1]['Обслуживание']) == 'table' and table.concat(nq[1]['Обслуживание']):match('Name'))
    )
    )
         then
         then
Строка 58: Строка 58:
             :wikitext( HF.Link('Special:FormEdit/Jutsu/' .. pageTitle, 'edit') ):allDone()
             :wikitext( HF.Link('Special:FormEdit/Jutsu/' .. pageTitle, 'edit') ):allDone()
local editFormURL = tostring(_editFormURL)
local editFormURL = tostring(_editFormURL)
if args['english'] then
if args['название'] then
mw.smw.set {
mw.smw.set {
['English name'] = args['english'],
['Название'] = args['название'],
['Names'] = args['english']
['Названия'] = args['название']
}
}
end
end
if args['kanji'] then
if args['кандзи'] then
mw.smw.set {
mw.smw.set {
['Kanji name'] = args['kanji'],
['Кандзи'] = args['кандзи'],
['Names'] = args['kanji']
['Названия'] = args['кандзи']
}
}
else
else
mw.smw.set { ['Maintenance'] = 'Kanji' }
mw.smw.set { ['Обслуживание'] = 'Кандзи' }
end
end
if args['romaji'] then
if args['киридзи'] then
mw.smw.set{
mw.smw.set{
['Romaji_name'] = args['romaji']:match(stripLinkToTarget),
['Киридзи'] = args['киридзи']:match(stripLinkToTarget),
['Names'] = args['romaji']
['Названия'] = args['киридзи']
}
}
end
end
if args['teams'] then
if args['команда'] then
local teams = mw.text.split( args['teams'], ',%s*' )
local teams = mw.text.split( args['команда'], ',%s*' )
for _, v in ipairs(teams) do
for _, v in ipairs(teams) do
mw.smw.set{ ['Team'] = mw.text.trim(v) }
mw.smw.set{ ['Команда'] = mw.text.trim(v) }
end
end
end
end
if args['image'] then
if args['изображение'] then
local images = mw.text.split( args['image'], '\n')
local images = mw.text.split( args['изображение'], '\n')
for _, image in ipairs(images) do
for _, image in ipairs(images) do
if type(image) == 'string' then
if type(image) == 'string' then
mw.smw.set{ ['Picture'] = 'File:' .. image:match("[^:;]*") }
mw.smw.set{ ['Изображение'] = 'File:' .. image:match("[^:;]*") }
end
end
end
end
else
else
mw.smw.set{ ['Maintenance'] = 'Missing image' }
mw.smw.set{ ['Обслуживание'] = 'Отсутствующее изображение' }
end
end
if args['unnamed jutsu'] == 'Yes' then
if args['безымянное дзюцу'] == 'Да' then
mw.smw.set{ ['Maintenance'] = 'Name' }
mw.smw.set{ ['Обслуживание'] = 'Название' }
table.insert( out, ("''%s''"):format( pageTitle:match("[^(]*") ) )
table.insert( out, ("''%s''"):format( pageTitle:match("[^(]*") ) )
else
else
Строка 111: Строка 111:
    return nil
    return nil
else
else
if args['unnamed jutsu'] == 'Yes' then
if args['безымянное дзюцу'] == 'Да' then
table.insert( out, ("''%s''"):format( args['english'] or pageTitle:match("[^(]*") ) )
table.insert( out, ("''%s''"):format( args['название'] or pageTitle:match("[^(]*") ) )
else
else
table.insert( out, args['english'] 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 '' )
Строка 123: Строка 123:
local args = getArgs(frame)
local args = getArgs(frame)
local classifications =
local classifications =
type(args['jutsu classification']) == 'string'
type(args['классификация дзюцу']) == 'string'
and mw.text.split( args['jutsu classification'], ',%s*' )
and mw.text.split( args['классификация дзюцу'], ',%s*' )
if type(classifications) == 'table' then
if type(classifications) == 'table' then
local out = {}
local out = {}
Строка 137: Строка 137:
if classification:match(basepattern):lower() == 'hiden' then
if classification:match(basepattern):lower() == 'hiden' then
local options = {
local options = {
['SemanticPropertyName'] = 'Clan',
['SemanticPropertyName'] = 'Клан',
['PrependText'] = 'Ninja clan',
['PrependText'] = 'Клан ниндзя',
['PrependTemplate'] = 'Infobox_icon',
['PrependTemplate'] = 'Infobox_icon',
['Print'] = 'none',
['Print'] = 'none',
Строка 147: Строка 147:
elseif kekkei[classification:match(basepattern):lower()] then
elseif kekkei[classification:match(basepattern):lower()] then
local options = {
local options = {
['SemanticPropertyName'] = 'Kekkei Genkai',
['SemanticPropertyName'] = 'Кэккэй Гэнкай',
['PrependText'] = 'Kekkei Genkai',
['PrependText'] = 'Кэккэй Гэнкай',
['PrependTemplate'] = 'Infobox_icon',
['PrependTemplate'] = 'Infobox_icon',
['Print'] = 'none',
['Print'] = 'none',
Строка 158: Строка 158:
end
end
if classification:match(basepattern) and #classification > 1 then
if classification:match(basepattern) and #classification > 1 then
mw.smw.set { ['Jutsu classification'] = classification:match(basepattern) }
mw.smw.set { ['Классификация дзюцу'] = classification:match(basepattern) }
table.insert( out, HF.Link(classification:match(basepattern)) )
table.insert( out, HF.Link(classification:match(basepattern)) )
end
end
Строка 170: Строка 170:
local args = getArgs(frame)
local args = getArgs(frame)
local options = {
local options = {
['SemanticPropertyName'] = 'Chakra Nature',
['SemanticPropertyName'] = 'Природа чакры',
['PrependText'] = 'Nature',
['PrependText'] = 'Природа',
['PrependTemplate'] = 'Infobox_icon',
['PrependTemplate'] = 'Infobox_icon',
['Link'] = 'default'
['Link'] = 'default'
}
}
local values = arrayTable ( args['jutsu type'], ',%s*', options, frame )
local values = arrayTable ( args['тип дзюцу'], ',%s*', options, frame )
return L.makeList( 'unbulleted' , values )
return L.makeList( 'unbulleted' , values )
end
end
Строка 181: Строка 181:
function Infobox.jutsuRank(frame)
function Infobox.jutsuRank(frame)
local args = getArgs(frame)
local args = getArgs(frame)
local array = mw.text.split( args['jutsu rank'], ',' )
local array = mw.text.split( args['ранг дзюцу'], ',' )
local out = {}
local out = {}
for _, v in ipairs( array ) do
for _, v in ipairs( array ) do
table.insert( out , HF.Link('Jutsu rank::'..v, v..'-rank') )
table.insert( out , HF.Link('Ранг дзюцу::'..v, v..'-rank') )
end
end
return table.concat( out, ',' )
return table.concat( out, ',' )
Строка 192: Строка 192:
local args = getArgs(frame)
local args = getArgs(frame)
local options = {
local options = {
['SemanticPropertyName'] = 'Jutsu class type',
['SemanticPropertyName'] = 'Тип класса дзюцу',
['Link'] = 'none'
['Link'] = 'none'
}
}
local classes = arrayTable ( args['jutsu class type'], ',%s*', options, frame )
local classes = arrayTable ( args['тип класса дзюцу'], ',%s*', options, frame )
return table.concat( classes, ', ' )
return table.concat( classes, ', ' )
end
end
Строка 202: Строка 202:
local args = getArgs(frame)
local args = getArgs(frame)
local ranges = {
local ranges = {
['Short'] = 'Short range (0-5m)',
['Короткий'] = 'Короткий диапазон (0-)',
['Mid'] = 'Mid range (5-10m)',
['Средний'] = 'Средний диапазон (5-10м)',
['Long'] = 'Long range (10m+)',
['Длинный'] = 'Дальность действия (10 м+)',
['Short, Mid, Long'] = 'All ranges',
['Короткий, Средний, Длинный'] = 'Все диапазоны',
['Short, Mid'] = 'Short to Mid range (0-10m)',
['Короткий, Средний'] = 'Короткий и средний диапазон (0-10м)',
['Mid, Long'] = 'Mid to Long range (5m+)',
['Средний, Длинный'] = 'Средний и длинный диапазон (5 м+)',
['Short, Long'] = 'Short or Long range (0-5m or 10m+)'
['Короткий, Длинный'] = 'Короткий или длинный диапазон (0-5м или 10м+)'
}
}
arrayTable ( args['jutsu range'], ',%s*', { ['SemanticPropertyName'] = 'Jutsu range' } )
arrayTable ( args['диапазон дзюцу'], ',%s*', { ['SemanticPropertyName'] = 'Диапазон дзюцу' } )
return ranges[args['jutsu range']] or args['jutsu range']..'-range'
return ranges[args['диапазон дзюцу']] or args['jutsu range']..'-range'
end
end


Строка 217: Строка 217:
local args = getArgs(frame)
local args = getArgs(frame)
local options = {
local options = {
['SemanticPropertyName'] = 'Parent',
['SemanticPropertyName'] = 'Родительское дзюцу',
['Link'] = 'Unnamed',
['Link'] = 'Безымянное',
['UnnamedFormat'] = true
['UnnamedFormat'] = true
}
}
local parents = arrayTable ( args['parent jutsu'], ',%s*', options )
local Parents = arrayTable ( args['родительское дзюцу'], ',%s*', options )
return L.makeList( 'unbulleted', parents )
return L.makeList( 'unbulleted', Parents )
end
end


Строка 229: Строка 229:
local out = {}
local out = {}
local mtypes = {
local mtypes = {
['Movie'] = 'Jutsu/NonCanon',
['Фильм'] = 'Дзюцу/НеКанон',
['Game'] = 'Jutsu/NonCanon',
['Игра'] = 'Дзюцу/НеКанон',
['Game, Movie'] = 'Jutsu/NonCanon'
['Игра, Фильм'] = 'Дзюцу/НеКанон'
}
}
local mq = mw.smw.ask {
local mq = mw.smw.ask {
(HF.Link('Concept:%s')):format( mtypes[args['jutsu media']] or 'Jutsu/Canon' ),
(HF.Link('Concept:%s')):format( mtypes[args['дзюцу медиа']] or 'Дзюцу/Канон' ),
(HF.Link('Parent::%s')):format( mw.title.getCurrentTitle().prefixedText ),
(HF.Link('Родительское дзюцу::%s')):format( mw.title.getCurrentTitle().prefixedText ),
'?Appears in',
'?Появляется в',
'?Maintenance',
'?Обслуживание',
('userparam=%s'):format(args['jutsu media']),
('userparam=%s'):format(args['дзюцу медиа']),
'mainlabel=main',
'mainlabel=main',
'limit=200'
'limit=200'
}
}
local hasNCderivatives = mw.smw.ask {
local hasNCderivatives = mw.smw.ask {
(HF.Link('Concept:%s')):format( 'Jutsu/NonCanon' ),
(HF.Link('Concept:%s')):format( 'Дзюцу/НеКанон' ),
(HF.Link('Parent::%s')):format( mw.title.getCurrentTitle().prefixedText )
(HF.Link('Родительское дзюцу::%s')):format( mw.title.getCurrentTitle().prefixedText )
}
}
if type(mq) == 'table' then
if type(mq) == 'table' then
for _, parent in ipairs(mq) do
for _, Parent in ipairs(mq) do
local mainlink =
local mainlink =
(
(
    parent['Maintenance'] == 'Name'
    Parent['Обслуживание'] == 'Название'
    or (
    or (
        type(parent['Maintenance']) == 'table'
        type(Parent['Обслуживание']) == 'table'
        and table.concat(parent['Maintenance']):match('Name')
        and table.concat(Parent['Обслуживание']):match('Название')
            )
            )
    )
    )
and ("''%s''"):format(
and ("''%s''"):format(
HF.Link(
HF.Link(
parent['main']:match(stripLinkToTarget),
Parent['main']:match(stripLinkToTarget),
parent['main']:match('%[%[:?([^|]*)|?'):match(stripPageTitleToBase)
Parent['main']:match('%[%[:?([^|]*)|?'):match(stripPageTitleToBase)
)
)
)
)
or HF.Link(
or HF.Link(
parent['main']:match(stripLinkToTarget),
Parent['main']:match(stripLinkToTarget),
parent['main']:match('%[%[:?([^|]*)|?'):match(stripPageTitleToBase)
Parent['main']:match('%[%[:?([^|]*)|?'):match(stripPageTitleToBase)
)
)
local dq = mw.smw.ask {
local dq = mw.smw.ask {
(HF.Link('Concept:%s')):format( mtypes[args['jutsu media']] or 'Jutsu/Canon' ),
(HF.Link('Concept:%s')):format( mtypes[args['дзюцу медиа']] or 'Дзюцу/Канон' ),
(HF.Link('Parent::%s')):format( parent['main']:match(stripLinkToTarget) ),
(HF.Link('Родительское дзюцу::%s')):format( Parent['main']:match(stripLinkToTarget) ),
('userparam=%s'):format( args['jutsu media'] or 'Anime, Manga' ),
('userparam=%s'):format( args['дзюцу медиа'] or 'Аниме, Манга' ),
'mainlabel=main',
'mainlabel=main',
'named args=yes',
'named args=yes',
Строка 278: Строка 278:
for _, derived in ipairs(dq) do
for _, derived in ipairs(dq) do
local dlink = (
local dlink = (
    derived['Maintenance'] == 'Name'
    derived['Обслуживание'] == 'Название'
    or type(derived['Maintenance']) == 'table'
    or type(derived['Обслуживание']) == 'table'
        and table.concat(derived['Maintenance']):match('Name')
        and table.concat(derived['Обслуживание']):match('Название')
    )
    )
and ("''%s''"):format(
and ("''%s''"):format(
Строка 304: Строка 304:
        mw.title.new( 'SearchByProperty', 'Special' ).prefixedText
        mw.title.new( 'SearchByProperty', 'Special' ).prefixedText
    local q = mw.uri.buildQueryString{  
    local q = mw.uri.buildQueryString{  
        ['property'] = 'Parent',
        ['property'] = 'Родительское дзюцу',
        ['value'] = mw.uri.encode(
        ['value'] = mw.uri.encode(
            mw.title.getCurrentTitle().prefixedText,
            mw.title.getCurrentTitle().prefixedText,
Строка 312: Строка 312:
         local searchlink = HF.ExternalLink(
         local searchlink = HF.ExternalLink(
             tostring(mw.uri.fullUrl(t,q)),
             tostring(mw.uri.fullUrl(t,q)),
             'All derived jutsu'
             'Все производные дзюцу'
         )
         )
    return ('<center class="smwsearch">%s</center>'):format( searchlink )
    return ('<center class="smwsearch">%s</center>'):format( searchlink )
Строка 320: Строка 320:
function Infobox.jutsuRelated(frame)
function Infobox.jutsuRelated(frame)
local args = getArgs(frame)
local args = getArgs(frame)
return arraymap( args['related jutsu'], ',%s*', HF.Link('%s'), ', ' )
return arraymap( args['родственные дзюцу'], ',%s*', HF.Link('%s'), ', ' )
end
end


Строка 329: Строка 329:
   local mtypes = {
   local mtypes = {
     anime = true, manga = true, novel = true,
     anime = true, manga = true, novel = true,
     game = true, movie = true, ['movie canon'] = true
     game = true, movie = true, ['фильм канон'] = true
   }
   }
   -- Divides users into actionable items (even if there's only one)
   -- Divides users into actionable items (even if there's only one)
   local users = args['users'] and mw.text.split( args['users'], ',%s*' )
   local users = args['пользователи'] and mw.text.split( args['пользователи'], ',%s*' )
   -- Checks if any user entries exist, and if they don't, return nil
   -- Checks if any user entries exist, and if they don't, return nil
   if type(users) ~= 'table' then return nil end
   if type(users) ~= 'table' then return nil end
Строка 353: Строка 353:
     local puppetry = user:match('~~puppet~(.*)$')
     local puppetry = user:match('~~puppet~(.*)$')
     if puppetry then
     if puppetry then
       puppetry = (' ([[Puppetry]] using %s)')
       puppetry = (' ([[Марионетка]] использует %s)')
         :format(mw.text.listToText(mw.text.split(puppetry, '~')))
         :format(mw.text.listToText(mw.text.split(puppetry, '~')))
     end
     end

Версия от 22:44, 12 февраля 2021


Документация
local Infobox = {}

------------------------------------
-- Libraries and Global functions --
------------------------------------
-- "High Frequency" functions
local HF = require('Module:HF')
-- Parses invocation and template parameters, trims whitespace, and removes blanks.
local getArgs = require('Module:Arguments').getArgs
-- Generates lists
local L = require('Module:List')
-- Language functions
local language = mw.language.new('ru')

-- Helper functions (local to not have to worry about namespaces)
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

-- The page title of whatever page is calling the function
local pageTitle = mw.title.getCurrentTitle().text

-- Convenient constants
local stripLinkToTarget = '^%[*([^%[|]*)|?'
local stripPageTitleToBase = "[^(]*"
local basepattern = '^[^~]*'
local extra1pattern = '^[^~]*~([^~]*)'

------------------------------------------------
-- Local functions (used only in this Module) --
------------------------------------------------
-- 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('Name'))
	    )
        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('Jutsu') )
		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['название'] then
			mw.smw.set {
				['Название'] = args['название'],
				['Названия'] = args['название']
			}
		end
		if args['кандзи'] then
			mw.smw.set {
				['Кандзи'] = args['кандзи'],
				['Названия'] = args['кандзи']
			}
		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
	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 = {
			['kekkei mōra'] = true,
			['kekkei tōta'] = true,
			['kekkei genkai'] = true
		}
		for _,classification in ipairs(classifications) do
			if classification:match(extra1pattern) then
				if classification:match(basepattern):lower() == 'hiden' then
					local options = {
						['SemanticPropertyName'] = 'Клан',
						['PrependText'] = 'Клан ниндзя',
						['PrependTemplate'] = 'Infobox_icon',
						['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'] = 'Infobox_icon',
						['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'] = 'Infobox_icon',
		['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..'-rank') )
	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['jutsu range']..'-range'
end

function Infobox.jutsuParent(frame)
	local args = getArgs(frame)
	local options = {
		['SemanticPropertyName'] = 'Родительское дзюцу',
		['Link'] = 'Безымянное',
		['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['дзюцу медиа']] 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('~~puppet~(.*)$')
    if puppetry then
      puppetry = (' ([[Марионетка]] использует %s)')
        :format(mw.text.listToText(mw.text.split(puppetry, '~')))
    end
    -- "with" handling
    local with = user:match('~~with~([^%~]*)')
      and (' (with %s)'):format(user:match('~~with~([^%~]*)'))
    local AdditionalInfo = puppetry or with or ''

    --- Media
    local Media = ''
    if media
      and mtypes[media:lower()]
      and media:lower() ~= 'movie canon'
    then
      Media = ('<sup> (%s only)</sup>')
        :format( language:ucfirst( media ) )
    elseif media
      and media:lower() == 'movie canon'
      then
        Media = '<sup> (Movie only)</sup>'
    end

    --- Summons
    local cq = mw.smw.ask {
      (HF.Link('Contract::%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 == 'Summoning Technique' 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 {
      ['User tech'] = 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