Редактирование: Модуль: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 {
['Название'] = args['название'],
['Название'] = tostring(pageTitle:match("[^(]*"):gsub(''',"'")),
['Названия'] = args['название']
['Названия'] = 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['команды'] then
local teams = mw.text.split( args['команда'], ',%s*' )
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
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
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 = {
['кэккэй мора'] = true,
['kekkei mōra'] = true,
['кэккэй тота'] = true,
['kekkei tōta'] = true,
['кэккэй гэнкай'] = 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м+)',
['Длинный'] = 'Дальность действия (10 м+)',
['Короткий, Средний, Длинный'] = 'Все диапазоны',
['Короткий, Средний, Длинный'] = 'Все диапазоны',
['Короткий, Средний'] = 'Короткий в Средний диапазон (0-10м)',
['Короткий, Средний'] = 'Короткий и средний диапазон (0-10м)',
['Средний, Длинный'] = 'Средний в Длинный диапазон (+)',
['Средний, Длинный'] = 'Средний и длинный диапазон (5 м+)',
['Короткий, Длинный'] = 'Короткий или Длинный диапазон (0-5м или 10м+)'
['Короткий, Длинный'] = 'Короткий или длинный диапазон (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'] = 'Unnamed',
['Link'] = 'Безымянное',
['UnnamedFormat'] = true
['UnnamedFormat'] = true
}
}
local parents = arrayTable ( args['родительское дзюцу'], ',%s*', options )
local Parents = arrayTable ( args['родительское дзюцу'], ',%s*', options )
return L.makeList( 'unbulleted', parents )
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 _, parent in ipairs(mq) do
for _, Parent in ipairs(mq) do
local mainlink =
local mainlink =
(
(
    parent['Обслуживание'] == 'Название'
    Parent['Обслуживание'] == 'Название'
    or (
    or (
        type(parent['Обслуживание']) == 'table'
        type(Parent['Обслуживание']) == 'table'
        and table.concat(parent['Обслуживание']):match('Название')
        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['дзюцу медиа']] or 'Дзюцу/Канонический' ),
(HF.Link('Concept:%s')):format( mtypes[args['дзюцу медиа']] or 'Дзюцу/Канон' ),
(HF.Link('Родительское дзюцу::%s')):format( parent['main']:match(stripLinkToTarget) ),
(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 args = getArgs(frame)
local out = {}
  local out = {}
-- Valid media types
  -- Valid media types
local mtypes = {
  local mtypes = {
['нет'] = true, ['аниме'] = true, ['манга'] = true,
    anime = true, manga = true, novel = true,
['роман'] = true, ['игра'] = true, ['фильм'] = true, ['фильм канон'] = 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 = (' (Использование марионеток %s)')
       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 (' (с %s)'):format(user:match('~~с~([^%~]*)'))
       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> (Фильм)</sup>'
         Media = '<sup> (Movie only)</sup>'
     end
     end


     --- Summons
     --- Summons
     local cq = mw.smw.ask {
     local cq = mw.smw.ask {
       (HF.Link('Контракт::%s')):format( prime:match(stripLinkToTarget) ),
       (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 == 'Техника Призыва' or pageTitle == 'Destruction Bug Host Technique' ))
         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 {
       ['Пользователи техники'] = prime .. ';' .. setmtype
       ['User tech'] = prime .. ';' .. setmtype
     }
     }


Быстрая вставка: «» „“ | {{}} [[]] [] [[|]] {{|}} {{подст:}} <br> &nbsp; #перенаправление [[]] [[Категория:]] {{DEFAULTSORT:}} [[Участник:]] {{u|}} {{userlinks|}} {{ping|}} {{pagelinks|}} {{D-|}} [[d:|]] ~~~~

__NOTOC__ __TOC__ __FORCETOC__   [[ ()|]] [[ (фильм)|]] {{commonscat|}} [[wikt:]] [[Special:Diff/|]] [[Special:Permalink/|]] [[Special:Contributions/]]

Теги: <></>   <!-- -->   <blockquote></blockquote>   <code></code>   <code><nowiki></nowiki></code>   <nowiki></nowiki>   <includeonly></includeonly>   <noinclude></noinclude>   <onlyinclude></onlyinclude>   <poem></poem>   <pre></pre>   <s></s>   <small></small>   <syntaxhighlight lang=""></syntaxhighlight>   <sub></sub>   <sup></sup>

Теги галереи файлов: <gallery></gallery>   <gallery class="center" caption=""></gallery>   <gallery mode="packed" heights="" caption=""></gallery>

Разделы: == ==   === ===   == См. также ==   == Примечания == {{примечания}}   == Литература ==   == Ссылки ==

Шаблоны: {{tl|}}   {{cl|}}   {{clear}}   {{lang-en|}}   {{ref-en}}   {{s|}}   {{неоднозначность}}   {{колонки}}{{колонки|конец}}   {{подст:L}}   {{начало цитаты}}{{конец цитаты|источник=}}   {{hello}}~~~~  

Источники: <ref></ref>   <ref name=""></ref>   <ref name="" />   <ref group=""></ref>   {{ref+||group=""}}  

Символы: Ё ё ~ # @ § · ¡ ¿ \ ½ ¼ ¾ ± × ÷ ° ^ ¹ ² ³ £ ¥ $ ¢ © ® {{подст:ударение}}

Греческий алфавит: Α α Β β Γ γ Δ δ Ε ε Ζ ζ Η η Θ θ Ι Ϊ ι ϊ Κ κ Λ λ Μ μ Ν ν Ξ ξ Ο ο Π π Ρ ρ Σ σ ς Τ τ Υ Ϋ υ ϋ Φ φ Χ χ Ψ ψ Ω ω