-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrc-changes
executable file
·59 lines (46 loc) · 2.42 KB
/
rc-changes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/local/bin/perl
## recent Raku updates on RosettaCode
#n# 2016-02-07 initial
#n# 2020-08-22 clean up, target 'Raku', not 'Perl6'
#n# 2022-08-29 upgrades for new RC hosting site (to-do: should base 'new' flag on 'data-mw-revid')
use v5.36;
open RC, qq{/opt/local/bin/curl -s --netrc 'https://rosettacode.org/w/index.php?title=Special:RecentChanges&days=7&from=&limit=500&namespace=0' |};
#open RC, '<', 'abc'; # test with local copy
my $cnt = 0;
my $new = 'N';
# skip users not known to be adding Raku code
my $not_these_users = 'Petelomax|Chunes|Robbie|CraigD|Chunes|Gerard|Cwt1078|Objeck|Nigel|Palaing|Paddy3118|Bellenuit';
#<div><table data-mw-revid="328877" data-mw-ts="20220829172945"
while ($_ = <RC>) {
next unless /table data-mw-revid|data-target-page/;
next unless m#\bRaku|:Contributions/(SqrtNegInf|Thundergnat|Hkdtam)#i; # passes Raku, any of mine, other habitual Raku offenders
next if m#Perl\b# and not m#Perl.6#; # but not my Perl entries
next if m#full.list#i; # skip thundergnat++ weekly site summaries
# two ways to catch maintainance
#next if /highlight/;
#next if /Thundergnat/ and not /Raku/;
my($user) = m#:Contributions/(.*?)"#;
next if $user =~ /$not_these_users/i;
my($title,$comment) = /autocomment.*?title="(.*?)".*?span>\s*(.*?)<.span>/; # kludgey way to extract
$title =~ s/_/ /g;
$title =~ s/'/'/g;
$comment =~ s/'/'/g;
$comment =~ s/\->/->/g;
my($mon,$day,$hr,$min) = m#data-mw-ts="20\d\d(\d\d)(\d\d)(\d\d)(\d\d)#;
my $line = sprintf "%02d-%d %d:%d %-18s %s (%s)\n", $mon, $day, $hr, $min, $user, $title, $comment; # the slug
my $checkpt = '';
if (0 == $cnt) {
my $file = "$ENV{HOME}/perl6/Rosetta-Code/meta/RC-recent.txt";
open F, "<$file"; $checkpt = <F>; close F; # read old check-point
exit if $line eq $checkpt; # no changes, bail
#open F, ">$file"; print F $line; close F; # save new check-point
}
our $prev = '';
$new = ' ' if $line eq $checkpt; # stop marking as 'new'
my $ooo = ' ';# out_of_order();
print "$new $ooo $line";
last if 30 < $cnt++; # just show recent updates
$prev = $line;
# RC groups multiple edits, which leads items to be out of sequence chronologically
#sub out_of_order { $prev ne '' && $prev lt $line ? '^' : ' ' }
}