# Special utilities for projects pages #read "contributors.list" # Documentation # # . All contributors are listed in the file 'contributors.list' as # RFC822-compliant addresses, i.e. "Real Name ". # They will automatically be added into a Contributors box (at max # names, default is 10). # # . There are three boxes that will appear on the right side if the # environment will be used: # # . News (max. items) # . Download (max. items) # . Contributors (max. items) # # . The download items will be revers sorted, i.e. the most recent # appears at the top of the list. # # . The same applies for news boxes and the entire news listing # # . The entire list of contributors it reserved for peoples.wml. Use # there # # . All news have to be named news-yyyy-mm-dd.wml, otherwise they won't # get included properly in the listings. Additionally, the # headline/subject of an item has to be written in # ... and has to be at last one line long, no # linebreaks are allowed. # # . The entire list of news items is reserved for news.wml. Please use # there # # . The entire list of ChangeLog entries reserved for changes.wml. # #Please use there # # . Since /projects/sysklogd/ was the first project to work on, use it # as an example. download <: sub get_news_list { my @news; opendir (THIS, "."); @news = reverse (sort (grep (/^news-.*\.wml$/, readdir (THIS)))); closedir (THIS); return @news; } sub get_news_headline { my $file = shift; my $headline; $headline = ""; if (open (NEWS, $file)) { while () { next until (/(.*)<\/headline>/); $headline = $1; } close (NEWS); } return $headline; } sub get_contrib_list { my @contrib; open (CONTRIB, "contributors.list"); # Bail out if the file is not there while () { chomp(); next if /^\s*#/; next if /^\s*$/; push (@contrib, $_); } close (CONTRIB); return @contrib; } sub get_changes_list { my @news; opendir (THIS, "."); @news = reverse (sort (grep (/^changes-.*\.wml$/, readdir (THIS)))); closedir (THIS); return @news; } sub get_changes_date { my $file = shift; my $date; $date = ""; if (open (F, $file)) { while () { next until (/Releasedate: (.*)<\/b>/); $date = $1; } close (F); } return $date; } :> read()) if ($dentry != "." && $dentry != ".." && is_file ($dirname . "/" . $dentry) && strstr ($dentry, ".tar.") !== false && substr ($dentry, -4, 4) != '.asc') $file[] = $dentry; } return $file; } ?> read()) { if ($dentry != "." && $dentry != ".." && is_file ($dirname . "/" . $dentry)) { $foo = strstr ($dentry, ".tar."); if ($foo) { #$name = substr ($dentry, 0, (strlen ($dentry) - strlen ($foo))); $file[] = $dentry; } } } } return $file; } ?> read()) { if ($dentry != "." && $dentry != ".." && is_file ($dirname . "/" . $dentry)) { if (preg_match ("/.*-$version\.[^0-9].*/", $dentry)) { $file[] = $dentry; } } } } return $file; } ?> # Default: maxcontrib=10 # maxnews=3 # maxdownload=4 > > > > > > >

%body

 

gifs/imgdot-1x1-transp.gif width=3 height=0 alt=""> "news" # Only draw a news box if more than 0 news are to be displayed # "0"
<: $row = "%s %s more"; $delim = " && $i <= $#news) { print $delim if ($printed > 0); if ($news[$i] ne ".wml") { $news[$i] =~ /news-(\d{4}-\d{2}-\d{2})\.wml/; $date = $1; $headline = get_news_headline ($news[$i]); printf $row, $date, $headline, $date; $printed++; } $i++; } :>

# "0" > # "news" > <: if (-r "download.wml" && "" ne "download") { :>

