Skip to content

Instantly share code, notes, and snippets.

View marcusramberg's full-sized avatar

Marcus Ramberg marcusramberg

View GitHub Profile
package TestPayFlow;
use lib 't/lib';
use TestCase -db;
sub pay_page : Tests(setup => no_plan) {
my $self = shift;
my $event_id = $self->dummy_event;
$self->visit('event', id => $event_id);
$self->click_link('buy');
}
~ $ mojo generate app foo
Your application name has to be a well formed (camel case) Perl module name
like "MyApp".
~ $ mojo generate app Foo
[mkdir] /Users/marcus/foo/script
[write] /Users/marcus/foo/script/foo
[chmod] foo/script/foo 744
[mkdir] /Users/marcus/foo/lib
[write] /Users/marcus/foo/lib/Foo.pm
[mkdir] /Users/marcus/foo/lib/Foo
~ $ mojo generate app foo
Your application name has to be a well formed (camel case) Perl module name
like "MyApp".
~ $ mojo generate app Foo
[mkdir] /Users/marcus/foo/script
[write] /Users/marcus/foo/script/foo
[chmod] foo/script/foo 744
[mkdir] /Users/marcus/foo/lib
[write] /Users/marcus/foo/lib/Foo.pm
[mkdir] /Users/marcus/foo/lib/Foo
package VCR;
use Mojo::Base 'Mojolicious';
use Mojo::Server::Daemon;
use Mojo::UserAgent;
use Mojo::JSON;
use Digest::MD5 qw/md5_hex/;
use File::Path qw/make_path/;
use File::Basename qw/dirname/;
use Mojo::Util qw/decode encode/;
sub friends_apps {
my ( $self, $friends, $page, $rows ) = @_;
return $self->search({
'person.screenname' => { -in => [map { $_->screenname} $friends->all] },
},
{ join => { iuses => 'person' },
distinct => 1,
order_by => 'MAX(iuses.timestamp) DESC',
}
)->at_page($page, $rows || 12);
$self->helper(
url_with => sub {
my $this = shift;
my $args = ref $_[-1] eq 'HASH' ? pop : {};
my $url = @_ ? $this->url_for(@_) : $this->req->url->clone;
my $query = $this->req->url->query->clone;
$url->query($query);
for my $key (keys %$args) {
> Is it good at what I want to do? (Answered by explaining what each framework does well and doesn't do well)
It's good for making general web applications as well as real time web applications.
>How easy is it to pick up?
The basic hello world is only 3 lines of code. Thanks to a sponsorship from TPF, there are comprehensive guides
to let you learn all the features of the framework, but you don't need to learn more than a handful to get started.
> How fast can I get a working web site going?
$ mojo generate lite_app foo.pl
$ morbo foo.pl
mojo/response.t .......................... ok
t/mojo/server.t ............................ ok
t/mojo/template.t .......................... ok
t/mojo/transactor.t ........................ ok
t/mojo/url.t ............................... ok
t/mojo/user_agent.t ........................ ok
t/mojo/user_agent_online.t ................. 1/109
# Failed test 'right error'
# at t/mojo/user_agent_online.t line 73.
# got: 'Connection refused'
[Thu Feb 2 12:33:40 2012] [debug] Dispatching "MeeTV::Web5::Films->list".
woot:2 at /Users/marcus/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/Mojolicious/Plugin/Parallol.pm line 54.
FLAIL? at /Users/marcus/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/Mojolicious/Plugin/Parallol.pm line 59.
woot:3 at /Users/marcus/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/Mojolicious/Plugin/Parallol.pm line 54.
dude:3 at /Users/marcus/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/Mojolicious/Plugin/Parallol.pm line 61.
FLAIL? at /Users/marcus/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/Mojolicious/Plugin/Parallol.pm line 59.
dude:2 at /Users/marcus/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/Mojolicious/Plugin/Parallol.pm line 61.
if (ref $callback && ref $callback eq 'CODE') {
[Thu Feb 2 13:16:02 2012] [debug] GET /overview (curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5).
[Thu Feb 2 13:16:02 2012] [debug] Dispatching "MeeTV::Web5::Channels->overview".
parallol called at /Users/marcus/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/Mojolicious/Plugin/Parallol.pm line 44.
Use of uninitialized value in concatenation (.) or string at /Users/marcus/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/Mojolicious/Plugin/Parallol.pm line 22.
paralloled: - paralolling:1 at /Users/marcus/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/Mojolicious/Plugin/Parallol.pm line 22.
parallol called at /Users/marcus/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/Mojolicious/Plugin/Parallol.pm line 44.