<? /* IDXNAME:AutoIDXgen IDXDESC:Simplifies maintenance of project list description webpages IDXDESC:by allowing storing the informations in the projects' pages. */ ?>
Editing this section is easier, as it is in plain view, making it less prone to forgetting to update. The mkindex script then has to be run. Alternatively, it can be run daily from crontab, in the worst case keeping the site nonupdated for only a day.
If the "IDXBOLD:" line is present in the index.php file, the link to the directory is shown in bold font. Useful for highlighting a project that's bigger or more important than the other ones.
The script contains a "safety belt" routine; before writing the output file, the script checks for its presence. If the file is present, the "AutoIDXgen autogenerated" string presence is checked for. If not present, the script refuses to overwrite the output file. This can save you a lot of work.
#!/bin/bash
OUT=index.php
# safety belt
if [ -f $OUT ]; then
if [ "`grep "^AutoIDXgen generated" $OUT`" == "" ]; then
echo Error: Refusing to overwrite $OUT as I am not sure I should.
exit 1
fi
fi
cat > $OUT << EOF
<HTML>
<HEAD>
<TITLE>Page Title</TITLE>
<H1>Page Title</H1>
<HR>
<TABLE WIDTH=100% CELLSPACING=10>
EOF
for x in *; do
if [ -d "$x" ]; then
BOLD="";NOBOLD="";
if [ -f "$x/index.php" ]; then
if [ "`grep "^IDXBOLD:" "$x/index.php"`" ]; then
BOLD="<B>";NOBOLD="</B>";
fi
fi
echo "<TR><TD VALIGN=TOP>$BOLD<A HREF=\"$x\">$x</A>$NOBOLD</TD><TD>" >> $OUT
if [ -f "$x/README.html" ]; then
cat "$x/README.html" >> $OUT
elif [ -f "$x/index.php" ]; then
PROJECTNAME="`grep "^IDXNAME:" "$x/index.php"|cut -b 9-`"
if [ "$PROJECTNAME" ]; then
echo "<B>$PROJECTNAME</B> - " >> $OUT
fi
grep "^IDXDESC:" $x/index.php|cut -b 9- >> $OUT
else
echo " " >> $OUT
fi
echo "</TD></TR>" >> $OUT
fi
done
cat >> $OUT << EOF
</TABLE>
<HR>
Some other comments for the project page.
</BODY>
</HTML>
EOF