| 1 | |||
| 2 | ### | ||
| 3 | # AxKit XSP taglib for MD5 digests | ||
| 4 | # Robin Berjon <robin@knowscape.com> | ||
| 5 | # 25/06/2001 - v.0.01 | ||
| 6 | ### | ||
| 7 | |||
| 8 | package AxKit::XSP::MD5; | ||
| 9 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 1 | ▶ | use Digest::MD5 qw(); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | 1 | ▶ | use vars qw($VERSION $NS); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | $VERSION = '0.01'; | ||
| 14 | |||
| 15 | 1 | ▶ | use base qw(Apache::AxKit::Language::XSP); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | |||
| 17 | # define the namespace we use (RDDL there one of these days) | ||
| 18 | $NS = 'http://xmlns.knowscape.com/xsp/MD5'; | ||
| 19 | |||
| 20 | |||
| 21 | |||
| 22 | #,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,# | ||
| 23 | #`,`, Parser subs `,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,# | ||
| 24 | #```````````````````````````````````````````````````````````````````# | ||
| 25 | |||
| 26 | sub parse_start { | ||
| 27 | my $e = shift; | ||
| 28 | my $tag = shift; | ||
| 29 | my %attr = @_; | ||
| 30 | |||
| 31 | my $code; | ||
| 32 | if ($tag eq 'md5' or $tag eq 'md5-hex' or $tag eq 'md5-base64') { | ||
| 33 | $code = "{ #start md5\n my \$axmd5_text = ''"; | ||
| 34 | } | ||
| 35 | else { | ||
| 36 | die "Unknown tag $tag in MD5 taglib"; | ||
| 37 | } | ||
| 38 | return $code; | ||
| 39 | } | ||
| 40 | |||
| 41 | sub parse_end { | ||
| 42 | my $e = shift; | ||
| 43 | my $tag = shift; | ||
| 44 | |||
| 45 | if ($tag eq 'md5' or $tag eq 'md5-hex' or $tag eq 'md5-base64') { | ||
| 46 | $e->append_to_script(";\n"); | ||
| 47 | $e->start_expr; | ||
| 48 | $tag =~ s/-/_/g; | ||
| 49 | $e->append_to_script(" Digest::MD5::$tag(\$axmd5_text)"); | ||
| 50 | $e->end_expr; | ||
| 51 | $e->append_to_script("} # end of md5\n"); | ||
| 52 | } | ||
| 53 | return ''; | ||
| 54 | } | ||
| 55 | |||
| 56 | sub parse_char { | ||
| 57 | my $e = shift; | ||
| 58 | my $txt = shift; | ||
| 59 | |||
| 60 | $txt =~ s/\|/\\\|/; | ||
| 61 | my $code = " . q|$txt|"; | ||
| 62 | return $code; | ||
| 63 | } | ||
| 64 | |||
| 65 | sub parse_comment {} | ||
| 66 | sub parse_final {} | ||
| 67 | |||
| 68 | |||
| 69 | 1; | ||
| 70 | |||
| 71 | #,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,# | ||
| 72 | #`,`, Documentation `,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,# | ||
| 73 | #```````````````````````````````````````````````````````````````````# | ||
| 74 | |||
| 75 | =pod | ||
| 76 | |||
| 77 | =head1 NAME | ||
| 78 | |||
| 79 | AxKit::XSP::MD5 - AxKit XSP taglib for MD5 digests | ||
| 80 | |||
| 81 | =head1 SYNOPSIS | ||
| 82 | |||
| 83 | Add the md5 namespace to your XSP C<<xsp:page>> tag: | ||
| 84 | |||
| 85 | <xsp:page | ||
| 86 | language='Perl' | ||
| 87 | xmlns:xsp='http://apache.org/xsp/core/v1' | ||
| 88 | xmlns:md5='http://xmlns.knowscape.com/xsp/MD5'> | ||
| 89 | |||
| 90 | And add the taglib to AxKit (via httpd.conf or .htaccess): | ||
| 91 | |||
| 92 | AxAddXSPTaglib AxKit::XSP::MD5 | ||
| 93 | |||
| 94 | =head1 DESCRIPTION | ||
| 95 | |||
| 96 | The XSP MD5 taglib implements MD5 digests (as provided by the | ||
| 97 | Digest::MD5 module). You may use it to generate keys for cookies or | ||
| 98 | checksums for files (if there is demand for this, I'll implement | ||
| 99 | MD5'ing an external file). | ||
| 100 | |||
| 101 | =head2 Tag Reference | ||
| 102 | |||
| 103 | There are three tags provided by this taglib, which map to | ||
| 104 | Digest::MD5's three functions: md5:md5, md5:md5-hex, md5:md5-base64. | ||
| 105 | Please refer to Digest::MD5's documentation for these. The data is | ||
| 106 | quite simply the content of the tags. | ||
| 107 | |||
| 108 | =head1 AUTHOR | ||
| 109 | |||
| 110 | Robin Berjon, robin@knowscape.com | ||
| 111 | |||
| 112 | =head1 COPYRIGHT | ||
| 113 | |||
| 114 | Copyright (c) 2001 Robin Berjon. All rights reserved. This program is | ||
| 115 | free software; you can redistribute it and/or modify it under the same | ||
| 116 | terms as Perl itself. | ||
| 117 | |||
| 118 | =cut | ||