[interchange-cvs] interchange - heins modified 5 files

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Sat Mar 6 22:14:42 EST 2004


User:      heins
Date:      2004-03-07 03:14:42 GMT
Modified:  code/SystemTag process.coretag
Modified:  lib/Vend Config.pm Dispatch.pm Interpolate.pm Util.pm
Log:
* Add PostURL, SecurePostURL, and ProcessPage directives. This allows
  a different path for GET and POST requests (presuming you only post
  with the [process] tag for the <form> action).

  This allows Interchange to handle internal redirects and DirectoryIndex
  requests via Apache transparently via reading the REDIRECT_* environment.
  It should also allow internal redirects via other modules such as mod_perl.

  The default for the [process ..] tag is the same as now, to use VendURL
  or SecureVendURL as the default URL.

  If you set up in Apache:

  	DirectoryIndex index.html /cgi-bin/foundation
	<LocationMatch *\.html>
		ErrorDocument 404 /cgi-bin/foundation
	</LocationMatch>

  In interchange.cfg:

  	AcceptRedirect Yes

  In catalog.cfg:

  	VendURL        http://www.foo.com/
  	SecureURL      https://www.foo.com/
  	PostURL        http://www.foo.com/cgi-bin/foundation
  	SecurePostURL  https://www.foo.com/cgi-bin/foundation

	ImageDir
	DirectoryIndex  index.html
	DeliverImage    yes

  then a properly set up catalog (using [process href="[whatever]"]
  on any form action that is a POST) will look just like a static
  HTML site, and will deliver relative images and simple links
  properly for a GET.

  There should be no difference to normal operation of Interchange if
  these changes are not made.

* Delivering images properly for a POST is a different story. There
  needs to be some thought on this -- it could be that:

	<head>
	[calc]
		my $method = $Tag->env('REQUEST_METHOD');
		return unless $method =~ /post/i;
		my $path = '@@MV_PAGE@@';
		return unless $path =~ s,(.*)/.*,$1,;
		return qq{<BASE HREF="$path">};
	[/calc]
	</head>

  will handle most anything.

