Ado

 view release on metacpan or  search on metacpan

lib/Ado/Control/Articles.pm  view on Meta::CPAN

            path($html_path)->spurt(b($html_content)->encode);
            $c->redirect_to($c->url_for('/articles/' . $html_file));
            return;
        }
        else {
            $c->render(html => $c->markdown($markdown, {self_url => $c->url_for->to_string}));
            return;
        }
    }
    else {
        $c->res->code(404);
        return;
    }
    Carp::croak('Should never get here!');
}

1;

=pod

=encoding utf8

lib/Ado/Plugin/MarkdownRenderer.pm  view on Meta::CPAN


    #Reuse previously produced html file if md_file is older than the html file.
    if (   $config->{md_reuse_produced_html}
        && -s $html_filepath
        && (stat($fullname))[9] < (stat($html_filepath))[9])
    {
        $c->debug('Found ' . $html_filepath);
        return b(path($html_filepath)->slurp)->decode;
    }

    #404 Not Found
    my $md_filepath = catfile($path, "$name$suffix");
    unless (-s $md_filepath) { $c->reply->not_found() && return '' }

    my $markdown = path($md_filepath)->slurp;
    my $self_url = $c->url_for()->to_string;
    my %options  = (%{$config->{md_options}}, self_url => $self_url);
    my $html     = $c->markdown($markdown, \%options);
    $c->debug($c->dumper({'%options' => \%options, '$html_filepath' => $html_filepath}));
    path($html_filepath)->spurt($html);
    return b($html)->decode;

public/img/Ado-Building-Blocks.svg  view on Meta::CPAN

         style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
         xml:space="preserve"><tspan
           y="715.87109"
           x="132.35156"
           id="tspan4556"
           sodipodi:role="line">Linux, Mac OSX, Free BSD, Windows...</tspan></text>
    </g>
    <rect
       style="fill:none;stroke:#000000;stroke-width:0.7151494;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
       id="rect4560"
       width="404.99161"
       height="61.914406"
       x="379.98889"
       y="628.24036"
       ry="10.218884" />
    <g
       id="g4582"
       transform="matrix(0.81466395,0,0,0.82412767,-18.737277,147.41433)">
      <rect
         style="fill:none;stroke:#000000;stroke-width:0.82433641;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
         id="rect4558"

public/img/Ado-Building-Blocks.svg  view on Meta::CPAN

           style="fill:none;stroke:#000000;stroke-width:0.97899681;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
           id="rect4627"
           width="135.02098"
           height="348.02097"
           x="362.52655"
           y="45.989479"
           ry="57.440357" />
        <text
           xml:space="preserve"
           style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
           x="-380.40427"
           y="439.41693"
           id="text4647"
           sodipodi:linespacing="125%"
           transform="matrix(0,-1,1,0,0,0)"><tspan
             sodipodi:role="line"
             id="tspan4649"
             x="-380.40427"
             y="439.41693"
             style="font-size:34px">Ado::Plugin::Admin</tspan></text>
      </g>
      <g
         transform="matrix(1,0,0,0.85391604,0,6.7183252)"
         id="g4691">
        <rect
           ry="57.440357"
           y="45.989479"
           x="520.56177"

t/plugin/auth-02.t  view on Meta::CPAN

#authorization
$t->get_ok('/test/ingroup')->status_is(200)->json_is('/0/login_name' => 'test1');
$t->get_ok('/test/ingroup', form => {limit => 20, offset => 1})->status_is(200)
  ->json_is('/0/login_name' => undef);

#logout
$t->get_ok('/logout')->status_is(302)->header_is('Location' => '/');
$t->get_ok('/')->status_is(200)->text_is('article.ui.main.container h1' => 'Hello Guest,');

#authorization
$t->get_ok('/test/ingroup')->status_is(404)->content_type_is('text/html;charset=UTF-8');


done_testing();

t/plugin/i18n-01.t  view on Meta::CPAN

$t->get_ok('/bg')->status_is(200)
  ->text_is('#login_form label[for="login_name"]', 'Потребител', '/:language content');
