Your SlideShare is downloading. ×
0
Mangling CPAN with Plack::App::Proxy Olaf Alders Toronto Perl Mongers September 30, 2010 [email_address] twitter.com/wunde...
What is PSGI/Plack? “ Superglue interface between perl web application frameworks and web servers, just like Perl is the d...
Plack::App::Proxy Plack middleware which allows you to map a local url to another local (or remote) url.  <ul><li>Easier t...
Doesn't require Apache
Doesn't appear to have the same security implications </li></ul>
How can we (ab)use this? <ul><li>search.cpan.org is a great resource
I wish it had syntax highlighting
I don't want to use a Firefox plugin (Greasemonkey)
Using Plack, I will subvert CPAN to my will
I have also enlisted @ioncache to help me out </li></ul>
Introducing cpan-mangler http://github.com/oalders/cpan-mangler
Install and Run git clone http://github.com/ioncache/Plack-Middleware-HTMLify.git git clone http://github.com/oalders/cpan...
Documentation before:
 
Documentation after:
 
Is there more? <ul><li>POD now looks much better
How about the module source? </li></ul>
Module source before:
 
Module source after:
Upcoming SlideShare
Loading in...5
×

Mangling

3,983

Published on

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,983
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
5
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Transcript of "Mangling "

  1. 1. Mangling CPAN with Plack::App::Proxy Olaf Alders Toronto Perl Mongers September 30, 2010 [email_address] twitter.com/wundercounter
  2. 2. What is PSGI/Plack? “ Superglue interface between perl web application frameworks and web servers, just like Perl is the duct tape of the internet. PSGI is an interface between Perl web applications and web servers, and Plack is a Perl module and toolkit that contains PSGI middleware, helpers and adapters to web servers. PSGI and Plack are inspired by Python's WSGI and Ruby's Rack.” http://plackperl.org
  3. 3. Plack::App::Proxy Plack middleware which allows you to map a local url to another local (or remote) url. <ul><li>Easier to set up than Apache's mod_proxy
  4. 4. Doesn't require Apache
  5. 5. Doesn't appear to have the same security implications </li></ul>
  6. 6. How can we (ab)use this? <ul><li>search.cpan.org is a great resource
  7. 7. I wish it had syntax highlighting
  8. 8. I don't want to use a Firefox plugin (Greasemonkey)
  9. 9. Using Plack, I will subvert CPAN to my will
  10. 10. I have also enlisted @ioncache to help me out </li></ul>
  11. 11. Introducing cpan-mangler http://github.com/oalders/cpan-mangler
  12. 12. Install and Run git clone http://github.com/ioncache/Plack-Middleware-HTMLify.git git clone http://github.com/oalders/cpan-mangler.git cpanm Plack Plack::App::Proxy cd cpan-mangler plackup -I../Plack-Middleware-HTMLify/lib
  13. 13. Documentation before:
  14. 15. Documentation after:
  15. 17. Is there more? <ul><li>POD now looks much better
  16. 18. How about the module source? </li></ul>
  17. 19. Module source before:
  18. 21. Module source after:
  19. 23. Looking under the hood Let's look at how we went about setting up the proxy. It's very easy to set up. You can proxy a site of your choice in just a few minutes.
  20. 24. Set up the proxy use Plack::App::Proxy; use Plack::Builder; my $app = builder { mount &quot;/&quot; => builder {; Plack::App::Proxy->new( remote => 'http://search.cpan.org/' )->to_app; }; }; $app; # http://github.com/oalders/cpan-mangler/blob/master/examples/proxy.psgi
  21. 25. Mangle the POD use Plack::App::Proxy; use Plack::Builder; my $pod_highlight = q[...]; # insert JavaScript and CSS here my $app = builder { enable &quot;Debug&quot;, panels => [qw(Environment Memory Timer Response)]; mount &quot;/&quot; => builder { enable 'SimpleContentFilter', filter => sub { s{</head>}{$pod_highlight</head>}i; }; Plack::App::Proxy->new( remote => 'http://search.cpan.org/' )->to_app; }; }; $app; # Find full code sample at # http://github.com/oalders/cpan-mangler/blob/master/examples/pod-mangler.psgi
  22. 26. Known Issues <ul><li>Doesn't perform perfectly
  23. 27. Can slow down page rendering on large pages (e.g. CGI.pm)
  24. 28. Some mangling may happen several times on a big page (chunking) </li></ul>
  25. 29. The Good Parts <ul><li>Makes proxying dead easy
  26. 30. Improve your CPAN experience (be creative) </li></ul>
  27. 31. Beyond CPAN <ul><li>can be used for Google ad tracking
  28. 32. proxy an entire site
  29. 33. set up a custom domain name for the proxy
  30. 34. direct all Google ads to this new domain
  31. 35. mangle the pages to add your own analytics code
  32. 36. site's existing functionality should remain the same
  33. 37. you can now replicate a site for tracking without making a copy of it or knowing/caring how it works under the hood </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×