* Improve handling of

	 [page href="http://www.foo.com/bar.html"
	 	   form="
		   		buz=baz
		   "]

   It will now deliver the link you would expect:

   		http://www.foo.com/bar.html?buz=baz

Revision  Changes    Path
1.5       +23 -5     interchange/code/SystemTag/process.coretag


rev 1.5, prev_rev 1.4
Index: process.coretag
===================================================================
RCS file: /var/cvs/interchange/code/SystemTag/process.coretag,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- process.coretag	15 Aug 2002 16:30:33 -0000	1.4
+++ process.coretag	7 Mar 2004 03:14:41 -0000	1.5
@@ -5,16 +5,34 @@
 sub {
 	my($target,$secure,$opt) = @_;
 
-	my $save;
 	$secure = defined $secure ? $secure : $CGI::secure;
 
-	my $page = $opt->{href} || 'process';
+	my $page = $opt->{href} || $Vend::Cfg->{ProcessPage};
 	if($opt->{download_name}) {
-		$save = delete $::Scratch->{mv_add_dot_html};
 		$page .= "/$opt->{download_name}";
 	}
-	my $url = $secure ? secure_vendUrl($page) : vendUrl($page);
-	$::Scratch->{mv_add_dot_html} = $save if $save;
+	my $url;
+	if($secure) {
+		$url = $Vend::Cfg->{SecurePostURL} || $Vend::Cfg->{SecureURL};
+	}
+	else {
+		$url = $Vend::Cfg->{PostURL} || $Vend::Cfg->{VendURL};
+	}
+	$url =~ s,/*$,/,;
+	$url .= $page;
+	if($Global::TolerateGet and ! $opt->{no_session}) {
+		my @args;
+		push @args, "?$::VN->{mv_session_id}=$Vend::SessionID"
+			unless  $::Scratch->{no_session_id};
+		push @args, "?$::VN->{mv_pc}=" . ++$Vend::Session->{pageCount}
+			unless  $::Scratch->{no_count};
+		push @args, "?$::VN->{mv_cat}=" . ++$Vend::Cat
+			if  $Vend::VirtualCat;
+		if(@args) {
+			$url .= '?';
+			$url .= join($Global::UrlJoiner, @args);
+		}
+	}
 	return $url unless $target;
 	return qq{$url" TARGET="$target};
 }



2.134     +5 -2      interchange/lib/Vend/Config.pm


rev 2.134, prev_rev 2.133
Index: Config.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Config.pm,v
retrieving revision 2.133
retrieving revision 2.134
diff -u -r2.133 -r2.134
--- Config.pm	20 Feb 2004 01:09:11 -0000	2.133
+++ Config.pm	7 Mar 2004 03:14:41 -0000	2.134
@@ -1,6 +1,6 @@
 # Vend::Config - Configure Interchange
 #
-# $Id: Config.pm,v 2.133 2004/02/20 01:09:11 jon Exp $
+# $Id: Config.pm,v 2.134 2004/03/07 03:14:41 mheins Exp $
 #
 # Copyright (C) 2002-2003 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
@@ -48,7 +48,7 @@
 use Vend::File;
 use Vend::Data;
 
-$VERSION = substr(q$Revision: 2.133 $, 10);
+$VERSION = substr(q$Revision: 2.134 $, 10);
 
 my %CDname;
 my %CPname;
@@ -410,6 +410,9 @@
 	['Sub',				 'subroutine',       ''],
 	['VendURL',          'url',              undef],
 	['SecureURL',        'url',              undef],
+	['PostURL',          'url',              ''],
+	['SecurePostURL',    'url',              ''],
+	['ProcessPage',      undef,              'process'],
 	['History',          'integer',          0],
 	['OrderReport',      undef,       		 'etc/report'],
 	['ScratchDir',       'relative_dir',     'tmp'],



1.36      +5 -5      interchange/lib/Vend/Dispatch.pm


rev 1.36, prev_rev 1.35
Index: Dispatch.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Dispatch.pm,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- Dispatch.pm	6 Mar 2004 22:11:53 -0000	1.35
+++ Dispatch.pm	7 Mar 2004 03:14:41 -0000	1.36
@@ -1,6 +1,6 @@
 # Vend::Dispatch - Handle Interchange page requests
 #
-# $Id: Dispatch.pm,v 1.35 2004/03/06 22:11:53 mheins Exp $
+# $Id: Dispatch.pm,v 1.36 2004/03/07 03:14:41 mheins Exp $
 #
 # Copyright (C) 2002-2003 Interchange Development Group
 # Copyright (C) 2002 Mike Heins <mike at perusion.net>
@@ -26,7 +26,7 @@
 package Vend::Dispatch;
 
 use vars qw($VERSION);
-$VERSION = substr(q$Revision: 1.35 $, 10);
+$VERSION = substr(q$Revision: 1.36 $, 10);
 
 use POSIX qw(strftime);
 use Vend::Util;
@@ -1383,11 +1383,11 @@
 	new Vend::Tags;
 # LEGACY
 	ROUTINES: {
-		last ROUTINES unless index($Vend::FinalPath, '/process/') == 0;
-		while ($Vend::FinalPath =~ s:/process/(locale|language|currency)/([^/]*)/:/process/:) {
+		last ROUTINES unless index($Vend::FinalPath, "/$Vend::Cfg->{ProcessPage}/") == 0;
+		while ($Vend::FinalPath =~ s{/$Vend::Cfg->{ProcessPage}/(locale|language|currency)/([^/]*)/}{/$Vend::Cfg->{ProcessPage}/}) {
 			$::Scratch->{"mv_$1"} = $2;
 		}
-		$Vend::FinalPath =~ s:/process/page/:/:;
+		$Vend::FinalPath =~ s{/$Vend::Cfg->{ProcessPage}/page/}{/};
 	}
 	my $locale;
 	if($locale = $::Scratch->{mv_language}) {



2.207     +26 -3     interchange/lib/Vend/Interpolate.pm


rev 2.207, prev_rev 2.206
Index: Interpolate.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.206
retrieving revision 2.207
diff -u -r2.206 -r2.207
--- Interpolate.pm	3 Mar 2004 16:07:30 -0000	2.206
+++ Interpolate.pm	7 Mar 2004 03:14:41 -0000	2.207
@@ -1,6 +1,6 @@
 # Vend::Interpolate - Interpret Interchange tags
 # 
-# $Id: Interpolate.pm,v 2.206 2004/03/03 16:07:30 jon Exp $
+# $Id: Interpolate.pm,v 2.207 2004/03/07 03:14:41 mheins Exp $
 #
 # Copyright (C) 2002-2003 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
@@ -28,7 +28,7 @@
 require Exporter;
 @ISA = qw(Exporter);
 
-$VERSION = substr(q$Revision: 2.206 $, 10);
+$VERSION = substr(q$Revision: 2.207 $, 10);
 
 @EXPORT = qw (
 
@@ -2868,12 +2868,35 @@
 		$Vend::Session->{$aloc}{$page} = $opt->{alias};
 	}
 
+	my $r;
+
 	if ($opt->{search}) {
 		$page = escape_scan($opt->{search});
 	}
 	elsif ($page =~ /^[a-z][a-z]+:/) {
 		### Javascript or absolute link
-		return $page;
+		return $page unless $opt->{form};
+		$page =~ s{(\w+://[^/]+)/}{}
+			or return $page;
+		my $intro = $1;
+		my @pieces = split m{/}, $page, 9999;
+		$page = pop(@pieces);
+		if(! length($page)) {
+			$page = pop(@pieces);
+			if(! length($page)) {
+				$r = $intro;
+				$r =~ s{/([^/]+)}{};
+				$page = "$1/";
+			}
+			else {
+				$page .= "/";
+			}
+		}
+		$r = join "/", $intro, @pieces unless $r;
+		$opt->{add_dot_html} = 0;
+		$opt->{no_session} = 1;
+		$opt->{secure} = 0;
+		$opt->{no_count} = 1;
 	}
 	elsif ($page eq 'scan') {
 		$page = escape_scan($arg);



2.71      +3 -3      interchange/lib/Vend/Util.pm


rev 2.71, prev_rev 2.70
Index: Util.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Util.pm,v
retrieving revision 2.70
retrieving revision 2.71
diff -u -r2.70 -r2.71
--- Util.pm	6 Mar 2004 22:11:53 -0000	2.70
+++ Util.pm	7 Mar 2004 03:14:41 -0000	2.71
@@ -1,6 +1,6 @@
 # Vend::Util - Interchange utility functions
 #
-# $Id: Util.pm,v 2.70 2004/03/06 22:11:53 mheins Exp $
+# $Id: Util.pm,v 2.71 2004/03/07 03:14:41 mheins Exp $
 # 
 # Copyright (C) 2002-2003 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
@@ -87,7 +87,7 @@
 use Vend::File;
 use subs qw(logError logGlobal);
 use vars qw($VERSION @EXPORT @EXPORT_OK);
-$VERSION = substr(q$Revision: 2.70 $, 10);
+$VERSION = substr(q$Revision: 2.71 $, 10);
 
 my $Eval_routine;
 my $Eval_routine_file;
@@ -1193,7 +1193,7 @@
 
 	my $extra;
 	if($opt->{form}) {
-		$path = 'process' unless $path;
+		$path = $Vend::Cfg->{ProcessPage} unless $path;
 		if($opt->{form} eq 'auto') {
 			my $form = '';
 			while( my ($k, $v) = each %$opt) {








More information about the interchange-cvs mailing list