view release on metacpan or search on metacpan
devdata/https_mojolicious.io_blog_2018_12_04_testing-hooks-and-helpers_ view on Meta::CPAN
<section id="section-1">
<p><a href="https://mojolicious.org/perldoc/Test/Mojo">Test::Mojo</a>, the
<a href="http://mojolicious.org">Mojolicious</a> testing tool, has a lot of ways to
<a href="https://mojolicious.org/perldoc/Mojolicious/Guides/Testing">test routes in web
applications</a>
(even for <a href="https://metacpan.org/pod/Test::Mojo::Role::PSGI">testing in other web
frameworks</a>).</p>
<p>But what if what I need to test isn't a route? What if it's
a <a href="https://mojolicious.org/perldoc/Mojolicious#HOOKS">hook</a>,
a <a href="https://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Adding-a-plugin-to-your-application">plugin</a>,
or
a <a href="https://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Helpers">helper</a>?
We can test all those things, too!</p>
</section>
<section id="section-2">
<h1>Hooks</h1>
<p>To thoroughly test hooks, I need to find ways to configure my test
cases. I could count on my application to do it, and find the right
devdata/https_mojolicious.io_blog_2018_12_08_authenticating-with-ldap_ view on Meta::CPAN
<p>Pro tip: You can even simplify it to</p>
<pre><code>%= form_for 'do_login'
</code></pre>
<p>which does it all for you including the <code>method</code> if the route only handles <code>POST</code>.</p>
<h3>Controller - lib/MyApp/Controller/Secure.pm</h3>
<p>Let's get started by cribbing from the
<a href="https://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Basic-authentication1">Mojolicious Cookbook</a>.</p>
<pre><code>package MyApp::Controller::Secure;
use Mojo::Base 'Mojolicious::Controller';
sub on_user_login {
my $self = shift;
my $username = $self->param('username');
my $password = $self->param('password');
devdata/https_mojolicious.io_blog_2018_12_16_browser-diet_ view on Meta::CPAN
<h2>... and <em>then</em> there was a <a href="https://perlmaven.com/deploying-a-mojolicious-application">Toad</a></h2>
<p>The forest creatures used the
<a href="https://github.com/mojolicious/mojo/wiki/Hypnotoad-prefork-web-server">Hypnotoad</a>
web server that comes with Mojolicious to serve their pages.
They found it a good fit for their arboreal production environment.</p>
<p><img class="align-center" src="Hypnotoad.gif" title="All glory to the Hypnotoad"></p>
<p>It can set the HTTP headers to turn it into a
<a href="https://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Hypnotoad">reverse proxy</a>,
but a popular setup is sitting Hypnotoad behind
<a href="https://www.mind-it.info/2014/09/27/running-hypnotoad-behind-nginx/">Nginx</a>
or Apache/mod_proxy.
Those servers should let you play with the <code>Expires</code> header.
But the Toad didn't <em>quite</em> have what this particular rodent was looking for.</p>
<p><em>An aside</em> - No, I didn't mention
<a href="https://metacpan.org/pod/Plack">Plack</a>.
Maybe if I'm good this year, Santa will
<a href="http://blogs.perl.org/users/aristotle/2018/11/modern-perl-cgi.html">tell me how</a>
devdata/https_mojolicious.io_blog_2018_12_19_you-only-export-twice_ view on Meta::CPAN
<!-- theme suggests 1300x500 -->
<img alt="Container ship leaving port" src="/blog/2018/12/19/you-only-export-twice/banner.jpg">
</div>
<div class="post-content">
<section id="section-1">
<p>With my Yancy documentation site built, with <a href="/blog/2018/12/17/a-website-for-yancy">a custom landing
page</a> and <a href="/blog/2018/12/18/a-view-to-a-pod">a POD
viewer</a>, I just need to deploy the site. I
could deploy the site using <a href="https://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Hypnotoad">hypnotoad, Mojolicious's preforking server with
hot
deployment</a>,
but that would require me to have a server and keep it online. It'd be a lot
better if I could just deploy a <a href="https://pages.github.com">static website to
Github</a> like all the cool people are doing.</p>
<p>But to do that, I'd need to take my dynamic website and turn it into a static
one, and that's impossible! Or is it? Why am I asking me, when I'm the one who
wrote a way to do it: The <a href="https://metacpan.org/pod/Mojolicious::Command::export">Mojolicious export
command</a>.</p>
devdata/https_mojolicious.io_blog_2018_12_19_you-only-export-twice_ view on Meta::CPAN
</code></pre>
<p>Since I'm hosting this site under a directory in my personal website, I need to
use the <code>--base</code> option to rewrite all the internal links to the correct path,
and I can use the <code>--to</code> option to write directly to the web server's
directory:</p>
<pre><code>$ ./myapp.pl export --base /yancy --to /var/www/preaction.me/yancy
</code></pre>
<p>And, if I want, I can use <a href="https://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Adding-a-configuration-file">the Mojolicious Config
plugin</a>
to change the default settings, including what pages to export, the export
directory, and a base URL.</p>
<p>The best part is that the export command handles redirects. So, when we're
using <a href="http://metacpan.org/pod/Mojolicious::Plugin::PODViewer">the PODViewer
plugin</a> and get
redirected to <a href="http://metacpan.org">MetaCPAN</a>, the page gets updated with the
redirected location!</p>
devdata/https_mojolicious.io_blog_2018_12_20_testing-dancer_ view on Meta::CPAN
<h5>Joel Berger</h5>
<p>Joel has Ph.D. in Physics from the University of Illinois at Chicago.
He an avid Perl user and <a href="https://metacpan.org/author/JBERGER">author</a> and is a member of the Mojolicious Core Team.</p>
</div>
</div>
<ul class="post-nav cf">
<li class="prev"><a href="/blog/2018/12/19/you-only-export-twice/index.html" rel="prev"><strong>Previous Article</strong> Day 19: You Only Export Twice</a></li>
<li class="next"><a href="/blog/2018/12/21/a-little-christmas-template-cooking/index.html" rel="next"><strong>Next Article</strong> Day 21: A Little Christmas Template Cooking </a></li>
</ul>
</div>
</article>
</div>
<div class="four columns end" id="secondary">
devdata/https_mojolicious.io_blog_2018_12_21_a-little-christmas-template-cooking_ view on Meta::CPAN
<link href="/theme/css/default.css" rel="stylesheet">
<link href="/theme/css/layout.css" rel="stylesheet">
<link href="/theme/css/media-queries.css" rel="stylesheet">
<link href="/theme/css/statocles.css" rel="stylesheet">
<!-- twitter and opengraph -->
<meta content="summary" name="twitter:card">
<meta content="@briandfoy_perl" name="twitter:creator">
<meta content="https://mojolicious.io/blog/2018/12/21/a-little-christmas-template-cooking/" property="og:url">
<meta content="Day 21: A Little Christmas Template Cooking" property="og:title">
<meta content="Using Mojo::Template for non-web applications." property="og:description">
<meta content="https://mojolicious.io/blog/2018/12/21/a-little-christmas-template-cooking/banner.jpg" property="og:image">
<meta content="summary_large_image" name="twitter:card">
<script src="/theme/js/modernizr.js"></script>
<link href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/sunburst.min.css" rel="stylesheet">
<title>Day 21: A Little Christmas Template Cooking - mojolicious.io</title>
<meta content="brian d foy" name="author">
<meta content="Statocles 0.093" name="generator">
<link href="/static/favicon.ico" rel="shortcut icon">
</head>
<body>
<header>
devdata/https_mojolicious.io_blog_2018_12_21_a-little-christmas-template-cooking_ view on Meta::CPAN
<div class="content-outer">
<div class="row" id="page-content">
<div class="eight columns" id="primary">
<article class="post">
<div class="entry-header cf">
<h1>Day 21: A Little Christmas Template Cooking</h1>
<p class="post-meta">
<time class="date" datetime="2018-12-21">Dec 21, 2018</time>
</p>
</div>
devdata/https_mojolicious.io_blog_2018_12_22_use-carton-for-your-mojolicious-app-deployment_ view on Meta::CPAN
</div>
<div class="about">
<h5>Luc Didry</h5>
<p>Luc Didry is a sysAdmin and Perl developer, in love with Perl since he discovered it 10 years ago, and a Mojolicious enthusiast.</p>
</div>
</div>
<ul class="post-nav cf">
<li class="prev"><a href="/blog/2018/12/21/a-little-christmas-template-cooking/index.html" rel="prev"><strong>Previous Article</strong> Day 21: A Little Christmas Template Cooking</a></li>
<li class="next"><a href="/blog/2018/12/23/mojolicious-and-angular/index.html" rel="next"><strong>Next Article</strong> Day 23: Mojolicious and Angular </a></li>
</ul>
</div>
</article>
</div>