Amon2

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

    You can override this method if you want to determine the mode by other method.

- `MyApp->new()`

    Create new context object.

- `MyApp->bootstrap()`

        my $c = MyApp->bootstrap();

    Create new context object and set it to global context. When you are writing CLI script, setup the global context object by this method.

- `MyApp->base_dir()`

    This method returns the application base directory.

- `MyApp->load_plugin($module_name[, \%config])`

    This method loads the plugin for the application.

    _$module\_name_ package name of the plugin. You can write it as two form like [DBIx::Class](https://metacpan.org/pod/DBIx%3A%3AClass):

README.md  view on Meta::CPAN

    **((EXPERIMENTAL))**

    This method returns a boolean value. It returns true when $ENV{AMON2\_DEBUG} is true value, false otherwise.

    You can override this method if you need.

# PROJECT LOCAL MODE

**THIS MODE IS HIGHLY EXPERIMENTAL**

Normally, Amon2's context is stored in a global variable.

This module makes the context to project local.

It means, normally context class using Amon2 use `$Amon2::CONTEXT` in each project, but context class using ["PROJECT LOCAL MODE"](#project-local-mode) use `$MyApp::CONTEXT`.

**It means you can't use code depend `<Amon2-`context>> and `<Amon2-`context>> under this mode.**>

## NOTES ABOUT create\_request

Older [Amon2::Web::Request](https://metacpan.org/pod/Amon2%3A%3AWeb%3A%3ARequest) has only 1 argument like following, it uses `Amon2->context` to get encoding:

lib/Amon2.pm  view on Meta::CPAN

You can override this method if you want to determine the mode by other method.

=item C<< MyApp->new() >>

Create new context object.

=item C<< MyApp->bootstrap() >>

    my $c = MyApp->bootstrap();

Create new context object and set it to global context. When you are writing CLI script, setup the global context object by this method.

=item C<< MyApp->base_dir() >>

This method returns the application base directory.

=item C<< MyApp->load_plugin($module_name[, \%config]) >>

This method loads the plugin for the application.

I<$module_name> package name of the plugin. You can write it as two form like L<DBIx::Class>:

lib/Amon2.pm  view on Meta::CPAN

This method returns a boolean value. It returns true when $ENV{AMON2_DEBUG} is true value, false otherwise.

You can override this method if you need.

=back

=head1 PROJECT LOCAL MODE

B<THIS MODE IS HIGHLY EXPERIMENTAL>

Normally, Amon2's context is stored in a global variable.

This module makes the context to project local.

It means, normally context class using Amon2 use C<$Amon2::CONTEXT> in each project, but context class using L</PROJECT LOCAL MODE> use C<$MyApp::CONTEXT>.

B<<< It means you can't use code depend C<<Amon2->context>> and C<<Amon2->context>> under this mode. >>>>

=head2 NOTES ABOUT create_request

Older L<Amon2::Web::Request> has only 1 argument like following, it uses C<< Amon2->context >> to get encoding:

lib/Amon2/Setup/Asset/Bootstrap.pm  view on Meta::CPAN

use warnings;

sub tags {
    <<',,,';
    <link href="<: uri_for('/static/bootstrap/css/bootstrap.css') :>" rel="stylesheet" type="text/css" />
    <script src="<: uri_for('/static/bootstrap/js/bootstrap.js') :>"></script>
,,,
}

sub files { {
  "bootstrap/alert.js" => "/*!\n  * Bootstrap alert.js v4.4.1 (https://getbootstrap.com/)\n  * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n  * Licensed under MIT (https://github.com/twbs/bootstra...
  "bootstrap/alert.js.map" => "{\"version\":3,\"file\":\"alert.js\",\"sources\":[\"../src/alert.js\"],\"sourcesContent\":[\"/**\\n * --------------------------------------------------------------------------\\n * Bootstrap (v4.4.1): alert.js\\n * Lic...
  "bootstrap/button.js" => "/*!\n  * Bootstrap button.js v4.4.1 (https://getbootstrap.com/)\n  * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n  * Licensed under MIT (https://github.com/twbs/bootst...
  "bootstrap/button.js.map" => "{\"version\":3,\"file\":\"button.js\",\"sources\":[\"../src/button.js\"],\"sourcesContent\":[\"/**\\n * --------------------------------------------------------------------------\\n * Bootstrap (v4.4.1): button.js\\n *...
  "bootstrap/carousel.js" => "/*!\n  * Bootstrap carousel.js v4.4.1 (https://getbootstrap.com/)\n  * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n  * Licensed under MIT (https://github.com/twbs/bo...
  "bootstrap/carousel.js.map" => "{\"version\":3,\"file\":\"carousel.js\",\"sources\":[\"../src/carousel.js\"],\"sourcesContent\":[\"/**\\n * --------------------------------------------------------------------------\\n * Bootstrap (v4.4.1): carousel...
  "bootstrap/collapse.js" => "/*!\n  * Bootstrap collapse.js v4.4.1 (https://getbootstrap.com/)\n  * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n  * Licensed under MIT (https://github.com/twbs/bo...
  "bootstrap/collapse.js.map" => "{\"version\":3,\"file\":\"collapse.js\",\"sources\":[\"../src/collapse.js\"],\"sourcesContent\":[\"/**\\n * --------------------------------------------------------------------------\\n * Bootstrap (v4.4.1): collapse...
  "bootstrap/css/bootstrap-grid.css" => "/*!\n * Bootstrap Grid v4.4.1 (https://getbootstrap.com/)\n * Copyright 2011-2019 The Bootstrap Authors\n * Copyright 2011-2019 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/mast...
  "bootstrap/css/bootstrap-grid.css.map" => "{\"version\":3,\"sources\":[\"../../scss/bootstrap-grid.scss\",\"bootstrap-grid.css\",\"../../scss/_grid.scss\",\"../../scss/mixins/_grid.scss\",\"../../scss/mixins/_breakpoints.scss\",\"../../scss/_variab...
  "bootstrap/css/bootstrap-grid.min.css" => "/*!\n * Bootstrap Grid v4.4.1 (https://getbootstrap.com/)\n * Copyright 2011-2019 The Bootstrap Authors\n * Copyright 2011-2019 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/...
  "bootstrap/css/bootstrap-grid.min.css.map" => "{\"version\":3,\"sources\":[\"../../scss/bootstrap-grid.scss\",\"dist/css/bootstrap-grid.css\",\"../../scss/_grid.scss\",\"../../scss/mixins/_grid.scss\",\"../../scss/mixins/_breakpoints.scss\",\"../.....
  "bootstrap/css/bootstrap-reboot.css" => "/*!\n * Bootstrap Reboot v4.4.1 (https://getbootstrap.com/)\n * Copyright 2011-2019 The Bootstrap Authors\n * Copyright 2011-2019 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/...
  "bootstrap/css/bootstrap-reboot.css.map" => "{\"version\":3,\"sources\":[\"../../scss/bootstrap-reboot.scss\",\"bootstrap-reboot.css\",\"../../scss/_reboot.scss\",\"../../scss/_variables.scss\",\"../../scss/vendor/_rfs.scss\",\"../../scss/mixins/_h...
  "bootstrap/css/bootstrap-reboot.min.css" => "/*!\n * Bootstrap Reboot v4.4.1 (https://getbootstrap.com/)\n * Copyright 2011-2019 The Bootstrap Authors\n * Copyright 2011-2019 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/b...
  "bootstrap/css/bootstrap-reboot.min.css.map" => "{\"version\":3,\"sources\":[\"../../scss/bootstrap-reboot.scss\",\"../../scss/_reboot.scss\",\"dist/css/bootstrap-reboot.css\",\"../../scss/vendor/_rfs.scss\",\"bootstrap-reboot.css\",\"../../scss/mi...
  "bootstrap/css/bootstrap.css" => "/*!\n * Bootstrap v4.4.1 (https://getbootstrap.com/)\n * Copyright 2011-2019 The Bootstrap Authors\n * Copyright 2011-2019 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE...
  "bootstrap/css/bootstrap.css.map" => "{\"version\":3,\"sources\":[\"../../scss/bootstrap.scss\",\"bootstrap.css\",\"../../scss/_root.scss\",\"../../scss/_reboot.scss\",\"../../scss/_variables.scss\",\"../../scss/vendor/_rfs.scss\",\"../../scss/mixi...
  "bootstrap/css/bootstrap.min.css" => "/*!\n * Bootstrap v4.4.1 (https://getbootstrap.com/)\n * Copyright 2011-2019 The Bootstrap Authors\n * Copyright 2011-2019 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LIC...
  "bootstrap/css/bootstrap.min.css.map" => "{\"version\":3,\"sources\":[\"../../scss/bootstrap.scss\",\"../../scss/_root.scss\",\"../../scss/_reboot.scss\",\"dist/css/bootstrap.css\",\"../../scss/vendor/_rfs.scss\",\"bootstrap.css\",\"../../scss/mixi...
  "bootstrap/dropdown.js" => "/*!\n  * Bootstrap dropdown.js v4.4.1 (https://getbootstrap.com/)\n  * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n  * Licensed under MIT (https://github.com/twbs/bo...
  "bootstrap/dropdown.js.map" => "{\"version\":3,\"file\":\"dropdown.js\",\"sources\":[\"../src/dropdown.js\"],\"sourcesContent\":[\"/**\\n * --------------------------------------------------------------------------\\n * Bootstrap (v4.4.1): dropdown...
  "bootstrap/index.js" => "/**\n * --------------------------------------------------------------------------\n * Bootstrap (v4.4.0): index.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * ------------------------...
  "bootstrap/index.js.map" => "{\"version\":3,\"sources\":[\"../src/index.js\"],\"names\":[\"\$\",\"TypeError\",\"version\",\"fn\",\"jquery\",\"split\",\"minMajor\",\"ltMajor\",\"minMinor\",\"minPatch\",\"maxMajor\",\"Error\"],\"mappings\":\"AAaA;;;;...
  "bootstrap/js/bootstrap.bundle.js" => "/*!\n  * Bootstrap v4.4.1 (https://getbootstrap.com/)\n  * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n  * Licensed under MIT (https://github.com/twbs/boo...
  "bootstrap/js/bootstrap.bundle.js.map" => "{\"version\":3,\"file\":\"bootstrap.bundle.js\",\"sources\":[\"../../js/src/util.js\",\"../../js/src/alert.js\",\"../../js/src/button.js\",\"../../js/src/carousel.js\",\"../../js/src/collapse.js\",\"../../...
  "bootstrap/js/bootstrap.bundle.min.js" => "/*!\n  * Bootstrap v4.4.1 (https://getbootstrap.com/)\n  * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n  * Licensed under MIT (https://github.com/twbs...
  "bootstrap/js/bootstrap.bundle.min.js.map" => "{\"version\":3,\"sources\":[\"../../js/src/util.js\",\"../../js/src/alert.js\",\"../../js/src/button.js\",\"../../js/src/carousel.js\",\"../../js/src/collapse.js\",\"../../node_modules/popper.js/dist/e...
  "bootstrap/js/bootstrap.js" => "/*!\n  * Bootstrap v4.4.1 (https://getbootstrap.com/)\n  * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n  * Licensed under MIT (https://github.com/twbs/bootstrap/...
  "bootstrap/js/bootstrap.js.map" => "{\"version\":3,\"file\":\"bootstrap.js\",\"sources\":[\"../../js/src/util.js\",\"../../js/src/alert.js\",\"../../js/src/button.js\",\"../../js/src/carousel.js\",\"../../js/src/collapse.js\",\"../../js/src/dropdow...
  "bootstrap/js/bootstrap.min.js" => "/*!\n  * Bootstrap v4.4.1 (https://getbootstrap.com/)\n  * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n  * Licensed under MIT (https://github.com/twbs/bootst...
  "bootstrap/js/bootstrap.min.js.map" => "{\"version\":3,\"sources\":[\"../../js/src/util.js\",\"../../js/src/alert.js\",\"../../js/src/button.js\",\"../../js/src/carousel.js\",\"../../js/src/collapse.js\",\"../../js/src/dropdown.js\",\"../../js/src/...
  "bootstrap/modal.js" => "/*!\n  * Bootstrap modal.js v4.4.1 (https://getbootstrap.com/)\n  * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n  * Licensed under MIT (https://github.com/twbs/bootstra...
  "bootstrap/modal.js.map" => "{\"version\":3,\"file\":\"modal.js\",\"sources\":[\"../src/modal.js\"],\"sourcesContent\":[\"/**\\n * --------------------------------------------------------------------------\\n * Bootstrap (v4.4.1): modal.js\\n * Lic...
  "bootstrap/popover.js" => "/*!\n  * Bootstrap popover.js v4.4.1 (https://getbootstrap.com/)\n  * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n  * Licensed under MIT (https://github.com/twbs/boot...
  "bootstrap/popover.js.map" => "{\"version\":3,\"file\":\"popover.js\",\"sources\":[\"../src/popover.js\"],\"sourcesContent\":[\"/**\\n * --------------------------------------------------------------------------\\n * Bootstrap (v4.4.1): popover.js\...
  "bootstrap/scrollspy.js" => "/*!\n  * Bootstrap scrollspy.js v4.4.1 (https://getbootstrap.com/)\n  * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n  * Licensed under MIT (https://github.com/twbs/...
  "bootstrap/scrollspy.js.map" => "{\"version\":3,\"file\":\"scrollspy.js\",\"sources\":[\"../src/scrollspy.js\"],\"sourcesContent\":[\"/**\\n * --------------------------------------------------------------------------\\n * Bootstrap (v4.4.1): scrol...
  "bootstrap/tab.js" => "/*!\n  * Bootstrap tab.js v4.4.1 (https://getbootstrap.com/)\n  * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n  * Licensed under MIT (https://github.com/twbs/bootstrap/bl...
  "bootstrap/tab.js.map" => "{\"version\":3,\"file\":\"tab.js\",\"sources\":[\"../src/tab.js\"],\"sourcesContent\":[\"/**\\n * --------------------------------------------------------------------------\\n * Bootstrap (v4.4.1): tab.js\\n * Licensed un...
  "bootstrap/toast.js" => "/*!\n  * Bootstrap toast.js v4.4.1 (https://getbootstrap.com/)\n  * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n  * Licensed under MIT (https://github.com/twbs/bootstra...
  "bootstrap/toast.js.map" => "{\"version\":3,\"file\":\"toast.js\",\"sources\":[\"../src/toast.js\"],\"sourcesContent\":[\"/**\\n * --------------------------------------------------------------------------\\n * Bootstrap (v4.4.1): toast.js\\n * Lic...
  "bootstrap/tooltip.js" => "/*!\n  * Bootstrap tooltip.js v4.4.1 (https://getbootstrap.com/)\n  * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n  * Licensed under MIT (https://github.com/twbs/boot...
  "bootstrap/tooltip.js.map" => "{\"version\":3,\"file\":\"tooltip.js\",\"sources\":[\"../src/tools/sanitizer.js\",\"../src/tooltip.js\"],\"sourcesContent\":[\"/**\\n * --------------------------------------------------------------------------\\n * B...
  "bootstrap/util.js" => "/*!\n  * Bootstrap util.js v4.4.1 (https://getbootstrap.com/)\n  * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n  * Licensed under MIT (https://github.com/twbs/bootstrap/...
  "bootstrap/util.js.map" => "{\"version\":3,\"file\":\"util.js\",\"sources\":[\"../src/util.js\"],\"sourcesContent\":[\"/**\\n * --------------------------------------------------------------------------\\n * Bootstrap (v4.4.1): util.js\\n * License...
}
 }

sub run {
    my ($class, $flavor) = @_;
    warn "THIS METHOD WAS DEPRECATED";

    my $files = $class->files;
    $flavor->mkpath('static/bootstrap/');

lib/Amon2/Setup/Asset/SprintfJS.pm  view on Meta::CPAN

(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Changelog:
2010.09.06 - 0.7-beta1
  - features: vsprintf, support for named placeholders
  - enhancements: format cache, reduced global namespace pollution

2010.05.22 - 0.6:
 - reverted to 0.4 and fixed the bug regarding the sign of the number 0
 Note:
 Thanks to Raphael Pigulla <raph (at] n3rd [dot) org> (http://www.n3rd.org/)
 who warned me about a bug in 0.5, I discovered that the last update was
 a regress. I appologize for that.

2010.05.09 - 0.5:
 - bug fix: 0 is now preceeded with a + sign

lib/Amon2/Setup/Asset/jQuery.pm  view on Meta::CPAN


sub tags {
    <<',,,';
    <script src="<: uri_for('/static/js/jquery-3.6.1.min.js') :>"></script>
,,,
}

sub files {
    return {
  'js/jquery-3.6.1.min.js' => '/*! jQuery v3.6.1 | (c) OpenJS Foundation and other contributors | jquery.org/license */
!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof windo...
'
}
;
}

# for backward compatibility
sub run {
    warn "THIS METHOD WAS DEPRECATED";
    my ($self, $flavor) = @_;
    $flavor->mkpath('static/js/');

share/flavor/Large/t/07_mech_links.t  view on Meta::CPAN

    my $mech = shift;

    my @links;
    my $parser = HTML::TokeParser->new( \( $mech->content ) );
    while ( my $token = $parser->get_tag( keys %link_tags ) ) {
        push @links, $token->[1]->{ $link_tags{ $token->[0] } };
    }
    return grep { m{^/} } @links;
}

for my $psgi (glob('script/*-server')) {
    subtest $psgi => sub {
        my $app = Plack::Util::load_psgi($psgi);

        my $mech = Test::WWW::Mechanize::PSGI->new( app => $app );
        $mech->credentials( 'admin', 'admin' );
        $mech->get_ok('/');

        my @links = _extract_links($mech);
        for (@links) {
            $mech->get('/');

share/flavor/Minimum/Build.PL  view on Meta::CPAN

        $prereq->{build} ? %{$prereq->{build}->{requires}} : (),
        $prereq->{test} ? %{$prereq->{test}->{requires}} : (),
    },
    configure_requires   => {
        %{$prereq->{configure}->{requires}},
    },
    requires             => {
        perl => '5.008001',
        %{$prereq->{runtime}->{requires}},
    },
    script_files => [glob('script/*'), glob('bin/*')],

    no_index    => { 'directory' => [ 'inc' ] },
    name        => '<% $module %>',
    module_name => '<% $module %>',
    author        => 'Some Person <person@example.com>',
    dist_abstract => 'A web site based on Amon2',

    test_files => (-d '.git' || $ENV{RELEASE_TESTING}) ? 't/ xt/' : 't/',
    recursive_test_files => 1,

t/100_core/017_local_context.t  view on Meta::CPAN

    package Foo;
    use parent qw(Amon2);
    __PACKAGE__->make_local_context();
}

subtest 'simple set context' => sub {
    is(Foo->context(), undef);
    my $c = Foo->new();
    Foo->set_context($c);
    is(Foo->context(), $c, 'context was set');
    is(Amon2->context(), undef, 'global context does not set');
    Foo->set_context(undef); # teardown
};

subtest 'context_guard' => sub {
    is(Foo->context(), undef);
    my $c = Foo->new();
    {
        my $guard = $c->context_guard();
        is(Foo->context(), $c, 'context was set');
        is(Amon2->context(), undef, 'global context does not set');
    }
    is(Foo->context(), undef, 'context was gone');
    is(Amon2->context(), undef, 'global context does not set');
};

subtest 'bootstrap' => sub {
    is(Foo->context(), undef);
    my $c = Foo->bootstrap();
    is(Foo->context(), $c, 'context was set');
    is(Amon2->context(), undef, 'global context does not set');
};

done_testing;

t/300_setup/02_basic.t  view on Meta::CPAN

	}
    ok(-f './lib/My/App.pm', 'lib/My/App.pm exists');
    like(slurp('./lib/My/App/Web/Plugin/Session.pm'), qr{secret => '.+'});
    ok((do './lib/My/App.pm'), 'lib/My/App.pm is valid') or do {
        diag $@;
        diag do {
            open my $fh, '<', './lib/My/App.pm' or die;
            local $/; <$fh>;
        };
    };
    is( scalar( my @files = glob('./static/js/jquery-*.js') ), 1 );
	like(slurp('./cpanfile'), qr{'Teng'\s*,\s*'[0-9.]+'});
}, 'Basic');

done_testing;



( run in 0.585 second using v1.01-cache-2.11-cpan-49f99fa48dc )