Module:ThinkerRelations3
Documentation for this module may be created at Module:ThinkerRelations3/doc
local p = {}
local getArgs = require('Module:Arguments').getArgs
function p.main(frame)
local args = getArgs(frame)
local root = mw.html.create('div')
-- 1. Check for relations
local has_relations = false
for i = 1, 5 do
if args['relation_' .. i .. '_target'] then
has_relations = true
break
end
end
if not has_relations then return '' end
-- 3. The Loop
for i = 1, 50 do
local target = args['relation_' .. i .. '_target']
if not target then break end
local content = args['relation_' .. i .. '_content']
local rel_type = args['relation_' .. i .. '_type']
local clean_target = target:gsub('%[%[', ''):gsub('%]%]', '')
local block = root:tag('div'):addClass('relation-block')
-- Header
local header = block:tag('div'):addClass('relation-header')
header:wikitext('To [[' .. clean_target .. ']]')
if rel_type then
header:tag('span')
:addClass('relation-type-tag')
:wikitext(rel_type)
-- Hard-coded color logic (Critique = Red, Influence = Green)
local t = rel_type:lower()
if t:find('critique') or t:find('rivalry') or t:find('opposition') then
block:css('border-left-color', '#e74c3c')
elseif t:find('influence') or t:find('mentor') or t:find('student') then
block:css('border-left-color', '#2ecc71')
end
end
-- Content
if content then
block:tag('div')
:addClass('relation-content')
:wikitext(content)
end
end
return tostring(root)
end
return p