Module:T-LibraryInterview: Difference between revisions

// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
--Module:T-LibraryInterview
--Module:T-LibraryInterview
-- Renders the Internet & Digital Governance Library template for Interviews, making use of ICANNWiki's "Template Blueprint Framework"
-- Makes use of ICANNWiki's "Template Blueprint Framework" to render the "Internet & Digital Governance Library" template


local p = {}
local p = {}
Line 7: Line 7:
local Blueprint = require('Module:LuaTemplateBlueprint')
local Blueprint = require('Module:LuaTemplateBlueprint')
local ErrorHandling = require('Module:ErrorHandling')
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 ==========
-- ========== Helper Functions ==========
Line 44: Line 26:
})
})


-- Initialize the standard configuration
-- Blueprint default: Initialize the standard configuration
Blueprint.initializeConfig(template)
Blueprint.initializeConfig(template)


-- Get property mappings from ConfigRepository for tooltips
-- ================================================================================
local propertyMappings = ConfigRepository.templates.LibraryInterview.semantics.properties


-- ================================================================================
-- TEMPLATE-SPECIFIC CALLS AND CODE


-- ========== Preprocessors ==========
-- ========== Preprocessors ==========
-- The ID field is handled by the 'setPageIdField' preprocessor
-- Basic preprocessors
Blueprint.addPreprocessor(template, 'setPageIdField')
Blueprint.addPreprocessor(template, 'setPageIdField')
-- Helper function to extract plain text from wiki links for semantic properties
local TemplateHelpers = require('Module:TemplateHelpers')
local function extractSemanticValue(fieldValue, fieldName)
    return TemplateHelpers.extractSemanticValue(fieldValue, fieldName, errorContext)
end
-- 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 ==========
-- ========== Main Render Function ==========
-- Main render function which delegates to the template's render method
-- Blueprint default: Render
function p.render(frame)
function p.render(frame)
     return ErrorHandling.protect(
     return ErrorHandling.protect(