FANDOM


local p = {}
 
local function escapePattern(str)
    return mw.ustring.gsub(str, "([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1")
end
 
local start = '<!--Start-->'
local stop = '<!--End-->'
local listpatt = escapePattern(start) .. '(.-)' .. escapePattern(stop)
local linkpatt = "%[%[Wookieepedia:Quote of the Day[^%]\n]+%]%]"
 
local function pick_article()
	local list = {}
	local quote_list = " "
	local pagename, pagetext, filename = " "
 
	quote_list = mw.title.new('Wookieepedia:Quote of the Day/Archive Calendar'):getContent()
	quote_list = quote_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
 
function p._main(args)
	local pagename, result
	if args.page then
		pagename = "Wookieepedia:Quote of the Day/" .. args.page
	else
		pagename = pick_article()
	end
 
	result = mw.title.new(pagename):getContent()
	result = result:gsub("%{%{[Qq]uote2%|", "%{%{Quote%|")
	result = result:gsub("%<noinclude(.*)", "")
	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 frame:preprocess(p._main(args))
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.