Squatting

 view release on metacpan or  search on metacpan

doc/squatting-propaganda-for-catalyst.txt  view on Meta::CPAN

STEP 2:  Run Pod::Server so you can see what it looks like.

  $ squatting Pod::Server -p 8088

    or

  $ pod_server

Then, visit http://localhost:8088/ and pay attention to the URLs as you
click around.  (This will be interesting when you see how the URLs of 
the whole site will be "relocated" later on in the demonstration.)



STEP 3:  Create a Catalyst application.

  $ catalyst.pl Propaganda



STEP 4:  Embed Pod::Server into the Catalyst application.

  $ cd Propaganda
  $ $EDITOR lib/Propaganda/Controller/Root.pm

Then, add the following lines of code to an appropriate place in the
controller.

  use Pod::Server ’On::Catalyst’;
  Pod::Server->init;
  Pod::Server->relocate(’/pod’);
  $Pod::Simple::HTML::Perldoc_URL_Prefix = ’/pod/’;
  sub pod : Local { Pod::Server->catalyze($_[1]) }



STEP 5: Start up the Catalyst application.

  $ script/propaganda_server.pl

Finally, visit http://localhost:3000/pod/ .  If everything worked, you should

doc/squatting-propaganda-for-perlmonks.html  view on Meta::CPAN


    or

<code>
  $ pod_server
</code>

<p>Then, visit <a href="http://localhost:8088/">http://localhost:8088/</a>
and pay attention to the URLs as you
click around.  (This will be interesting when you see how the URLs of 
the whole site will be "relocated" later on in the demonstration.)
</p>


<h2>STEP 3:  Create a Catalyst application.</h2>

<code>
  $ catalyst.pl Propaganda
</code>


doc/squatting-propaganda-for-perlmonks.html  view on Meta::CPAN

  $ $EDITOR lib/Propaganda/Controller/Root.pm
</code>

<p>Then, add the following lines of code to an appropriate place in the
controller.
</p>

<code>
  use Pod::Server ’On::Catalyst’;
  Pod::Server->init;
  Pod::Server->relocate(’/pod’);
  $Pod::Simple::HTML::Perldoc_URL_Prefix = ’/pod/’;
  sub pod : Local { Pod::Server->catalyze($_[1]) }
</code>



<h2>STEP 5: Start up the Catalyst application.</h2>

<code>
  $ script/propaganda_server.pl

lib/Squatting.pm  view on Meta::CPAN

  my ($app, $other, $prefix) = @_;
  push @{$app."::O"}, $other;
  push @{$app."::Controllers::C"}, map {
    my $urls = $_->urls;
    $_->urls = [ map { $prefix.$_ } @$urls ];
    $_;
  } @{$other."::Controllers::C"}
}

# 2
# App->relocate($prefix)  # Map main app to a URL $prefix
sub relocate {
  my ($app, $prefix) = @_;
  for (@{$app."::Controllers::C"}) {
    my $urls = $_->urls;
    $_->urls = [ map { $prefix.$_ } @$urls ];
  }
  ${$app."::CONFIG"}{relocated} = $prefix;
}

# 3
# App->init  # Initialize $app
sub init {
  $_->init for (@{$_[0]."::O"});
  %{$_[0]."::Controllers::C"} = map { $_->name => $_ } @{$_[0]."::Controllers::C"};
  %{$_[0]."::Views::V"}       = map { $_->name => $_ } @{$_[0]."::Views::V"};
}

lib/Squatting.pm  view on Meta::CPAN


  App->mount('My::Blog'   => '/my/ridiculous/rantings');
  App->mount('Forum'      => '/forum');
  App->mount('ChatterBox' => '/chat');

B<NOTE>:  You can only mount an app once.  Don't try to mount it again
at some other prefix, because it won't work.  This is a consequence
of storing so much information in package variables and a strong argument
for going all objects all the time.

