Module:BookChapterInfo

From Little Tail Wiki
Jump to navigationJump to search
Chapter title

Chapter cover (IMAGE REQUIRED)
Info.
Japanese name Optional
Romanized name Optional
Volume Optional
Pages Optional
Release date Optional
Magazine issue Optional
Previous chapter Optional
Next chapter Optional


The BookChapterInfo infobox lists basic facts about the article's featured book chapter.

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 book's original title in Japanese
  • Romanized name: The book's Japanese title romanized
  • Volume: The number of the volume the chapter is collected in
  • Pages: The number of pages in the chapter
  • Release date: The date the chapter was released. Use the in-store date with magazine issues.
  • Magazine issue: The magazine issue the chapter was released in

Usage

{{BookChapterInfo
| title       = Chapter title
| headerstyle = (defaults to background-color:grey)
| image       = [[File:Unknown.png|200px]]
| caption     =  Chapter image (IMAGE REQUIRED)
| ("Info.")
| ja_kanji = Optional
| ja_romaji = Optional
| vol = Optional
| pages = Optional
| date = Optional
| issue = Optional
| prev_chap = Optional
| next_chap = 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 = {
        { 'Japanese name', args.ja_kanji },
        { 'Romanized name', args.ja_romaji },
        { 'Volume', args.vol },
        { 'Pages', args.pages },
        { 'Release date', args.date },
        { 'Magazine issue', args.issue },
        { 'Previous chapter', args.prev_chap },
        { 'Next chapter', args.next_chap },

    }

    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