Changeset 25465

Show
Ignore:
Timestamp:
11/30/08 23:10:51 (5 years ago)
Author:
kazuho
Message:

add openid demo

Location:
lang/perl/NanoA/trunk
Files:
3 added
4 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/NanoA/trunk/lib/NanoA.pm

    r25131 r25465  
    125125    } 
    126126    $status ||= 302; 
    127     print 'Status: ', $status, "\nLocation: " . $uri . "\n\n"; 
     127    $self->header(-status   => 302); 
     128    $self->header(-location => $uri); 
     129    my $body = ''; 
     130    $self->run_hooks('postrun', \$body); 
     131    $self->print_header(); 
     132    utf8::encode($body) 
     133         if utf8::is_utf8($body); 
     134    print $body; 
    128135    CGI::ExceptionManager::detach(); 
    129136} 
     
    161168} 
    162169 
     170sub uri_escape { 
     171    my $s = shift; 
     172    join( 
     173        '', 
     174        map { 
     175            /^[a-zA-Z0-9_.!~*'()-]$/ ? $_ : '%' . uc(unpack('H2', $_)) 
     176        } split(//, $s), 
     177    ); 
     178} 
     179 
    163180sub nanoa_uri { 
    164181    $ENV{SCRIPT_NAME} || '/nanoa.cgi'; 
     182} 
     183 
     184sub uri_for { 
     185    my ($app, $path, $query) = @_; 
     186    $path = nanoa_uri . '/' . $path 
     187        unless $path =~ m|^/|; 
     188    return $path unless $query && ref $query eq 'HASH'; 
     189    $path . '?' . join( 
     190        '&', 
     191        map { 
     192            uri_escape($_) . '=' . uri_escape($query->{$_}), 
     193        } sort keys %$query, 
     194    ); 
    165195} 
    166196 
  • lang/perl/NanoA/trunk/lib/NanoA/Plugin.pm

    r24561 r25465  
    55use utf8; 
    66 
     7use base qw(NanoA); 
     8 
    79sub import { 
    810    my $pkg = caller; 
    911    # plugins loading other plugins should call init_plugin explicitely 
    10     return if $pkg =~ /^plugin::/; 
     12    local $@; 
     13    my $pkg_is_plugin; 
     14    eval { 
     15        $pkg_is_plugin = $pkg->is_plugin; 
     16    }; 
     17    return if $pkg_is_plugin; 
    1118    shift->init_plugin($pkg); 
    1219} 
     
    1724} 
    1825 
     26sub is_plugin { 1 } 
     27 
    19281; 
  • lang/perl/NanoA/trunk/nanoa.pl

    r24409 r25465  
    44 
    55BEGIN { 
    6     unshift @INC, 'extlib'; 
     6    unshift @INC, qw(extlib app); 
    77}; 
    88 
  • lang/perl/NanoA/trunk/plugin/form.pm

    r25439 r25465  
    66 
    77use HTML::AutoForm; 
    8 use plugin::session; 
    98 
    109use base qw(NanoA::Plugin); 
     10 
     11use plugin::session; 
    1112 
    1213BEGIN {