=head3 App->relocate($prefix)

This method will relocate a Squatting app to the specified prefix.  It's useful
for embedding a Squatting app into apps written in other frameworks.

This also has a side-effect of setting C<$CONFIG{relocated}> to C<$prefix>.

=head2 Use as a Helper for Controllers

In this package, you will define a list of L<Squatting::Controller> objects in C<@C>.

  package App::Controllers;
  use Squatting ':controllers';
  our @C = (
    C(...),
    C(...),

lib/Squatting/On/CGI.pm  view on Meta::CPAN


Squatting::On::CGI - if all else fails, you can still deploy on CGI

=head1 SYNOPSIS

Create an app.cgi to drive the Squatting app in a CGI environment.

  use App 'On::CGI';
  my $q = CGI->new;
  App->init;
  App->relocate('/cgi-bin/app.cgi');
  App->cgi($q);

=head1 DESCRIPTION

The purpose of this module is to allow Squatting apps to be used in a CGI
environment.  This is done by adding a C<cgi> method to the Squatting app that
knows how to "translate" between CGI and Squatting.  To use this module, pass
the string C<'On::CGI'> to the C<use> statement that loads your Squatting
app.

lib/Squatting/On/Catalyst.pm  view on Meta::CPAN


Squatting::On::Catalyst - embed a Squatting app into a Catalyst app

=head1 SYNOPSIS

Add these 4 lines to your Catalyst app's Root Controller to embed a Squatting
App.

  use App 'On::Catalyst'
  App->init;
  App->relocate('/somewhere')
  sub somewhere : Local { App->catalyze($_[1]) }

=head1 DESCRIPTION

The purpose of this module is to allow Squatting apps to be embedded inside
Catalyst apps.  This is done by adding a C<catalyze> method to the Squatting
app that knows how to "translate" between Catalyst and Squatting.  To use this
module, pass the string C<'On::Catalyst'> to the C<use> statement that loads
your Squatting app.

lib/squatting.pl  view on Meta::CPAN

pop @regex_captures if($#+==0);return($c,\@regex_captures)}}}
($Squatting::Controller::r404,[])}unless exists ${$app."::"}{D}}
my@c;for(@_){if($_ eq':controllers'){*{$p."::C"}=sub{
Squatting::Controller->new(@_,app=>$app)};
}elsif($_ eq':views'){*{$p."::V"}=sub{Squatting::View->new(@_)};
}elsif(/::/){push @c,$_}}$m->load_components(@c)if@c}
sub component_base_class{__PACKAGE__}sub mount{my($app,$other,$prefix)=@_;
push @{$app."::O"},$other;push @{$app."::Controllers::C"},map{
my$urls=$_->urls;$_->urls=[map{$prefix.$_}@$urls];$_;
}@{$other."::Controllers::C"}}
sub relocate{my($app,$prefix)=@_;for(@{$app."::Controllers::C"}){
my$urls=$_->urls;$_->urls=[map{$prefix.$_}@$urls]}}
sub init{$_->init for(@{$_[0]."::O"});%{$_[0]."::Controllers::C"}=
map{$_->name=>$_}@{$_[0]."::Controllers::C"};
%{$_[0]."::Views::V"}=map{$_->name=>$_}@{$_[0]."::Views::V"}}
sub service{my($app,$c,@args)=grep{defined}@_;my$method=lc
$c->env->{REQUEST_METHOD};my$content;eval{$content=$c->$method(@args)};
warn"EXCEPTION: $@"if($@);my$cookies=$c->cookies;$c->headers->{'Set-Cookie'}=
join("; ",map{CGI::Cookie->new(-name=>$_,%{$cookies->{$_}})}
grep{ref$cookies->{$_}eq'HASH'}keys %$cookies)if(%$cookies);$content}
package Squatting::View;sub new{



( run in 0.958 second using v1.01-cache-2.11-cpan-5511b514fd6 )