Jump to content

Module:Metrics dashboard

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Harej (talk | contribs) at 02:59, 11 May 2023 (adding class name). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}

local function listItem(value, label)
    return string.format('* <span class="md-value">%s</span><span class="md-label">%s</span>', value, label)
end

function p.list(frame)
    local output = ''
    local i = 1
    local args = frame:getParent().args

    while args['figure' .. i .. '-value'] and args['figure' .. i .. '-label'] do
        local value = args['figure' .. i .. '-value']
        local label = args['figure' .. i .. '-label']

        output = output .. listItem(value, label) .. '\n'

        i = i + 1
    end

    output = output .. '<div class="metrics-dashboard-footer" style="display: flex; justify-content: space-between; font-size: smaller; padding-top: 2em; padding-bottom: 1.5em;">'
    if args['footer'] then
        output = output .. '<span style="text-align: left;">' .. args['footer'] .. '</span>'
    else
        output = output .. '<span></span>'
    end
    if args['last-updated'] then
        if args['bot'] then
            local user_link = frame:preprocess('{{U|' .. args['bot'] .. '}}')
            output = output .. '<span style="text-align: right; font-style: italic;"> Last updated by 🤖 ' .. user_link .. ' on ' .. args['last-updated'] .. '</span>'
        else
            output = output .. '<span style="text-align: right; font-style: italic;"> Last updated: ' .. args['last-updated'] .. '</span>'
        end
    end
    output = output .. '</div>'

    return output
end

return p