Jump to content

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

Module:InfoboxCreator: Difference between revisions

Godman Andrew
Godman Andrew (talk | contribs) (Created page with "local p = {} function p.main(frame) local args = frame:getParent().args local res = mw.html.create('table') res:addClass('infobox') :css('width', '22em') :css('font-size', '88%') :css('line-height', '1.5em') -- HEADER: The Creator's Name res:tag('tr'):tag('th') :attr('colspan', '2') :css('text-align', 'center') :css('font-size', '125%') :css('font-weight', 'bold') :css('background-col...")
 
 
Line 1: Line 1:
local p = {}
local p = {}


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


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


     -- IMAGE
     -- IMAGE LOGIC
     if args.image then
     if args.image then
         local imgRow = res:tag('tr')
         local imgRow = res:tag('tr')
Line 30: Line 31:
                 :attr('colspan', '2')
                 :attr('colspan', '2')
                 :css('text-align', 'center')
                 :css('text-align', 'center')
                :css('font-size', '90%')
                 :wikitext(args.caption)
                 :wikitext(args.caption)
         end
         end
Line 36: Line 36:


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


     -- SECTION: PERSONAL DATA
     -- DATA FIELDS
     addRow('Birth name', args.birth_name)
     addRow('Birth name', args.birth_name, 'nickname')
     addRow('Born', args.birth_date)
     addRow('Born', args.birth_date)
     addRow('Origin', args.birth_place)
     addRow('Origin', args.birth_place, 'adr')
     addRow('Nationality', args.nationality)
     addRow('Nationality', args.nationality)
     addRow('Education', args.alma_mater)
     addRow('Education', args.alma_mater)
    -- SECTION: CREATOR DATA
     addRow('Other names', args.other_names)
     addRow('Other names', args.other_names)
     addRow('Occupation', args.occupation)
     addRow('Occupation', args.occupation, 'role')
     addRow('Years active', args.years_active)
     addRow('Years active', args.years_active)
    addRow('Niche', args.niche)
     addRow('Catchphrase', args.catchphrase)
     addRow('Catchphrase', args.catchphrase)
   
    -- SECTION: BUSINESS (The Giant Factor)
     addRow('Net worth', args.net_worth)
     addRow('Net worth', args.net_worth)
    addRow('Endorsements', args.endorsements)
     addRow('Primary platform', args.platform)
   
     addRow('Followers', args.followers)
    -- SECTION: PLATFORMS
     addRow('Primary Platform', args.platform)
     addRow('Follower Count', args.followers)
     addRow('Website', args.website)
     addRow('Website', args.website)