Adapted to new coding standards.
[grutatxt.git] / apache_handlers.txt
blobd8bd4bbcc4157d61d37b14d1f2f2306c141be38e
1 Apache + Grutatxt: The Simplest Possible Website
2 ================================================
4 By http://gweb.org (Geoffrey Plitt)
6 I envisioned an entire website consisting of nothing but human-readable
7 text files that are converted to HTML by the web server when necessary,
8 with the least amount of extra junk in there. Here's how I did it.
10 .htaccess (root folder):
11 ------------------------
12   Options -Indexes
13   DirectoryIndex index.html index.text
14   Action handle_text /cgi-bin/handle_text.cgi
15   AddHandler handle_text .text
17 This allows you to mix html and "text" content, which is converted to HTML
18 by Grutatxt.
20 /cgi-bin/handle_text.cgi:
21 -------------------------
22   #!/bin/bash
23   echo "Content-type: text/html"
24   echo
25   base=`basename $PATH_TRANSLATED`
26   if [ "$QUERY_STRING" = "" ]; then
27     echo "<HTML><BODY>"
28     cat $PATH_TRANSLATED | grutatxt -nb
29     echo "<br><br><small><i>"
30     echo "Generated with <a href='"
31     echo "http://www.triptico.com/software/grutatxt.html"
32     echo "'>Grutatxt</a>. View <a href='$base?SOURCE'>page source</a>"
33     echo "</i></small></BODY></HTML>"
34   else
35     echo "<html><body><small>"
36     # The confusing sed stuff just displays ampersands and brackets.
37     cat $PATH_TRANSLATED | sed 's/&/\&amp;/g;s/</\&lt;/g;s/>/\&gt;/g' |
38      while read L; do
39        echo "$L<br>"
40      done
41     echo "</small></body></html>"
42   fi
44 /index.text (any folder)
45 -----------------------
46   I'm an auto-grutatxt'ed HTML page
47   -----
49   And here is a body paragraph!