$t->get_ok('/bg/test')
  ->content_like(qr'Здрасти, Guest!', '/:language/:controller content');
$t->get_ok('/de/test/l10n')
  ->content_like(qr'Hallo Guest,', '/:language/:controller/:action content');
$t->get_ok('/en/test/l10n')
  ->content_like(qr'Hello Guest,', '/:language/:controller/:action content');
$t->get_ok('/en/test/bgl10n')
  ->content_like(qr'Здрасти, Guest!', 'language explicitly set in action');
$t->get_ok('/fr')->status_is(404, 'unknown /:language not found');
$t->get_ok('/fr/test')->status_is(404, 'unknown /:language/:controller not found');
$t->get_ok('/fr/test/l10n')->status_is(404, 'unknown /:language/:controller:action not found');

#$config->{language_from_host} TODO

#$config->{language_from_param}
$t->get_ok('/?language=bg')->status_is(200)->text_is('#login_form label[for="login_name"]',
    'Потребител', '/?language=bg content');
$t->get_ok('/test?language=bg')
  ->content_like(qr'Здрасти, Guest!', '/:controller?language=bg content');
$t->get_ok('/test/l10n?language=de')
  ->content_like(qr'Hallo Guest,', '/:controller/:action?language=de content');

t/plugin/markdown_renderer-01.t  view on Meta::CPAN


#test Ado::Control::Articles
my $config = $app->config('Ado::Plugin::MarkdownRenderer');

is($config->{md_reuse_produced_html}, 1);
my $static_file = $app->home->rel_file('public/articles/hello.html');
unlink($static_file);

#file is generated and the user is redirected to it.
$t->get_ok('/articles/hello.html')->status_is(302);
$t->get_ok('/articles/not_found.html')->status_is(404)->text_like('h1' => qr'Not Found');
ok(-e $static_file, 'file /articles/hello.html really exists');

#static file
$t->get_ok('/articles/hello.html')->status_is(200)
  ->text_like('h1' => qr'Ползата от историята');

#cached static file: Check If-Modified-Since
my $mtime = Mojo::Date->new(Mojo::Asset::File->new(path => $static_file)->mtime)->to_string;
$t->head_ok('/articles/hello.html' => {'If-Modified-Since' => $mtime})->status_is(304);

t/plugin/markdown_renderer.t  view on Meta::CPAN

$dom->find('#toc a')->each(
    sub {
        my $a    = shift;
        my $text = $a->text();
        $t->get_ok("$a->{href}")->status_is(200)->text_is('title' => $text)
          ->text_is('article h1' => $text);
    }
);

#not found
$t->get_ok('/help/bg/alabala.md')->status_is(404);

# Fails on https://travis-ci.org/kberov/Ado/builds/34763956 Why?
#->text_is('h1' => 'Page not found... yet!');


#test missing/default configuration
$plugin->{config} = {};
isa_ok($plugin->register($app) => $class);
is_deeply($plugin->config('md_file_sufixes') => ['.md'], 'default md_file_sufixes');
is($plugin->config('md_method') => 'markdown', 'default md_method');

templates/partials/apache2htaccess.ep  view on Meta::CPAN


  % if($has_msfcgi){
    # Use your own perl. You may need to fix paths if they contain spaces.
    # Using Mojo::Server::FastCGI. 
    # Uncomment the following (and comment any previous "FcgidWrapper")
    # if you prefer Mojo::Server::FastCGI.
    <%= $plackup? '#':''%> FcgidWrapper "<%= "$args->{perl} $root/bin/$moniker" %> fastcgi"
  % }
</IfModule>
% }
# Make Ado handle any 404 errors.
ErrorDocument 404 /bin/<%=$moniker%>
DirectoryIndex /bin/<%=$moniker%>

#Some more security. Redefine the mime type for the most common types of scripts
AddType text/plain .shtml .php .php3 .phtml .phtm .pl .py .cgi

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

  # Set "protossl" to "s" if we were accessed via https://.  This is used later



( run in 1.845 second using v1.01-cache-2.11-cpan-39bf76dae61 )