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

Module:Link: Difference between revisions

From PC Gaming Shelter
No edit summary
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 7: Line 7:
['URL']   = {'Has URL'},
['URL']   = {'Has URL'},
['Link text']  = {'Has link text'},
['Link text']  = {'Has link text'},
['Link group'] = {'Belongs to group'}
['Link group'] = {'Belongs to group'},
['File size']  = {'Has file size'}
}
}
end
end
Line 25: Line 26:
local url = args['URL'] or nil
local url = args['URL'] or nil
local label = args['Link text'] or nil
local label = args['Link text'] or nil
local size = args['File size'] or ''
local link = ''
local link = ''
if label and url then
if label and url then
link = string.format('<li>[%s %s]</li>', url, label)
link = string.format('<li>[%s %s] <span class="float-right">%s</span></li>', url, label, size)
end
end

Latest revision as of 21:48, 15 June 2026

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

local utils = require( 'Module:Utils' )

local p = {}

local function propertiesPlan()
	return {
		['URL'] 	   = {'Has URL'},
		['Link text']  = {'Has link text'},
		['Link group'] = {'Belongs to group'},
		['File size']  = {'Has file size'}
	}
end

function p.main(frame)
	local args = frame:getParent().args
	local propMap = propertiesPlan()
	local props = utils.setProperties(propMap, args) or {}
	mw.smw.subobject(props)
	
	local parentProp = args['Link group']
	local escalateLink = {
		[parentProp] = args['URL']
	}
	mw.smw.set(escalateLink)

	local url = args['URL'] or nil
	local label = args['Link text'] or nil
	local size = args['File size'] or ''
	local link = ''	
	if label and url then
		link = string.format('<li>[%s %s] <span class="float-right">%s</span></li>', url, label, size)
	end
	
	return link
end

return p