Module:URL to diff
Appearance
From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by Pppery (talk | contribs) at 01:12, 11 September 2020 (Pppery moved page Module:ConvertDiff to Module:URL to diff without leaving a redirect: Match name with template). The present address (URL) is a permanent link to this version.Revision as of 01:12, 11 September 2020 by Pppery (talk | contribs) (Pppery moved page Module:ConvertDiff to Module:URL to diff without leaving a redirect: Match name with template)
This module implements {{URL to diff }}. Please see the template page for documentation.
The above documentation is transcluded from Module:URL to diff/doc. (edit | history)
Editors can experiment in this module's sandbox (create | mirror) and testcases (create) pages.
Subpages of this module.
Editors can experiment in this module's sandbox (create | mirror) and testcases (create) pages.
Subpages of this module.
-- This module converts Wikipedia diff URLs to the {{diff}} template format. localnewBuffer=require('Module:OutputBuffer') localp={} localfunctiondecodeUrl(url) iftype(url)~='string'then returnnil end url=mw.uri.new(url) ifnoturlorurl.host~='en.wikipedia.org'then returnnil end localdata={} data.title=url.query.titleandmw.uri.decode(url.query.title,'WIKI') data.diff=url.query.diff data.oldid=url.query.oldid data.diffonly=url.query.diffonly returndata end localfunctionencodeDiffTemplate(data) ifnotdata.titleandnotdata.diffandnotdata.oldidthen returnnil end localisNamed=false-- Track whether we need to use named parameters fork,vinpairs(data)do ifstring.find(v,'=')then isNamed=true break end end localgetBuffer,print,printf=newBuffer() print('diff') printf('%s%s',isNamedand'page='or'',data.titleor'') printf('%s%s',isNamedand'diff='or'',data.diffor'') printf('%s%s',isNamedand'oldid='or'',data.oldidor'') ifdata.labelthen printf('%s%s',isNamedand'label='or'',data.label) end ifdata.diffonlythen printf('diffonly=%s',data.diffonly) end localret=getBuffer('|') ret='{{'..ret..'}}' returnret end functionp._url(args) localdata=decodeUrl(args.url) ifdatathen data.label=args.label returnencodeDiffTemplate(data) else returnnil end end functionp.url(frame) localargs=require('Module:Arguments').getArgs(frame,{ wrappers='Template:URL to diff', }) returnp._url(args) end returnp