Module:LocationInfo: Difference between revisions

From Little Tail Wiki
Jump to navigationJump to search
Created page with "local capiunto = require 'capiunto' local p = {} function p.main(frame) local args = frame:getParent().args -- Set header style, defaulting to 'background-color:grey' if not provided local headerStyle = args.headerstyle and args.headerstyle ~= '' and string.format('background-color:%s;', args.headerstyle) or 'background-color:grey;' -- Create the infobox local retval = capiunto.create({ title = tostring(mw.title.getCurrentTitle()),..."
 
No edit summary
Line 12: Line 12:
     -- Create the infobox
     -- Create the infobox
     local retval = capiunto.create({
     local retval = capiunto.create({
         title = tostring(mw.title.getCurrentTitle()),
         title = args.title,
         headerStyle = headerStyle,
         headerStyle = headerStyle,
     })
     })

Revision as of 19:33, 2 March 2025

Location name (required)

An example image (IMAGE REQUIRED)
Info.
Origin Country Optional
Namesake Optional
Greater Area Optional
Country Optional
Capital Optional
Ruler Optional
Demographic Optional
Inhabitants Optional


The LocationInfo infobox lists basic facts about the article's featured location.

Infoboxes are put together via Capiunto, which calls upon a Lua-based module. This keeps infoboxes clean and easy to form.

In source editor, excluding any optional row will make that row not render. Leaving out any required fields will throw an error over the page. HTML tags can be used within the infobox if necessary.

Specific rows

  • Japanese name: The location's original name in Japanese
  • Romanized name: The location's Japanese title romanized
  • Origin: The Old World origin of the location
  • Namesake: The namesake of the location
  • Greater area: The general greater area the location is a part of
  • Country: The country the location is in
  • Capital: The capital of the location (mostly for countries).
  • Ruler: The ruler of the location (mostly for countries)
  • Demographics: The location's demographics, i.e. amount of Caninus vs Felinekos
  • Inhabitants: Notable inhabitants of the area

Usage

{{LocationInfo
| title       = Location name (required)
| headerstyle = (defaults to background-color:grey)
| image       = [[File:Waffle.png|200px]]
| caption     = An example image (IMAGE REQUIRED)
| ("Bio.")
| ja_kanji      = Optional
| ja_romaji     = Optional
| origin        = Optional
| namesake      = Optional
| greaterarea   = Optional
| country       = Optional
| capital       = Optional
| ruler         = Optional
| demographic   = Optional
| inhabitants   = Optional
}}



local capiunto = require 'capiunto'

local p = {}

function p.main(frame)
    local args = frame:getParent().args

    -- Set header style, defaulting to 'background-color:grey' if not provided
    local headerStyle = args.headerstyle and args.headerstyle ~= '' and
        string.format('background-color:%s;', args.headerstyle) or 'background-color:grey;'

    -- Create the infobox
    local retval = capiunto.create({
        title = args.title,
        headerStyle = headerStyle,
    })

    -- Add image and caption
    if args.image then
        retval:addImage(args.image, args.caption or '')
    end

    -- Add a general header
    retval:addHeader('Info.')

    -- Add rows only for fields that are not empty
    local rows = {
        { 'Origin Country', args.origin },
        { 'Namesake', args.namesake },
        { 'Greater Area', args.greaterarea },
        { 'Country', args.country },
        { 'Capital', args.capital },
        { 'Ruler', args.ruler },
        { 'Demographic', args.demographic },
        { 'Inhabitants', args.inhabitants },
    }

    for _, row in ipairs(rows) do
        local label, value = row[1], row[2]
        if value and value ~= '' then
            retval:addRow(label, value)
        end
    end

    return retval
end

return p