Module:RandomQuote

local p = {} local function escapePattern(str) return mw.ustring.gsub(str, "([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1") end local start = '' local stop = '' local listpatt = escapePattern(start) .. '(.-)' .. escapePattern(stop) local linkpatt = "%[%[Wookieepedia:Quote of the Day[^%]\n]+%]%]" local function pick_article(mode) local list = {} local quote_list = " " local pagename, pagetext, filename = " " quote_list = mw.title.new('Wookieepedia:Quote of the Day/Archive Calendar'):getContent quote_list = fa_list:match(listpatt) for link in quote_list:gmatch(linkpatt) do		pagename = link:gsub("%[%[(.*)%]%]", "%1") pagename = pagename:gsub("(.*)%|.*", "%1") list[#list + 1] = pagename end local num = 0 math.randomseed(os.time) num = math.random(1, #list) -- Extract the page name and load it	return list[num] end

local function queueify(pagename) local pagetext = mw.title.new(pagename):getContent local x = pagetext:gsub("%<noinclude(.*)", "") return x end

function p._main(args) local pagename, result if args.page then pagename = args.page else pagename = pick_article(string.lower(args.mode)) end result = queueify(pagename) return result end

function p.main(frame) local args = {} for k, v in pairs(frame:getParent.args) do		v = v:match('^%s*(.-)%s*$') -- trim whitespace if v ~= '' then args[k] = v		end end return p._main(args) end return p