Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

please accept this request , what is fixed kamui.pl #1

Merged
merged 1 commit into from Jan 31, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile.PL
Expand Up @@ -18,6 +18,8 @@ requires 'Template';
requires 'Template::Stash::EscapeHTML';
requires 'Scalar::Util';
requires 'FormValidator::Lite';
requires 'JSON::XS';
requires 'Text::MicroTemplate::Extended';

test_requires 'Test::More';
test_requires 'Test::Exception';
Expand Down
4 changes: 3 additions & 1 deletion lib/Kamui/Manual/JA/Tutorial.pod
Expand Up @@ -31,7 +31,9 @@ Kamui::Manual::JA::Tutorial - Kamui 日本語チュートリアル
| |-- script
| | `-- Hello.psgi
| `-- tmpl
| |-- base.html
| `-- common
| `-- header.html
| `-- footer.html
| `-- root
| `-- index.html
|-- config.pl
Expand Down
60 changes: 31 additions & 29 deletions script/kamui.pl
Expand Up @@ -14,28 +14,28 @@

my $confsrc = <<'...';
-- lib/$path.pm
package [%= $module %];
package <%= $module %>;
1;
-- lib/$path/Web.pm
package [%= $module %]::Web;
-- lib/$path/Web/Handler.pm
package <%= $module %>::Web::Handler;
use Kamui;
use base 'Kamui::Web';
use base 'Kamui::Web::Handler';

use [%= $module %]::Web::Context;
sub context {'[%= $module %]::Web::Context'}
use <%= $module %>::Web::Context;
sub context {'<%= $module %>::Web::Context'}

use [%= $module %]::Web::Dispatcher;
sub dispatcher {'[%= $module %]::Web::Dispatcher'}
use <%= $module %>::Web::Dispatcher;
sub dispatcher {'<%= $module %>::Web::Dispatcher'}

sub view {'Kamui::View::TT'}
sub plugins {['Encode']}

use [%= $module %]::Container -no_export;
sub container { [%= $module %]::Container->instance }
use <%= $module %>::Container -no_export;
sub container { <%= $module %>::Container->instance }

1;
-- lib/$path/Web/Dispatcher.pm
package [%= $module %]::Web::Dispatcher;
package <%= $module %>::Web::Dispatcher;
use Kamui::Web::Dispatcher;

on '/' => run {
Expand All @@ -44,12 +44,12 @@ package [%= $module %]::Web::Dispatcher;

1;
-- lib/$path/Web/Context.pm
package [%= $module %]::Web::Context;
package <%= $module %>::Web::Context;
use Kamui;
use base 'Kamui::Web::Context';
1;
-- lib/$path/Web/Controller/Root.pm
package [%= $module %]::Web::Controller::Root;
package <%= $module %>::Web::Controller::Root;
use Kamui::Web::Controller -base;

__PACKAGE__->add_trigger(
Expand All @@ -60,51 +60,52 @@ package [%= $module %]::Web::Controller::Root;

sub do_index {
my ($class, $c, $args) = @_;
$c->stash->{title} = 'kamui page';
$c->stash->{content} = 'hello, Kamui world!';
}

1;
-- lib/$path/Container.pm
package [%= $module %]::Container;
package <%= $module %>::Container;
use Kamui::Container -base;

register foo => sub {
my $self = shift;
};

1;
-- assets/tmpl/root/index.html
? extends 'base.html';
? block title => 'kamui page';
? block content => sub { 'hello, Kamui world!' };
-- assets/tmpl/base.html
-- assets/tmpl/common/header.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title><? block title => 'Kamui' ?></title>
<title>[% title | html %]</title>
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
</head>
-- assets/tmpl/root/index.html
[% INCLUDE common/header.html %]
<body>
<div id="Container">
<div id="Header">
<a href="/">Kamui Startup Page</a>
</div>
<div id="Content">
<? block content => 'body here' ?>
[% content | html %]
</div>
<div id="Footer">
Powered by Kamui
</div>
</div>
</body>
[% INCLUDE common/footer.html %]
-- assets/tmpl/common/footer.html
</html>
-- assets/script/$dist.psgi
use [%= $module %]::Web::Handler;
use [%= $module %]::Container;
use <%= $module %>::Web::Handler;
use <%= $module %>::Container;
use Plack::Builder;
my $app = [%= $module %]::Web::Handler->new;
$app->setup;
my $app = <%= $module %>::Web::Handler->new;

my $home = container('home');
builder {
Expand All @@ -116,14 +117,14 @@ package [%= $module %]::Container;
};
-- config.pl
use Kamui;
use [%= $module %]::Container;
use <%= $module %>::Container;
use Path::Class;

my $home = container('home');

return +{
view => {
mt => +{
tt => +{
path => $home->file('assets/tmpl')->stringify,
},
},
Expand Down Expand Up @@ -167,15 +168,16 @@ sub main {
_mkpath "assets/htdocs/css/";
_mkpath "assets/htdocs/img/";
_mkpath "assets/tmpl/root/";
_mkpath "assets/tmpl/common/";
_mkpath "assets/script/";
_mkpath "t/";

my $conf = _parse_conf($confsrc);
while (my ($file, $tmpl) = each %$conf) {
$file =~ s/(\$\w+)/$1/gee;
my $code = Text::MicroTemplate->new(
tag_start => '[%',
tag_end => '%]',
tag_start => '<%',
tag_end => '%>',
line_start => '%',
template => $tmpl,
)->code;
Expand Down
2 changes: 1 addition & 1 deletion t/030_plugin/mobile/agent.t
Expand Up @@ -5,7 +5,7 @@ use Mock::Web::Handler;

BEGIN {
eval "use HTTP::MobileAgent";
plan skip_all => 'needs HTP::MobileAgent for testing' if $@;
plan skip_all => 'needs HTTP::MobileAgent for testing' if $@;
};

my $plugins = [qw/Mobile::Agent/];
Expand Down
2 changes: 1 addition & 1 deletion t/030_plugin/mobile/css_filter.t
Expand Up @@ -6,7 +6,7 @@ use Mock::Container;

BEGIN {
eval "use HTTP::MobileAgent";
plan skip_all => 'needs HTP::MobileAgent for testing' if $@;
plan skip_all => 'needs HTTP::MobileAgent for testing' if $@;
eval "use HTML::MobileJpCSS";
plan skip_all => 'needs HTML::MobileJpCSS for testing' if $@;
};
Expand Down
2 changes: 1 addition & 1 deletion t/030_plugin/mobile/docomo_guid_filter.t
Expand Up @@ -5,7 +5,7 @@ use Mock::Web::Handler;

BEGIN {
eval "use HTTP::MobileAgent";
plan skip_all => 'needs HTP::MobileAgent for testing' if $@;
plan skip_all => 'needs HTTP::MobileAgent for testing' if $@;
eval "use HTML::StickyQuery::DoCoMoGUID";
plan skip_all => 'needs HTML::StickyQuery::DoCoMoGUID for testing' if $@;
};
Expand Down
2 changes: 1 addition & 1 deletion t/030_plugin/mobile/emoji_filter.t
Expand Up @@ -5,7 +5,7 @@ use Mock::Web::Handler;

BEGIN {
eval "use HTTP::MobileAgent";
plan skip_all => 'needs HTP::MobileAgent for testing' if $@;
plan skip_all => 'needs HTTP::MobileAgent for testing' if $@;
};

my $plugins = [qw/Encode Mobile::EmojiFilter/];
Expand Down