Squatting::On::Catalyst

(This was originally posted to the Catalyst Mailing List. It's being reposted on PerlMonks for the benefit of the broader Perl community.)

Squatting is a web microframework for Perl that's based on Camping from the Ruby world. During the transition from Ruby to Perl, Squatting gained some mutant powers which is why I'm writing to you today.

One of Squatting's mutant powers is its ability to embed itself into other frameworks (like Catalyst). You can take whole Squatting apps, and embed them into your existing web application with just a few lines of glue code. Allow me to demonstrate.

STEP 1: Install Pod::Server from CPAN.

$ sudo cpan Pod::Server

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 see that Pod::Server has just been embedded into a Catalyst application.

What Are The Implications of This?

Right now, anyone who is developing a web app with Catalyst can install Pod::Server from CPAN and embed it directly into their web app. However, this is just the beginning.

Imagine if you could install a blog, a wiki, a forum, or a store just as easily.

Imagine adding major functionality to any Perl-based site with ~5 lines of code.

Squatting makes modular web applications both possible and probable.

http://search.cpan.org/dist/Squatting/

http://github.com/beppu/squatting/tree/master


In reply to Squatting::On::Catalyst and Truly Modular Web Apps by beppu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.