Difference between revisions of "Caretaker.pl"

From Organic Design wiki
m
(link to talk:caretaker.pl in edit comments)
Line 40: Line 40:
  
 
# If article changed, write and comment
 
# If article changed, write and comment
wikiPageEdit $::wiki, $title, $article, 'Caretaker: '.join(', ',@comments) if $article ne $backup;
+
wikiPageEdit $::wiki, $title, $article, '[[talk:caretaker.pl|Caretaker]]: '.join(', ',@comments) if $article ne $backup;
 
}
 
}
 
sleep(1);
 
sleep(1);

Revision as of 05:09, 24 October 2006

use DBI;

sub caretaker { my $dbh = DBI->connect('DBI:mysql:wiki',lc $::peer,$::pwd1) or die DBI->errstr; my @ns = (,'Talk:','User:','User talk:','Project:','Project talk:', 'Image:','Image talk:','Mediawiki:','Mediawiki talk:','Template:', 'Template talk:','Help:','Help talk:','Category:','Category talk:');

# Get id of first article after mediawiki built in articles my $sth = $dbh->prepare('SELECT cur_id FROM cur WHERE cur_title = "Zhconversiontable"'); $sth->execute(); my @row = $sth->fetchrow_array; $sth->finish; my $first = $row[0]+1;

# Get last article id my $sth = $dbh->prepare('SELECT cur_id FROM cur ORDER BY cur_id DESC'); $sth->execute(); @row = $sth->fetchrow_array; $sth->finish; my $last = $row[0];

# Loop through all articles one per second my $sth = $dbh->prepare('SELECT cur_namespace,cur_title FROM cur WHERE cur_id=?'); my $done = 0; for ($first..$last) { $sth->execute($_); @row = $sth->fetchrow_array; my @comments = (); my $title = ; if ($title = $ns[$row[0]].$row[1]) {

# Read the article content my $article = my $backup = wikiRawPage $::wiki, $title;

# Apply rules to Xml:Articles if ($title =~ /^Xml:/) { push @comments, 'removed empty elements' if $article =~ s/^\s*<(read|write|category|init|data|view|edit|save)>\s*<\/\w+>[\r\n]*//gms; }

# If article changed, write and comment wikiPageEdit $::wiki, $title, $article, 'Caretaker: '.join(', ',@comments) if $article ne $backup; } sleep(1); }

my $comment = "Daily caretaking tasks completed: $last articles examined, $done adjusted."; logAdd $comment; wikiLogin($::wiki, $::peer, $::pwd1); wikiPageAppend($::wiki, $::wikilog, "\n*".localtime()." : $comment", $comment); $sth->finish; $dbh->disconnect; }