"); rsort ($file); for ($i=0; ($i < count ($file)) && ($i < ); $i++) { # Correct the filename again... $foo = strstr ($file[$i], ".tar."); if ($foo) { $name = substr ($file[$i], 0, (strlen ($file[$i]) - strlen ($foo))); $copy = 0; for ($token = strtok ($name, "-"); strlen ($token); $token = strtok ("-")) { if ($copy) { $version .= "-" . $token; } else { if (preg_match("/^[0-9][0-9a-zA-Z\.:]*/", $token)) { $copy = 1; $version = $token; } } } } printf ("/%s\">Version %s (%d kB)
", $file[$i], $version, filesize ("/" . $file[$i]) / 1024); } if (count ($file) == 0) { echo "Nothing to download yet."; } ?> # all files

<: } :> "people"

/; printf " \$contrib[] = \"%s\";\n", $1; } :> srand (time ()); $ci = array (); $max = > count ($contrib) ? count ($contrib) : ; if (count ($contrib) == 1) { $ci[0] = 0; } else { while (count ($ci) < $max) { $r = rand (0, count ($contrib)-1); # Filter out already selected items $new = 1; for ($i=0; $i < count ($ci); $i++) { if ($ci[$i] == $r) $new = 0; } if ($new) $ci[] = $r; } } for ($i=0; $i < count ($ci); $i++) { printf ("%s
", $contrib[$ci[$i]]); } ?>

# "people" >

<: "" =~ /news-(\d{4}-\d{2}-\d{2})/; print $1; :>: %body

Contributors

Alphabetically sorted
    <: $row = "
  • %s <%s>
    "; @contrib = get_contrib_list (); foreach $c (sort(@contrib)) { if ($c =~ /(.*)\s+<(.*)>/) { $n = $1; $e = $2; $e =~ s/\@/@/; printf $row, $n, $e; } else { printf $row, $c, ""; } } :>

News Items

<: # $delim = ''; # $delim =~ s/XXXXXX/$menucolor/; $delim = "

"; $row = "%s: %s more"; @news = get_news_list (); $i = 0; while ($i <= $#news) { print $delim if ($i > 0); $news[$i] =~ /news-(\d{4}-\d{2}-\d{2})\.wml/; $date = $1; $headline = get_news_headline ($news[$i]); printf $row, $date, $headline, $date; $i++; } :>

ChangeLog entries

<: $delim = "

"; $row = "%s: Version %s more"; @changes = get_changes_list (); $i = 0; while ($i <= $#changes) { print $delim if ($i > 0); $changes[$i] =~ /changes-(.*)\.wml/; $version = $1; $date = get_changes_date ($changes[$i]); printf $row, $date, $version, $version; $i++; } :>

#

Download

"); rsort ($file); for ($i=0; $i < count ($file); $i++) { $foo = strstr ($file[$i], ".tar."); if ($foo) { $name = substr ($file[$i], 0, (strlen ($file[$i]) - strlen ($foo))); $copy = 0; for ($token = strtok ($name, "-"); strlen ($token); $token = strtok ("-")) { if ($copy) { $version .= "-" . $token; } else { if (preg_match("/^[0-9][0-9a-zA-Z\.:]*/", $token)) { $copy = 1; $version = $token; } } } } printf ("

Version %s

", $version); $files = get_files ("", $version); sort ($files); if (count ($files) > 0) { echo "
    "; if (is_file ("changes-" . $version . ".php")) { printf ("
  • ChangeLog", $version); } for ($k=0; $k < count ($files); $k++) { printf ("
  • /%s\">%s (%d kB)", $files[$k], $files[$k], filesize ("/" . $files[$k]) / 1024); } echo "
"; } } echo "

/\">All files

"; ?>
# Only available for changes-*.wml files <: if ("" =~ /^changes-(.*)/) { $version = $1; $version =~ s/\./\\./g; :> # Should already known because of download box, but the box comes # later in source /%s\">Download

"; $file = get_tarfiles2 (""); for ($i=0; $i < count ($file); $i++) { if (preg_match("/.*-<: print $version; :>\.tar\..*/", $file[$i])) { printf ($fstr, $file[$i]); } } ?> <: } :> # Local variables: # mode: indented-text # mode: auto-fill # end: