Module:Related changes

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
Module documentation[view] [edit] [history] [purge]

The module “Related changes” is a Lua counterpart to Special:Related changes. Unlike that feature, the module only has access to the last revision date and user. However, it can be run through filters so that only the articles that have gone longest without being edited are listed, only IP users are listed, bots are omitted, etc. ( That is, it can be run through those filters once that part is written! Present status is "proof of concept" only.)

Usage[edit]

To find related changes for Velociraptor: {{#invoke:Related changes|main|Velociraptor}}

Name Last edited Last editor
dromaeosaurid 20040510163407 User:205.204.242.21
disembowel 20040725074017 User:Johnleemk
oviraptorid 20050108220604 User:68.81.231.127
AMNH 20050312001552 User:68.62.162.65
troodontid 20060108175718 User:Dinoguy2
azhdarchid 20060118015041 User:Dinoguy2
Oviraptor philoceratops 20061014113042 User:Eugene van der Pijll
biped 20061217180949 User:Samsara
Tsaagan mangas 20070826091108 User:Eugene van der Pijll
Magnirostris dodsoni 20070903033750 User:J. Spencer
Pinacosaurus grangeri 20070903035337 User:J. Spencer
Protoceratops andrewsi 20070903035633 User:J. Spencer
Saurornithoides mongoliensis 20070903144034 User:J. Spencer
phylogenetic taxonomy 20070915141830 User:Dinoguy2
prezygapophysis 20080115032435 User:RussBot
Protoceratops hellenikorhinus 20080617032609 User:J. Spencer
faunal stage 20080708212448 User:RussBot
paravian 20100112182440 User:Abyssal
Linheraptor exquisitus 20100319035204 User:Darth Ag.Ent
Pinacosaurus mephistocephalus 20101130002739 User:Dinoguy2
Machairasaurus leptonychus 20101130002858 User:Dinoguy2
million years ago 20121027075733 User:Cpiral
pronation 20131218041834 User:Tom (LT)
vertebrate trachea 20140329223655 User:Tom (LT)
20140617182158 User:Abyssal
nocturnal 20140707061241 User:SoledadKabocha
geologic formation 20140912012624 User:Invadibot
Manus (zoology) 20141005033511 User:SoledadKabocha
Lateral and medial 20141109165013 User:Bamyers99
carpal 20151005013008 User:Xqbot
20160528065724 User:Look2See1
Tarsometatarsus 20160908012739 User:Look2See1
20161117191811 User:Abyssal
paraphyletic 20170103192036 User:72.239.0.15
20170110183441 User:184.186.6.124
20170223082843 User:Caftaric
feathers 20170608195248 User:Tom.Reding
sclerotic ring 20170620120710 User:151.177.62.193
Bayan Mandahu Formation 20170831023432 User:Tisquesusa
carotid artery 20170925203446 User:Facts707
Latin language 20171011145819 User:NewEnglandYankee
type specimen 20171107172511 User:Leo1pard
cursorial 20171123221912 User:69.122.115.223
birds of prey 20171124214320 User:2601:541:4304:E6B0:218:8BFF:FE74:FE4F
Pascal Godefroit 20171210223243 User:Spicemix
Gregory S. Paul 20171226190950 User:MWAK
cathemeral 20171229064825 User:SoledadKabocha
20180118025710 User:Hike395
Ömnögovi Province 20180122200036 User:InternetArchiveBot
Timeline of dromaeosaurid research 20180217092728 User:Rjwilmsi
The Truth About Killer Dinosaurs 20180224122127 User:162.254.122.172
Epoch (geology) 20180304192458 User:Vsmith
jugular vein 20180306024735 User:ClueBot NG
claw 20180311164009 User:HCA
Campanian 20180315121308 User:Vsmith
Archaeopterygidae 20180322140540 User:Tom.Bot
Adasaurus 20180322150328 User:Tom.Bot
Bambiraptor 20180323011623 User:Tom.Bot
Tianyuraptor 20180323015303 User:Tom.Bot
Oviraptor 20180323023120 User:Tom.Bot
Achillobator 20180323030032 User:Tom.Bot
Rahonavis 20180323031921 User:Tom.Bot
Dakotaraptor 20180323045516 User:Tom.Bot
dewclaw 20180324113548 User:70.176.54.26
Unenlagiinae 20180329130134 User:Yobot
Tenontosaurus 20180330175833 User:Mikenorton
muscle 20180330211925 User:Marcos canbeiro
20180401225225 User:JarBot
Halszka Osmólska 20180412072206 User:Kintaro
Mongolian Academy of Sciences 20180412084341 User:103.14.38.130
maniraptora 20180413175658 User:Richard.sutt
pack hunter 20180428192043 User:75.110.35.202
Azhdarchidae 20180501091006 User:203.194.54.245
Saurornitholestes 20180503163002 User:Saberrex-Strongheart
Dromaeosaurus 20180503163054 User:Saberrex-Strongheart
Atrociraptor 20180504102749 User:115.64.191.197
nomen nudum 20180505123258 User:Mgiganteus1
Barun Goyot Formation 20180508002309 User:Atlantis536
vertebra 20180508211105 User:Bazinga2018
Deinonychus 20180512204023 User:Apokryltaros
feather 20180514161251 User:DeprecatedFixerBot
pork belly 20180517193125 User:Dbsseven
stream 20180519154338 User:Acamicamacaraca
type species 20180523115642 User:SemiHypercube
Djadochta Formation 20180524191609 User:Tisquesusa
Mahakala omnogovae 20180530015945 User:Extrapolaris
Flaming Cliffs 20180530043605 User:ClueBot NG
skull 20180531180549 User:78.26
Anatomical terms of location 20180531201744 User:Deuterostome
Period (geology) 20180601131807 User:Fayenatic london
Ichabod Crane 20180601150110 User:Bound-for-Glory, All His Own
Accipitridae 20180601221414 User:Plantdrew
Microraptoria 20180602215831 User:OAbot
owl 20180603005855 User:Plantdrew
bird 20180603050824 User:Pbsouthwood
Late Cretaceous 20180604004401 User:Dunkleosteus77
Archaeopteryx 20180605083208 User:Wtmitchell
flightless bird 20180605154527 User:RhysLemoine
Velociraptorinae 20180605172041 User:Ovicephalus
Eudromaeosauria 20180605172135 User:Ovicephalus
Dromaeosaurinae 20180605175923 User:Ovicephalus
Utahraptor 20180607012559 User:KH-1
John Ostrom 20180607175137 User:Ornitholestes
Origin of avian flight 20180607185237 User:Bibcode Bot
Dromaeosauridae 20180608050557 User:118.210.165.215
dromaeosauridae 20180608050557 User:118.210.165.215
lacrimal bone 20180608151009 User:Homfet
Raptor Red 20180609135313 User:David Fuchs
flamingo 20180609235939 User:Deli nk
Jurassic Park (novel) 20180610100329 User:Cplusplusboy
predation 20180611234926 User:LucklessPedestrian
eagle 20180612005042 User:Mandruss
Microraptor 20180612024640 User:LittlePuppers
kiwi 20180612191648 User:Maczkopeti
hawk 20180612232451 User:Wiki Wikardo
Mongolia 20180613130435 User:Batternut
Mongolian People's Republic 20180614140303 User:Jon Kolbert
tendon 20180614152855 User:171.51.151.32
Maxilla 20180614163529 User:Oranjelo100
fossil 20180615162348 User:Wjhonson
hypothesis 20180616092115 User:D.Lazard
genus 20180616145745 User:Rodw
paleontology 20180616152844 User:Pbsouthwood
Megalosauridae 20180617045034 User:Lusotitan
Protoceratops 20180617051644 User:Richard.sutt
Cretaceous 20180617051739 User:STH235SilverLover
BBC 20180617091953 User:KH-1
skin 20180617152921 User:Baerentp
ceratopsia 20180617175509 User:IJReid
dinosaur 20180618115451 User:Slate Weasel
Canadians 20180618145147 User:Walter Görlitz
Komodo dragon 20180618155104 User:Plantdrew
Dust storm 20180618195808 User:MoreInput
carnivore 20180618220310 User:173.52.54.140
Synapomorphy 20180619063052 User:EmausBot
anatomy 20180619072027 User:ClueBot NG
Latin 20180619153255 User:Tajotep
Henry Fairfield Osborn 20180619204131 User:Skeptic from Britain
Megalosaurus 20180619233133 User:PaleoGeekSquared
metabolism 20180620073038 User:Bibcode Bot
pterosaur 20180620083443 User:Azcolvin429
Wyoming Dinosaur Center 20180620180551 User:Kzirkel
scavenger 20180620183006 User:LilHelpa
Washington Irving 20180620204244 User:Ser Amantio di Nicolao
New York City 20180620235903 User:Epicgenius
Steven Spielberg 20180621031603 User:KolbertBot
Theropoda 20180621111033 User:DocWatson42
Brussels 20180621171204 User:KolbertBot
warm-blooded 20180621202117 User:Lusotitan
Jurassic Park (film) 20180621203541 User:Imdabes7
dune 20180621205532 User:Ruslik0
sandstone 20180621223824 User:KolbertBot
Yale University 20180622000209 User:KolbertBot
China 20180622002700 User:KolbertBot
Turkey (bird) 20180622005746 User:Gianttrombone
Taxonomy (biology) 20180622011608 User:Drbogdan
Montana 20180622013311 User:TheFrenchTickler1031
Gobi Desert 20180622022010 User:Ifnord
Michael Crichton 20180622082505 User:All Hallow's Wraith
Jurassic Park 20180622082822 User:All Hallow's Wraith
Inner Mongolia 20180622091758 User:Cncs wikipedia
Soviet Union 20180622094807 User:MouseCatDog
ossification 20180622101137 User:Jim1138
Cold War 20180622113551 User:Polmandc
American Museum of Natural History 20180622123844 User:StarHOG
Poland 20180622133020 User:Rob984

Parameters[edit]

The text below assumes that functions are declared as

function p.function_name( frame )
  • Positional parameters – the value of frame.args[1] is passed after function name and vertical bar, the value of frame.args[2] is passed after the value of frame.args[1] and vertical bar, and so on.
  • Named parameters (specify them) – the same name=value syntax as in MediaWiki templates, are accessible inside the function as frame.args["name"].

Examples[edit]

Name Last edited Last editor
Module:Related changes 20140909000444 User:Jackmcbarn

local p={}

function getParam(frame)
    -- This is a longwinded way to return all the args (first choice) or parent.args (second choice) in an array.
    local parent, pargs, args
    local param={}
    parent = frame['parent']
    if (parent) then
        pargs = parent['args']
    end
    if (pargs) then
        for k,v in pairs(args) do
            param[k] = v
        end
    end
    args = frame['args']
    if (args) then
        for k,v in pairs(args) do
            param[k] = v
        end
    end
    return param
end

function getIndexpage(page)
	-- get the contents of either the current page (inadvisable...) or a specified page
	-- returns either a title object or an error string, and a boolean true for successful completion
	local indexpage
    if (page) then
        indexpage = mw.title.new(page)
        if (not(indexpage)) then
            return '<span style="color:red">[[Module:Related changes]] error: failed to access page: [[' + tostring(page) + ']]</span>',false
        end
    else
        indexpage = mw.title.getCurrentTitle()
        if (not(indexpage)) then
            return '<span style="color:red">[[Module:Related changes]] bug: failed to access getCurrentTitle!</span>',false
        end
    end
    return indexpage, true
end

function getLinks(frame,indexpage)
	local index = indexpage:getContent() or "" -- indexpage should exist, so no further checking for errors, just return blank
	local nextLink = mw.ustring.gmatch(index,"%[%[([^%]|]+)[^%]]-%]%]")
	local linklist = {}
	for link in nextLink do
		local linkval = frame:callParserFunction('REVISIONTIMESTAMP', link)
		if (mw.ustring.len(linkval) > 8) then -- don't even index pages that don't get meaningful results
            linklist[tostring(link)] = linkval .. '|' .. frame:callParserFunction('REVISIONUSER', link)
        end
    end
    return linklist
end

function display(linklist, options)
	if (not(options)) then
		options = 'd-'
	end
	local sorttype = mw.ustring.match(options,'([%l%u])')
    local sortdir = mw.ustring.match(options,'([%+%-])')
	if (sorttype == 'n') then
		sorttype = 'name'
		if (sortdir == '-') then
			sortdir = 'descending'
		else
			sortdir = 'ascending'
	    end
    else
	    sorttype = 'date'
	    if (sortdir == '+') then
			sortdir = 'ascending'
		else
			sortdir = 'descending'
	    end
	end
	local outsort, outarray = {}, {'{| class="wikitable sortable"\n!Name\n!Last edited\n!Last editor'}
	for k,v in pairs(linklist) do
		if sorttype == 'name' then
    	    table.insert(outsort, k..'|'..v)
    	else
    		table.insert(outsort, v..'|'..k)
        end
	end
	table.sort(outsort)
	for i = 1,#outsort do
		local n, d, u, split
		split = mw.text.split(outsort[i],'|',true)
		if sorttype == 'name' then
		    n, d, u= split[3], split[1], split[2]
        else
    	    d, u, n = split[1], split[2], split[3]
    	end
    	if ((mw.ustring.sub(n, 1, 5) == 'File:') or (mw.ustring.sub(n, 1, 6) == 'Image:')) then
    		n = ':' .. n
    	end
		table.insert(outarray,'\n|-\n|[['..(n or '[[Module:Related changes]] bug: missing name') .. ']]\n|' .. (d or '[[Module:Related changes]] bug: missing date') .. '\n|[[User:' .. u .. ']]')
	end
	table.insert(outarray,'\n|}')
	return table.concat(outarray)
end

function filter(linklist, action)
	-- pass
end

function p.main(frame)

    local param = getParam(frame) -- get all parameters in param tabel; args override parent.args
    local indexpage = getIndexpage(param.page)
    local linklist = getLinks(frame,indexpage)
    for operation = 1, #param do
    	filter(linklist, param[operation])
    end
    if param.nowiki then
    	return frame:preprocess('<nowiki>'..display(linklist)..'</nowiki>')
    else
    	return display(linklist,param.options)
    end
end

return p