summaryrefslogtreecommitdiff
path: root/archives/bin
diff options
context:
space:
mode:
authorAlvaro Herrera2008-09-01 00:05:47 +0000
committerAlvaro Herrera2008-09-01 00:05:47 +0000
commitda5feb77effc1366014aba3791b2fc31d15b5ee7 (patch)
treee0c17218017174739b38eed8a7fe7aa07b27a9e1 /archives/bin
parentc538e217520494c15ee8d765c78d1bf1cdbf3b6e (diff)
Make the list-specific index.php file be template-based. This has rather
wide-ranging side effects, and the resulting code is not very modular nor pretty, but it's still better than the statu quo. At least we don't have a shell script driving a Perl program and "cat" generating PHP code. As a secondary effect, the lists list in the left-side menu should keep up-to-date with the database. git-svn-id: file:///Users/dpage/pgweb/svn-repo/trunk@2191 8f5c7a92-453e-0410-a47f-ad33c8a6b003
Diffstat (limited to 'archives/bin')
-rwxr-xr-xarchives/bin/generate-list-descriptions37
-rwxr-xr-xarchives/bin/list_dates.pl31
-rwxr-xr-xarchives/bin/mk-mhonarc16
3 files changed, 37 insertions, 47 deletions
diff --git a/archives/bin/generate-list-descriptions b/archives/bin/generate-list-descriptions
index 28f78bb4..d9423d15 100755
--- a/archives/bin/generate-list-descriptions
+++ b/archives/bin/generate-list-descriptions
@@ -3,6 +3,23 @@
# $Id$
#
# Script to generate text files with descriptions of each list and group.
+#
+# We generate five families of files:
+# <list>.descr -- contains the description of each list
+# <list>.group -- contains the group "id" that each list belongs to
+# (note: not the group ID on database; it's generated here)
+# group.<id> -- contains the name of each group, and the name of each list
+# on the group
+# groups -- contains the list of all groups, with its "id", the
+# name of the "first" list on the group, and the group name
+# groups.complete
+# a listing of all groups, with its name and the names
+# and descriptions of lists on it
+#
+# The various files are used in several places, both in the PHP templates and
+# in the Perl program that calls Mhonarc. Probably it'd be possible to get rid
+# of most of the files and keep just "groups.complete", but I'm feeling lazy
+# today.
. $HOME/etc/archives.conf
@@ -10,18 +27,9 @@ psql_exec() {
$PSQL -tA -U $DBUSER -h $DBHOST $DBNAME -c "$1"
}
-psql_exec "select name, description from lists" |
-while read line; do
- # strip backslashes from description. Note: quoting below ensure
- # that " and ' do not need escaping.
- line=${line//\\/}
- description=${line##[a-zA-Z-]*\|}
- list=${line%%\|$description}
- echo "$description" > $ARCHIVES_TEMPLATES/$list.descr
-done
-
prevgrp=
curr=0
+printedfirst=
> $ARCHIVES_TEMPLATES/groups.new
> $ARCHIVES_TEMPLATES/groups.complete.new
psql_exec "select lg.id, lg.name, l.name, l.description from listgroups lg join lists l on (lg.id = l.grp) order by sortkey, l.name" |
@@ -37,13 +45,20 @@ while read line; do
if [ "$grp" != "$prevgrp" ]; then
curr=$(($curr+1))
filename=$ARCHIVES_TEMPLATES/group.$curr
- echo "group.$curr" >> $ARCHIVES_TEMPLATES/groups.new
+ echo -n "group.$curr " >> $ARCHIVES_TEMPLATES/groups.new
+ printedfirst=
echo "groupname: $grp" > $filename
echo "groupname: $grp" >> $ARCHIVES_TEMPLATES/groups.complete.new
prevgrp=$grp
fi
echo "list: $list" >> $filename
echo "list: $list $descr" >> $ARCHIVES_TEMPLATES/groups.complete.new
+ if [ -z $printedfirst ]; then
+ echo "$list $grp" >> $ARCHIVES_TEMPLATES/groups.new
+ printedfirst=42
+ fi
+ echo "$curr" > $ARCHIVES_TEMPLATES/$list.group
+ echo "$descr" > $ARCHIVES_TEMPLATES/$list.descr
done
mv $ARCHIVES_TEMPLATES/groups.new $ARCHIVES_TEMPLATES/groups
mv $ARCHIVES_TEMPLATES/groups.complete.new $ARCHIVES_TEMPLATES/groups.complete
diff --git a/archives/bin/list_dates.pl b/archives/bin/list_dates.pl
index 9b138214..dc93cbee 100755
--- a/archives/bin/list_dates.pl
+++ b/archives/bin/list_dates.pl
@@ -2,24 +2,11 @@
use File::Find;
-@months = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
-
$listdir = shift;
$list = shift;
-$year_holder = 0;
-
-print <<EOT;
-<center>
-<table border="0">
-EOT
find({ wanted => \&wanted, preprocess => \&sortfiles }, $listdir);
-print <<EOT;
-</table>
-</center>
-EOT
-
exit;
sub sortfiles {
@@ -30,19 +17,7 @@ sub sortfiles {
sub wanted {
return unless /^$list/;
/$list.(\d{4})(\d{2})/;
- $year = $1; $month = $2;
- $date = "$year-$month";
- if ($year ne $year_holder) {
- print " <tr><td height=\"10\"></td></tr>\n";
- $year_holder = $year;
- } else {
- $year = "";
- }
- print <<EOT;
- <tr>
- <td>$year</td>
- <td>$months[$month - 1]</td>
- <td>[<a href="$date/index.php">by date</a>][<a href="$date/threads.php">by thread</a>][<a href="mbox/$list.$date.gz">mbox</a>]</td>
- </tr>
-EOT
+ $year = $1;
+ $month = $2;
+ print "$year $month\n";
}
diff --git a/archives/bin/mk-mhonarc b/archives/bin/mk-mhonarc
index 3cc73968..05cf9090 100755
--- a/archives/bin/mk-mhonarc
+++ b/archives/bin/mk-mhonarc
@@ -135,14 +135,14 @@ for list in `ls $MAJORDOMO_FILES`; do
if [ ! -r $descrfile ]; then
echo "WARNING: description not found for list $list"
fi
- # Warning: we trust generate-list-descriptions to strip backslashes. We only
- # need to worry about forward-slashes, which would confuse sed below.
- description=$(cat $descrfile | sed -e 's/\([\/]\)/\\\1/g')
- (sed -e "s/LISTNAME/$list/g" \
- -e "s/DESCRIPTION/$description/" \
- $ARCHIVES_TEMPLATES/top ; \
- $ARCHIVES_BIN/list_dates.pl $listdir $list ; \
- cat $ARCHIVES_TEMPLATES/bottom) > index.php
+
+ # XXX maybe this can be done better with mod_rewrite?
+ # Ensure that index.php exists and is a symlink
+ test -f index.php && rm index.php
+ test ! -e index.php && ln -s ../list_index.php index.php
+
+ # create the list of extant months
+ $ARCHIVES_BIN/list_dates.pl $listdir $list > months
date > last-updated
done