Module:Unsigned: Difference between revisions

From Path of Exile 2 Wiki
Jump to navigation Jump to search
(Created page with "local getArgs = require('Module:Arguments').getArgs local p = {} function p.main(frame) local args = getArgs(frame, { wrappers = 'Template:Unsigned' }) r...")
 
m (5 revisions imported)
 
(4 intermediate revisions by 3 users not shown)
Line 4: Line 4:


function p.main(frame)
function p.main(frame)
     local args = getArgs(frame, {
     local args = getArgs(frame)
        wrappers = 'Template:Unsigned'
    })
     return p._main(args)
     return p._main(args)
end
end
Line 26: Line 24:
         end
         end
     end
     end
     local html = mw.html.create()
     local html = mw.html.create('small')
     html
     html
         :tag('small')
         :wikitext(
             :wikitext(
             mw.ustring.format(
                mw.ustring.format(
                '—Preceding [[Help:Signatures|unsigned]] comment added by %s (%s • %s) %s',
                    '—Preceding [[gphelp:Signatures|unsigned]] comment added by %s (%s • %s) %s',
                mw.ustring.format('[[User:%s|%s]]', username, username),
                    mw.ustring.format('[[User:%s|%s]]', username, username),
                mw.ustring.format('[[User talk:%s#top|talk]]', username),
                    mw.ustring.format('[[User talk:%s#top|talk]]', username),
                mw.ustring.format('[[Special:Contributions/%s|contribs]]', username),
                    mw.ustring.format('[[Special:Contributions/%s|contribs]]', username),
                timestamp
                    timestamp
                )
             )
             )
            :done()
        )
     return tostring(html)
     return tostring(html)
end
end


return p
return p

Latest revision as of 16:50, 23 September 2024

Module documentation[create] [purge]
local getArgs = require('Module:Arguments').getArgs

local p = {}

function p.main(frame)
    local args = getArgs(frame)
    return p._main(args)
end

function p._main(args)
    if not args[1] then
        error('Argument "1" is required')
    end
    local username
    local timestamp = mw.ustring.match(args[1], '([^ ]+ [^ ]+ [^ ]+ [^ ]+) .+')
    if timestamp then -- Revision history format
        username = mw.ustring.match(args[1], '[^ ]+ [^ ]+ [^ ]+ [^ ]+ (.+)')
        timestamp = timestamp .. ' (UTC)'
    else -- Standard format
        username = args[1]
        timestamp = args[2] or ''
        if #timestamp > 0 and not mw.ustring.find(timestamp, '(UTC)', 1, true) then
            timestamp = timestamp .. ' (UTC)'
        end
    end
    local html = mw.html.create('small')
    html
        :wikitext(
            mw.ustring.format(
                '—Preceding [[Help:Signatures|unsigned]] comment added by %s (%s • %s) %s',
                mw.ustring.format('[[User:%s|%s]]', username, username),
                mw.ustring.format('[[User talk:%s#top|talk]]', username),
                mw.ustring.format('[[Special:Contributions/%s|contribs]]', username),
                timestamp
            )
        )
    return tostring(html)
end

return p