Модуль:Предмет: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 26: | Строка 26: | ||
local size = args["size"] or "32px" | local size = args["size"] or "32px" | ||
local prefix = args[2] or "" | local prefix = args[2] or "" | ||
local vertical = argsRaw.vertical | |||
-- Получение данных о предмете через другие модули | -- Получение данных о предмете через другие модули | ||
| Строка 85: | Строка 86: | ||
-- Формирование итогового результата | -- Формирование итогового результата | ||
local imagerepository = "<span>".. image .. repository.."</span>" | local imagerepository = "" | ||
local result = "" | |||
-- Если передан параметр vertical, применяем вертикальное форматирование | |||
if vertical ~= nil then | |||
imagerepository = string.format("<span style='display:inline-flex;flex-direction:column;align-items:center;'>%s<b>%s</b></span>", image, labelOutput) | |||
result = table.concat({ imagerepository, itemStack, prefix }, " ") | |||
else | |||
imagerepository = "<span>" .. image .. repository .. "</span>" | |||
result = table.concat({ imagerepository, labelOutput, itemStack, prefix }, " ") | |||
end | |||
-- Если указан wrapper, формируем LinkCard | -- Если указан wrapper, формируем LinkCard | ||
| Строка 92: | Строка 102: | ||
local pixel = string.match(size, "(%d+)") | local pixel = string.match(size, "(%d+)") | ||
local linkParam = "" | local linkParam = "" | ||
if rawLink ~= nil then | if rawLink ~= nil then | ||
linkParam = (rawLink == "" and itemName) or rawLink | linkParam = (rawLink == "" and itemName) or rawLink | ||
end | end | ||
-- Если vertical передан, не добавляем SideStyle=1 | |||
local sideStyle = (vertical ~= nil) and "" or "|SideStyle=1" | |||
return frame:preprocess(string.format( | return frame:preprocess(string.format( | ||
"{{LinkCard|name=%s %s %s|pin=%s|image-full=%s|pixel=%s|link=%s | "{{LinkCard|name=%s %s %s|pin=%s|image-full=%s|pixel=%s|link=%s%s}}", | ||
labelOutput, itemStack, prefix, repository, image, pixel, linkParam | labelOutput, itemStack, prefix, repository, image, pixel, linkParam, sideStyle | ||
)) | )) | ||
end | end | ||