Skip to content

Commit

Permalink
新しいNephia(0.80)に対応
Browse files Browse the repository at this point in the history
config.plに更新あり

--- a/config.pl.sample
+++ b/config.pl.sample
@@ -71,8 +71,9 @@ use strict;

     'view' => {
-        class => 'Xslate',
-        'function' => {
+        syntax => 'Kolon',
+        path => [qw(view)],
+        function => {
             static => sub {
                 my $uri = shift;
                 $uri =~ s/^\///;
  • Loading branch information
ichigotake committed Sep 29, 2013
1 parent 4ab81bf commit 01e5466
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 83 deletions.
5 changes: 3 additions & 2 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ WriteMakefile(
'JSON' => 0,
'DBI' => 0,
'Encode' => 0,
'Nephia' => 0.10,
'Nephia::View::Xslate' => 0.02,
'Nephia' => 0.80,
'Nephia::Plugin::Dispatch' => '0.01',
'Nephia::Plugin::View::Xslate' => '0.01',
'Time::HiRes' => 0,
'PocketIO' => 0.13,
'Plack' => 0,
Expand Down
36 changes: 8 additions & 28 deletions chat.psgi
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,6 @@ use Yancha::DataStorage::DBI;
use Yancha::Config::Simple;

my $config = Yancha::Config::Simple->load_file( $ENV{ YANCHA_CONFIG_FILE } || "$root/config.pl" );
unless (defined($config->{view})) {
die <<'ERR'
config.plに以下の設定が見つかりません.
config.pl.sampleからコピーしてから起動してください
------
'view' => {
'function' => {
static => sub {
my $uri = shift;
$uri =~ s/^\///;
return '/static/'.$uri;
},
uri => sub {
my $uri = shift;
$uri =~ s/^\///;
return '/'.$uri;
},
},
},
------
ERR
}

my $data_storage = Yancha::DataStorage::DBI->connect(
connect_info => $config->{ database }->{ connect_info },
Expand All @@ -67,15 +43,19 @@ builder {
enable 'Session';
enable "SimpleLogger", level => 'debug';

enable 'Plack::Middleware::Static',
root => $root,
path => qr{^/static/};

enable 'Plack::Middleware::Static',
path => qr{^(?:/robots\.txt|/favicon\.ico)$},
root => File::Spec->catdir(dirname(__FILE__), 'root', 'static');
root => File::Spec->catdir($root, 'static');

mount '/socket.io/socket.io.js' =>
Plack::App::File->new(file => File::Spec->catfile($root, 'root', 'static', 'socket.io.js'));
Plack::App::File->new(file => File::Spec->catfile($root, 'static', 'socket.io.js'));

mount '/socket.io/static/flashsocket/WebSocketMain.swf' =>
Plack::App::File->new(file => File::Spec->catfile($root, 'root', 'static', 'WebSocketMain.swf'));
Plack::App::File->new(file => File::Spec->catfile($root, 'static', 'WebSocketMain.swf'));

mount '/socket.io/static/flashsocket/WebSocketMainInsecure.swf' =>
Plack::App::File->new(file => File::Spec->catfile($root, 'static', 'WebSocketMainInsecure.swf'));
Expand All @@ -86,5 +66,5 @@ builder {

$yancha->build_psgi_endpoint_from_server_info('auth');

mount '/' => Yancha::Web->run({ view => $config->{view} });
mount '/' => Yancha::Web->run(%$config);
}
5 changes: 3 additions & 2 deletions config.pl.sample
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ use strict;


'view' => {
class => 'Xslate',
'function' => {
syntax => 'Kolon',
path => [qw(view)],
function => {
static => sub {
my $uri = shift;
$uri =~ s/^\///;
Expand Down
96 changes: 45 additions & 51 deletions lib/Yancha/Web.pm
Original file line number Diff line number Diff line change
@@ -1,65 +1,59 @@
package Yancha::Web;

my $config;

BEGIN {
use Yancha::Config::Simple;
$config = Yancha::Config::Simple->load_file( $ENV{ YANCHA_CONFIG_FILE } || undef );
}

use strict;
use warnings;
use Nephia;
use utf8;
use Yancha::Util;

use Nephia plugins => [
'Dispatch',
'View::Xslate' => $config->{'view'},
];

our $VERSION = 0.01;

path '/' => sub {
my ($req, @args) = @_;

my $template;
if (Yancha::Util->is_smartphone( $req->env->{HTTP_USER_AGENT} || '' )) {
return res { redirect('/android.html'); };
}

$template = 'chat.tx';

return {
template => 'chat.tx',

app {
get '/' => sub {
my $req = req;

my $template;
if (Yancha::Util->is_smartphone( $req->env->{HTTP_USER_AGENT} || '' )) {
return $req->redirect('/android.html');
}

return [200, [], render('chat.tx')];
};
};

path '/android.html' => sub {
return {
template => 'android.tx',

get '/android.html' => sub {
return [200, [], render('android.tx')];
};
};

path qr{^/about(\.html)?} => sub {
my $req = shift;
return {
template => 'about.tx',

get qr{^/about(\.html)?} => sub {
return [200, [], render('about.tx')];
};
};

path qr{/hints(\.html)?} => sub {
my $req = shift;
return {
template => 'hints.tx',

get qr{/hints(\.html)?} => sub {
return [200, [], render('hints.tx')];
};
};

path qr{^/join_users(\.html)?} => sub {
my $req = shift;
return {
template => 'join_users.tx',

get qr{^/join_users(\.html)?} => sub {
return [200, [], render('join_users.tx')];
};
};


path qr{^/quot(ation\.html)?$} => sub {
return {
template => 'quot.tx',


get qr{^/quot(ation\.html)?$} => sub {
return [200, [], render('quot.tx')];
};
};

path qr{^/search(\.html)?$} => sub {
my $req = shift;
return {
template => 'search.tx',

get qr{^/search(\.html)?$} => sub {
return [200, [], render('search.tx')];
};
};

1;

0 comments on commit 01e5466

Please sign in to comment.