Module:Developer: 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 and normalize parameter values local title = args['name'] or args['Name'] or args['title'] or titleObj.text local logo = args['logo'] or args['Logo'] or '' local logoFilename = '' if logo ~= '' then logoFilename = frame:preprocess('{{PAGENAME:' .. logo .. '}}') end local..." |
mNo edit summary |
||
| Line 16: | Line 16: | ||
end | end | ||
local image = args['image'] or args['photo'] or args['Photo'] or '' | local image = args['image'] or args['photo'] or args['Photo'] or '' | ||
local imageFilename, imageCaption = '', '' | local imageFilename, imageAlt, imageCaption = '', '', '' | ||
if image ~= '' then | if image ~= '' then | ||
imageFilename = frame:preprocess('{{PAGENAME:' .. image .. '}}') | local fn, alt = utils.parseFileLink(image) | ||
if fn then | |||
imageFilename = fn | |||
imageAlt = alt or args['caption'] or args['Caption'] or '' | |||
else | |||
imageFilename = frame:preprocess('{{PAGENAME:' .. image .. '}}') | |||
end | |||
imageCaption = args['caption'] or args['Caption'] or '' | imageCaption = args['caption'] or args['Caption'] or '' | ||
end | end | ||
Revision as of 16:02, August 19, 2025
Documentation for this module may be created at Module:Developer/doc
local utils = require('Module:Utils')
local p = {}
function p.semanticStore(frame)
local titleObj = mw.title.getCurrentTitle()
local args = frame:getParent().args or {}
-- Get and normalize parameter values
local title = args['name'] or args['Name'] or args['title'] or titleObj.text
local logo = args['logo'] or args['Logo'] or ''
local logoFilename = ''
if logo ~= '' then
logoFilename = frame:preprocess('{{PAGENAME:' .. logo .. '}}')
end
local image = args['image'] or args['photo'] or args['Photo'] or ''
local imageFilename, imageAlt, imageCaption = '', '', ''
if image ~= '' then
local fn, alt = utils.parseFileLink(image)
if fn then
imageFilename = fn
imageAlt = alt or args['caption'] or args['Caption'] or ''
else
imageFilename = frame:preprocess('{{PAGENAME:' .. image .. '}}')
end
imageCaption = args['caption'] or args['Caption'] or ''
end
local address = args['address'] or args['Address'] or ''
local country = args['country'] or args['Country'] or ''
local founded = args['founded'] or args['Founded'] or ''
local defunct = args['defunct'] or args['Defunct'] or ''
local acquiredBy = args['acquiredby'] or args['Acquired by'] or ''
local labelOf = args['labelof'] or args['Label of'] or ''
local phone = args['phone'] or args['Phone'] or ''
local fax = args['fax'] or args['Fax'] or ''
local website = args['website'] or args['Website'] or ''
-- Set properties
local data = {
'Has Title=' .. title,
'Has Logo=' .. logoFilename,
'Has Image=' .. imageFilename,
'Has Image Caption=' .. imageCaption,
'Address=' .. address,
'Country=' .. country,
'Foundation Date=' .. founded,
'Defunct Info=' .. defunct,
'Acquired By=' .. acquiredBy,
'Label=' .. labelOf,
'Phone=' .. phone,
'Fax=' .. fax,
'Website URL=' .. website
}
mw.smw.set( data )
end
return p
