ssic: Set __SSIC__ SSI variable.
[ssic.git] / bin / ssic
index a88e5654a9a5ba047f8333cb96c3b89a18510bb3..8e5695b0077f5dd8f2738699680f2049f5310a57 100755 (executable)
--- a/bin/ssic
+++ b/bin/ssic
@@ -1,21 +1,10 @@
 #!/usr/bin/perl
-#
-# ssic - Server Side Includes Compiler
-#
-# Copyright (C) 2013  Patrick "P. J." McDermott
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+=head1 NAME
+
+ssic - Server Side Includes Compiler
+
+=cut
 
 use strict;
 use warnings;
@@ -23,6 +12,9 @@ use warnings;
 use Getopt::Long;
 use CGI::SSI;
 
+my $VERSION;
+$VERSION = '1.0.0';
+
 sub main
 {
        my %opts;
@@ -89,9 +81,9 @@ sub help
 
        usage($fh);
        print("Options:\n");
-       print("  -D <name>=<value>  Set the variable <name> to <value>\n");
-       print("  -I <directory>     Set the document root to <directory>\n");
        print("  -o <output>        Place the output into <output>\n");
+       print("  -I <directory>     Set the document root to <directory>\n");
+       print("  -D <name>=<value>  Set the variable <name> to <value>\n");
        print("  -h, --help         Display this information\n");
        print("  -V, --version      Display compiler version information\n");
 }
@@ -100,7 +92,7 @@ sub version
 {
        my ($fh) = @_;
 
-       print("ssic 0.1.0\n");
+       printf("ssic %s\n", $VERSION);
        print("Copyright (C) 2013 Patrick \"P. J.\" McDermott\n");
        print("License GPLv3+: GNU GPL version 3 or later " .
                "<http://gnu.org/licenses/gpl.html>.\n");
@@ -138,6 +130,7 @@ sub init_compiler
        $CGI::SSI::DEBUG = 0;
        $ssi = CGI::SSI->new();
 
+       $ssi->set("__SSIC__" => 1);
        $ssi->set("DOCUMENT_ROOT" => $root);
 
        while (($var_name, $var_value) = each(%{$vars})) {
@@ -203,3 +196,76 @@ sub compile
 }
 
 main();
+
+__END__
+
+=head1 SYNOPSIS
+
+B<ssic>
+[B<-o> I<output>]
+[B<-I> I<directory>] 
+[B<-D> I<name>=I<value> ...]
+I<input> ...
+
+=head1 DESCRIPTION
+
+B<ssic> processes HTML documents with SSI directives formatted as SGML comments.
+It can be used to process documents without an HTTP server for local browsing or
+to generate static HTML documents to be efficiently served by an HTTP server.
+Documents could even be preprocessed, e.g. by a Markdown processor, before being
+parsed with ssic.
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<-o> I<output>
+
+Place the output into I<output>.
+
+=item B<-I> I<directory>
+
+Set the document root to I<directory>.
+
+=item B<-D> I<name>=I<value>
+
+Set the variable I<name> to I<value>.
+
+=item B<-h>, B<--help>
+
+Display help information.
+
+=item B<-V>, B<--version>
+
+Display compiler version information.
+
+=back
+
+=head1 COPYRIGHT
+
+Copyright (C) 2013  Patrick "P. J." McDermott
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+=head1 SEE ALSO
+
+L<CGI::SSI(3)>
+
+NCSA HTTPd SSI documentation:
+L<http://web.archive.org/web/19971210170837/http://hoohoo.ncsa.uiuc.edu/docs/tutorials/includes.html>
+
+Apache HTTPd mod_include documentation:
+L<http://httpd.apache.org/docs/current/mod/mod_include.html>
+
+=cut