Rosetta Code/List authors of task descriptions: Difference between revisions
Rosetta Code/List authors of task descriptions (view source)
Revision as of 14:19, 22 December 2017
, 6 years ago→{{header|Perl 6}}: Add comments, style tweaks, minor enhancements
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: Replaced accidentally overwritten code - Change to version using mediawiki API) |
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: Add comments, style tweaks, minor enhancements) |
||
Line 296:
my %tasks;
# clear screen
#=begin skip update▼
run($*DISTRO.is-win ?? 'cls' !! 'clear');
note 'Retreiving task authors...';
for %cat.keys -> $category {
Line 317 ⟶ 322:
)}
).map({
%tasks{.[0]<title>}
%tasks{.[0]<title>}
%tasks{.[0]<title>}<date> = .[0]<revisions>[0]<timestamp>.subst(/'T'.+$/, '')
}
)
}
# Save information to a local file
$hashfile.IO.spurt(%tasks.&to-json);
#=end
# Load information from local file
%tasks = $hashfile.IO.e ?? $hashfile.IO.slurp.&from-json !! ( );
Line 347 ⟶ 355:
# Get sorted unique list of task authors
for %tasks{*}».<author>.unique.sort(*.&naturally) -> $author {
# Add author and contributions link to the first cell
$out.print( "<tr><td><ul>[[User:$author|$author]] [[Special:Contributions/$author|?]]</ul></td><td><ul><ol>" );
# Get list of tasks by this author, sorted by name
for %tasks.grep( { $_.value.<author> eq $author } ).sort(*.key.&naturally) -> $task {
# and add the date, status and task link to the list in the second cell
$out.print( "<li>{$task.value.<date>} - {$task.value.<category>}",
" [[{uri-encode $task.key}|{$task.key}]]</li>"
)
}
$out.say( '</ol></ul></td></tr>' );
Line 364 ⟶ 376:
sub mediawiki-query ($site, $type, *%query) {
my $url = "$site/api.php?" ~ uri-query-string(
:action<query>, :format<json>, :formatversion
my $continue = '';
Line 383 ⟶ 395:
}
$str.subst(/<[\x00..\x7f]-[a..zA..Z0..9_.~-]>/, *.ord.fmt('%%%02X'), :g);
}</lang>▼
▲</lang>
;Sample output
|