[svn:mod_parrot] r315 - in mod_parrot/trunk/eg: . perl6 perl6/ModPerl6 php pir

[email protected] Sat, 19 Jan 2008 08:18:41 -0800 (PST)
Newsgroups perl.cvs.mod_parrot
Message-ID <[email protected]>
Author: jhorwitz
Date: Sat Jan 19 08:18:40 2008
New Revision: 315

Added:
   mod_parrot/trunk/eg/perl6/
   mod_parrot/trunk/eg/perl6/ModPerl6/
   mod_parrot/trunk/eg/perl6/ModPerl6/Counter.pm
   mod_parrot/trunk/eg/perl6/ModPerl6/Polly.pm
   mod_parrot/trunk/eg/php/
   mod_parrot/trunk/eg/php/README
   mod_parrot/trunk/eg/php/polly.php
   mod_parrot/trunk/eg/pir/
   mod_parrot/trunk/eg/pir/authenhandler.pir
      - copied, changed from r305, /mod_parrot/trunk/eg/authenhandler.pir
   mod_parrot/trunk/eg/pir/handler.pir
      - copied, changed from r305, /mod_parrot/trunk/eg/handler.pir
   mod_parrot/trunk/eg/pir/interpinfo.pir
      - copied unchanged from r305, /mod_parrot/trunk/eg/interpinfo.pir
Removed:
   mod_parrot/trunk/eg/authenhandler.pir
   mod_parrot/trunk/eg/handler.pir
   mod_parrot/trunk/eg/interpinfo.pir

Log:
reorganize eg directory and add new example handlers


Added: mod_parrot/trunk/eg/perl6/ModPerl6/Counter.pm
==============================================================================
--- (empty file)
+++ mod_parrot/trunk/eg/perl6/ModPerl6/Counter.pm	Sat Jan 19 08:18:40 2008
@@ -0,0 +1,34 @@
+# $Id$
+
+# This response handler outputs the number of times it's been invoked.
+# Since each child process/thread gets its own interpreter, the value of 
+# the counter may "jump" as you cycle through processes.  Enabling KeepAlive
+# will lock you to a child process for a short period and provide a proper
+# demonstration.
+#
+# Usage:
+#
+# ParrotIncludePath /path/to/eg/perl6
+# ParrotLoad ModParrot/HLL/perl6.pbc
+# ParrotAddHandler perl6 perl6-script
+# <Location /perl6/counter>
+#     SetHandler perl6-script
+#     ParrotHandler ModPerl6::Counter
+# </Location>
+#
+# Stop Apache
+# Set the PERL6LIB environment variable to /path/to/eg/perl6
+# Start Apache
+
+module ModPerl6::Counter;
+
+sub handler($r)
+{
+    our $x;
+    unless ($x) {
+        $x = 1;
+    }
+    $r.puts("Page views for this interpreter: $x\n");
+    $x++;
+    0; # Apache OK
+}

Added: mod_parrot/trunk/eg/perl6/ModPerl6/Polly.pm
==============================================================================
--- (empty file)
+++ mod_parrot/trunk/eg/perl6/ModPerl6/Polly.pm	Sat Jan 19 08:18:40 2008
@@ -0,0 +1,30 @@
+# $Id$
+
+# This response handler outputs the query string from the URL.
+# Example: http://example.com/perl6/polly?meep
+#
+# Usage:
+#
+# ParrotIncludePath /path/to/mod_parrot/lib:/path/to/runtime/parrot/library
+# ParrotLoad ModParrot/HLL/perl6.pbc
+# ParrotAddHandler perl6 perl6-script
+# <Location /perl6/polly>
+#     SetHandler perl6-script
+#     ParrotHandler ModPerl6::Polly
+# </Location>
+#
+# Stop Apache
+# Set the PERL6LIB environment variable to /path/to/eg/perl6
+# Start Apache
+
+module ModPerl6::Polly;
+
+sub handler($r)
+{
+    my $text = $r.args();
+    if ($text ne "") {
+        $r.puts("SQUAWK!  Polly says $text<p>");
+    }
+    $r.puts("Reload with a query string and Polly will repeat it.\n");
+    0; # Apache OK
+}

Added: mod_parrot/trunk/eg/php/README
==============================================================================
--- (empty file)
+++ mod_parrot/trunk/eg/php/README	Sat Jan 19 08:18:40 2008
@@ -0,0 +1,7 @@
+This is a PHP implementation of "Polly" from the Perl 6 examples.  It uses
+the Plumhead compiler included with the Parrot distribution.  Place it in your
+document root and configure as follows:
+
+ParrotLoad ModParrot/HLL/plumhead.pbc
+AddType application/x-httpd-php .php
+ParrotAddType plumhead application/x-httpd-php

Added: mod_parrot/trunk/eg/php/polly.php
==============================================================================
--- (empty file)
+++ mod_parrot/trunk/eg/php/polly.php	Sat Jan 19 08:18:40 2008
@@ -0,0 +1,10 @@
+<?php
+    echo "<h1>Polly (PHP/Plumhead)</h1>\n";
+    $say = $_GET['say'];
+    if ($say) {
+        echo "SQUAWK!  Polly says ";
+        echo $say;
+        echo "!<p>\n";
+    }
+    echo "Reload with an argument called 'say' and Polly will repeat it.\n";
+?>

Copied: mod_parrot/trunk/eg/pir/authenhandler.pir (from r305, /mod_parrot/trunk/eg/authenhandler.pir)
==============================================================================
--- /mod_parrot/trunk/eg/authenhandler.pir	(original)
+++ mod_parrot/trunk/eg/pir/authenhandler.pir	Sat Jan 19 08:18:40 2008
@@ -1,6 +1,19 @@
 # $Id$
 
-# use ParrotAuthenHandler to set the authentication handler for a location
+# This is an authentication handler that grants access based on the password
+# provided through HTTP basic authentication.  Any username with a password
+# of 'squawk' will be allowed through.
+#
+# Usage:
+#
+# ParrotLoad /path/to/this/file
+# <Directory /my/protected/directory>
+#     AuthType Basic
+#     AuthName "Parrot Auth"
+#     ParrotAuthenHandler MyAuthHandler
+#     Require valid-user
+# </Directory>
+
 
 .namespace [ 'MyAuthHandler' ]
 
@@ -14,10 +27,6 @@
 
     ap_const = get_root_global [ 'Apache'; 'Constants' ], 'ap_constants'
 
-    # decline if not the initial request
-    $I1 = r.'is_initial_req'( )
-    if $I1 != 1 goto auth_declined
-
     (status, pw) = r.'get_basic_auth_pw'( )
 
     if pw != 'squawk' goto auth_failure

Copied: mod_parrot/trunk/eg/pir/handler.pir (from r305, /mod_parrot/trunk/eg/handler.pir)
==============================================================================
--- /mod_parrot/trunk/eg/handler.pir	(original)
+++ mod_parrot/trunk/eg/pir/handler.pir	Sat Jan 19 08:18:40 2008
@@ -1,5 +1,15 @@
 # $Id$
 
+# This is a simple response handler that outputs its query string.
+#
+# Usage:
+#
+# ParrotLoad /path/to/this/file
+# <Location /testhandler>
+#     SetHandler parrot-code
+#     ParrotHandler Handler
+# </Location>
+
 # handler namespace is used for ParrotHandler in httpd.conf
 .namespace [ 'Handler' ]