Редактирование: Модуль:HF/Infobox/Jutsu
Перейти к навигации
Перейти к поиску
Примечание. Ваши правки будут показаны в статье только после их проверки участником с соответствующими правами.
Правка может быть отменена. Проверьте сравнение версий ниже и нажмите «Записать страницу».
Если отменяемые вами изменения не вандализм, пожалуйста, допишите причину в описании правки.
Текущая версия | Ваш текст | ||
Строка 1: | Строка 1: | ||
local Infobox = {} | local Infobox = {} | ||
-- | ------------------------------------ | ||
-- Libraries and Global functions -- | |||
-- " | ------------------------------------ | ||
-- "High Frequency" functions | |||
local HF = require('Module:HF') | local HF = require('Module:HF') | ||
-- | -- Parses invocation and template parameters, trims whitespace, and removes blanks. | ||
local getArgs = require('Module:Arguments').getArgs | local getArgs = require('Module:Arguments').getArgs | ||
-- | -- Generates lists | ||
local L = require('Module:List') | local L = require('Module:List') | ||
-- | -- Language functions | ||
local language = mw.language.new('ru') | local language = mw.language.new('ru') | ||
-- | -- Helper functions (local to not have to worry about namespaces) | ||
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 | ||
Строка 18: | Строка 19: | ||
local extra1 = require('Module:HF/Infobox').extra1 | local extra1 = require('Module:HF/Infobox').extra1 | ||
-- | -- The page title of whatever page is calling the function | ||
local pageTitle = mw.title.getCurrentTitle().text | local pageTitle = mw.title.getCurrentTitle().text | ||
-- | -- Convenient constants | ||
local stripLinkToTarget = '^%[*([^%[|]*)|?' | local stripLinkToTarget = '^%[*([^%[|]*)|?' | ||
local stripPageTitleToBase = "[^(]*" | local stripPageTitleToBase = "[^(]*" | ||
Строка 27: | Строка 28: | ||
local extra1pattern = '^[^~]*~([^~]*)' | local extra1pattern = '^[^~]*~([^~]*)' | ||
------------------------------------------------ | |||
-- | -- Local functions (used only in this Module) -- | ||
------------------------------------------------ | |||
-- Replaces {{IsUnnamed}} | -- Replaces {{IsUnnamed}} | ||
local function nameCheck ( target ) | local function nameCheck ( target ) | ||
Строка 44: | Строка 45: | ||
end | end | ||
--------------------------------------------------------- | ---------------------------------------------------------- | ||
-- | -- Public functions (called from a Template or article) -- | ||
--------------------------------------------------------- | ---------------------------------------------------------- | ||
-- Creates the infobox main title | -- Creates the infobox main title | ||
function Infobox.titleJutsu(frame) | function Infobox.titleJutsu(frame) | ||
Строка 52: | Строка 53: | ||
local out = {} | local out = {} | ||
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') | |||
-- :css('float','right'):css('font-size','x-small') | |||
-- :wikitext( HF.Link('Special:FormEdit/Jutsu/' .. pageTitle, 'edit') ):allDone() | |||
--local editFormURL = tostring(_editFormURL) | |||
if args['название'] then | if args['название'] then | ||
mw.smw.set{ ['Название'] = args['название'], ['Названия'] = args['название'] } | |||
table.insert( out, ('%s'):format(mw.text.trim(args['название']:match('[^(]*'))) ) | |||
else | |||
mw.smw.set { | mw.smw.set { | ||
['Название'] = | ['Название'] = tostring(pageTitle:match("[^(]*"):gsub(''',"'")), | ||
['Названия'] = | ['Названия'] = pageTitle:match("[^(]*") | ||
} | } | ||
table.insert( out, ('%s'):format(mw.text.trim(pageTitle:match('[^(]*'))) ) | |||
end | end | ||
if args['кандзи'] then | if args['кандзи'] then | ||
mw.smw.set { | mw.smw.set { | ||
Строка 68: | Строка 76: | ||
mw.smw.set { ['Обслуживание'] = 'Кандзи' } | mw.smw.set { ['Обслуживание'] = 'Кандзи' } | ||
end | end | ||
if args['киридзи'] then | if args['киридзи'] then | ||
mw.smw.set{ | mw.smw.set{ | ||
Строка 76: | Строка 82: | ||
} | } | ||
end | end | ||
if args['команда'] then | |||
if args[' | local teams = mw.text.split( args['команда'], ',%s*' ) | ||
local teams = mw.text.split( args[' | |||
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') | ||
Строка 101: | Строка 98: | ||
mw.smw.set{ ['Обслуживание'] = 'Отсутствующее изображение' } | mw.smw.set{ ['Обслуживание'] = 'Отсутствующее изображение' } | ||
end | end | ||
if args['безымянное дзюцу'] == 'Да' then | if args['безымянное дзюцу'] == 'Да' then | ||
mw.smw.set{ ['Обслуживание'] = 'Название' } | mw.smw.set{ ['Обслуживание'] = 'Название' } | ||
table.insert( out, (''%s''):format( pageTitle:match("[^(]*") ) ) | 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( | |||
return table.concat( out ) .. ( args['ref'] or '' ) | "{{#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 | elseif mw.title.getCurrentTitle().namespace == 10 | ||
and not pageTitle:match('/testcases') then | and not pageTitle:match('/testcases') then | ||
Строка 119: | Строка 120: | ||
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 | ||
Строка 129: | Строка 129: | ||
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 = { | ||
[' | ['kekkei mōra'] = true, | ||
[' | ['kekkei tōta'] = true, | ||
[' | ['kekkei genkai'] = true | ||
} | } | ||
for _,classification in ipairs(classifications) do | for _,classification in ipairs(classifications) do | ||
Строка 143: | Строка 142: | ||
local options = { | local options = { | ||
['SemanticPropertyName'] = 'Клан', | ['SemanticPropertyName'] = 'Клан', | ||
['PrependText'] = 'Клан', | ['PrependText'] = 'Клан ниндзя', | ||
['PrependTemplate'] = 'Карточка/Наруто/Значки', | ['PrependTemplate'] = 'Карточка/Наруто/Значки', | ||
['Print'] = 'none', | ['Print'] = 'none', | ||
Строка 176: | Строка 175: | ||
local options = { | local options = { | ||
['SemanticPropertyName'] = 'Природа чакры', | ['SemanticPropertyName'] = 'Природа чакры', | ||
['PrependText'] = ' | ['PrependText'] = 'Природа', | ||
['PrependTemplate'] = 'Карточка/Наруто/Значки', | ['PrependTemplate'] = 'Карточка/Наруто/Значки', | ||
['Link'] = 'default' | ['Link'] = 'default' | ||
Строка 189: | Строка 188: | ||
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..'-rank') ) | ||
end | end | ||
return table.concat( out, ',' ) | return table.concat( out, ',' ) | ||
Строка 209: | Строка 208: | ||
['Короткий'] = 'Короткий диапазон (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['jutsu range']..'-range' | ||
end | end | ||
Строка 223: | Строка 222: | ||
local options = { | local options = { | ||
['SemanticPropertyName'] = 'Родительское дзюцу', | ['SemanticPropertyName'] = 'Родительское дзюцу', | ||
['Link'] = ' | ['Link'] = 'Безымянное', | ||
['UnnamedFormat'] = true | ['UnnamedFormat'] = true | ||
} | } | ||
local | local Parents = arrayTable ( args['родительское дзюцу'], ',%s*', options ) | ||
return L.makeList( 'unbulleted', | return L.makeList( 'unbulleted', Parents ) | ||
end | end | ||
Строка 234: | Строка 233: | ||
local out = {} | local out = {} | ||
local mtypes = { | local mtypes = { | ||
['Фильм'] = 'Дзюцу/ | ['Фильм'] = 'Дзюцу/НеКанон', | ||
['Игра'] = 'Дзюцу/ | ['Игра'] = 'Дзюцу/НеКанон', | ||
['Игра, Фильм'] = 'Дзюцу/ | ['Игра, Фильм'] = 'Дзюцу/НеКанон' | ||
} | } | ||
local mq = mw.smw.ask { | local mq = mw.smw.ask { | ||
(HF.Link('Concept:%s')):format( mtypes[args['дзюцу медиа']] or 'Дзюцу/ | (HF.Link('Concept:%s')):format( mtypes[args['дзюцу медиа']] or 'Дзюцу/Канон' ), | ||
(HF.Link('Родительское дзюцу::%s')):format( mw.title.getCurrentTitle().prefixedText ), | (HF.Link('Родительское дзюцу::%s')):format( mw.title.getCurrentTitle().prefixedText ), | ||
'?Появляется в', | '?Появляется в', | ||
Строка 248: | Строка 247: | ||
} | } | ||
local hasNCderivatives = mw.smw.ask { | local hasNCderivatives = mw.smw.ask { | ||
(HF.Link('Concept:%s')):format( 'Дзюцу/ | (HF.Link('Concept:%s')):format( 'Дзюцу/НеКанон' ), | ||
(HF.Link('Родительское дзюцу::%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 _, | 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 (''%s''):format( | 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', | ||
Строка 329: | Строка 328: | ||
function Infobox.jutsuUsers(frame) | 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) | -- Divides users into actionable items (even if there's only one) | ||
local users = args['пользователи'] and mw.text.split( args['пользователи'], ',%s*' ) | local users = args['пользователи'] and mw.text.split( args['пользователи'], ',%s*' ) | ||
Строка 356: | Строка 355: | ||
--- AdditionalInfo | --- AdditionalInfo | ||
-- Puppetry handling | -- Puppetry handling | ||
local puppetry = user:match('~~ | local puppetry = user:match('~~puppet~(.*)$') | ||
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 | ||
-- "with" handling | -- "with" handling | ||
local with = user:match('~~ | local with = user:match('~~with~([^%~]*)') | ||
and (' ( | and (' (with %s)'):format(user:match('~~with~([^%~]*)')) | ||
local AdditionalInfo = puppetry or with or '' | local AdditionalInfo = puppetry or with or '' | ||
Строка 370: | Строка 369: | ||
if media | if media | ||
and mtypes[media:lower()] | and mtypes[media:lower()] | ||
and media:lower() ~= ' | and media:lower() ~= 'movie canon' | ||
then | then | ||
Media = ('<sup> (%s)</sup>') | Media = ('<sup> (%s only)</sup>') | ||
:format( language:ucfirst( media ) ) | :format( language:ucfirst( media ) ) | ||
elseif media | elseif media | ||
and media:lower() == ' | and media:lower() == 'movie canon' | ||
then | then | ||
Media = '<sup> ( | Media = '<sup> (Movie only)</sup>' | ||
end | end | ||
--- Summons | --- Summons | ||
local cq = mw.smw.ask { | local cq = mw.smw.ask { | ||
(HF.Link(' | (HF.Link('Contract::%s')):format( prime:match(stripLinkToTarget) ), | ||
'mainlabel=main' | 'mainlabel=main' | ||
} | } | ||
Строка 392: | Строка 391: | ||
end | end | ||
local Summons = ((#sl > 0) | local Summons = ((#sl > 0) | ||
and ( pageTitle == ' | and ( pageTitle == 'Summoning Technique' or pageTitle == 'Destruction Bug Host Technique' )) | ||
and ( ' (%s)' ):format( table.concat( sl, ", " ) ) | and ( ' (%s)' ):format( table.concat( sl, ", " ) ) | ||
or '' | or '' | ||
Строка 401: | Строка 400: | ||
or 'null' | or 'null' | ||
mw.smw.set { | mw.smw.set { | ||
[' | ['User tech'] = prime .. ';' .. setmtype | ||
} | } | ||