Acme-CPANModulesBundle-Import-MojoliciousAdvent-2018

 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&#39;t a route? What if it&#39;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 &#39;do_login&#39;
</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&#39;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 &#39;Mojolicious::Controller&#39;;

sub on_user_login {
  my $self = shift;

  my $username = $self-&gt;param(&#39;username&#39;);
  my $password = $self-&gt;param(&#39;password&#39;);

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&#39;t <em>quite</em> have what this particular rodent was looking for.</p>

<p><em>An aside</em> - No, I didn&#39;t mention
<a href="https://metacpan.org/pod/Plack">Plack</a>.
Maybe if I&#39;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&#39;s preforking server with
hot
deployment</a>,
but that would require me to have a server and keep it online. It&#39;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&#39;d need to take my dynamic website and turn it into a static
one, and that&#39;s impossible! Or is it? Why am I asking me, when I&#39;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&#39;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&#39;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&#39;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>



( run in 0.492 second using v1.01-cache-2.11-cpan-e9199f4ba4c )