You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axkit-dev@xml.apache.org by ma...@apache.org on 2002/12/23 14:45:19 UTC
cvs commit: xml-axkit/lib/Apache/AxKit/StyleChooser Cookie.pm QueryString.pm
matts 2002/12/23 05:45:19
Modified: lib/Apache/AxKit/StyleChooser Cookie.pm QueryString.pm
Log:
Patch from Christopher Laco to allow changing the key
Revision Changes Path
1.4 +15 -4 xml-axkit/lib/Apache/AxKit/StyleChooser/Cookie.pm
Index: Cookie.pm
===================================================================
RCS file: /home/cvs/xml-axkit/lib/Apache/AxKit/StyleChooser/Cookie.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Cookie.pm 30 Jul 2002 10:33:42 -0000 1.3
+++ Cookie.pm 23 Dec 2002 13:45:19 -0000 1.4
@@ -12,9 +12,11 @@
sub handler {
my $r = shift;
+ my $key = $r->dir_config('AxStyleChooserCookieKey') ||
+ 'axkit_preferred_style';
my $oreo = Apache::Cookie->fetch; # if dougm can call a cookie method "bake". . .
- if ( defined $oreo->{'axkit_preferred_style'} ) {
- $r->notes('preferred_style', $oreo->{'axkit_preferred_style'}->value);
+ if ( defined $oreo->{$key} ) {
+ $r->notes('preferred_style', $oreo->{$key}->value);
}
return OK;
@@ -35,7 +37,16 @@
This module checks for the presence of a cookie named 'axkit_preferred_style'
and sets the preferred style accordingly.
-To use it, simply add this module as an AxKit plugin that
+
+The name of the cookie can be changed by setting the variable
+C<AxStyleChooserCookieKey> in your httpd.conf:
+
+ PerlSetVar AxStyleChooserCookieKey mystyle
+
+Once set, this module will check for the presence of the cookie named
+'mystyle' instead of the cookie named 'axkit_preferred_style'.
+
+To use the module, simply add this module as an AxKit plugin that
will be run before main AxKit processing is done.
AxAddPlugin Apache::AxKit::StyleChooser::Cookie
1.4 +23 -10 xml-axkit/lib/Apache/AxKit/StyleChooser/QueryString.pm
Index: QueryString.pm
===================================================================
RCS file: /home/cvs/xml-axkit/lib/Apache/AxKit/StyleChooser/QueryString.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- QueryString.pm 30 Jul 2002 10:33:42 -0000 1.3
+++ QueryString.pm 23 Dec 2002 13:45:19 -0000 1.4
@@ -6,13 +6,15 @@
use Apache::Constants qw(OK);
sub handler {
- my $r = shift;
-
- my %in = $r->args();
- if ($in{style}) {
- $r->notes('preferred_style', $in{style});
- }
- return OK;
+ my $r = shift;
+
+ my %in = $r->args();
+ my $key = $r->dir_config('AxStyleChooserQueryStringKey') || 'style';
+
+ if ($in{$key}) {
+ $r->notes('preferred_style', $in{$key});
+ }
+ return OK;
}
1;
@@ -34,12 +36,23 @@
AxAddPlugin Apache::AxKit::StyleChooser::QueryString
+By default, the key name of the name/value pair is 'style'.
+This can be changed by setting the variable AxStyleChooserQueryStringKey
+in your httpd.conf:
+
+ PerlSetVar AxStyleChooserQueryStringKey mystyle
+
Then simply by referencing your xml files as follows:
http://xml.server.com/myfile.xml?style=printable
+
+or
+
+ http://xml.server.com/myfile.xml?mystyle=printable
-You will recieve the alternate stylesheets with title "printable". See
-the HTML 4.0 specification for more details on stylesheet choice.
+respectively - you will recieve the alternate stylesheets with title
+"printable". See the HTML 4.0 specification for more details on
+stylesheet choice.
See the B<AxStyleName> AxKit configuration directive
for more information on how to setup named styles.