Module:Software: Difference between revisions
From Eli's Software Encyclopedia
mNo edit summary |
mNo edit summary |
||
| Line 135: | Line 135: | ||
appendIfExists('Product UPC', upc) | appendIfExists('Product UPC', upc) | ||
appendIfExists('Product EAN', ean) | appendIfExists('Product EAN', ean) | ||
appendIfExists('Product ISBN', | appendIfExists('Product ISBN', isbn) | ||
appendIfExists('[[:Category:Hardware|Platform(s)]]', platform) | appendIfExists('[[:Category:Hardware|Platform(s)]]', platform) | ||
appendIfExists('[[Video Standard]]', videostandard) | appendIfExists('[[Video Standard]]', videostandard) | ||
Revision as of 19:13, December 7, 2025
Documentation for this module may be created at Module:Software/doc
local utils = require('Module:Utils')
local p = {}
function p.semanticStore(frame)
local titleObj = mw.title.getCurrentTitle()
local args = frame:getParent().args or {}
-- Get infobox helper params
local collapsible = args['collapsible'] or 'no'
local state = args['state'] or 'autocollapse'
local showImage = args['show image'] or 'no'
-- Get other properties
local title = args['title'] or titleObj.text
local publisher = args['publisher'] or ''
local publabel = args['publabel'] or ''
local manpartnum = args['manpartnum'] or ''
local productid = args['productid'] or ''
local upc = args['UPC'] or ''
local ean = args['EAN'] or ''
local isbn = args['ISBN'] or ''
local platform = args['platform'] or args['platforms'] or ''
local videostandard = args['videostandard'] or ''
local packaging = args['packaging'] or ''
local media = args['media'] or ''
local copyrighted = args['copyrighted'] or args['copyright'] or ''
local released = args['released'] or ''
local distributor = args['distributor'] or ''
local developer = args['developer'] or ''
local series = args['series'] or ''
local genre = args['genre'] or ''
local engine = args['engine'] or ''
local age = args['age'] or ''
local ratings = args['ratings'] or ''
local country = args['country'] or ''
local language = args['language'] or ''
local image = args['image'] or ''
local imageFilename, imageAlt, imageCaption = '', '', ''
if image ~= '' then
local fn, alt = utils.parseFileLink(image)
if fn then
imageFilename = fn
imageAlt = alt or imageCaption or ''
else
imageFilename = frame:preprocess('{{PAGENAME:' .. image .. '}}')
end
end
-- Set properties
local data = {
'Has Title=' .. title,
'Manufacturer Code=' .. manpartnum,
'Product ID=' .. productid,
'Product UPC=' .. upc,
'Product EAN=' .. ean,
'Product ISBN=' .. isbn,
'Platform=' .. utils.unwrapList(platform),
'+sep=,',
'Video Standard=' .. utils.unwrapList(videostandard),
'Software Packaging=' .. packaging,
'Digital Media=' .. media,
'Copyright Date=' .. copyrighted,
'Released Date=' .. released,
'Publisher=' .. utils.unwrapList(utils.unwrapLink(publisher)),
'Publisher Label=' .. publabel,
'Distributor=' .. utils.unwrapList(distributor),
'+sep=,',
'Developer=' .. utils.unwrapList(utils.unwrapLink(developer)),
'+sep=,',
'Series=' .. series,
'Genre=' .. utils.unwrapList(utils.unwrapLink(genre)),
'+sep=,',
'Game Engine=' .. engine,
'Recommended Age=' .. age,
'Software Content Rating System=' .. ratings,
'Country Of Origin=' .. country,
'Language=' .. language,
'+sep=,',
'Has Image=' .. imageFilename,
'Has Image Caption=' .. imageCaption
}
mw.smw.set( data )
-- Infobox variables
local infoboxClass = 'chameleon-infobox smwtable-clean d-table w-100 w-md-30 d-md-flex float-none float-md-right border shadow-sm ml-md-4 mb-4 text-left'
local pad = ''
if collapsible == 'yes' then
infoboxClass = infoboxClass .. ' collapsible ' .. state
pad = frame:preprocess('{{pad|5em}}')
end
-- Build infobox
local html = mw.html.create()
local infobox = html:tag('table'):addClass(infoboxClass)
:css('font-size', '90%')
:attr('cellpadding', '0')
:attr('cellspacing', '0')
-- Header row (title + optional image)
local headerTr = mw.html.create('tr')
headerTr:tag('td'):attr('colspan', '2')
:tag('div'):addClass('summary text-center font-italic font-weight-bold')
:css('font-size', '110%')
:wikitext(pad .. title):done()
infobox:node(headerTr)
-- Image and caption
if image ~= '' then
local imgTr = mw.html.create('tr')
imgTr:tag('td'):attr('colspan', '2'):addClass('text-center px-0')
:wikitext(string.format('[[File:%s|class=img-fluid|%s]]',
imageFilename, imageCaption
))
infobox:node(imgTr)
if imageCaption ~= '' then
local capTr = mw.html.create('tr')
capTr:tag('td'):attr('colspan', '2'):addClass('text-center px-0')
:wikitext(imageCaption)
infobox:node(capTr)
end
end
-- Print data rows
local function appendIfExists(label, value)
local tr = utils.addLabelValue(label, value)
if tr then infobox:node(tr) end
end
appendIfExists('Title', title)
appendIfExists('Manufacturer #', manpartnum)
appendIfExists('Product ID', productid)
appendIfExists('Product UPC', upc)
appendIfExists('Product EAN', ean)
appendIfExists('Product ISBN', isbn)
appendIfExists('[[:Category:Hardware|Platform(s)]]', platform)
appendIfExists('[[Video Standard]]', videostandard)
appendIfExists('[[Software Packaging|Packaging]]', packaging)
appendIfExists('[[Digital Media|Media]]', media)
appendIfExists('Copyright date(s)', copyrightDate)
appendIfExists('Release date(s)', releaseDate)
appendIfExists('[[:Category:Software Publisher|Publisher(s)]]', publisher)
appendIfExists('Publisher label', publabel)
appendIfExists('Distributor(s)', distributor)
appendIfExists('[[:Category:Software Developer|Developer(s)]]', developer)
appendIfExists('Series', series)
appendIfExists('[[:Category:Software|Category(s)]]', genre)
appendIfExists('[[Game engine|Engine]]', engine)
appendIfExists('Recommended age(s)', age)
appendIfExists('[[Software content rating system|Rating(s)]]', ratings)
appendIfExists('Language(s)', language)
appendIfExists('Country of Origin', country)
return html
end
return p
