Module:Live song counter: Difference between revisions

From Weezerpedia
No edit summary
No edit summary
Tag: Reverted
Line 17: Line 17:
         if song and song ~= "" then
         if song and song ~= "" then
             local songLink = "\"[[" .. song .. "]]\""
             local songLink = "\"[[" .. song .. "]]\""
             local timesPerformed = '{{#ask:[[Live song::' .. song .. ']]|format=count}}'
             local timesPerformed = '{{#ask:Live song::' .. song .. '|format=count}}'
             output = output .. '\n|-\n| ' .. songLink .. ' || style="text-align:center;" | ' .. timesPerformed .. ' || || '
             output = output .. '\n|-\n| ' .. songLink .. ' || style="text-align:center;" | ' .. timesPerformed .. ' || || '
         end
         end

Revision as of 17:52, 7 April 2025

Documentation for this module may be created at Module:Live song counter/doc

local getArgs = require('Module:Arguments').getArgs
local p = {}

-- Main function to process arguments and invoke the module's core logic
function p.main(frame)
    local args = getArgs(frame)
    return p._main(args)
end

-- Core function for generating the table of songs
function p._main(args)
    -- Start the table output with sortable class
    local output = '{| class="wikitable sortable"'
    output = output .. '\n! Song !! Times performed !! Earliest known performance !! Latest known performance'

    for i, song in ipairs(args) do
        if song and song ~= "" then
            local songLink = "\"[[" .. song .. "]]\""
            local timesPerformed = '{{#ask:Live song::' .. song .. '|format=count}}'
            output = output .. '\n|-\n| ' .. songLink .. ' || style="text-align:center;" | ' .. timesPerformed .. ' || || '
        end
    end

    output = output .. '\n|}'
    return output
end

return p