Модуль:Карточка: различия между версиями

мНет описания правки
мНет описания правки
Строка 45: Строка 45:
h.increment()
h.increment()
local args = h.overwrite()
local args = h.overwrite()
args.skipSectionRows = tonumber(args.skipSectionRows or 0)
h.sectionHeaderCounter = 0
local sep = args.sep or ','
local sep = args.sep or ','
h.castArgs(args, sep)
h.castArgs(args, sep)
if h.castBool(args.setmainimage or 'yes') then
if h.castBool(args.setmainimage or 'yes') then
    h.setMainImage(args.images[1])
h.setMainImage(args.images[1])
end
end
    -- suggest to use HIDDENCAT here; will be used for maintenance & gadget imports
-- suggest to use HIDDENCAT here; will be used for maintenance & gadget imports
    local output = h.makeInfobox(args, sep)
local output = h.makeInfobox(args, sep)
    local finalOutput = tostring(output)
return frame:preprocess(tostring(output))
    return frame:preprocess(finalOutput)
end
end


Строка 134: Строка 135:
function h.setMainImage(file)
function h.setMainImage(file)
if h.counter > 1 then return end
if h.counter > 1 then return end
    if not file then return end
if not file then return end
    local fileText = file:gsub('.-:', '')
local fileText = file:gsub('.-:', '')
fileText = fileText:gsub('^([^|%]]+).*', '%1')
fileText = fileText:gsub('^([^|%]]+).*', '%1')
-- setmainimage is guaranteed to exist on wiki.gg but may not exist on other wikis
-- setmainimage is guaranteed to exist on wiki.gg but may not exist on other wikis
Строка 426: Строка 427:
local a, b = sizeOfLastRow, numCols
local a, b = sizeOfLastRow, numCols
while b ~= 0 do
while b ~= 0 do
    a, b = b, a % b
a, b = b, a % b
end
end
local lcm = sizeOfLastRow * numCols / a
local lcm = sizeOfLastRow * numCols / a
Строка 487: Строка 488:
function h.printSectionHeader(node, section, args)
function h.printSectionHeader(node, section, args)
if h.castBool(args[section .. '_nolabel']) then return end
if h.castBool(args[section .. '_nolabel']) then return end
h.sectionHeaderCounter = (h.sectionHeaderCounter or 0) + 1
if args.skipSectionRows and h.sectionHeaderCounter <= args.skipSectionRows then return end
local tr = node:tag(h.getTag('row'))
local tr = node:tag(h.getTag('row'))
:attr('data-druid-section', h.escape(section))
:attr('data-druid-section', h.escape(section))
:addClass('data-druid-section')
local th = tr:tag(h.getTag('sectionTitle'))
:attr('colspan', 2)
:addClass('druid-section')
:addClass('druid-section')
:addClass('druid-section-' .. h.escape(section))
:addClass('druid-section-' .. h.escape(section))
Строка 500: Строка 502:
end
end
end
end
local th = tr:tag(h.getTag('sectionTitle'))
:attr('colspan', 2)
:addClass('druid-section')
:addClass('druid-section-' .. h.escape(section))
local emptySections = {}
local emptySections = {}
for _, label in ipairs(args.tabs) do
for _, label in ipairs(args.tabs) do
Строка 534: Строка 540:
local tabs = args[section .. '_tabs']
local tabs = args[section .. '_tabs']
if not tabs or #tabs == 0 then return end
if not tabs or #tabs == 0 then return end
if args.skipSectionRows and (h.sectionHeaderCounter or 0) <= args.skipSectionRows then return end
local tr = node:tag(h.getTag('sectionTabsOuter'))
local tr = node:tag(h.getTag('sectionTabsOuter'))
:attr('data-druid-section', h.escape(section))
:attr('data-druid-section', h.escape(section))
:addClass('data-druid-section')
:addClass('druid-section-tabs')
local th = tr:tag(h.getTag('sectionTabs'))
local th = tr:tag(h.getTag('sectionTabs'))
:attr('colspan', 2)
:attr('colspan', 2)