Module:T-LibraryInterview: Difference between revisions
Appearance
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| Line 54: | Line 54: | ||
-- ================================================================================ | -- ================================================================================ | ||
-- TEMPLATE-SPECIFIC CALLS AND CODE | |||
-- Get property mappings from ConfigRepository for tooltips | -- Get property mappings from ConfigRepository for tooltips | ||
| Line 80: | Line 82: | ||
-- ========== Main Render Function ========== | -- ========== Main Render Function ========== | ||
-- | -- Blueprint default: Render | ||
function p.render(frame) | function p.render(frame) | ||
return ErrorHandling.protect( | return ErrorHandling.protect( | ||
Revision as of 04:48, 1 May 2025
Documentation for this module may be created at Module:T-LibraryInterview/doc
--Module:T-LibraryInterview
-- Renders the Internet & Digital Governance Library template for Interviews, making use of ICANNWiki's "Template Blueprint Framework"
local p = {}
-- ========== Required modules ==========
local Blueprint = require('Module:LuaTemplateBlueprint')
local TemplateHelpers = require('Module:TemplateHelpers')
local ErrorHandling = require('Module:ErrorHandling')
local ConfigRepository = require('Module:ConfigRepository')
local LinkParser = require('Module:LinkParser')
-- Blueprint default: Module-level cache for lazy-loaded modules
local moduleCache = {}
-- Blueprint default: Lazy module loader
local function lazyRequire(moduleName)
return function()
if not moduleCache[moduleName] then
moduleCache[moduleName] = require(moduleName)
end
return moduleCache[moduleName]
end
end
-- Blueprint default: Modules to lazy load
-- local getTemplateHelpers = lazyRequire('')
-- ========== Helper Functions ==========
-- Blueprint default: Create error context for the module
local errorContext = ErrorHandling.createContext("T-LibraryInterview")
-- Blueprint default: Helper for extracting semantic values from wiki links
local function extractSemanticValue(fieldValue, fieldName)
return TemplateHelpers.extractSemanticValue(fieldValue, fieldName, errorContext)
end
-- ================================================================================
-- 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. EXTENSIVE TESTING WAS PERFORMED SO THAT THIS CAN BE TOGGLED AT ANY TIME WITH A TRUE/FALSE BOOLEAN CHOICE FROM THIS MODULE, AS IT CAN BE DONE IN ANY OTHER MODULE USING ICANNWIKI'S THE TEMPLATE BLUEPRINT FRAMEWORK
local template = Blueprint.registerTemplate('LibraryInterview', {
features = {
title = true,
fields = true,
semanticProperties = true,
categories = true,
errorReporting = true
}
})
-- Blueprint default: Initialize the standard configuration
Blueprint.initializeConfig(template)
-- ================================================================================
-- TEMPLATE-SPECIFIC CALLS AND CODE
-- Get property mappings from ConfigRepository for tooltips
local propertyMappings = ConfigRepository.templates.LibraryInterview.semantics.properties
-- ========== Preprocessors ==========
-- The ID field is handled by the 'setPageIdField' preprocessor
Blueprint.addPreprocessor(template, 'setPageIdField')
-- Configure semantic properties and transforms for interviewer and interviewee
template.config.semantics = template.config.semantics or {}
template.config.semantics.properties = template.config.semantics.properties or {}
template.config.semantics.properties["Has interviewee"] = "Interviewee"
template.config.semantics.properties["Has interviewer"] = "Interviewer"
template.config.semantics.transforms = template.config.semantics.transforms or {}
template.config.semantics.transforms["Has interviewee"] = function(value)
return extractSemanticValue(value, "Interviewee")
end
template.config.semantics.transforms["Has interviewer"] = function(value)
return extractSemanticValue(value, "Interviewer")
end
template.config.semantics.transforms["Has person"] = function(value)
return extractSemanticValue(value, "Person")
end
-- ========== 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