Module:Community: Difference between revisions
From PC Gaming Shelter
No edit summary |
No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 31: | Line 31: | ||
'Related game', | 'Related game', | ||
'Has status', | 'Has status', | ||
' | 'Year active from', | ||
' | 'Year active until', | ||
'Has short description' | 'Has short description' | ||
} | } | ||
| Line 61: | Line 61: | ||
local from = utils.clean(args['from']) | local from = utils.clean(args['from']) | ||
local until_year = utils.clean(args['until']) | local until_year = utils.clean(args['until']) | ||
local result | |||
if from and until_year then | if from and until_year then | ||
if from == until_year then | if from == until_year then | ||
result = from | |||
else | |||
result = from .. '–' .. until_year | |||
end | end | ||
elseif from then | elseif from then | ||
result = from .. '–present' | |||
elseif until_year then | elseif until_year then | ||
result = 'until ' .. until_year | |||
else | |||
return '' | |||
end | end | ||
mw.smw.set({ | |||
['Has activity period'] = result, | |||
['Year active from'] = from, | |||
['Year active until'] = until_year | |||
}) | |||
return result | |||
end | end | ||
return p | return p | ||
Latest revision as of 16:17, 15 June 2026
Documentation for this module may be created at Module:Community/doc
local utils = require( 'Module:Utils' )
local p = {}
local function propertiesPlan()
-- ['Form field name'] = { 'Semantic property', 'delimiter' }
local propMap = {
['Image'] = {'Image', 'file' },
['Related game'] = {'Related game' },
['Has status'] = {'Has status' },
['Has short description'] = {'Has short description' }
}
return propMap
end
local function infoboxSectionPlan()
local sectionMap = {
['Cover image'] = {
heading = '',
template = 'Infobox/Cover',
order = '1',
rows = {
'Image'
}
},
['Clan Info'] = {
heading = 'Community Info',
template = 'Infobox/Community Info',
order = '2',
rows = {
'Related game',
'Has status',
'Year active from',
'Year active until',
'Has short description'
}
},
['Community links'] = {
heading = 'Join',
template = 'Infobox/Community links',
order = '3',
rows = {
'Community links'
}
}
}
return sectionMap
end
function p.infobox(frame)
local category = 'Communities'
local properties = propertiesPlan()
local sections = infoboxSectionPlan()
local footer = 'Community footer'
local infobox = utils.createInfobox(frame, category, properties, sections, footer)
return infobox
end
function p.yearsActive(frame)
local args = frame.args
local from = utils.clean(args['from'])
local until_year = utils.clean(args['until'])
local result
if from and until_year then
if from == until_year then
result = from
else
result = from .. '–' .. until_year
end
elseif from then
result = from .. '–present'
elseif until_year then
result = 'until ' .. until_year
else
return ''
end
mw.smw.set({
['Has activity period'] = result,
['Year active from'] = from,
['Year active until'] = until_year
})
return result
end
return p
