Jump to content

Module:Old moves

Permanently protected module
From Wikipedia, the free encyclopedia

-- This module implements {{Old move}}.localp={}localmessageBox=require('Module:Message box')localyesno=require('Module:Yesno')localdateModule=require('Module:Date')._DatelocallistModule=require('Module:List').horizontal-- Create variable used in other functionslocalpageTypeif(mw.title.getCurrentTitle():inNamespace(1))thenpageType="article"elsepageType="page"end-- Build the HTML for collapsing listslocalfunctionmakeCollapsible(list,text)localbox=mw.html.create("div")box:addClass("mw-collapsible mw-collapsed"):css('padding','0.5em 0 0'):tag('div'):css('font-weight','bold'):wikitext(text):done():tag("div"):addClass('mw-collapsible-content'):wikitext(mw.ustring.format("\n%s",list))returnboxendlocalfunctionsingleText(args)localdate=args["date"]orargs["date1"]or""localfrom=args["from"]orargs["from1"]or""localto=args["destination"]orargs["destination1"]orargs["to1"]orargs["to"]or""localresult=args["result"]orargs["result1"]or""locallink=args["link"]orargs["link1"]or""localdateformat=args["dateformat"]or"dmy"localtext=""if(date~="")thenifdateModule(date)thendate=dateModule(date):text(dateformat)endtext=mw.ustring.format("On %s, it was proposed that this %s be [[Wikipedia:Requested moves|moved]]",date,pageType)elsetext=mw.ustring.format("It has previously been proposed that this %s be [[Wikipedia:Requested moves|moved]]",pageType)endif(from~="")thentext=mw.ustring.format("%s from [%s %s]",text,tostring(mw.uri.fullUrl(from,{redirect="no"})),from)endif(to~="")thentext=mw.ustring.format("%s to [[%s]]",text,to)endtext=mw.ustring.format("%s.",text)if(result~="")thenif(link~="")thentext=mw.ustring.format("%s The result of [[%s|the discussion]] was '''%s'''.",text,link,result)elsetext=mw.ustring.format("%s The result of the discussion was '''%s'''.",text,result)endelseif(link~="")thentext=mw.ustring.format("%s See [[%s|discussion]].",text,link)endreturntextendlocalfunctionrow(args,i)localdate=args["date"..i]or""localfrom=args["from"..i]or""localdateformat=args["dateformat"]or"dmy"localto=args["destination"..i]orargs["to"..i]or""localresult=mw.language.getContentLanguage():ucfirst(args["result"..i])or""locallink=args["link"..i]or""localrowText=mw.ustring.format("\n*'''%s'''",result)if(date~="")thenifdateModule(date)thendate=dateModule(date):text(dateformat)endrowText=mw.ustring.format("%s, %s",rowText,date)endif(from~="")thenrowText=mw.ustring.format("%s, from [%s %s]",rowText,tostring(mw.uri.fullUrl(from,{redirect="no"})),from)if(to~="")thenrowText=mw.ustring.format("%s to [[%s]]",rowText,to)endelseif(to~="")thenrowText=mw.ustring.format("%s, to [[%s]]",rowText,to)endif(link~="")thenrowText=mw.ustring.format("%s, see [[%s|discussion]]",rowText,link)endrowText=rowText.."."returnrowTextendlocalfunctionlist(args)localtext=""if(args["result1"])then-- Support to1 and to in case of multiple rowstext=mw.ustring.format("%s%s",text,row(args,1))elsetext=mw.ustring.format("%s%s",text,row(args,""))endlocali=2while(args["result"..i])dotext=mw.ustring.format("%s%s",text,row(args,i))i=i+1-- Check if to(i+1) existendreturntextendlocalfunctionmanualList(args)localmanualListText=""if(args["list"]orargs[1])thenif(args["result"]orargs["result1"])thenmanualListText=mw.ustring.format("%s\n'''Other discussions: '''\n%s",manualListText,args["list"]orargs[1])elsemanualListText=mw.ustring.format("%s\n%s",manualListText,args["list"]orargs[1])endendif(args["oldlist"])thenif(yesno(args["collapse"])oryesno(args["collapsed"]))thenmanualListText=mw.ustring.format("%s\n'''Older discussions: '''\n%s",manualListText,tostring(args["oldlist"]))elsemanualListText=mw.ustring.format("%s\n%s",manualListText,tostring(makeCollapsible(args["oldlist"],"Older discussions:")))endendreturnmanualListTextendlocalfunctionshowLogs(args)locallogList,i={},1while(args["title"..i])dolocalquery=mw.uri.buildQueryString({["page"]=args["title"..i],["type"]="move"})if(i==1)then-- Hacky way to make the hlist go after "move logs"table.insert(logList,mw.ustring.format("\n'''Move logs: '''[%s %s]",tostring(mw.uri.canonicalUrl("Special:Log",query)),args["title"..i]))elsetable.insert(logList,mw.ustring.format("[%s %s]",tostring(mw.uri.canonicalUrl("Special:Log",query)),args["title"..i]))endi=i+1endlogList["style"]="padding-top: 0.5em;"returnlistModule(logList)endlocalfunctionevaluate(args)localtext=""localis_collapsed=yesno(args["collapse"])oryesno(args["collapsed"])localhas_log_args=args["title"]orargs["title1"]localhas_manual_list=args["list"]orargs[1]orargs["oldlist"]localhas_multiple_rows=args["result1"]if(has_log_args)thentext=mw.ustring.format("%s%s",text,showLogs(args))endif(notis_collapsedorhas_log_args)then-- if the template is collapsed and there are no log arguments,-- then we already have "Discussions:" in bold text in bannerText(),-- so we don't need to repeat it heretext=mw.ustring.format("%s\n'''Discussions: '''\n",text)end-- This makes sure we don't show the single version when there's a log or manual listif(args["result"])thenif(has_log_argsorhas_manual_listorargs["result2"])thentext=mw.ustring.format("%s%s",text,list(args))elsetext=singleText(args)endendif(has_multiple_rows)thentext=mw.ustring.format("%s%s",text,list(args))endif(has_manual_list)thentext=mw.ustring.format("%s%s",text,manualList(args))if(args[1])thentext=mw.ustring.format("%s%s",text,"[[Category:Talk pages listing old moves with the first unnamed parameter]]")endendif(notargs["result"]andnothas_multiple_rowsandnothas_manual_listandnothas_log_args)thenreturn""endreturntextendlocalfunctionbannerText(args)localblurb=mw.ustring.format("This %s has previously been nominated to be moved.".." Please review the prior discussions if you are considering re-nomination.",pageType)locallist=""if(yesno(args["collapse"])oryesno(args["collapsed"]))thenif(args["title"]orargs["title1"])thenlist=mw.ustring.format("%s%s",blurb,tostring(makeCollapsible(evaluate(args),"Logs and discussions:")))elselist=mw.ustring.format("%s%s",blurb,tostring(makeCollapsible(evaluate(args),"Discussions:")))endelselist=evaluate(args)if(mw.ustring.find(list,"proposed that this")==nil)thenlist=mw.ustring.format("%s%s",blurb,evaluate(args))endendreturnlistendlocalfunctionrenderBanner(args)returnmessageBox.main('tmbox',{small=yesno(args["small"]),type='move',text=bannerText(args)})endfunctionp.main(frame)localargs=require('Module:Arguments').getArgs(frame)returnrenderBanner(args)endreturnp
close