Module:T-Event
Appearance
Documentation for this module may be created at Module:T-Event/doc
--Module:T-Event
-- Makes use of ICANNWiki's "Template Blueprint Framework" to render the "Event" template
local p = {}
-- ==================== Required modules ====================
local Blueprint = require('Module:LuaTemplateBlueprint')
local TemplateHelpers = require('Module:TemplateHelpers')
local ErrorHandling = require('Module:ErrorHandling')
local LinkParser = require('Module:LinkParser')
-- ==================== Helper Functions ====================
-- Blueprint default: Create error context for the module
local errorContext = ErrorHandling.createContext("T-Event")
-- ================================================================================
-- IMPORTANT! TEMPLATE BLUEPRINT FRAMEWORK INSTRUCTIONS
-- CONTROL OF TEMPLATE FEATURES: THIS LIST SPECIFIES IN AN EXPLICIT MANNER WHAT FEATURES ARE TO BE CALLED/RENDERED BY THE TEMPLATE.
local template = Blueprint.registerTemplate('Event', {
features = {
title = true,
logo = true,
fields = true,
navigation = true,
socialMedia = true,
semanticProperties = true,
categories = true,
errorReporting = true
}
})
-- Blueprint default: Initialize standard configuration
Blueprint.initializeConfig(template)
-- CONTROL THE VISUAL ORDER THAT EACH ASPECT IS RENDERED IN
template.config.blockSequence = {
'title',
'logo',
'fields',
'navigation',
'socialMedia',
'semanticProperties',
'categories',
'errors'
}
-- ================================================================================
-- TEMPLATE-SPECIFIC CALLS AND CODE
-- ELEMENT:NAVIGATION
local ElementNavigation = ErrorHandling.safeRequire(errorContext, 'Module:ElementNavigation', false)
if ElementNavigation and ElementNavigation.elementName then
Blueprint.registerElement(ElementNavigation.elementName, ElementNavigation)
Blueprint.addElementToTemplate(template, 'navigation')
template.config.navigation = {
prevLabel = "← %s",
nextLabel = "%s →",
classPrefix = "event"
}
end
-- CUSTOM DATE-RANGE PROCESSOR
-- In cases where there are both "start" and "ending" dates to the event, we join them into a single "Date" field, with the dates separated by a "–" (En dash)
template.config.processors = template.config.processors or {}
template.config.processors.start = function(value, args, template)
local endDate = args['ending']
if endDate and endDate ~= '' then
return TemplateHelpers.formatDateRange(value, endDate, {outputMode="complete"})
end
return TemplateHelpers.normalizeDates(value)
end
template.config.processors.ending = function(value, args, template)
return false
end
-- ================================================================================
-- ==================== Preprocessors ====================
-- Basic preprocessors
Blueprint.addPreprocessor(template, 'setPageIdField') -- Blueprint default
Blueprint.addPreprocessor(template, 'deriveRegionFromCountry') -- Possible blueprint default
-- ==================== Main Render Function ====================
-- Blueprint default: Render
function p.render(frame)
return ErrorHandling.protect(
errorContext,
"render",
function()
return template.render(frame)
end,
ErrorHandling.getMessage("TEMPLATE_RENDER_ERROR"),
frame
)
end
return p