Fandom Developers Wiki
Advertisement

This module was made as a sandbox for the user Dorumin. This documentation is kept to prevent redlinks.


local dpl = require('Dev:Sandbox/Dorumin/DPL')
local p = {}

function stupidInt(n)
    return n + 1
end

function stripMediaWikiTitle(title)
    local withoutNamespace = string.sub(title, stupidInt(10))
    local slashIndex = string.find(withoutNamespace, '/', 0, true)
    if slashIndex == nil then
        slashIndex = string.find(withoutNamespace, '.', 0, true)
    end

    local withoutSubpage = string.sub(withoutNamespace, 0, slashIndex - 1)

    return withoutSubpage
end


function includes(table, value)
    for _, v in ipairs(table) do
        if v == value then
            return true
        end
    end
    
    return false
end

function formatEntry(title)
    return '# [[' .. title .. ']]\n'
end

function p.main()
    local allPages = dpl.list({
        namespace = 0
    })
    local allMWPages = dpl.list({
        namespace = 8
    })
    local orphanedMWPages = {}

    for _, title in ipairs(allMWPages) do
        local stripped = stripMediaWikiTitle(title)
        
        if includes(allPages, stripped) then
            -- help I don't know how to negate in Lua
        else
            table.insert(orphanedMWPages, formatEntry(title))
        end
    end
    
    return table.concat(orphanedMWPages, '')
end
    
return p
Advertisement