Модуль:UBox: различия между версиями
Внешний вид
Spark108 (обсуждение | вклад) м 1 версия импортирована |
Нет описания правки |
||
Строка 4: | Строка 4: | ||
local args = require( 'Module:ProcessArgs' ).merge( true ) | local args = require( 'Module:ProcessArgs' ).merge( true ) | ||
local msgbox = {} | local msgbox = {} | ||
local | local page = mw.title.getCurrentTitle() | ||
local typebox = args["тип"] or 'ubox' | |||
if typebox == 'ubox' then | |||
if page.isContentPage then | |||
typebox = 'ubox ambox' | |||
else | |||
typebox = 'ubox msgbox' | |||
end | |||
end | |||
local class = args["класс"] or 'ubox-default' | local class = args["класс"] or 'ubox-default' | ||
local title = args["назв"] or '' | local title = args["назв"] or '' | ||
Строка 15: | Строка 23: | ||
talk = '<sup>[[' .. talkPage .. '#' .. talkTheme .. '|Обсуждение]]</sup>' | talk = '<sup>[[' .. talkPage .. '#' .. talkTheme .. '|Обсуждение]]</sup>' | ||
end | end | ||
local nocat = args["некат"] | local nocat = args["некат"] | ||
local cat = args["категория"] | local cat = args["категория"] | ||
local doc = args["док"] | |||
if (not nocat and cat) then | if (not nocat and cat) then | ||
cat = mw.ustring.gsub( cat, ';', ']][[Категория:' ) | cat = '[[Категория: ' .. mw.ustring.gsub( cat, ';', ']][[Категория:' ) .. ']]' | ||
cat = ' | if (doc and page.subpageText ~= 'док') then | ||
cat = '' | |||
elseif (not doc and page.subpageText == 'док') then | |||
cat = '' | |||
end | |||
else | else | ||
cat = '' | cat = '' | ||
end | |||
local image = args["изобр"] or args["image"] or '' | |||
local imgClass = 'ubox-img-table' | |||
if image ~= '' then | |||
image = '[[Файл:' .. image .. '|48px]]' | |||
imgClass = 'ubox-img-hand' | |||
end | end | ||
table.insert( msgbox, ' {| class="' .. | table.insert( msgbox, ' {| class="' .. typebox ..' ' .. class .. '" ') | ||
table.insert( msgbox, '|-\n| class="ubox-img"| <div></div>') | table.insert( msgbox, '|-\n| class="ubox-img ' .. imgClass .. '"| <div>' .. image .. '</div>') | ||
table.insert( msgbox, '| class="ubox-field"| <span class="ubox-title">' .. title .. talk .. '</span>\n<div class="ubox-text">' .. text .. '</div>') | table.insert( msgbox, '| class="ubox-field"| <span class="ubox-title">' .. title .. talk .. '</span>\n<div class="ubox-text">' .. text .. '</div>') | ||
if smalltext ~= '' then | if smalltext ~= '' then |
Версия от 17:15, 10 июня 2025
Для документации этого модуля может быть создана страница Модуль:UBox/doc
local p = {}
function p.box( f )
local args = require( 'Module:ProcessArgs' ).merge( true )
local msgbox = {}
local page = mw.title.getCurrentTitle()
local typebox = args["тип"] or 'ubox'
if typebox == 'ubox' then
if page.isContentPage then
typebox = 'ubox ambox'
else
typebox = 'ubox msgbox'
end
end
local class = args["класс"] or 'ubox-default'
local title = args["назв"] or ''
local text = args["текст"] or ''
local smalltext = args["примечание"] or args["опись"] or ''
local talkPage = args["стробс"] or 'Обсуждение Minecraft Wiki:Портал сообщества'
local talk = ''
local talkTheme = args["тема"] or ''
if talkTheme ~= '' then
talk = '<sup>[[' .. talkPage .. '#' .. talkTheme .. '|Обсуждение]]</sup>'
end
local nocat = args["некат"]
local cat = args["категория"]
local doc = args["док"]
if (not nocat and cat) then
cat = '[[Категория: ' .. mw.ustring.gsub( cat, ';', ']][[Категория:' ) .. ']]'
if (doc and page.subpageText ~= 'док') then
cat = ''
elseif (not doc and page.subpageText == 'док') then
cat = ''
end
else
cat = ''
end
local image = args["изобр"] or args["image"] or ''
local imgClass = 'ubox-img-table'
if image ~= '' then
image = '[[Файл:' .. image .. '|48px]]'
imgClass = 'ubox-img-hand'
end
table.insert( msgbox, ' {| class="' .. typebox ..' ' .. class .. '" ')
table.insert( msgbox, '|-\n| class="ubox-img ' .. imgClass .. '"| <div>' .. image .. '</div>')
table.insert( msgbox, '| class="ubox-field"| <span class="ubox-title">' .. title .. talk .. '</span>\n<div class="ubox-text">' .. text .. '</div>')
if smalltext ~= '' then
table.insert( msgbox, '|-\n| colspan=2 class="ubox-summary"|\n' .. smalltext )
end
table.insert( msgbox, '|} ' .. cat)
msgbox = table.concat( msgbox, '\n' )
return msgbox
end
return p