-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stefan Adams
committed
Apr 24, 2017
0 parents
commit ec0bb18
Showing
7 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
~$ | ||
*.bak | ||
*.old | ||
*.swp | ||
/local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class = App::git::ship::perl | ||
project_name = | ||
homepage = https://github.com/s1037989/Mojolicious-Plugin-Mojolyst | ||
bugtracker = https://github.com/s1037989/Mojolicious-Plugin-Mojolyst/issues | ||
license = artistic_2 | ||
build_test_options = # Example: -l -j8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
0.01 Not Released | ||
- Initial release based on kraih's Mojolicious hack of the day: Mojolyst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Generated by git-ship. See 'git-ship --man' for help or https://github.com/jhthorsen/app-git-ship | ||
use ExtUtils::MakeMaker; | ||
WriteMakefile( | ||
NAME => 'Mojolicious::Plugin::Mojolyst', | ||
AUTHOR => 'Stefan Adams <stefan@borgia.com>', | ||
LICENSE => 'artistic_2', | ||
ABSTRACT_FROM => 'lib/Mojolicious/Plugin/Mojolyst.pm', | ||
VERSION_FROM => 'lib/Mojolicious/Plugin/Mojolyst.pm', | ||
EXE_FILES => [qw( )], | ||
META_MERGE => { | ||
resources => { | ||
bugtracker => 'https://github.com/s1037989/Mojolicious-Plugin-Mojolyst/issues', | ||
homepage => 'https://github.com/s1037989/Mojolicious-Plugin-Mojolyst', | ||
repository => 'https://github.com/stefan/mojolicious-plugin-mojolyst', | ||
}, | ||
}, | ||
BUILD_REQUIRES => { | ||
'Test::More' => '0.90' | ||
} | ||
, | ||
PREREQ_PM => { | ||
'ExtUtils::MakeMaker' => '6.00', | ||
'Mojolicious' => '7.11', | ||
'perl' => '5.014' | ||
} | ||
, | ||
test => {TESTS => (-e 'META.yml' ? 't/*.t' : 't/*.t xt/*.t')}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
requires "perl" => "5.014"; | ||
requires "ExtUtils::MakeMaker" => "6.00"; | ||
requires "Mojolicious" => "7.11"; | ||
|
||
test_requires "Test::More" => "0.90"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package Mojolicious::Plugin::Mojolyst; | ||
use Mojo::Base 'Mojolicious::Plugin'; | ||
|
||
our $VERSION = '0.01'; | ||
|
||
use Mojo::Loader qw/find_modules load_class/; | ||
|
||
sub register { | ||
my ($self, $app, $conf) = @_; | ||
|
||
# Discover controllers | ||
for my $class ( find_modules $conf->{controllers} ) { | ||
|
||
# Steal children | ||
my $e = load_class $class; | ||
my @children = @{$class->new->routes->children}; | ||
$app->routes->add_child($_) for @children; | ||
|
||
# Make DATA sections accessible | ||
push @{$app->static->classes}, $class; | ||
push @{$app->renderer->classes}, $class; | ||
} | ||
} | ||
|
||
1; | ||
__END__ | ||
=encoding utf8 | ||
=head1 NAME | ||
Mojolicious::Plugin::Mojolyst - Mojolicious::Lite syntax in a full Mojolicious | ||
app. | ||
=head1 SYNOPSIS | ||
# Mojolicious | ||
$self->plugin('Mojolyst' => {controllers => 'MyApp::Controller'}); | ||
# Mojolicious::Lite | ||
plugin 'Mojolyst' => {controllers => 'MyApp::Controller'}; | ||
# In your MyApp::Controller controller | ||
package MyApp::Controller::Foo; | ||
use Mojolicious::Lite; | ||
get '/' => {text => 'Welcome to Mojolyst!'}; | ||
1; | ||
=head1 DESCRIPTION | ||
L<Mojolicious::Plugin::Mojolyst> is a L<Mojolicious> plugin to hijack the | ||
Mojolicious router and turn it into a more Catalyst-ish decentralized one. | ||
=head1 METHODS | ||
L<Mojolicious::Plugin::Mojolyst> inherits all methods from | ||
L<Mojolicious::Plugin> and implements the following new ones. | ||
=head2 register | ||
$plugin->register(Mojolicious->new); | ||
Register plugin in L<Mojolicious> application. | ||
=head1 SEE ALSO | ||
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicious.org>, | ||
L<http://blog.mojolicious.org/post/157278582436/mojolicious-hack-of-the-day-mojolyst>. | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package MyApp::Controller::Foo; | ||
use Mojolicious::Lite; | ||
|
||
get '/' => {text => 'Welcome to Mojolyst!'}; | ||
|
||
package main; | ||
use Mojo::Base -strict; | ||
|
||
use Test::More; | ||
use Mojolicious::Lite; | ||
use Test::Mojo; | ||
|
||
plugin 'Mojolyst' => {controllers => 'MyApp::Controller'}; | ||
|
||
my $t = Test::Mojo->new; | ||
$t->get_ok('/')->status_is(200)->content_is('Welcome to Mojolyst!'); | ||
|
||
done_testing(); |