PC Gaming Shelter
An archive dedicated to preserving PC Gaming history and more

Module:Navigation: Difference between revisions

From PC Gaming Shelter
No edit summary
No edit summary
 
(57 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
local p = {}


local function renderThumb(row)
local function renderRow(label, image, target, model)
    local caption, img, target = row[1], row[2], row[3]
local defaultTarget = label
if not target then
if not target then
target = caption
target = defaultTarget
end
end
local html = mw.html.create()
local cardClass = 'navthumb'
html:tag('div')
if image ~= '' and model == '1' then
:tag('div'):attr('data-bg', img):wikitext(string.format([[%s|%s]], target, caption)):done()
cardClass = 'navthumb p-3'
:tag('div'):wikitext(string.format([[%s|%s]], target, caption)):done()
end
:done()
local labelClass = 'navthumb-label'
if image ~= '' and model == '0' then
labelClass = 'navthumb-label h-100 with-icon'
end
    local html = mw.html.create()
    local card = html:tag('div'):addClass(cardClass)
    if image ~= '' and model == '1' then
        card:tag('div'):addClass('navthumb-image'):attr({
        ['data-bg'] = image,
        }):done()
    end
    if image ~= '' and model == '0' then
    card:tag('div'):addClass(labelClass):attr({
        ['data-bg'] = image,
        }):css({
        ['background-size'] = 'contain',
['background-repeat'] = 'no-repeat',
-- ['padding-left'] = '30px',
        }):wikitext(string.format('[[%s|%s]]', target, label)):done()
else   
card:tag('div'):addClass(labelClass):wikitext(string.format('[[%s|%s]]', target, label)):done()
    end
 
     return html
     return html
end
end


function p.thumbwall(frame)
function p.data(frame)
local args = frame:getParent().args
  local args = frame:getParent().args or {}
local title = args[1] or 'Navigate'
  local title = args[1] or args['title'] or 'Navigate'
local thumbs = args[2]
  local showThumbs = args['show thumbs'] or '1'
if not thumbs then return end
  local freeText = args['free text'] or nil
  local footer = args['footer'] or nil
 
  local html = mw.html.create()
  local card = html:tag('div'):addClass('card bg-transparent thumbwall mb-3')
  local header = card:tag('div'):addClass('card-header border-bottom-0'):wikitext(title):done()
  local body = card:tag('div'):addClass('card-body pt-2')
 
local i = 1
while args['label' .. i] do
local label = args['label' .. i]
local imageUrl = ''
local image = args['image' .. i] or ''
if image and image ~= '' then
imageUrl = frame:preprocess(
string.format('{{filepath:{{PAGENAME:%s}}}}', image)
)
end
local target = args['target' .. i] or label
        body:node(renderRow(label, imageUrl, target, showThumbs))
    i = i + 1
end
    local thumbTable = {}
if freeText then
    for line in thumbs:gmatch("[^\r\n]+") do
    body:node(freeText)
        -- Split into two or three parts (target optional)
end
        local img, caption, target = line:match("^%s*(.-)%s*;%s*(.-)%s*;%s*(.-)%s*$")
        if not target then target = caption end
        if img and caption then
            table.insert(thumbTable, { caption, img, target })
        end
    end
local wallContent = ''
if footer then
for _, row in ipairs(thumbTable) do
    card:tag('div'):addClass('card-footer'):wikitext(footer)
        wallContent = wallContent .. renderThumb(row):allHtml()
end
end
local html = mw.html.create()
local wall = html:tag('div'):addClass('card bg-dark thumbwall')
:tag('div'):addClass('card-header'):wikitext(title):done()
:tag('div'):addClass('card-body'):html(table.concat(wallContent, "\n"))
:done()
    return wall
return html
end
end


return p
return p

Latest revision as of 09:16, 20 June 2026

Documentation for this module may be created at Module:Navigation/doc

local p = {}

local function renderRow(label, image, target, model)
	local defaultTarget = label
	if not target then
		target = defaultTarget
	end
	
	local cardClass = 'navthumb'
	if image ~= '' and model == '1' then
		cardClass = 'navthumb p-3'
	end
	
	local labelClass = 'navthumb-label'
	if image ~= '' and model == '0' then
		labelClass = 'navthumb-label h-100 with-icon'
	end
	
    local html = mw.html.create()
    local card = html:tag('div'):addClass(cardClass)
    if image ~= '' and model == '1' then
        card:tag('div'):addClass('navthumb-image'):attr({
        	['data-bg'] = image,
        }):done()
    end
    if image ~= '' and model == '0' then
    	card:tag('div'):addClass(labelClass):attr({
        	['data-bg'] = image,
        }):css({
        	['background-size'] = 'contain',
			['background-repeat'] = 'no-repeat',
			-- ['padding-left'] = '30px',
        }):wikitext(string.format('[[%s|%s]]', target, label)):done()
	else    	
		card:tag('div'):addClass(labelClass):wikitext(string.format('[[%s|%s]]', target, label)):done()
    end

    return html
end

function p.data(frame)
  local args = frame:getParent().args or {}
  local title = args[1] or args['title'] or 'Navigate'
  local showThumbs = args['show thumbs'] or '1'
  local freeText = args['free text'] or nil
  local footer = args['footer'] or nil
  
  local html = mw.html.create()
  local card = html:tag('div'):addClass('card bg-transparent thumbwall mb-3')
  local header = card:tag('div'):addClass('card-header border-bottom-0'):wikitext(title):done()
  local body = card:tag('div'):addClass('card-body pt-2')
  
	local i = 1
	while args['label' .. i] do
		local label = args['label' .. i]
		local imageUrl = ''
		
		local image = args['image' .. i] or ''
		if image and image ~= '' then
			imageUrl = frame:preprocess(
				string.format('{{filepath:{{PAGENAME:%s}}}}', image)
			)
		end
		
		local target = args['target' .. i] or label
        body:node(renderRow(label, imageUrl, target, showThumbs))
    	i = i + 1
	end
	
	if freeText then
	    body:node(freeText)
	end
	
	if footer then
	    card:tag('div'):addClass('card-footer'):wikitext(footer)
	end
	
	return html
end

return p