Module:Feature page

-- Displays content from randomly featured live article from a list or lua table (e.g. Module:Top/data) local p ={} local utility = require("Dev:Utility") function p.main(frame) local tArgs = utility.getArgs(frame) local extTable if tArgs then extTable = mw.clone(tArgs) if tArgs["#table"] then extTable = require(tArgs["#table"]) end math.randomseed(os.time) math.random local iRand = math.random(#extTable) local titleFeatured = mw.title.new(extTable[iRand]) local pageContents = mw.clone(titleFeatured:getContent) -- Follow redirect once if titleFeatured.isRedirect then pageContents = pageContents:match("%[%[(.-)%]%]") titleFeatured = mw.title.new(pageContents) end --Sanitize content and display if titleFeatured and titleFeatured.exists then pageContents = mw.clone(titleFeatured:getContent) pageContents = mw.text.truncate(pageContents,300) pageContents = string.gsub(pageContents,"%.-%<%/ref%>","") pageContents = pageContents:gsub("%[%[File%:.-%]%]","") pageContents = mw.text.truncate(pageContents,200) return pageContents end end end return p