Module:RandomQueue

local p = {}

local function escapePattern(str) return mw.ustring.gsub(str, "([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1") end local start1 = '' local stop1 = '' local listpatt = escapePattern(start1) .. '(.-)' .. escapePattern(stop1) local linkpatt = "%[%[[^%]\n]+%]%]" local namepatt = "[^%]|]" local patt = ".*%}%}\n(.*?)(.*?)(.*?)$"

local function main(list_page) local wikitext = mw.title.new(list_page):getContent local raw_list = mw.ustring.match(wikitext, listpatt) local list = {} for link in mw.ustring.gmatch(raw_list, linkpatt) do       list[#list + 1] = link end math.randomseed(os.time) local num = math.random(1, #list) local pagename = mw.ustring.gsub(list[num], "%[%[(.*)%]%]", "%1") pagename = mw.ustring.gsub(pagename, "(.*)%|.*", "%1") local page = mw.title.new(pagename) local pagetext = page:getContent -- local s = mw.ustring.gsub(pagetext, patt, "%%%2%%%3%%%4") -- return s	return pagetext end

function p.FA(frame) return main('Wookieepedia:Featured articles') end function p.GA(frame) return main('Wookieepedia:Good articles') end function p.CA(frame) return main('Wookieepedia:Comprehensive articles') end

return p