Module:Software: Difference between revisions
From Eli's Software Encyclopedia
Created page with "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 founders local function addIfNotEmpty(tbl, val) if val and val ~= '' then table.insert(tbl,..." |
mNo edit summary |
||
| (16 intermediate revisions by 2 users not shown) | |||
| Line 13: | Line 13: | ||
local showImage = args['show image'] or 'no' | local showImage = args['show image'] or 'no' | ||
-- Get other properties | -- Get other properties | ||
local title = args[' | local title = args['title'] or titleObj.text | ||
local publisher = args['publisher'] or '' | local publisher = args['publisher'] or '' | ||
local | local publabel = args['publabel'] or '' | ||
local | local manpartnum = args['manpartnum'] or '' | ||
local | local productid = args['productid'] or '' | ||
local | local upc = args['UPC'] or '' | ||
local | local ean = args['EAN'] or '' | ||
local | local isbn = args['ISBN'] or '' | ||
local | local platform = args['platform'] or args['platforms'] or '' | ||
local | local videostandard = args['videostandard'] or '' | ||
local | local packaging = args['packaging'] or '' | ||
local | local media = args['media'] or '' | ||
local | local copyrighted = args['copyrighted'] or args['copyright'] or '' | ||
local | 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 country = args['country'] or '' | ||
local language = args['language'] or '' | local language = args['language'] or '' | ||
local image = args['image'] or '' | local image = args['image'] or '' | ||
local wikiUrl = args['wiki url'] or '' | |||
local imageFilename, imageAlt, imageCaption = '', '', '' | local imageFilename, imageAlt, imageCaption = '', '', '' | ||
| Line 60: | Line 50: | ||
end | end | ||
end | end | ||
-- Set properties | -- Set properties | ||
| Line 69: | Line 58: | ||
'Product UPC=' .. upc, | 'Product UPC=' .. upc, | ||
'Product EAN=' .. ean, | 'Product EAN=' .. ean, | ||
'Product ISBN=' .. | 'Product ISBN=' .. isbn, | ||
'Platform=' .. platform, | 'Platform=' .. utils.unwrapList(platform), | ||
'Video Standard=' .. videostandard, | '+sep=,', | ||
'Video Standard=' .. utils.unwrapList(videostandard), | |||
'Software Packaging=' .. packaging, | 'Software Packaging=' .. packaging, | ||
'Digital Media=' .. media, | 'Digital Media=' .. media, | ||
'Copyright Date=' .. copyrighted, | 'Copyright Date=' .. copyrighted, | ||
'Released Date=' .. released, | 'Released Date=' .. released, | ||
'Publisher=' .. publisher, | 'Publisher name=' .. utils.unwrapList(utils.unwrapLink(publisher)), | ||
'Publisher Label=' .. publabel, | 'Publisher Label=' .. publabel, | ||
'Distributor=' .. distributor, | 'Distributor=' .. utils.unwrapList(distributor), | ||
'Developer=' .. developer, | '+sep=,', | ||
'Developer=' .. utils.unwrapList(utils.unwrapLink(developer)), | |||
'+sep=,', | |||
'Series=' .. series, | 'Series=' .. series, | ||
'Genre=' .. genre, | 'Genre=' .. utils.unwrapList(utils.unwrapLink(genre)), | ||
'+sep=,', | |||
'Game Engine=' .. engine, | 'Game Engine=' .. engine, | ||
'Recommended Age=' .. age, | 'Recommended Age=' .. age, | ||
| Line 89: | Line 82: | ||
'+sep=,', | '+sep=,', | ||
'Has Image=' .. imageFilename, | 'Has Image=' .. imageFilename, | ||
'Has Image Caption=' .. imageCaption | 'Has Image Caption=' .. imageCaption, | ||
'Wiki URL=' .. wikiUrl | |||
} | } | ||
mw.smw.set( data ) | mw.smw.set( data ) | ||
| Line 116: | Line 110: | ||
-- Image and caption | -- Image and caption | ||
if image ~= ' | if image ~= '' then | ||
local imgTr = mw.html.create('tr') | local imgTr = mw.html.create('tr') | ||
imgTr:tag('td'):attr('colspan', '2'):addClass('text-center px-0') | imgTr:tag('td'):attr('colspan', '2'):addClass('text-center px-0') | ||
| Line 133: | Line 127: | ||
-- Print data rows | -- Print data rows | ||
local function appendIfExists(label, value) | local function appendIfExists(label, value, link) | ||
local tr = utils.addLabelValue(label, value) | local tr = utils.addLabelValue(label, value, link) | ||
if tr then infobox:node(tr) end | if tr then infobox:node(tr) end | ||
end | end | ||
| Line 143: | Line 137: | ||
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) | ||
| Line 153: | Line 147: | ||
appendIfExists('Publisher label', publabel) | appendIfExists('Publisher label', publabel) | ||
appendIfExists('Distributor(s)', distributor) | appendIfExists('Distributor(s)', distributor) | ||
appendIfExists('[[:Category:Software Developer|Developer(s)]]', developer) | appendIfExists('[[:Category:Software Developer|Developer(s)]]', developer, 'catlink') | ||
appendIfExists('Series', series) | appendIfExists('Series', series) | ||
appendIfExists('[[:Category:Software|Category(s)]]', genre) | appendIfExists('[[:Category:Software|Category(s)]]', genre) | ||
| Line 161: | Line 155: | ||
appendIfExists('Language(s)', language) | appendIfExists('Language(s)', language) | ||
appendIfExists('Country of Origin', country) | appendIfExists('Country of Origin', country) | ||
appendIfExists('Wiki URL', wikiUrl) | |||
return html | return html | ||
Latest revision as of 20:55, December 10, 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 wikiUrl = args['wiki url'] 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 name=' .. 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,
'Wiki URL=' .. wikiUrl
}
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, link)
local tr = utils.addLabelValue(label, value, link)
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, 'catlink')
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)
appendIfExists('Wiki URL', wikiUrl)
return html
end
return p
