]> rtime.felk.cvut.cz Git - edu/osp-wiki.git/blob - student/projects.pl
Merge branch 'master' into uloha-server
[edu/osp-wiki.git] / student / projects.pl
1 #!/usr/bin/perl -w
2 use strict;
3 use Data::Dumper;
4
5 my %projects;
6
7
8 foreach my $year (qw/2010 2011 2012 2013 2014/) {
9     open LIST, "projects$year";
10     while (<LIST>) {
11         chomp;
12         my $file = $_;
13         my ($project, $url, $name);
14         open PAGE, $file;
15         while (<PAGE>) {
16             if (/Project name and homepage[:* ]*\[([^\[\]]*)\]\(([^()]*)\)/) {
17                 $project = $1;
18                 $url = $2;
19             }
20             if (/(Název projektu|Project name)[:* ]*(.*)/) {
21                 if (!$project) {
22                     $project = $2;
23                 }
24             }
25             if (/(Domovská stránka projektu|Project home ?page)[:* ]*<([^<>]*)>/) {
26                 $url = $2;
27             }
28             if (/\[\[!meta title="([^"]*)"\]\]/) {
29                 $name = $1;
30             }
31         }
32
33         if (!$project or !$name or !$url) {
34             print STDERR "Expected field missing in $file\n";
35         }
36
37         print STDERR "Working on student $name ($year)\n";
38         if (!$projects{$project}) {
39             $projects{$project} = {};
40             $projects{$project}{'students'} = [];
41         }
42         my $p = $projects{$project};
43         if (!$$p{'url'} or $url) {
44             $$p{'url'} = $url;
45         }
46         push @{$$p{'students'}}, { 'file' => $file, 'name' => $name, 'year' => $year };
47     }
48 }
49
50 print '[[!meta title="Projekty"]]'."\n";
51 print '[[!meta stylesheet="/columns" rel="stylesheet"]]'."\n";
52 print "\n";
53 print 'This page lists the projects and which students worked on them in the'."\n";
54 print 'past years.'."\n";
55
56 foreach (sort(keys(%projects))) {
57     print "\n* [$_](", $projects{$_}{'url'}, ")\n";
58     #print Dumper($projects{$_}{'students'});
59     foreach (@{$projects{$_}{'students'}}) {
60         my $page = $_->{'file'};
61         $page =~ s|.mdwn$||;
62         $page =~ s|/index$||;
63         my $name = $_->{'name'} || "???";
64         my $year = $_->{'year'} || "20??";
65         
66         print "  * [[", $name || "", "|student/", $page, "]] ($year)\n";
67     }
68 }