CocoaDevHistoryViewer

I enjoy to read and use CocoaDev (cocoadev.com)… The whole wiki thing is cool, and encourages some interesting connections. There is however a problem… people can edit the complete page and make changes anywhere inside of it. This script uses curl/perl to download the source, remove the markup tags, findout the name of a previous revision to do the same with and then opens the old text and the new text in FileMerge so you can see added and removed content highlighted nicely… the default node was RecentChanges but perhaps another node would be a better example would be something like DynamicallySizingScalingText where there are distributed changes in conversation and code (at least now there is August 2, 2004-10:24 AM JST)… The code is mostly based around the curl perl, thing but you may also have not known about the opendiff command… a little tweaking and you could use this for many things with differences popping up all over the place.

OS version:

display dialog "CocoaDev Node?" default answer "RecentChanges" buttons {"Cancel", "Ok"} default button "Ok"
if the button returned of the result is "Ok" then
	
	set nodeName to the text returned of the result
	set nodeURL to "http://www.cocoadev.com/index.pl?" & nodeName
	
	set previousURL to previousURLAt(nodeURL)
	
	set oldFile to POSIX path of (((path to temporary items) as string) & "cocoadevOld.txt")
	set newFile to POSIX path of (((path to temporary items) as string) & "cocoadevNew.txt")
	
	set nowText to putNoTagTextAt(nodeURL, newFile)
	set oldText to putNoTagTextAt(previousURL, oldFile)
	
	do shell script "opendiff " & oldFile & " " & newFile
	
end if

on putNoTagTextAt(theURL, fpath)
	do shell script "curl " & theURL & " | perl -pe 's/<.*?>//g;' | tail +10 > " & fpath
end putNoTagTextAt

on previousURLAt(theURL)
	do shell script "curl " & theURL & " | head -n 15 | tail -1 | perl -pe 's/^.*?\\?.*?\\?//;s/\">.*$//' "
	"http://www.cocoadev.com/index.pl?" & the result
end previousURLAt