Jump to content

Welcome to the βeta launch of Creatorpedia, make your favorite creator shine.

Module:InfoboxCreator

From Creatorpedia, the creator economy encyclopedia

Technical Details

This module implements the logic for Template:Infobox Creator. It uses the Scribunto Lua engine to render a standardized, SEO-optimized infobox for content creators.

Functions

main(frame)
The primary entry point. Processes arguments from the template call and returns the HTML table.

Dependencies

  • Requires the `infobox` and `vcard` CSS classes in MediaWiki:Common.css.
  • Relies on the Scribunto extension.

local p = {}

-- Main function called by {{#invoke:InfoboxCreator|main}}
function p.main(frame)
    -- Get arguments from the parent template
    local args = frame:getParent().args
    local res = mw.html.create('table')
    
    -- Wikipedia-standard infobox classes (requires your Common.css)
    res:addClass('infobox vcard')
       :css('width', '22em')

    -- HEADER: Moniker/Stage Name
    res:tag('tr'):tag('th')
        :attr('colspan', '2')
        :addClass('fn')
        :css('text-align', 'center')
        :css('font-size', '125%')
        :css('background-color', '#cedff2')
        :wikitext(args.name or mw.title.getCurrentTitle().text)

    -- IMAGE LOGIC
    if args.image then
        local imgRow = res:tag('tr')
        imgRow:tag('td')
            :attr('colspan', '2')
            :css('text-align', 'center')
            :wikitext('[[File:' .. args.image .. '|frameless|size=220px]]')
        if args.caption then
            res:tag('tr'):tag('td')
                :attr('colspan', '2')
                :css('text-align', 'center')
                :wikitext(args.caption)
        end
    end

    -- HELPER FUNCTION FOR ROWS
    local function addRow(label, value, class)
        if value and value ~= "" then
            local row = res:tag('tr')
            row:tag('th'):attr('scope', 'row'):css('text-align', 'left'):wikitext(label)
            local td = row:tag('td'):wikitext(value)
            if class then td:addClass(class) end
        end
    end

    -- DATA FIELDS
    addRow('Birth name', args.birth_name, 'nickname')
    addRow('Born', args.birth_date)
    addRow('Origin', args.birth_place, 'adr')
    addRow('Nationality', args.nationality)
    addRow('Education', args.alma_mater)
    addRow('Other names', args.other_names)
    addRow('Occupation', args.occupation, 'role')
    addRow('Years active', args.years_active)
    addRow('Catchphrase', args.catchphrase)
    addRow('Net worth', args.net_worth)
    addRow('Primary platform', args.platform)
    addRow('Followers', args.followers)
    addRow('Website', args.website)

    return tostring(res)
end

return p