Module:Event: Difference between revisions
From PC Gaming Shelter
No edit summary |
No edit summary |
||
| (10 intermediate revisions by the same user not shown) | |||
| Line 10: | Line 10: | ||
['Has genre'] = {'Has genre', ',' }, | ['Has genre'] = {'Has genre', ',' }, | ||
['Has short description'] = {'Has short description' }, | ['Has short description'] = {'Has short description' }, | ||
['Is recurring'] = {'Is recurring event' }, | ['Is recurring'] = {'Is recurring event' }, | ||
['Has tag'] = {'Has tag', ',' } | ['Has tag'] = {'Has tag', ',' } | ||
| Line 33: | Line 31: | ||
order = '2', | order = '2', | ||
rows = { | rows = { | ||
'Is recurring', | 'Is recurring', | ||
'Has start date', | 'Has start date', | ||
'Has end date', | 'Has end date', | ||
'Recurring period', | |||
'Recurring unit', | |||
'Include dates', | |||
'Exclude dates', | |||
'Has tag' | 'Has tag' | ||
} | } | ||
| Line 61: | Line 60: | ||
local infobox = utils.createInfobox(frame, category, properties, sections, footer) | local infobox = utils.createInfobox(frame, category, properties, sections, footer) | ||
return infobox | return infobox | ||
end | |||
function p.setDates(frame) | |||
local args = frame.args | |||
local propMap = { | |||
['Has start date'] = args['start'] or '', | |||
['Has end date'] = args['end'] or args['start'] | |||
} | |||
mw.smw.set(propMap) | |||
end | |||
function p.setRecurringEvent(frame) | |||
local args = frame.args | |||
local recurringEvent = { | |||
[1] = '', | |||
property = args.property or 'Has start date', | |||
start = args.start or '', | |||
['end'] = args['end'] or '', | |||
unit = args.unit or 'month', | |||
period = args.period or '1', | |||
include = args.include or '', | |||
exclude = args.exclude or '', | |||
} | |||
return frame:callParserFunction( '#set_recurring_event', recurringEvent ) | |||
end | end | ||
return p | return p | ||
Latest revision as of 11:10, 18 June 2026
Documentation for this module may be created at Module:Event/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 genre'] = {'Has genre', ',' },
['Has short description'] = {'Has short description' },
['Is recurring'] = {'Is recurring event' },
['Has tag'] = {'Has tag', ',' }
}
return propMap
end
local function infoboxSectionPlan()
local sectionMap = {
['Cover image'] = {
heading = '',
template = 'Infobox/Cover',
order = '1',
rows = {
'Image'
}
},
['Event Info'] = {
heading = 'Event Info',
template = 'Infobox/Event Info',
order = '2',
rows = {
'Is recurring',
'Has start date',
'Has end date',
'Recurring period',
'Recurring unit',
'Include dates',
'Exclude dates',
'Has tag'
}
},
['Event Links'] = {
heading = 'Discover & Join',
template = 'Infobox/Event links',
order = '3',
rows = {
'Event links'
}
}
}
return sectionMap
end
function p.infobox(frame)
local category = 'Events'
local properties = propertiesPlan()
local sections = infoboxSectionPlan()
local footer = ''
local infobox = utils.createInfobox(frame, category, properties, sections, footer)
return infobox
end
function p.setDates(frame)
local args = frame.args
local propMap = {
['Has start date'] = args['start'] or '',
['Has end date'] = args['end'] or args['start']
}
mw.smw.set(propMap)
end
function p.setRecurringEvent(frame)
local args = frame.args
local recurringEvent = {
[1] = '',
property = args.property or 'Has start date',
start = args.start or '',
['end'] = args['end'] or '',
unit = args.unit or 'month',
period = args.period or '1',
include = args.include or '',
exclude = args.exclude or '',
}
return frame:callParserFunction( '#set_recurring_event', recurringEvent )
end
return p
