package Bavl; use strict; no warnings 'redefine'; use base 'Squatting'; # use Aspect; # this position causes a segfault! However... I can 'use' it later and be fine. use Bavl::Models '$bavl'; use Bavl::Controllers; use Bavl::Views; use Bavl::L10N 'x'; use Net::OpenID::Consumer; use Aspect::Hook::LexWrap; use DateTime; use DateTime::Format::ISO8601; our $VERSION = '0.02'; our %state; sub service { my ($class, $c, @args) = @_; my $cr = $c->cr; # setup session my $sid = $cr->{session_id}; if (defined $sid) { $c->state = $state{$sid} ||= Bavl::Object->new; } # common variables my $v = $c->v; $v->{title} = "towr.of.bavl.org"; $v->{lang} = "en"; $v->{css} = \@Bavl::Views::css; $v->{js} = \@Bavl::Views::js; # u is the currently logged in user if ($c->state->{u}) { $v->{u} = $c->state->{u}; } elsif ($c->cookies->{guest}) { my $user = JSON::XS::decode_json($c->cookies->{guest}); $user->{is_guest} = 1; for (qw(doc)) { delete($user->{$_}); } $v->{u} = $c->state->{u} = $bavl->user->clone($user); } else { # explicitly set $u $v->{u} = $c->state->{u} = undef; } # all this so that I can use x($string) for localization my $wrap = wrap \&x, pre => sub { my ($args, $original, $return) = @_; my $phrase = $args->[0]; $args->[0] = { phrase => $phrase, lang => $v->{lang}, }; }; # hand control over to the controllers $class->SUPER::service($c, @args); } sub go { my $app = shift; $app->SUPER::go(docroot => "www/main", @_); } 1; __END__ =head1 NAME Bavl - towr.of.bavl.org =head1 DESCRIPTION We're all going to teach each other how to speak the various languages of the world. =head1 AUTHOR John BEPPU Ebeppu@cpan.orgE =head1 COPYRIGHT Copyright (C) 2008 John BEPPU Ebeppu@cpan.orgE This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . =cut # Local Variables: *** # mode: cperl *** # indent-tabs-mode: nil *** # cperl-close-paren-offset: -2 *** # cperl-continued-statement-offset: 2 *** # cperl-indent-level: 2 *** # cperl-indent-parens-as-block: t *** # cperl-tab-always-indent: nil *** # End: *** # vim:tabstop=2 softtabstop=2 shiftwidth=2 shiftround expandtab