#!/usr/bin/perl -w
=pod
=head1 NAME
TypeKISS 1.1 (TypeKey Included Server Side)
=head1 SYNOPSIS
Thanks for signing in, .
(">sign out)
">Sign in with
TypeKey.
=head1 DESCRIPTION
TypeKISS allows you to add TypeKey to your custom Movable Type comments
forms without the use of MT's standard JavaScript for including the
commenter name. Instead, TypeKISS uses Server-Side Includes (SSI).
Because TypeKISS requires SSI, it is incompatible with dynamic publishing
and static publishing to PHP files.
As the SSI code requires the C cookie to be available,
TypeKISS only works on weblogs published to the same domain as your
C.
=head1 USAGE
=head2
Display the contents if the viewer is signed in with TypeKey. Otherwise,
display the contents of the contained C tag, if any.
=head2
Display the viewer's TypeKey name, or "" (the empty string) if the viewer
is not signed in.
=head1 AUTHOR & COPYRIGHT
Copyright 2004-2005 Mark Paschal
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
=cut
use strict;
package MT::Plugin::TypeKiss;
require MT::Template::Context;
require MT::Plugin;
our
$VERSION = '1.1';
sub if_signed_in {
my ($ctx, $args, $cond) = @_;
my $builder = $ctx->stash('builder');
if($ctx->stash('comment_preview')) {
return $builder->build($ctx, $ctx->stash($ctx->stash('commenter') ?
'tokens' : 'tokens_else'), $cond) or $ctx->error($builder->errstr);
}
my $out = '';
$out .= $builder->build($ctx, $ctx->stash('tokens'), $cond)
or return $ctx->error($builder->errstr);
$out .= '';
$out .= $builder->build($ctx, $ctx->stash('tokens_else'), $cond)
or return $ctx->error($builder->errstr);
$out .= '';
$out;
}
sub signed_in_name {
my ($ctx, $args, $cond) = @_;
if($ctx->stash('comment_preview')) {
local $ctx->{__stash}->{tag} = 'CommentPreviewAuthor';
return $ctx->_hdlr_comment_author(@_);
}
return '';
}
MT::Template::Context->add_container_tag('IfSignedIn', \&if_signed_in);
MT::Template::Context->add_tag('SignedInName', \&signed_in_name);
my $plugin = new MT::Plugin({
name => 'TypeKISS',
version => $VERSION,
author_name => 'Mark Paschal',
author_link => 'http://markpasc.org/mark/',
plugin_link => 'http://markpasc.org/code/mt/typekiss/',
description => "TypeKey-enable your comments without JavaScript"
});
MT->add_plugin($plugin);
1;